Plugin Hooks
From Habari Project
The information available on this page are based on revision 2696.
Habari plugins are divided into two types: actions and filters.
- Actions do something.
- Filters modify something.
The above distinction is a little imprecise: actions can modify things, since objects are passed by reference. But the intent of actions is to perform some task, and filters are designed to return some modified value.
For example, the filter post_insert_allow is used to determine if a specific post can be inserted. Plugins that filter against this hook must accept as their parameters a boolean value, and the post object that is to be inserted. If the plugin determines that the post should not be inserted, the filter should return a boolean false value.
Plugin hooks are (usually) invoked using the format class_method_extra. This makes it easy, when reading a plugin's source code, to see where in the core Habari code the plugin is being invoked.
Plugins connect to the Habari hooks using the format type_hookname, where "type" is either action or filter and "hookname" is the hook name as described above. As an example, consider a plugin that prevents anyone from saving new posts after 10 PM. The plugin will be invoked by the post_insert_allow filter, so the plugin will contain a function called filter_post_insert_allow. When Habari prepares to insert a post, it will trigger the plugin hook, thereby invoking the plugin's filter. The plugin's filter would check the local time, and if it's after 10 PM the filter would return boolean false. The post insertion process of Habari would be short-circuited, and the post would not be saved.
List of Plugin Hooks
Actions
admin/footer.php:10: Plugins::act( 'admin_footer', $this );
admin/header.php:34: Plugins::act( 'admin_header', $this );
admin/header.php:75: Plugins::act('admin_info', $theme, $page);
admin/login.php:24: Plugins::act( 'admin_header', $this );
admin/login.php:37: Plugins::act( 'theme_loginform_before' );
admin/login.php:46: Plugins::act( 'theme_loginform_controls' );
admin/login.php:52: Plugins::act( 'theme_loginform_after' );
admin/login.php:58: Plugins::act( 'admin_footer', $this );
admin/plugins.php:60: Plugins::act( 'plugin_ui', $configure, $configaction );
admin/themes.php:34: Plugins::act( 'theme_ui', $active_theme );
admin/user.php:180: Plugins::act( 'theme_admin_user', $user );
classes/acl.php:121: Plugins::act('permission_create_before', $name, $description);
classes/acl.php:129: Plugins::act('permission_create_after', $name, $description );
classes/acl.php:154: Plugins::act('permission_destroy_before', $permission );
classes/acl.php:167: Plugins::act('permission_destroy_after', $permission );
classes/actionhandler.php:52: Plugins::act( $before_action_method, $this );
classes/actionhandler.php:63: Plugins::act( $after_action_method );
classes/adminhandler.php:87: Plugins::act('admin_theme_post_' . $page, $this, $this->theme);
classes/adminhandler.php:101: Plugins::act('admin_theme_get_' . $page, $this, $this->theme);
classes/adminhandler.php:454: Plugins::act('publish_post', $post, $form);
classes/adminhandler.php:601: Plugins::act('form_publish', $form, $post);
classes/adminhandler.php:950: Plugins::act('adminhandler_get_plugin_toggle_action', $action, $file, $plugin_id, $plugins);
classes/adminhandler.php:1126: Plugins::act('form_comment_edit', $form, $comment);
classes/adminhandler.php:1182: Plugins::act('comment_edit', $comment, $form);
classes/adminhandler.php:1310: Plugins::act( 'admin_moderate_comments', $action, $to_update, $this );
classes/adminhandler.php:1902: Plugins::act( 'admin_moderate_comments', $handler_vars['action'], $comments, $this );
classes/ajaxhandler.php:29: Plugins::act('ajax_' . $this->handler_vars['context'], $this);
classes/ajaxhandler.php:48: Plugins::act('auth_ajax_' . $this->handler_vars['context'], $this);
classes/atomhandler.php:21: Plugins::act('init_atom');
classes/atomhandler.php:154: Plugins::act( 'atom_create_wrapper', $xml );
classes/atomhandler.php:197: Plugins::act( 'atom_add_post', $feed_entry, $post );
classes/atomhandler.php:229: Plugins::act( 'atom_add_comment', $item, $comment );
classes/atomhandler.php:354: Plugins::act( 'rsd', $xml, $this->handler_vars );
classes/atomhandler.php:393: Plugins::act( 'atom_introspection', $xml, $this->handler_vars );
classes/atomhandler.php:468: Plugins::act( 'atom_get_comments', $xml, $params, $this->handler_vars );
classes/atomhandler.php:525: Plugins::act( 'atom_get_entry', $xml, $post, $this->handler_vars );
classes/atomhandler.php:551: Plugins::act( 'atom_put_entry', $xml, $post, $this->handler_vars );
classes/atomhandler.php:652: Plugins::act( 'atom_get_collection', $xml, $params, $handler_vars );
classes/atomhandler.php:672: Plugins::act( 'atom_post_collection', $xml, $post, $this->handler_vars );
classes/comment.php:120: Plugins::act('comment_insert_before', $this);
classes/comment.php:123: Plugins::act('comment_update_' . $fieldname, $this, $this->$fieldname, $value );
classes/comment.php:130: Plugins::act('comment_insert_after', $this);
classes/comment.php:145: Plugins::act('comment_update_before', $this);
classes/comment.php:148: Plugins::act('comment_update_' . $fieldname, $this, $this->fields[$fieldname], $value);
classes/comment.php:154: Plugins::act('comment_update_after', $this);
classes/comment.php:169: Plugins::act('comment_delete_before', $this);
classes/comment.php:175: Plugins::act('comment_delete_after', $this);
classes/controller.php:165: Plugins::act('handler_' . Controller::instance()->action, Controller::get_handler_vars());
classes/logentry.php:278: Plugins::act( 'logentry_delete_before', $this );
classes/logentry.php:280: Plugins::act( 'logentry_delete_after', $this );
classes/plugins.php:351: Plugins::act('plugin_activation', $file); // For the plugin to install itself
classes/plugins.php:352: Plugins::act('plugin_activated', $file); // For other plugins to react to a plugin install
classes/plugins.php:378: Plugins::act('plugin_deactivation', $file); // For the plugin to uninstall itself
classes/plugins.php:381: Plugins::act('plugin_deactivated', $file); // For other plugins to react to a plugin uninstallation
classes/post.php:587: Plugins::act( 'post_insert_before', $this );
classes/post.php:591: Plugins::act( 'post_update_' . $fieldname, $this, ( $this->id == 0 ) ? null : $value, $this->$fieldname );
classes/post.php:594: Plugins::act( 'post_status_' . self::status_name( $this->status ), $this, null );
classes/post.php:604: Plugins::act( 'post_insert_after', $this );
classes/post.php:634: Plugins::act( 'post_update_before', $this );
classes/post.php:647: Plugins::act( 'post_update_' . $fieldname, $this, $this->fields[$fieldname], $value );
classes/post.php:652: Plugins::act( 'post_status_' . self::status_name( $this->newfields['status'] ), $this, $this->fields['status'] );
classes/post.php:666: Plugins::act( 'post_update_after', $this );
classes/post.php:682: Plugins::act( 'post_delete_before', $this );
classes/post.php:704: Plugins::act( 'post_delete_after', $this );
classes/post.php:723: Plugins::act( 'post_publish_before', $this );
classes/post.php:742: Plugins::act( 'post_publish_after', $this );
classes/posts.php:597: Plugins::act( 'posts_reassign_before', array( $user, $posts ) );
classes/posts.php:599: Plugins::act( 'posts_reassign_after', array( $user, $posts ) );
classes/tag.php:87: Plugins::act( 'tag_attach_to_post_before', $tag_id, $post_id );
classes/tag.php:92: Plugins::act( 'tag_attach_to_post_after', $tag_id, $post_id );
classes/tag.php:140: Plugins::act( 'tag_insert_before', $this );
classes/tag.php:144: Plugins::act( 'tag_update_' . $fieldname, $this, ( $this->id == 0 ) ? null : $value, $this->$fieldname );
classes/tag.php:152: Plugins::act( 'tag_insert_after', $this );
classes/tag.php:169: Plugins::act( 'tag_update_before', $this );
classes/tag.php:182: Plugins::act( 'tag_update_' . $fieldname, $this, $this->fields[$fieldname], $value );
classes/tag.php:189: Plugins::act( 'tag_update_after', $this );
classes/tag.php:205: Plugins::act( 'tag_delete_before', $this );
classes/tag.php:215: Plugins::act( 'tag_delete_after', $this );
classes/theme.php:115: Plugins::act( 'add_template_vars', $this, Controller::get_handler()->handler_vars );
classes/theme.php:557: Plugins::act( 'template_header', $theme );
classes/theme.php:568: Plugins::act( 'template_footer', $theme );
classes/theme.php:843: Plugins::act( 'theme_action', $action, $this, $user_filters );
classes/themes.php:191: Plugins::act('init_theme');
classes/update.php:62: Plugins::act('update_check');
classes/user.php:114: Plugins::act('user_insert_before', $this);
classes/user.php:123: Plugins::act('user_insert_after', $this);
classes/user.php:138: Plugins::act('user_update_before', $this);
classes/user.php:142: Plugins::act('user_update_after', $this);
classes/user.php:156: Plugins::act('user_delete_before', $this);
classes/user.php:166: Plugins::act('user_delete_after', $this);
classes/user.php:192: Plugins::act( 'user_forget', $this );
classes/user.php:221: Plugins::act( 'user_authenticate_successful', self::$identity );
classes/user.php:253: Plugins::act( 'user_authenticate_successful', self::$identity );
classes/usergroup.php:75: Plugins::act('usergroup_insert_before', $this);
classes/usergroup.php:83: Plugins::act('usergroup_insert_after', $this);
classes/usergroup.php:98: Plugins::act('usergroup_update_before', $this);
classes/usergroup.php:103: Plugins::act('usergroup_update_after', $this);
classes/usergroup.php:133: Plugins::act('usergroup_delete_before', $this);
classes/usergroup.php:140: Plugins::act('usergroup_delete_after', $this);
classes/userhandler.php:96: Plugins::act( 'user_logout', $user );
themes/k2/login-disabled.php:7: Plugins::act( 'theme_login' );
themes/k2/loginform.php:17: Plugins::act( 'theme_loginform_before' );
themes/k2/loginform.php:27: Plugins::act( 'theme_loginform_controls' );
themes/k2/loginform.php:32: Plugins::act( 'theme_loginform_after' );
themes/k2/searchform.php:2: Plugins::act( 'theme_searchform_before' );
themes/k2/searchform.php:6: Plugins::act( 'theme_searchform_after' );
themes/k2/sidebar.php:2: Plugins::act( 'theme_sidebar_top' );
themes/k2/sidebar.php:19: Plugins::act( 'theme_sidebar_bottom' );
themes/mzingi/loginform.php:15: Plugins::act( 'theme_loginform_before' );
themes/mzingi/loginform.php:25: Plugins::act( 'theme_loginform_controls' );
themes/mzingi/loginform.php:30: Plugins::act( 'theme_loginform_after' );
themes/mzingi/searchform.php:2: Plugins::act( 'theme_searchform_before' );
themes/mzingi/searchform.php:6: Plugins::act( 'theme_searchform_after' );
Filters
admin/import.php:10: $import_names = Plugins::filter('import_names', $import_names);
admin/import.php:28: echo Plugins::filter('import_stage', '', @$_POST['importer'], @$_POST['stage'], @$_POST['step']);
admin/plugins.php:31: $plugin_actions = Plugins::filter( 'plugin_config', $plugin_actions, $plugin['plugin_id'] );
admin/posts_items.php:20: $actions = Plugins::filter('post_actions', $actions, $post);
classes/acl.php:117: $allow = Plugins::filter('permission_create_allow', $allow, $name, $description );
classes/acl.php:150: $allow = Plugins::filter('permission_destroy_allow', $allow, $permission);
classes/adminhandler.php:72: $theme_dir = Plugins::filter( 'admin_theme_dir', Site::get_dir( 'admin_theme', TRUE ) );
classes/adminhandler.php:243: $option_items = Plugins::filter( 'admin_option_items', $option_items );
classes/adminhandler.php:385: $module = Plugins::filter( 'dash_module_' .$slug, $module, $id, $this->theme );
classes/adminhandler.php:550: $statuses = Plugins::filter( 'admin_publish_list_post_statuses', $statuses );
classes/adminhandler.php:659: $fields = Plugins::filter( 'adminhandler_post_user_fields', $fields );
classes/adminhandler.php:999: $this->theme->configurable = Plugins::filter( 'theme_config', false, $this->active_theme);
classes/adminhandler.php:1095: $statuses = Plugins::filter( 'admin_publish_list_comment_statuses', $statuses );
classes/adminhandler.php:1452: $plugin['actions']= Plugins::filter( 'plugin_config', $plugin_actions, $plugin_id );
classes/adminhandler.php:1650: $theme_dir = Plugins::filter( 'admin_theme_dir', Site::get_dir( 'admin_theme', TRUE ) );
classes/adminhandler.php:1696: $theme_dir = Plugins::filter( 'admin_theme_dir', Site::get_dir( 'admin_theme', TRUE ) );
classes/adminhandler.php:1724: $theme_dir = Plugins::filter( 'admin_theme_dir', Site::get_dir( 'admin_theme', TRUE ) );
classes/adminhandler.php:1753: $theme_dir = Plugins::filter( 'admin_theme_dir', Site::get_dir( 'admin_theme', TRUE ) );
classes/adminhandler.php:1928: $status_msg = Plugins::filter( 'admin_comments_action', $status_msg, $handler_vars['action'], $comments );
classes/adminhandler.php:2126: $theme_dir = Plugins::filter( 'admin_theme_dir', Site::get_dir( 'admin_theme', TRUE ) );
classes/adminhandler.php:2320: $theme_dir = Plugins::filter( 'admin_theme_dir', Site::get_dir( 'admin_theme', TRUE ) );
classes/adminhandler.php:2413: $mainmenus = Plugins::filter( 'adminhandler_post_loadplugins_main_menu', $mainmenus );
classes/adminhandler.php:2462: $controls = Plugins::filter( 'media_controls', $controls, $silo, $rpath, '' );
classes/adminhandler.php:2476: $panel = Plugins::filter( 'media_panels', $panel, $silo, $rpath, $panelname );
classes/adminhandler.php:2478: $controls = Plugins::filter( 'media_controls', $controls, $silo, $rpath, $panelname );
classes/atomhandler.php:82: $namespaces = Plugins::filter( 'atom_get_collection_namespaces', $namespaces );
classes/atomhandler.php:287: $apis_list = Plugins::filter('rsd_api_list', $apis_list);
classes/atomhandler.php:617: $alternate_rules = Plugins::filter( 'atom_get_collection_alternate_rules', $alternate_rules );
classes/atomhandler.php:636: $params['content_type'] = Plugins::filter( 'atom_get_collection_content_type', $params['content_type'] );
classes/comment.php:116: $allow = Plugins::filter('comment_insert_allow', $allow, $this);
classes/comment.php:141: $allow = Plugins::filter('comment_update_allow', $allow, $this);
classes/comment.php:165: $allow = Plugins::filter('comment_delete_allow', $allow, $this);
classes/comment.php:217: $out = Plugins::filter( "comment_{$name}", $out, $this );
classes/comment.php:219: $out = Plugins::filter( "comment_{$name}_{$filter}", $out, $this );
classes/controller.php:135: $start_url = Plugins::filter('rewrite_request', $start_url);
classes/cronjob.php:113: $result = Plugins::filter( $this->callback, $result, $paramarray );
classes/databaseconnection.php:209: $query = Plugins::filter( 'db_exec', $query, array() );
classes/databaseconnection.php:215: $query = Plugins::filter( 'db_exec_postprocess', $query, array() );
classes/databaseconnection.php:234: $query = Plugins::filter( 'query', $query, $args );
classes/databaseconnection.php:240: $query = Plugins::filter( 'query_postprocess', $query, $args );
classes/feedbackhandler.php:129: $spam_rating = Plugins::filter('spam_filter', $spam_rating, $comment, $this->handler_vars);
classes/formui.php:180: $theme_dir = Plugins::filter( 'control_theme_dir', Plugins::filter( 'admin_theme_dir', Site::get_dir( 'admin_theme', TRUE ) ) . 'formcontrols/', $control );
classes/formui.php:774: $this->default = Plugins::filter($location, '', $this->name, false);
classes/formui.php:815: Plugins::filter($location, $this->value, $this->name, true);
classes/hiengine.php:42: $template_file = Plugins::filter('include_template_file', $template_file, $template, __CLASS__);
classes/logentry.php:198: Plugins::filter( 'insert_logentry', $this );
classes/logentry.php:274: $allow = Plugins::filter( 'logentry_delete_allow', $allow, $this );
classes/logentry.php:314: $out = Plugins::filter( "logentry_{$name}", $out, $this );
classes/logentry.php:316: $out = Plugins::filter( "logentry_{$name}_{$filter}", $out, $this );
classes/modules.php:20:self:: $available_modules = (array) Plugins::filter( 'dash_modules', array() );
classes/modules.php:214:self:: $status_data = Plugins::filter('dashboard_status', array());
classes/options.php:115: $option_value = Plugins::filter('option_get_value', $option_value, $name);
classes/options.php:150: $value = Plugins::filter( 'option_set_value', $value, $name, isset($this->options[$name]) ? $this->options[$name] : null );
classes/plugins.php:339: $ok = Plugins::filter('activate_plugin', $ok, $file); // Allow plugins to reject activation
classes/plugins.php:366: $ok = Plugins::filter('deactivate_plugin', $ok, $file); // Allow plugins to reject deactivation
classes/post.php:378: $slug = Plugins::filter( 'post_setslug', $value );
classes/post.php:583: $allow = Plugins::filter( 'post_insert_allow', $allow, $this );
classes/post.php:630: $allow = Plugins::filter( 'post_update_allow', $allow, $this );
classes/post.php:677: $allow = Plugins::filter( 'post_delete_allow', $allow, $this );
classes/post.php:719: $allow = Plugins::filter( 'post_publish_allow', $allow, $this );
classes/post.php:798: $out = Plugins::filter( "post_{$name}", $out, $this );
classes/post.php:800: $out = Plugins::filter( "post_{$name}_{$filter}", $out, $this );
classes/posts.php:570: $allow = Plugins::filter( 'posts_reassign_allow', $allow );
classes/rawphpengine.php:90: //$template_file= Plugins::filter('include_template_file', $this->template_dir . $template . '.php', $template, __CLASS__);
classes/rawphpengine.php:92: $template_file = Plugins::filter('include_template_file', $template_file, $template, __CLASS__);
classes/rawphpengine.php:118: $this->available_templates = Plugins::filter('available_templates', $this->available_templates, __CLASS__);
classes/remoterequest.php:221: return Plugins::filter( 'remoterequest', $data, $url );
classes/rewriterule.php:106: $args = Plugins::filter( 'rewrite_args', $args, $this->name );
classes/rewriterule.php:153: $args = Plugins::filter( 'rewrite_args', $args, $this->name );
classes/rewriterules.php:59: $default_rules = Plugins::filter('default_rewrite_rules', $default_rules);
classes/rewriterules.php:90: $rewrite_rules = Plugins::filter('rewrite_rules', $system_rules);
classes/session.php:93: $dodelete = Plugins::filter( 'session_read', $dodelete, $session, $session_id );
classes/session.php:98: $sql = Plugins::filter( 'sessions_clean', $sql, 'read', $args );
classes/session.php:106: $probability = Plugins::filter( 'gc_probability', ( is_numeric($probability) && $probability > 0 ) ? $probability : 1 );
classes/session.php:129: $dowrite = Plugins::filter( 'session_write', $dowrite, $session_id, $data );
classes/session.php:157: $sql = Plugins::filter( 'sessions_clean', $sql, 'destroy', $args );
classes/session.php:171: $sql = Plugins::filter( 'sessions_clean', $sql, 'gc', $args );
classes/site.php:190: $url = Plugins::filter( 'site_url_' . $name, $url );
classes/site.php:241: $path = Plugins::filter( 'site_path_' . $name, $path );
classes/site.php:325: $path = Plugins::filter( 'site_dir_' . $name, $path );
classes/smartyengine.php:98: //$template_file= Plugins::filter('include_template_file', $this->template_dir . $template . '.php', $template, __CLASS__);
classes/smartyengine.php:100: $template_file = Plugins::filter('include_template_file', $template_file, $template, __CLASS__);
classes/smartyengine.php:129: $this->available_templates = Plugins::filter('available_templates', $this->available_templates, __CLASS__);
classes/stack.php:159: $stack = Plugins::filter( 'stack_out', $stack, $stack_name );
classes/tag.php:122: $slug = Plugins::filter( 'tag_setslug', $value );
classes/tag.php:136: $allow = Plugins::filter( 'tag_insert_allow', $allow, $this );
classes/tag.php:165: $allow = Plugins::filter( 'tag_update_allow', $allow, $this );
classes/tag.php:200: $allow = Plugins::filter( 'tag_delete_allow', $allow, $this );
classes/theme.php:175: $user_filters = Plugins::filter( 'template_user_filters', $user_filters );
classes/theme.php:178: $where_filters = Plugins::filter( 'template_where_filters', $where_filters );
classes/theme.php:246: $fallback = Plugins::filter( 'template_fallback', $fallback );
classes/user.php:110: $allow = Plugins::filter('user_insert_allow', $allow, $this);
classes/user.php:134: $allow = Plugins::filter('user_update_allow', $allow, $this);
classes/user.php:152: $allow = Plugins::filter('user_delete_allow', $allow, $this);
classes/user.php:218: $user = Plugins::filter('user_authenticate', $user, $who, $pw);
classes/usergroup.php:71: $allow = Plugins::filter('usergroup_insert_allow', $allow, $this);
classes/usergroup.php:94: $allow = Plugins::filter('usergroup_update_allow', $allow, $this);
classes/usergroup.php:127: $allow = Plugins::filter('usergroup_delete_allow', $allow, $this);
classes/userthemehandler.php:48: $handled = Plugins::filter('theme_act_' . $action, $handled, $this->theme);
classes/utils.php:592: $slug = Plugins::filter('slugify', $slug, $string);
classes/utils.php:872: $mimetype = Plugins::filter('get_mime_type', $mimetype, $filename);
classes/xmlrpcexception.php:74: return Plugins::filter( 'xmlrpcexception_get_message', _t('Unknown XMLRPC Exception'), $code );
classes/xmlrpcserver.php:60: $res = Plugins::filter('xmlrpc_methods', $res);
plugins/spamchecker/spamchecker.plugin.php:239: $code = Plugins::filter('comment_code', $code, $post_id, $ip);
plugins/spamchecker/spamchecker.plugin.php:255: $code = Plugins::filter('comment_code', $code, $post_id, $ip);
