You appear to be a bot. Output may be restricted
Description
Register custom post type: oik_hookAction hooks and filters extend the processing of WordPress, plugins and themes. Rather than maintain a list of functions that the hook calls we need to list the functions that implement the hook. We can determine this from the add_action(), add_filter() calls which specify the hook name and the API that implements it. Since hook names can be dynamically specified we need to find a mechanism of looking up the hook using wild cards. The plugin and sourcefile is required to identify where the hook documentation is originally held. This seems a bit tricky doesn't it? We use _oik_hook_docblock to keep a copy of the most recent docblock comment for the hook and _oik_hook_parms for the @param definitions
Usage
oik_register_hook();
Parameters
Returns
voidSource
File name: oik-shortcodes/oik-shortcodes.phpLines:
function oik_register_hook() { $post_type = 'oik_hook'; $post_type_args = array(); $post_type_args['label'] = 'Hooks'; $post_type_args['description'] = 'Action and filter hooks'; $post_type_args['has_archive'] = true; $post_type_args['show_in_rest'] = true; $post_type_args['supports'] = array( 'title', 'editor', 'revisions', 'author' ); bw_register_post_type( $post_type, $post_type_args ); bw_register_field( "_oik_hook_name", "text", "Hook name" , array( "#length" => 80 )); bw_register_field( "_oik_hook_type", "select", "Hook type", array( "#options" => oiksc_hook_types()) ); bw_register_field( "_oik_hook_plugin", "noderef", "Plugin ref", array( "#type" => array( "oik-plugins", "oik-themes" ), "#optional" => true )); bw_register_field( "_oik_hook_source", "text", "Sourcefile" , array( "#length" => 80 )); //bw_register_field( "_oik_fileref", "noderef", "File ref", array( "#type" => "oik-plugins" )); bw_register_field( "_oik_hook_docblock", "textarea", "Description" ); bw_register_field( "_oik_hook_parms", "textarea", "Parameters" ); bw_register_field( "_oik_hook_deprecated_cb", "checkbox", "Deprecated?" ); // // _oik_hook_invokers is a (yet to be developed) dummy field. // It's a dummy field since it can be built in reverse from the _oik_api_hooks field // Invokers are the functions that initiate the hook. // bw_register_field( "_oik_hook_calls", "noderef", "Implementers", array( "#type" => "oik_api", "#multiple" => true, "#optional" => true, "#form" => false, "#theme" => false )); bw_register_field_for_object_type( "_oik_hook_name", $post_type ); bw_register_field_for_object_type( "_oik_hook_type", $post_type ); bw_register_field_for_object_type( "_oik_hook_plugin", $post_type ); bw_register_field_for_object_type( "_oik_hook_source", $post_type ); bw_register_field_for_object_type( "_oik_fileref", $post_type ); bw_register_field_for_object_type( "_oik_hook_docblock", $post_type ); bw_register_field_for_object_type( "_oik_hook_parms", $post_type ); bw_register_field_for_object_type( "_oik_hook_deprecated_cb", $post_type ); bw_register_field_for_object_type( "_oik_hook_calls", $post_type ); if ( function_exists( "oikp_columns_and_titles" ) ) { oikp_columns_and_titles( $post_type ); } }View on GitHub