From fc843ce4d0147d1851fa2e64ae7184f59a1b658b Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 12 Jan 2015 16:40:23 +0000 Subject: [PATCH] There are some random `add_action()` and `add_filter()` calls littered around some files in `wp-includes/`. These should be moved to `wp-includes/default-filters.php` with the rest of the registered hooks. It seems like this was the best practice for awhile and then we randomly stopped. This file loads way before any of the includes, so the hooks will be registered for any request that loads WordPress, even `SHORTINIT` - a lot of the hooks registered won't run anyways (that's already the case). See #30947. Built from https://develop.svn.wordpress.org/trunk@31168 git-svn-id: http://core.svn.wordpress.org/trunk@31149 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/admin-bar.php | 5 -- wp-includes/author-template.php | 1 - wp-includes/canonical.php | 4 -- wp-includes/default-filters.php | 90 +++++++++++++++++++++++++++++- wp-includes/general-template.php | 4 -- wp-includes/kses.php | 3 - wp-includes/media.php | 2 - wp-includes/ms-default-filters.php | 5 ++ wp-includes/ms-functions.php | 3 - wp-includes/nav-menu-template.php | 1 - wp-includes/post-formats.php | 5 -- wp-includes/post.php | 4 -- wp-includes/script-loader.php | 7 --- wp-includes/shortcodes.php | 2 - wp-includes/taxonomy.php | 1 - wp-includes/theme.php | 6 -- wp-includes/update.php | 24 -------- wp-includes/version.php | 2 +- 18 files changed, 95 insertions(+), 74 deletions(-) diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php index 32853c3a14..2849d43f92 100644 --- a/wp-includes/admin-bar.php +++ b/wp-includes/admin-bar.php @@ -44,9 +44,6 @@ function _wp_admin_bar_init() { return true; } -// Don't remove. Wrong way to disable. -add_action( 'template_redirect', '_wp_admin_bar_init', 0 ); -add_action( 'admin_init', '_wp_admin_bar_init' ); /** * Render the admin bar to the page based on the $wp_admin_bar->menu member var. @@ -92,8 +89,6 @@ function wp_admin_bar_render() { */ do_action( 'wp_after_admin_bar_render' ); } -add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); -add_action( 'in_admin_header', 'wp_admin_bar_render', 0 ); /** * Add the WordPress logo menu. diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php index c795e1216a..491689a7d8 100644 --- a/wp-includes/author-template.php +++ b/wp-includes/author-template.php @@ -451,4 +451,3 @@ function is_multi_author() { function __clear_multi_author_cache() { delete_transient( 'is_multi_author' ); } -add_action('transition_post_status', '__clear_multi_author_cache'); diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index 5b2f84d6b7..4e247a945f 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -553,8 +553,6 @@ function redirect_guess_404_permalink() { return false; } -add_action('template_redirect', 'redirect_canonical'); - function wp_redirect_admin_locations() { global $wp_rewrite; if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) ) @@ -582,5 +580,3 @@ function wp_redirect_admin_locations() { exit; } } - -add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 ); diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index dc0c8f80d0..21419f23b0 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -306,4 +306,92 @@ add_filter( 'authenticate', 'wp_authenticate_spam_check', 99 ); add_filter( 'determine_current_user', 'wp_validate_auth_cookie' ); add_filter( 'determine_current_user', 'wp_validate_logged_in_cookie', 20 ); -unset($filter, $action); +/** + * Filters formerly mixed into wp-includes + */ +// Theme +add_action( 'setup_theme', 'preview_theme' ); +add_action( 'wp_loaded', '_custom_header_background_just_in_time' ); +add_action( 'plugins_loaded', '_wp_customize_include' ); +add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' ); +add_action( 'delete_attachment', '_delete_attachment_theme_mod' ); + +// Calendar widget cache +add_action( 'save_post', 'delete_get_calendar_cache' ); +add_action( 'delete_post', 'delete_get_calendar_cache' ); +add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' ); +add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' ); + +// Author +add_action( 'transition_post_status', '__clear_multi_author_cache' ); + +// Post +add_action( 'init', 'create_initial_post_types', 0 ); // highest priority +add_action( 'admin_menu', '_add_post_type_submenus' ); +add_action( 'before_delete_post', '_reset_front_page_settings_for_post' ); +add_action( 'wp_trash_post', '_reset_front_page_settings_for_post' ); + +// Post Formats +add_filter( 'request', '_post_format_request' ); +add_filter( 'term_link', '_post_format_link', 10, 3 ); +add_filter( 'get_post_format', '_post_format_get_term' ); +add_filter( 'get_terms', '_post_format_get_terms', 10, 3 ); +add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' ); + +// KSES +add_action( 'init', 'kses_init' ); +add_action( 'set_current_user', 'kses_init' ); + +// Script Loader +add_action( 'wp_default_scripts', 'wp_default_scripts' ); +add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); +add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); + +add_action( 'wp_default_styles', 'wp_default_styles' ); +add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 ); + +// Taxonomy +add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority + +// Update +add_action( 'admin_init', '_maybe_update_core' ); +add_action( 'wp_version_check', 'wp_version_check' ); +add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 ); +add_action( 'load-plugins.php', 'wp_update_plugins' ); +add_action( 'load-update.php', 'wp_update_plugins' ); +add_action( 'load-update-core.php', 'wp_update_plugins' ); +add_action( 'admin_init', '_maybe_update_plugins' ); +add_action( 'wp_update_plugins', 'wp_update_plugins' ); +add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 ); +add_action( 'load-themes.php', 'wp_update_themes' ); +add_action( 'load-update.php', 'wp_update_themes' ); +add_action( 'load-update-core.php', 'wp_update_themes' ); +add_action( 'admin_init', '_maybe_update_themes' ); +add_action( 'wp_update_themes', 'wp_update_themes' ); +add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 ); +add_action( 'update_option_WPLANG', 'wp_clean_update_cache' , 10, 0 ); +add_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' ); +add_action( 'init', 'wp_schedule_update_checks' ); + +// Canonical +add_action( 'template_redirect', 'redirect_canonical' ); +add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 ); + +// Shortcodes +add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop() + +// Media +add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' ); +add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' ); + +// Nav menu +add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 ); + +// Admin Bar +// Don't remove. Wrong way to disable. +add_action( 'template_redirect', '_wp_admin_bar_init', 0 ); +add_action( 'admin_init', '_wp_admin_bar_init' ); +add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); +add_action( 'in_admin_header', 'wp_admin_bar_render', 0 ); + +unset( $filter, $action ); diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 94bdb6fbf1..080a4ba29e 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -1756,10 +1756,6 @@ function get_calendar($initial = true, $echo = true) { function delete_get_calendar_cache() { wp_cache_delete( 'get_calendar', 'calendar' ); } -add_action( 'save_post', 'delete_get_calendar_cache' ); -add_action( 'delete_post', 'delete_get_calendar_cache' ); -add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' ); -add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' ); /** * Display all of the allowed tags in HTML format with attributes. diff --git a/wp-includes/kses.php b/wp-includes/kses.php index 353dde2043..69d897efc1 100644 --- a/wp-includes/kses.php +++ b/wp-includes/kses.php @@ -1452,9 +1452,6 @@ function kses_init() { kses_init_filters(); } -add_action('init', 'kses_init'); -add_action('set_current_user', 'kses_init'); - /** * Inline CSS filter * diff --git a/wp-includes/media.php b/wp-includes/media.php index 9ffb98941d..6a1bddbefc 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1156,7 +1156,6 @@ function wp_playlist_scripts( $type ) { add_action( 'wp_footer', 'wp_underscore_playlist_templates', 0 ); add_action( 'admin_footer', 'wp_underscore_playlist_templates', 0 ); } -add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' ); /** * The playlist shortcode. @@ -2595,7 +2594,6 @@ function wp_plupload_default_settings() { $wp_scripts->add_data( 'wp-plupload', 'data', $script ); } -add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' ); /** * Prepares an attachment post object for JS, where it is expected diff --git a/wp-includes/ms-default-filters.php b/wp-includes/ms-default-filters.php index 7481ec9a02..3a3979c111 100644 --- a/wp-includes/ms-default-filters.php +++ b/wp-includes/ms-default-filters.php @@ -13,6 +13,11 @@ * @since 3.0.0 */ +// Functions +add_action( 'update_option_blog_public', 'update_blog_public', 10, 2 ); +add_filter( 'option_users_can_register', 'users_can_register_signup_filter' ); +add_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' ); + // Users add_filter( 'wpmu_validate_user_signup', 'signup_nonce_check' ); add_action( 'init', 'maybe_add_existing_user_to_blog' ); diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 5537fb3644..28d2db4c71 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -2028,7 +2028,6 @@ function is_user_spammy( $user = null ) { function update_blog_public( $old_value, $value ) { update_blog_status( get_current_blog_id(), 'public', (int) $value ); } -add_action('update_option_blog_public', 'update_blog_public', 10, 2); /** * Check whether a usermeta key has to do with the current blog. @@ -2069,7 +2068,6 @@ function users_can_register_signup_filter() { return false; } -add_filter('option_users_can_register', 'users_can_register_signup_filter'); /** * Ensure that the welcome message is not empty. Currently unused. @@ -2098,7 +2096,6 @@ Thanks! } return $text; } -add_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' ); /** * Whether to force SSL on content. diff --git a/wp-includes/nav-menu-template.php b/wp-includes/nav-menu-template.php index 46cb025c12..5feac802f8 100644 --- a/wp-includes/nav-menu-template.php +++ b/wp-includes/nav-menu-template.php @@ -673,4 +673,3 @@ function _nav_menu_item_id_use_once( $id, $item ) { $_used_ids[] = $item->ID; return $id; } -add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 ); diff --git a/wp-includes/post-formats.php b/wp-includes/post-formats.php index ac613f396c..eb2c95ed5c 100644 --- a/wp-includes/post-formats.php +++ b/wp-includes/post-formats.php @@ -161,7 +161,6 @@ function _post_format_request( $qvs ) { $qvs['post_type'] = $tax->object_type; return $qvs; } -add_filter( 'request', '_post_format_request' ); /** * Filters the post format term link to remove the format prefix. @@ -180,7 +179,6 @@ function _post_format_link( $link, $term, $taxonomy ) { return add_query_arg( 'post_format', str_replace( 'post-format-', '', $term->slug ), $link ); } } -add_filter( 'term_link', '_post_format_link', 10, 3 ); /** * Remove the post format prefix from the name property of the term object created by get_term(). @@ -194,7 +192,6 @@ function _post_format_get_term( $term ) { } return $term; } -add_filter( 'get_post_format', '_post_format_get_term' ); /** * Remove the post format prefix from the name property of the term objects created by get_terms(). @@ -218,7 +215,6 @@ function _post_format_get_terms( $terms, $taxonomies, $args ) { } return $terms; } -add_filter( 'get_terms', '_post_format_get_terms', 10, 3 ); /** * Remove the post format prefix from the name property of the term objects created by wp_get_object_terms(). @@ -234,4 +230,3 @@ function _post_format_wp_get_object_terms( $terms ) { } return $terms; } -add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' ); diff --git a/wp-includes/post.php b/wp-includes/post.php index 2257101033..642b1d8360 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -164,7 +164,6 @@ function create_initial_post_types() { 'exclude_from_search' => false, ) ); } -add_action( 'init', 'create_initial_post_types', 0 ); // highest priority /** * Retrieve attached file path based on attachment ID. @@ -1714,7 +1713,6 @@ function _add_post_type_submenus() { add_submenu_page( $ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype" ); } } -add_action( 'admin_menu', '_add_post_type_submenus' ); /** * Register support of certain features for a post type. @@ -2713,8 +2711,6 @@ function _reset_front_page_settings_for_post( $post_id ) { } unstick_post( $post->ID ); } -add_action( 'before_delete_post', '_reset_front_page_settings_for_post' ); -add_action( 'wp_trash_post', '_reset_front_page_settings_for_post' ); /** * Move a post or page to the Trash diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 3ec6896b3c..ebac79e947 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -1051,10 +1051,3 @@ function script_concat_settings() { $compress_css = false; } } - -add_action( 'wp_default_scripts', 'wp_default_scripts' ); -add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); -add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); - -add_action( 'wp_default_styles', 'wp_default_styles' ); -add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 ); diff --git a/wp-includes/shortcodes.php b/wp-includes/shortcodes.php index db41da21a0..f6855f542c 100644 --- a/wp-includes/shortcodes.php +++ b/wp-includes/shortcodes.php @@ -399,5 +399,3 @@ function strip_shortcode_tag( $m ) { return $m[1] . $m[6]; } - -add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop() diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index a95c7a39e5..991f59552f 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -127,7 +127,6 @@ function create_initial_taxonomies() { 'show_in_nav_menus' => current_theme_supports( 'post-formats' ), ) ); } -add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority /** * Get a list of registered taxonomy objects. diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 4a8d342fde..cc2c4cbc01 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -676,7 +676,6 @@ function preview_theme() { ob_start( 'preview_theme_ob_filter' ); } -add_action('setup_theme', 'preview_theme'); /** * Private function to modify the current template when previewing a theme @@ -1663,7 +1662,6 @@ function _custom_header_background_just_in_time() { } } } -add_action( 'wp_loaded', '_custom_header_background_just_in_time' ); /** * Gets the theme support arguments passed when registering that support @@ -1872,8 +1870,6 @@ function _delete_attachment_theme_mod( $id ) { remove_theme_mod( 'background_image' ); } -add_action( 'delete_attachment', '_delete_attachment_theme_mod' ); - /** * Checks if a theme has been changed and runs 'after_switch_theme' hook on the next WP load * @@ -1930,7 +1926,6 @@ function _wp_customize_include() { // Init Customize class $GLOBALS['wp_customize'] = new WP_Customize_Manager; } -add_action( 'plugins_loaded', '_wp_customize_include' ); /** * Adds settings for the customize-loader script. @@ -1966,7 +1961,6 @@ function _wp_customize_loader_settings() { $wp_scripts->add_data( 'customize-loader', 'data', $script ); } -add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' ); /** * Returns a URL to load the Customizer. diff --git a/wp-includes/update.php b/wp-includes/update.php index 597a020f83..2e2ef9ebb3 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -669,27 +669,3 @@ function wp_clean_update_cache() { if ( ( ! is_main_site() && ! is_network_admin() ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { return; } - -add_action( 'admin_init', '_maybe_update_core' ); -add_action( 'wp_version_check', 'wp_version_check' ); -add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 ); - -add_action( 'load-plugins.php', 'wp_update_plugins' ); -add_action( 'load-update.php', 'wp_update_plugins' ); -add_action( 'load-update-core.php', 'wp_update_plugins' ); -add_action( 'admin_init', '_maybe_update_plugins' ); -add_action( 'wp_update_plugins', 'wp_update_plugins' ); -add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 ); - -add_action( 'load-themes.php', 'wp_update_themes' ); -add_action( 'load-update.php', 'wp_update_themes' ); -add_action( 'load-update-core.php', 'wp_update_themes' ); -add_action( 'admin_init', '_maybe_update_themes' ); -add_action( 'wp_update_themes', 'wp_update_themes' ); -add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 ); - -add_action( 'update_option_WPLANG', 'wp_clean_update_cache' , 10, 0 ); - -add_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' ); - -add_action('init', 'wp_schedule_update_checks'); diff --git a/wp-includes/version.php b/wp-includes/version.php index 6f51d6e366..7c2078e9e4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31167'; +$wp_version = '4.2-alpha-31168'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.