WordPress で現在実行中のフィルター (またはアクション) 名と、それに登録されているフックの一覧と、現在実行中のフックの情報をログに出力する PHP コード
以下のようにログに出力されます。
[13-Feb-2015 11:50:29 UTC] # filter or action name: save_post ## current priority: 99 ## current hook name: s2_admin->publish ### priority: 10 1. delete_get_calendar_cache 2. acf_form_post->save_post 3. acf_admin_field_group->save_post 4. s2_admin->s2_meta_handler 5. twentyfourteen_category_transient_flusher 6. WP_Widget_Recent_Posts->flush_widget_cache 7. Custom_Field_Revisions->save_post_meta_in_revision 8. Featured_Content ### priority: 99 1. s2_admin->publish
次のコードを wp-config.php とかに書いてください。
それで適当なところから `log_current_hook()' を実行すると上記のようなログが出力されます。
各フックが呼び出される順番もログの通りなはずです。違ってたらごめんなさい。
あと、ソートしてないので優先度の順番が変わる場合があるかもしれないです。直したかったら ksort( $wp_filter[$tag] ) を呼ぶようにすれば直ると思います。
function log_current_hook() { global $wp_current_filter, $wp_filter; $clone_wp_current_filter = $wp_current_filter; $tag = end( $clone_wp_current_filter ); $message = "\n"; $message .= '# filter or action name: ' . $tag . "\n"; $priorities = $wp_filter[$tag]; $current_priority = key( $wp_filter[$tag] ); $current_idx = key( $wp_filter[$tag][$current_priority] ); $message .= '## current priority: ' . $current_priority . "\n"; $current_hook_name = _get_hook_name_for_log( $wp_filter[$tag][$current_priority][$current_idx] ); $message .= '## current hook name: ' . $current_hook_name . "\n"; if ( is_array( $priorities ) ) { foreach ( $priorities as $priority => $hooks ) { $message .= '### priority: ' . $priority . "\n"; $count = 0; foreach ( $hooks as $hook ) { $message .= str_pad( ++$count . '.', 4, ' ' ); $message .= _get_hook_name_for_log( $hook ); $message .= "\n"; } } } error_log( $message ); } function _get_hook_name_for_log( $hook ) { if ( is_string( $hook['function'] ) ) { return $hook['function']; } else if ( is_array( $hook['function'] ) ) { if ( 1 <= count( $hook['function'] ) && is_string( $hook['function'][0] ) ) { return $hook['function'][0]; } else if ( 2 <= count( $hook['function'] ) && is_object( $hook['function'][0] ) && is_string( $hook['function'][1] ) ) { return get_class( $hook['function'][0] ) . '->' . $hook['function'][1]; } else { return 'CAN NOT GET THIS HOOK NAME.'; } } else { return 'CAN NOT GET THIS HOOK NAME.'; } }