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.


git-svn-id: https://develop.svn.wordpress.org/trunk@31168 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-01-12 16:39:39 +00:00
parent 47ba5e6c2e
commit 865185903b
17 changed files with 94 additions and 73 deletions

View File

@ -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.

View File

@ -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');

View File

@ -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 );

View File

@ -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 );

View File

@ -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.

View File

@ -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
*

View File

@ -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

View File

@ -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' );

View File

@ -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.

View File

@ -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 );

View File

@ -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' );

View File

@ -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

View File

@ -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 );

View File

@ -399,5 +399,3 @@ function strip_shortcode_tag( $m ) {
return $m[1] . $m[6];
}
add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop()

View File

@ -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.

View File

@ -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.

View File

@ -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');