Plugin Hooks
From Habari Project
The information available on this page are based on revision 1260.
Habari plugins are divided into two types: actions and filters.
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: Plugins::act( 'admin_footer', $this );
admin/header.php: Plugins::act( 'admin_header', $this );
admin/login.php: Plugins::act( 'admin_header', $this );
admin/login.php: Plugins::act( 'admin_footer', $this );
admin/plugins.php: Plugins::act( 'plugin_ui', $configure, $action );
admin/user.php: Plugins::act( 'theme_admin_user', $user );
classes/actionhandler.php: Plugins::act( $before_action_method );
classes/actionhandler.php: Plugins::act( $after_action_method );
classes/adminhandler.php: Plugins::activate_plugin( $plugin );
classes/ajaxhandler.php: Plugins::act('ajax_' . $this->handler_vars['context'], $this);
classes/ajaxhandler.php: Plugins::act('auth_ajax_' . $this->handler_vars['context'], $this);
classes/atomhandler.php: Plugins::act('init_atom');
classes/comment.php: Plugins::act('comment_insert_before', $this);
classes/comment.php: Plugins::act('comment_update_' . $fieldname, $this, $this->$fieldname, $value );
classes/comment.php: Plugins::act('comment_insert_after', $this);
classes/comment.php: Plugins::act('comment_update_before', $this);
classes/comment.php: Plugins::act('comment_update_' . $fieldname, $this, $this->fields[$fieldname], $value);
classes/comment.php: Plugins::act('comment_update_after', $this);
classes/comment.php: Plugins::act('comment_delete_before', $this);
classes/comment.php: Plugins::act('comment_delete_after', $this);
classes/controller.php: Plugins::act('handler_' . Controller::instance()->action, Controller::get_handler_vars());
classes/plugins.php: Plugins::act('plugin_activation', $file); // For the plugin to install itself
classes/plugins.php: Plugins::act('plugin_activated', $file); // For other plugins to react to a plugin install
classes/plugins.php: Plugins::act('plugin_deactivation', $file); // For the plugin to uninstall itself
classes/plugins.php: Plugins::act('plugin_deactivated', $file); // For other plugins to react to a plugin uninstallation
classes/post.php: Plugins::act('post_insert_before', $this);
classes/post.php: Plugins::act('post_update_' . $fieldname, $this, ($this->id == 0) ? null : $value, $this->$fieldname );
classes/post.php: Plugins::act('post_status_' . self::status_name($this->status), $this, null );
classes/post.php: Plugins::act('post_insert_after', $this);
classes/post.php: Plugins::act('post_update_before', $this);
classes/post.php: Plugins::act('post_update_' . $fieldname, $this, $this->fields[$fieldname], $value );
classes/post.php: Plugins::act('post_status_' . self::status_name($this->newfields['status']), $this, $this->fields['status'] );
classes/post.php: Plugins::act('post_update_after', $this);
classes/post.php: Plugins::act('post_delete_before', $this);
classes/post.php: Plugins::act('post_delete_after', $this);
classes/post.php: Plugins::act('post_publish_before', $this);
classes/post.php: Plugins::act('post_publish_after', $this);
classes/theme.php: Plugins::act('add_template_vars', $this, Controller::get_handler()->handler_vars);
classes/theme.php: Plugins::act( 'template_header', $this );
classes/theme.php: Plugins::act( 'template_footer', $this );
classes/theme.php: Plugins::act('theme_action', $action, $this, $user_filters);
classes/themes.php: Plugins::act('init_theme');
classes/update.php: Plugins::act('update_check');
classes/user.php: Plugins::act('user_insert_before', $this);
classes/user.php: Plugins::act('user_insert_after', $this);
classes/user.php: Plugins::act('user_update_before', $this);
classes/user.php: Plugins::act('user_update_after', $this);
classes/user.php: Plugins::act('user_delete_before', $this);
classes/user.php: Plugins::act('user_delete_after', $this);
classes/user.php: Plugins::act( 'user_authenticate_successful', self::$identity );
classes/user.php: Plugins::act( 'user_authenticate_successful', self::$identity );
Filters
admin/dashboard.php: Plugins::filter( 'statistics_summary', $stats );
admin/import.php: Plugins::filter('import_names', $import_names);
admin/import.php: Plugins::filter('import_stage', '', @$_POST['importer'], @$_POST['stage'], @$_POST['step']);
admin/plugins.php: Plugins::filter( 'plugin_config', $plugin_actions, $plugin['plugin_id'] );
classes/adminhandler.php: Plugins::filter( 'admin_publish_list_post_statuses', $statuses );
classes/adminhandler.php: Plugins::filter( 'publish_controls', $controls, $post );
classes/adminhandler.php: Plugins::filter( 'adminhandler_post_user_fields', $fields );
classes/adminhandler.php: Plugins::filter( 'plugin_config', $plugin_actions, $plugin_id );
classes/adminhandler.php: Plugins::filter( 'adminhandler_post_loadplugins_main_menu', $mainmenus );
classes/atomhandler.php: Plugins::filter('rsd_api_list', $apis_list);
classes/atomhandler.php: Plugins::filter( 'rsd', $xml, $this->handler_vars );
classes/atomhandler.php: Plugins::filter( 'atom_introspection', $xml, $this->handler_vars );
classes/atomhandler.php: Plugins::filter( 'atom_get_comments', $xml, $params, $this->handler_vars );
classes/atomhandler.php: Plugins::filter( 'atom_get_entry', $xml, $slug, $this->handler_vars );
classes/atomhandler.php: Plugins::filter( 'atom_put_entry', $xml, $slug, $this->handler_vars );
classes/atomhandler.php: Plugins::filter( 'atom_get_collection_namespaces', $namespaces );
classes/atomhandler.php: Plugins::filter( 'atom_get_collection_content_type', $params['content_type'] );
classes/atomhandler.php: Plugins::filter( 'atom_get_collection', $xml, $params, $handler_vars );
classes/atomhandler.php: Plugins::filter( 'atom_post_collection', $xml, $this->handler_vars );
classes/comment.php: Plugins::filter('comment_insert_allow', $allow, $this);
classes/comment.php: Plugins::filter('comment_update_allow', $allow, $this);
classes/comment.php: Plugins::filter('comment_delete_allow', $allow, $this);
classes/comment.php: Plugins::filter( "comment_{$name}", $out, $this );
classes/comment.php: Plugins::filter( "comment_{$name}_{$filter}", $out, $this );
classes/controller.php: Plugins::filter('rewrite_request', $start_url);
classes/cronjob.php: Plugins::filter( $this->callback, $result, $paramarray );
classes/databaseconnection.php: Plugins::filter( 'query', $query, $args );
classes/databaseconnection.php: Plugins::filter( 'query_postprocess', $query, $args );
classes/feedbackhandler.php: Plugins::filter('spam_filter', $spam_rating, $comment, $this->handler_vars);
classes/formui.php: Plugins::filter($this->success_callback, $result, $this);
classes/formui.php: Plugins::filter($validator, $valid, $this->value);
classes/logentry.php: Plugins::filter( 'insert_logentry', $this );
classes/logentry.php: Plugins::filter( "logentry_{$name}", $out, $this );
classes/logentry.php: Plugins::filter( "logentry_{$name}_{$filter}", $out, $this );
classes/options.php: Plugins::filter('option_get_value', $option_value, $name);
classes/plugins.php: Plugins::filter('activate_plugin', $ok, $file);
classes/plugins.php: Plugins::filter('deactivate_plugin', $ok, $file);
classes/post.php: Plugins::filter('post_setslug', $value);
classes/post.php: Plugins::filter('post_insert_allow', $allow, $this);
classes/post.php: Plugins::filter('post_update_allow', $allow, $this);
classes/post.php: Plugins::filter('post_delete_allow', $allow, $this);
classes/post.php: Plugins::filter('post_publish_allow', $allow, $this);
classes/post.php: Plugins::filter( "post_{$name}", $out, $this );
classes/post.php: Plugins::filter( "post_{$name}_{$filter}", $out, $this );
classes/rawphpengine.php: Plugins::filter('include_template_file', $this->template_dir . $template . '.php', $template);
classes/remoterequest.php: Plugins::filter( 'remoterequest', $data, $url );
classes/rewriterule.php: Plugins::filter( 'rewrite_args', $args, $this->name );
classes/rewriterule.php: Plugins::filter( 'rewrite_args', $args, $this->name );
classes/rewriterules.php: Plugins::filter('default_rewrite_rules', $default_rules);
classes/rewriterules.php: Plugins::filter('rewrite_rules', $system_rules);
classes/session.php: Plugins::filter( 'session_read', $dodelete, $session, $session_id );
classes/session.php: Plugins::filter( 'sessions_clean', $sql, 'read', $args );
classes/session.php: Plugins::filter( 'sessions_clean', $sql, 'destroy', $args );
classes/session.php: Plugins::filter( 'sessions_clean', $sql, 'gc', $args );
classes/site.php: Plugins::filter( 'site_url_' . $name, $url );
classes/site.php: Plugins::filter( 'site_path_' . $name, $path );
classes/site.php: Plugins::filter( 'site_dir_' . $name, $path );
classes/stack.php: Plugins::filter( 'stack_out', $stack, $stack_name );
classes/theme.php: Plugins::filter( 'template_user_filters', $user_filters );
classes/theme.php: Plugins::filter( 'template_fallback', $fallback );
classes/user.php: Plugins::filter('user_insert_allow', $allow, $this);
classes/user.php: Plugins::filter('user_update_allow', $allow, $this);
classes/user.php: Plugins::filter('user_delete_allow', $allow, $this);
classes/user.php: Plugins::filter('user_authenticate', $user, $who, $pw);
classes/userthemehandler.php: Plugins::filter('theme_act_' . $action, $handled, $this->theme);
classes/utils.php: Plugins::filter('slugify', $slug, $string);
classes/xmlrpcexception.php: Plugins::filter( 'xmlrpcexception_get_message', _t('Unknown XMLRPC Exception'), $code );
classes/xmlrpcserver.php: Plugins::filter('xmlrpc_methods', $res);
