How do I create a custom plugin? Basically, I want to port a custom ctools plugin created for content type from Drupal 7 to Drupal 8. This is the code I want to port.

function my_module_ctools_plugin_directory($module, $plugin) {
  if (($module == 'ctools') &amp;&amp; ($plugin == 'content_types')) {
    return 'plugins/content_types';
  }
}


In my_module/plugins/content_types/my_module.inc file i have following code:

/**
 * Plugin array() of ctools plugin.
 */
$plugin = array(
  'title' =&gt; t('My Module'),
  'single' =&gt; TRUE,
  'content_types' =&gt; array('my_module_custom_content_type'),
  'render callback' =&gt; 'my_module_render',
  'required context' =&gt; new ctools_context_required(t('Node'), 'node'),
  'edit form' =&gt; 'my_module_settings_form',
  'edit form validation' =&gt; 'my_module_settings_form_submit',
  'category' =&gt; 'Widgets',
);

/**
 * Render callback function.
 */
function my_module_render($subtype, $conf, $args, $context) {
  $node = $context-&gt;data;
  if (empty($node)) {
    return;
  }
  $data = \Drupal::formBuilder()-&gt;getForm('my_module_form', $context, $conf);
  $block = new stdClass();
  $block-&gt;content = $data;
  $block-&gt;title = '';
  $block-&gt;id = 'my_module_form';
  return $block;
}


How do I port the plugin to Drupal 8?
There are no ctools plugins anymore in Drupal 8. There's just the Drupal 8 plugin API.

Page Manager, Panels and so on use standard block plugins now in 8.x, so you basically have to port this to a block an then it should work fine.

Also, the "code" you posted only defines that you have such a plugin in your module, nothing else. If you need more specific support, you will need to post your actual code, and ask specific questions (which are probably better as a follow-up question).