WordPress.org

Make WordPress Core

Changeset 31168


Ignore:
Timestamp:
01/12/2015 04:39:39 PM (3 years ago)
Author:
wonderboymusic
Message:

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.

Location:
trunk/src/wp-includes
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/admin-bar.php

    r30598 r31168  
    4545    return true;
    4646}
    47 // Don't remove. Wrong way to disable.
    48 add_action( 'template_redirect', '_wp_admin_bar_init', 0 );
    49 add_action( 'admin_init', '_wp_admin_bar_init' );
    5047
    5148/**
     
    9390    do_action( 'wp_after_admin_bar_render' );
    9491}
    95 add_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
    96 add_action( 'in_admin_header', 'wp_admin_bar_render', 0 );
    9792
    9893/**
  • trunk/src/wp-includes/author-template.php

    r31098 r31168  
    452452    delete_transient( 'is_multi_author' );
    453453}
    454 add_action('transition_post_status', '__clear_multi_author_cache');
  • trunk/src/wp-includes/canonical.php

    r30681 r31168  
    554554}
    555555
    556 add_action('template_redirect', 'redirect_canonical');
    557 
    558556function wp_redirect_admin_locations() {
    559557    global $wp_rewrite;
     
    583581    }
    584582}
    585 
    586 add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
  • trunk/src/wp-includes/default-filters.php

    r30585 r31168  
    307307add_filter( 'determine_current_user', 'wp_validate_logged_in_cookie', 20 );
    308308
    309 unset($filter, $action);
     309/**
     310 * Filters formerly mixed into wp-includes
     311 */
     312// Theme
     313add_action( 'setup_theme', 'preview_theme' );
     314add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
     315add_action( 'plugins_loaded', '_wp_customize_include' );
     316add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' );
     317add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
     318
     319// Calendar widget cache
     320add_action( 'save_post', 'delete_get_calendar_cache' );
     321add_action( 'delete_post', 'delete_get_calendar_cache' );
     322add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
     323add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
     324
     325// Author
     326add_action( 'transition_post_status', '__clear_multi_author_cache' );
     327
     328// Post
     329add_action( 'init', 'create_initial_post_types', 0 ); // highest priority
     330add_action( 'admin_menu', '_add_post_type_submenus' );
     331add_action( 'before_delete_post', '_reset_front_page_settings_for_post' );
     332add_action( 'wp_trash_post',      '_reset_front_page_settings_for_post' );
     333
     334// Post Formats
     335add_filter( 'request', '_post_format_request' );
     336add_filter( 'term_link', '_post_format_link', 10, 3 );
     337add_filter( 'get_post_format', '_post_format_get_term' );
     338add_filter( 'get_terms', '_post_format_get_terms', 10, 3 );
     339add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' );
     340
     341// KSES
     342add_action( 'init', 'kses_init' );
     343add_action( 'set_current_user', 'kses_init' );
     344
     345// Script Loader
     346add_action( 'wp_default_scripts', 'wp_default_scripts' );
     347add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
     348add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
     349
     350add_action( 'wp_default_styles', 'wp_default_styles' );
     351add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
     352
     353// Taxonomy
     354add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
     355
     356// Update
     357add_action( 'admin_init', '_maybe_update_core' );
     358add_action( 'wp_version_check', 'wp_version_check' );
     359add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 );
     360add_action( 'load-plugins.php', 'wp_update_plugins' );
     361add_action( 'load-update.php', 'wp_update_plugins' );
     362add_action( 'load-update-core.php', 'wp_update_plugins' );
     363add_action( 'admin_init', '_maybe_update_plugins' );
     364add_action( 'wp_update_plugins', 'wp_update_plugins' );
     365add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 );
     366add_action( 'load-themes.php', 'wp_update_themes' );
     367add_action( 'load-update.php', 'wp_update_themes' );
     368add_action( 'load-update-core.php', 'wp_update_themes' );
     369add_action( 'admin_init', '_maybe_update_themes' );
     370add_action( 'wp_update_themes', 'wp_update_themes' );
     371add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 );
     372add_action( 'update_option_WPLANG', 'wp_clean_update_cache' , 10, 0 );
     373add_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' );
     374add_action( 'init', 'wp_schedule_update_checks' );
     375
     376// Canonical
     377add_action( 'template_redirect', 'redirect_canonical' );
     378add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
     379
     380// Shortcodes
     381add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop()
     382
     383// Media
     384add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' );
     385add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' );
     386
     387// Nav menu
     388add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
     389
     390// Admin Bar
     391// Don't remove. Wrong way to disable.
     392add_action( 'template_redirect', '_wp_admin_bar_init', 0 );
     393add_action( 'admin_init', '_wp_admin_bar_init' );
     394add_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
     395add_action( 'in_admin_header', 'wp_admin_bar_render', 0 );
     396
     397unset( $filter, $action );
  • trunk/src/wp-includes/general-template.php

    r30983 r31168  
    17571757    wp_cache_delete( 'get_calendar', 'calendar' );
    17581758}
    1759 add_action( 'save_post', 'delete_get_calendar_cache' );
    1760 add_action( 'delete_post', 'delete_get_calendar_cache' );
    1761 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
    1762 add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
    17631759
    17641760/**
  • trunk/src/wp-includes/kses.php

    r31100 r31168  
    14531453}
    14541454
    1455 add_action('init', 'kses_init');
    1456 add_action('set_current_user', 'kses_init');
    1457 
    14581455/**
    14591456 * Inline CSS filter
  • trunk/src/wp-includes/media.php

    r31102 r31168  
    11571157    add_action( 'admin_footer', 'wp_underscore_playlist_templates', 0 );
    11581158}
    1159 add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' );
    11601159
    11611160/**
     
    25962595    $wp_scripts->add_data( 'wp-plupload', 'data', $script );
    25972596}
    2598 add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' );
    25992597
    26002598/**
  • trunk/src/wp-includes/ms-default-filters.php

    r29668 r31168  
    1313 * @since 3.0.0
    1414 */
     15
     16// Functions
     17add_action( 'update_option_blog_public', 'update_blog_public', 10, 2 );
     18add_filter( 'option_users_can_register', 'users_can_register_signup_filter' );
     19add_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
    1520
    1621// Users
  • trunk/src/wp-includes/ms-functions.php

    r30742 r31168  
    20292029    update_blog_status( get_current_blog_id(), 'public', (int) $value );
    20302030}
    2031 add_action('update_option_blog_public', 'update_blog_public', 10, 2);
    20322031
    20332032/**
     
    20702069    return false;
    20712070}
    2072 add_filter('option_users_can_register', 'users_can_register_signup_filter');
    20732071
    20742072/**
     
    20992097    return $text;
    21002098}
    2101 add_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
    21022099
    21032100/**
  • trunk/src/wp-includes/nav-menu-template.php

    r30618 r31168  
    674674    return $id;
    675675}
    676 add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
  • trunk/src/wp-includes/post-formats.php

    r30105 r31168  
    162162    return $qvs;
    163163}
    164 add_filter( 'request', '_post_format_request' );
    165164
    166165/**
     
    181180    }
    182181}
    183 add_filter( 'term_link', '_post_format_link', 10, 3 );
    184182
    185183/**
     
    195193    return $term;
    196194}
    197 add_filter( 'get_post_format', '_post_format_get_term' );
    198195
    199196/**
     
    219216    return $terms;
    220217}
    221 add_filter( 'get_terms', '_post_format_get_terms', 10, 3 );
    222218
    223219/**
     
    235231    return $terms;
    236232}
    237 add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' );
  • trunk/src/wp-includes/post.php

    r31132 r31168  
    165165    ) );
    166166}
    167 add_action( 'init', 'create_initial_post_types', 0 ); // highest priority
    168167
    169168/**
     
    17151714    }
    17161715}
    1717 add_action( 'admin_menu', '_add_post_type_submenus' );
    17181716
    17191717/**
     
    27142712    unstick_post( $post->ID );
    27152713}
    2716 add_action( 'before_delete_post', '_reset_front_page_settings_for_post' );
    2717 add_action( 'wp_trash_post',      '_reset_front_page_settings_for_post' );
    27182714
    27192715/**
  • trunk/src/wp-includes/script-loader.php

    r31032 r31168  
    10521052    }
    10531053}
    1054 
    1055 add_action( 'wp_default_scripts', 'wp_default_scripts' );
    1056 add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
    1057 add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
    1058 
    1059 add_action( 'wp_default_styles', 'wp_default_styles' );
    1060 add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
  • trunk/src/wp-includes/shortcodes.php

    r31099 r31168  
    400400    return $m[1] . $m[6];
    401401}
    402 
    403 add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop()
  • trunk/src/wp-includes/taxonomy.php

    r31087 r31168  
    128128    ) );
    129129}
    130 add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
    131130
    132131/**
  • trunk/src/wp-includes/theme.php

    r30982 r31168  
    677677    ob_start( 'preview_theme_ob_filter' );
    678678}
    679 add_action('setup_theme', 'preview_theme');
    680679
    681680/**
     
    16641663    }
    16651664}
    1666 add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
    16671665
    16681666/**
     
    18721870        remove_theme_mod( 'background_image' );
    18731871}
    1874 
    1875 add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
    18761872
    18771873/**
     
    19311927    $GLOBALS['wp_customize'] = new WP_Customize_Manager;
    19321928}
    1933 add_action( 'plugins_loaded', '_wp_customize_include' );
    19341929
    19351930/**
     
    19671962    $wp_scripts->add_data( 'customize-loader', 'data', $script );
    19681963}
    1969 add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' );
    19701964
    19711965/**
  • trunk/src/wp-includes/update.php

    r30856 r31168  
    670670    return;
    671671}
    672 
    673 add_action( 'admin_init', '_maybe_update_core' );
    674 add_action( 'wp_version_check', 'wp_version_check' );
    675 add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 );
    676 
    677 add_action( 'load-plugins.php', 'wp_update_plugins' );
    678 add_action( 'load-update.php', 'wp_update_plugins' );
    679 add_action( 'load-update-core.php', 'wp_update_plugins' );
    680 add_action( 'admin_init', '_maybe_update_plugins' );
    681 add_action( 'wp_update_plugins', 'wp_update_plugins' );
    682 add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 );
    683 
    684 add_action( 'load-themes.php', 'wp_update_themes' );
    685 add_action( 'load-update.php', 'wp_update_themes' );
    686 add_action( 'load-update-core.php', 'wp_update_themes' );
    687 add_action( 'admin_init', '_maybe_update_themes' );
    688 add_action( 'wp_update_themes', 'wp_update_themes' );
    689 add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 );
    690 
    691 add_action( 'update_option_WPLANG', 'wp_clean_update_cache' , 10, 0 );
    692 
    693 add_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' );
    694 
    695 add_action('init', 'wp_schedule_update_checks');
Note: See TracChangeset for help on using the changeset viewer.