I figured out two ways to do this.
First way
It requires that any style plugins you want to filter be
- provided by the module in which you're doing the filtering (unless you want to hand-code in a list of modules or something), and
- named such that the machine name includes the name(s) of the content type(s) of the panes on which it should be able to be selected.
Inside a hook_form_FORM_ID_alter()
:
// Only show style plugins relevant to the type of pane we have.
$type = $form_state['pane']->type;
$this_module = basename(__FILE__, '.module');
foreach ($form['style']['#options'] as $key => $style) {
$style_info = panels_get_style($key);
$module = $style_info['module'];
// If the style plugin was defined by our module and it does not have the
// current pane's type in the name, don't make it an option.
if (($module == $this_module) && (strpos($key, $type) === FALSE)) {
unset($form['style']['#options'][$key]);
}
}
Second Way
After doing it the first way, I wanted to make it more robust (not rely on naming conventions) so I submitted a feature request to Panels and attached some patches. Issue here: https://www.drupal.org/node/2320045
This way allows you to just add something like 'content type' => array('foo', 'bar', 'baz'),
(Where foo, bar, and baz are the machine names of Panels content types) to the $plugin
declaration, along with the title and description and all that. If you have plugins that don't have that, they won't break, they'll just continue to appear as options for every content type. If you do specify some types, it will only appear as an option on panels of those types.