array( 'path' => drupal_get_path('module', 'foo') .'/plugins', 'file' => 'foo_context_condition_bar.inc', 'class' => 'foo_context_condition_bar', 'parent' => 'context_condition', ), ); $plugins['foo_context_reaction_baz'] = array( 'handler' => array( 'path' => drupal_get_path('module', 'foo') .'/plugins', 'file' => 'foo_context_reaction_baz.inc', 'class' => 'foo_context_reaction_baz', 'parent' => 'context_reaction', ), ); return $plugins; } /** * Registry hook for conditions & reactions. * * Each entry associates a condition or reaction with the CTools plugin to be * used as its plugin class. */ function hook_context_registry() { return array( 'conditions' => array( 'bar' => array( 'title' => t('Name of condition "bar"'), 'plugin' => 'foo_context_condition_bar', ), ), 'reactions' => array( 'baz' => array( 'title' => t('Name of reaction "baz"'), 'plugin' => 'foo_context_reaction_baz', ), ), ); } /** * Alter the registry. * * Allows modules to alter the registry. Default plugins can be replaced by * custom ones declared in hook_context_plugins(). * * @param $registry * The registry, passed by reference. */ function hook_context_registry_alter(&$registry) { if (isset($registry['reactions']['baz'])) { $registry['reactions']['baz']['plugin'] = 'custom_context_reaction_baz'; } } /** * Alter/add a condition to a node-related event. * * Allows modules to add one or more context condition plugin executions to a * node view, form, etc. * * @param $node * The node object. * @param $op * The node-related operation: 'node', 'form', 'comment'. */ function hook_context_node_condition_alter(&$node, $op) { if ($plugin = context_get_plugin('condition', 'bar')) { $plugin->execute($node, $op); } }