wp/wp-includes/default-filters.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    70 	'pre_link_image',
    70 	'pre_link_image',
    71 	'pre_link_rss',
    71 	'pre_link_rss',
    72 	'pre_post_guid',
    72 	'pre_post_guid',
    73 ) as $filter ) {
    73 ) as $filter ) {
    74 	add_filter( $filter, 'wp_strip_all_tags' );
    74 	add_filter( $filter, 'wp_strip_all_tags' );
    75 	add_filter( $filter, 'esc_url_raw' );
    75 	add_filter( $filter, 'sanitize_url' );
    76 	add_filter( $filter, 'wp_filter_kses' );
    76 	add_filter( $filter, 'wp_filter_kses' );
    77 }
    77 }
    78 
    78 
    79 // Display URL.
    79 // Display URL.
    80 foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url', 'post_guid' ) as $filter ) {
    80 foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url', 'post_guid' ) as $filter ) {
   112 
   112 
   113 // Post meta.
   113 // Post meta.
   114 add_action( 'added_post_meta', 'wp_cache_set_posts_last_changed' );
   114 add_action( 'added_post_meta', 'wp_cache_set_posts_last_changed' );
   115 add_action( 'updated_post_meta', 'wp_cache_set_posts_last_changed' );
   115 add_action( 'updated_post_meta', 'wp_cache_set_posts_last_changed' );
   116 add_action( 'deleted_post_meta', 'wp_cache_set_posts_last_changed' );
   116 add_action( 'deleted_post_meta', 'wp_cache_set_posts_last_changed' );
       
   117 
       
   118 // User meta.
       
   119 add_action( 'added_user_meta', 'wp_cache_set_users_last_changed' );
       
   120 add_action( 'updated_user_meta', 'wp_cache_set_users_last_changed' );
       
   121 add_action( 'deleted_user_meta', 'wp_cache_set_users_last_changed' );
       
   122 add_action( 'add_user_role', 'wp_cache_set_users_last_changed' );
       
   123 add_action( 'set_user_role', 'wp_cache_set_users_last_changed' );
       
   124 add_action( 'remove_user_role', 'wp_cache_set_users_last_changed' );
   117 
   125 
   118 // Term meta.
   126 // Term meta.
   119 add_action( 'added_term_meta', 'wp_cache_set_terms_last_changed' );
   127 add_action( 'added_term_meta', 'wp_cache_set_terms_last_changed' );
   120 add_action( 'updated_term_meta', 'wp_cache_set_terms_last_changed' );
   128 add_action( 'updated_term_meta', 'wp_cache_set_terms_last_changed' );
   121 add_action( 'deleted_term_meta', 'wp_cache_set_terms_last_changed' );
   129 add_action( 'deleted_term_meta', 'wp_cache_set_terms_last_changed' );
   185 add_filter( 'the_content', 'wptexturize' );
   193 add_filter( 'the_content', 'wptexturize' );
   186 add_filter( 'the_content', 'convert_smilies', 20 );
   194 add_filter( 'the_content', 'convert_smilies', 20 );
   187 add_filter( 'the_content', 'wpautop' );
   195 add_filter( 'the_content', 'wpautop' );
   188 add_filter( 'the_content', 'shortcode_unautop' );
   196 add_filter( 'the_content', 'shortcode_unautop' );
   189 add_filter( 'the_content', 'prepend_attachment' );
   197 add_filter( 'the_content', 'prepend_attachment' );
   190 add_filter( 'the_content', 'wp_filter_content_tags' );
       
   191 add_filter( 'the_content', 'wp_replace_insecure_home_url' );
   198 add_filter( 'the_content', 'wp_replace_insecure_home_url' );
       
   199 add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop().
       
   200 add_filter( 'the_content', 'wp_filter_content_tags', 12 ); // Runs after do_shortcode().
   192 
   201 
   193 add_filter( 'the_excerpt', 'wptexturize' );
   202 add_filter( 'the_excerpt', 'wptexturize' );
   194 add_filter( 'the_excerpt', 'convert_smilies' );
   203 add_filter( 'the_excerpt', 'convert_smilies' );
   195 add_filter( 'the_excerpt', 'convert_chars' );
   204 add_filter( 'the_excerpt', 'convert_chars' );
   196 add_filter( 'the_excerpt', 'wpautop' );
   205 add_filter( 'the_excerpt', 'wpautop' );
   197 add_filter( 'the_excerpt', 'shortcode_unautop' );
   206 add_filter( 'the_excerpt', 'shortcode_unautop' );
   198 add_filter( 'the_excerpt', 'wp_filter_content_tags' );
       
   199 add_filter( 'the_excerpt', 'wp_replace_insecure_home_url' );
   207 add_filter( 'the_excerpt', 'wp_replace_insecure_home_url' );
       
   208 add_filter( 'the_excerpt', 'wp_filter_content_tags', 12 );
   200 add_filter( 'get_the_excerpt', 'wp_trim_excerpt', 10, 2 );
   209 add_filter( 'get_the_excerpt', 'wp_trim_excerpt', 10, 2 );
   201 
   210 
   202 add_filter( 'the_post_thumbnail_caption', 'wptexturize' );
   211 add_filter( 'the_post_thumbnail_caption', 'wptexturize' );
   203 add_filter( 'the_post_thumbnail_caption', 'convert_smilies' );
   212 add_filter( 'the_post_thumbnail_caption', 'convert_smilies' );
   204 add_filter( 'the_post_thumbnail_caption', 'convert_chars' );
   213 add_filter( 'the_post_thumbnail_caption', 'convert_chars' );
   220 add_filter( 'widget_text_content', 'capital_P_dangit', 11 );
   229 add_filter( 'widget_text_content', 'capital_P_dangit', 11 );
   221 add_filter( 'widget_text_content', 'wptexturize' );
   230 add_filter( 'widget_text_content', 'wptexturize' );
   222 add_filter( 'widget_text_content', 'convert_smilies', 20 );
   231 add_filter( 'widget_text_content', 'convert_smilies', 20 );
   223 add_filter( 'widget_text_content', 'wpautop' );
   232 add_filter( 'widget_text_content', 'wpautop' );
   224 add_filter( 'widget_text_content', 'shortcode_unautop' );
   233 add_filter( 'widget_text_content', 'shortcode_unautop' );
   225 add_filter( 'widget_text_content', 'wp_filter_content_tags' );
       
   226 add_filter( 'widget_text_content', 'wp_replace_insecure_home_url' );
   234 add_filter( 'widget_text_content', 'wp_replace_insecure_home_url' );
   227 add_filter( 'widget_text_content', 'do_shortcode', 11 ); // Runs after wpautop(); note that $post global will be null when shortcodes run.
   235 add_filter( 'widget_text_content', 'do_shortcode', 11 ); // Runs after wpautop(); note that $post global will be null when shortcodes run.
       
   236 add_filter( 'widget_text_content', 'wp_filter_content_tags', 12 ); // Runs after do_shortcode().
   228 
   237 
   229 add_filter( 'widget_block_content', 'do_blocks', 9 );
   238 add_filter( 'widget_block_content', 'do_blocks', 9 );
   230 add_filter( 'widget_block_content', 'wp_filter_content_tags' );
       
   231 add_filter( 'widget_block_content', 'do_shortcode', 11 );
   239 add_filter( 'widget_block_content', 'do_shortcode', 11 );
       
   240 add_filter( 'widget_block_content', 'wp_filter_content_tags', 12 ); // Runs after do_shortcode().
   232 
   241 
   233 add_filter( 'block_type_metadata', 'wp_migrate_old_typography_shape' );
   242 add_filter( 'block_type_metadata', 'wp_migrate_old_typography_shape' );
   234 
   243 
   235 add_filter( 'wp_get_custom_css', 'wp_replace_insecure_home_url' );
   244 add_filter( 'wp_get_custom_css', 'wp_replace_insecure_home_url' );
   236 
   245 
   275 ) {
   284 ) {
   276 	add_action( $action, '_delete_option_fresh_site', 0 );
   285 	add_action( $action, '_delete_option_fresh_site', 0 );
   277 }
   286 }
   278 
   287 
   279 // Misc filters.
   288 // Misc filters.
       
   289 add_filter( 'wp_default_autoload_value', 'wp_filter_default_autoload_value_via_option_size', 5, 4 ); // Allow the value to be overridden at the default priority.
   280 add_filter( 'option_ping_sites', 'privacy_ping_filter' );
   290 add_filter( 'option_ping_sites', 'privacy_ping_filter' );
   281 add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop.
   291 add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop.
   282 add_filter( 'option_blog_charset', '_canonical_charset' );
   292 add_filter( 'option_blog_charset', '_canonical_charset' );
   283 add_filter( 'option_home', '_config_wp_home' );
   293 add_filter( 'option_home', '_config_wp_home' );
   284 add_filter( 'option_siteurl', '_config_wp_siteurl' );
   294 add_filter( 'option_siteurl', '_config_wp_siteurl' );
   322 
   332 
   323 // Actions.
   333 // Actions.
   324 add_action( 'wp_head', '_wp_render_title_tag', 1 );
   334 add_action( 'wp_head', '_wp_render_title_tag', 1 );
   325 add_action( 'wp_head', 'wp_enqueue_scripts', 1 );
   335 add_action( 'wp_head', 'wp_enqueue_scripts', 1 );
   326 add_action( 'wp_head', 'wp_resource_hints', 2 );
   336 add_action( 'wp_head', 'wp_resource_hints', 2 );
       
   337 add_action( 'wp_head', 'wp_preload_resources', 1 );
   327 add_action( 'wp_head', 'feed_links', 2 );
   338 add_action( 'wp_head', 'feed_links', 2 );
   328 add_action( 'wp_head', 'feed_links_extra', 3 );
   339 add_action( 'wp_head', 'feed_links_extra', 3 );
   329 add_action( 'wp_head', 'rsd_link' );
   340 add_action( 'wp_head', 'rsd_link' );
   330 add_action( 'wp_head', 'wlwmanifest_link' );
       
   331 add_action( 'wp_head', 'locale_stylesheet' );
   341 add_action( 'wp_head', 'locale_stylesheet' );
   332 add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 );
   342 add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 );
   333 add_action( 'wp_head', 'wp_robots', 1 );
   343 add_action( 'wp_head', 'wp_robots', 1 );
   334 add_action( 'wp_head', 'print_emoji_detection_script', 7 );
   344 add_action( 'wp_head', 'print_emoji_detection_script', 7 );
   335 add_action( 'wp_head', 'wp_print_styles', 8 );
   345 add_action( 'wp_head', 'wp_print_styles', 8 );
   343 add_action( 'template_redirect', 'wp_shortlink_header', 11, 0 );
   353 add_action( 'template_redirect', 'wp_shortlink_header', 11, 0 );
   344 add_action( 'wp_print_footer_scripts', '_wp_footer_scripts' );
   354 add_action( 'wp_print_footer_scripts', '_wp_footer_scripts' );
   345 add_action( 'init', '_register_core_block_patterns_and_categories' );
   355 add_action( 'init', '_register_core_block_patterns_and_categories' );
   346 add_action( 'init', 'check_theme_switched', 99 );
   356 add_action( 'init', 'check_theme_switched', 99 );
   347 add_action( 'init', array( 'WP_Block_Supports', 'init' ), 22 );
   357 add_action( 'init', array( 'WP_Block_Supports', 'init' ), 22 );
   348 add_action( 'switch_theme', array( 'WP_Theme_JSON_Resolver', 'clean_cached_data' ) );
   358 add_action( 'switch_theme', 'wp_clean_theme_json_cache' );
   349 add_action( 'start_previewing_theme', array( 'WP_Theme_JSON_Resolver', 'clean_cached_data' ) );
   359 add_action( 'start_previewing_theme', 'wp_clean_theme_json_cache' );
   350 add_action( 'after_switch_theme', '_wp_menus_changed' );
   360 add_action( 'after_switch_theme', '_wp_menus_changed' );
   351 add_action( 'after_switch_theme', '_wp_sidebars_changed' );
   361 add_action( 'after_switch_theme', '_wp_sidebars_changed' );
   352 add_action( 'wp_print_styles', 'print_emoji_styles' );
   362 add_action( 'wp_enqueue_scripts', 'wp_enqueue_emoji_styles' );
   353 add_action( 'plugins_loaded', '_wp_theme_json_webfonts_handler' );
   363 add_action( 'wp_print_styles', 'print_emoji_styles' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_emoji_styles().
   354 
   364 
   355 if ( isset( $_GET['replytocom'] ) ) {
   365 if ( isset( $_GET['replytocom'] ) ) {
   356 	add_filter( 'wp_robots', 'wp_robots_no_robots' );
   366 	add_filter( 'wp_robots', 'wp_robots_no_robots' );
   357 }
   367 }
   358 
   368 
   377 
   387 
   378 // WP Cron.
   388 // WP Cron.
   379 if ( ! defined( 'DOING_CRON' ) ) {
   389 if ( ! defined( 'DOING_CRON' ) ) {
   380 	add_action( 'init', 'wp_cron' );
   390 	add_action( 'init', 'wp_cron' );
   381 }
   391 }
   382 
       
   383 // HTTPS detection.
       
   384 add_action( 'init', 'wp_schedule_https_detection' );
       
   385 add_action( 'wp_https_detection', 'wp_update_https_detection_errors' );
       
   386 add_filter( 'cron_request', 'wp_cron_conditionally_prevent_sslverify', 9999 );
       
   387 
   392 
   388 // HTTPS migration.
   393 // HTTPS migration.
   389 add_action( 'update_option_home', 'wp_update_https_migration_required', 10, 2 );
   394 add_action( 'update_option_home', 'wp_update_https_migration_required', 10, 2 );
   390 
   395 
   391 // 2 Actions 2 Furious.
   396 // 2 Actions 2 Furious.
   405 add_action( 'init', 'smilies_init', 5 );
   410 add_action( 'init', 'smilies_init', 5 );
   406 add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 );
   411 add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 );
   407 add_action( 'plugins_loaded', 'wp_maybe_load_embeds', 0 );
   412 add_action( 'plugins_loaded', 'wp_maybe_load_embeds', 0 );
   408 add_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
   413 add_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
   409 // Create a revision whenever a post is updated.
   414 // Create a revision whenever a post is updated.
       
   415 add_action( 'wp_after_insert_post', 'wp_save_post_revision_on_insert', 9, 3 );
   410 add_action( 'post_updated', 'wp_save_post_revision', 10, 1 );
   416 add_action( 'post_updated', 'wp_save_post_revision', 10, 1 );
   411 add_action( 'publish_post', '_publish_post_hook', 5, 1 );
   417 add_action( 'publish_post', '_publish_post_hook', 5, 1 );
   412 add_action( 'transition_post_status', '_transition_post_status', 5, 3 );
   418 add_action( 'transition_post_status', '_transition_post_status', 5, 3 );
   413 add_action( 'transition_post_status', '_update_term_count_on_transition_post_status', 10, 3 );
   419 add_action( 'transition_post_status', '_update_term_count_on_transition_post_status', 10, 3 );
   414 add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' );
   420 add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' );
   434 add_action( 'delete_post', '_wp_delete_post_menu_item' );
   440 add_action( 'delete_post', '_wp_delete_post_menu_item' );
   435 add_action( 'delete_term', '_wp_delete_tax_menu_item', 10, 3 );
   441 add_action( 'delete_term', '_wp_delete_tax_menu_item', 10, 3 );
   436 add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3 );
   442 add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3 );
   437 add_action( 'delete_post', '_wp_delete_customize_changeset_dependent_auto_drafts' );
   443 add_action( 'delete_post', '_wp_delete_customize_changeset_dependent_auto_drafts' );
   438 
   444 
   439 // Post Thumbnail CSS class filtering.
   445 // Post Thumbnail specific image filtering.
   440 add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add' );
   446 add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add' );
   441 add_action( 'end_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_remove' );
   447 add_action( 'end_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_remove' );
       
   448 add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_context_filter_add' );
       
   449 add_action( 'end_fetch_post_thumbnail_html', '_wp_post_thumbnail_context_filter_remove' );
   442 
   450 
   443 // Redirect old slugs.
   451 // Redirect old slugs.
   444 add_action( 'template_redirect', 'wp_old_slug_redirect' );
   452 add_action( 'template_redirect', 'wp_old_slug_redirect' );
   445 add_action( 'post_updated', 'wp_check_for_changed_slugs', 12, 3 );
   453 add_action( 'post_updated', 'wp_check_for_changed_slugs', 12, 3 );
   446 add_action( 'attachment_updated', 'wp_check_for_changed_slugs', 12, 3 );
   454 add_action( 'attachment_updated', 'wp_check_for_changed_slugs', 12, 3 );
   512 /**
   520 /**
   513  * Filters formerly mixed into wp-includes.
   521  * Filters formerly mixed into wp-includes.
   514  */
   522  */
   515 // Theme.
   523 // Theme.
   516 add_action( 'setup_theme', 'create_initial_theme_features', 0 );
   524 add_action( 'setup_theme', 'create_initial_theme_features', 0 );
   517 add_action( 'setup_theme', '_add_default_theme_supports', 1 );
   525 add_action( 'after_setup_theme', '_add_default_theme_supports', 1 );
   518 add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
   526 add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
   519 add_action( 'wp_head', '_custom_logo_header_styles' );
   527 add_action( 'wp_head', '_custom_logo_header_styles' );
   520 add_action( 'plugins_loaded', '_wp_customize_include' );
   528 add_action( 'plugins_loaded', '_wp_customize_include' );
   521 add_action( 'transition_post_status', '_wp_customize_publish_changeset', 10, 3 );
   529 add_action( 'transition_post_status', '_wp_customize_publish_changeset', 10, 3 );
   522 add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' );
   530 add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' );
   523 add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
   531 add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
   524 add_action( 'transition_post_status', '_wp_keep_alive_customize_changeset_dependent_auto_drafts', 20, 3 );
   532 add_action( 'transition_post_status', '_wp_keep_alive_customize_changeset_dependent_auto_drafts', 20, 3 );
   525 
   533 
       
   534 // Block Theme Previews.
       
   535 add_action( 'plugins_loaded', 'wp_initialize_theme_preview_hooks', 1 );
       
   536 
   526 // Calendar widget cache.
   537 // Calendar widget cache.
   527 add_action( 'save_post', 'delete_get_calendar_cache' );
   538 add_action( 'save_post', 'delete_get_calendar_cache' );
   528 add_action( 'delete_post', 'delete_get_calendar_cache' );
   539 add_action( 'delete_post', 'delete_get_calendar_cache' );
   529 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
   540 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
   530 add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
   541 add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
   554 add_action( 'wp_default_scripts', 'wp_default_scripts' );
   565 add_action( 'wp_default_scripts', 'wp_default_scripts' );
   555 add_action( 'wp_default_scripts', 'wp_default_packages' );
   566 add_action( 'wp_default_scripts', 'wp_default_packages' );
   556 
   567 
   557 add_action( 'wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
   568 add_action( 'wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
   558 add_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
   569 add_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
       
   570 add_action( 'wp_enqueue_scripts', 'wp_enqueue_classic_theme_styles' );
   559 add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
   571 add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
   560 add_action( 'admin_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
   572 add_action( 'admin_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
   561 add_action( 'enqueue_block_assets', 'wp_enqueue_registered_block_scripts_and_styles' );
   573 add_action( 'enqueue_block_assets', 'wp_enqueue_registered_block_scripts_and_styles' );
   562 add_action( 'enqueue_block_assets', 'enqueue_block_styles_assets', 30 );
   574 add_action( 'enqueue_block_assets', 'enqueue_block_styles_assets', 30 );
       
   575 /*
       
   576  * `wp_enqueue_registered_block_scripts_and_styles` is bound to both
       
   577  * `enqueue_block_editor_assets` and `enqueue_block_assets` hooks
       
   578  * since the introduction of the block editor in WordPress 5.0.
       
   579  *
       
   580  * The way this works is that the block assets are loaded before any other assets.
       
   581  * For example, this is the order of styles for the editor:
       
   582  *
       
   583  * - front styles registered for blocks, via `styles` handle (block.json)
       
   584  * - editor styles registered for blocks, via `editorStyles` handle (block.json)
       
   585  * - editor styles enqueued via `enqueue_block_editor_assets` hook
       
   586  * - front styles enqueued via `enqueue_block_assets` hook
       
   587  */
   563 add_action( 'enqueue_block_editor_assets', 'wp_enqueue_registered_block_scripts_and_styles' );
   588 add_action( 'enqueue_block_editor_assets', 'wp_enqueue_registered_block_scripts_and_styles' );
   564 add_action( 'enqueue_block_editor_assets', 'enqueue_editor_block_styles_assets' );
   589 add_action( 'enqueue_block_editor_assets', 'enqueue_editor_block_styles_assets' );
   565 add_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );
   590 add_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );
   566 add_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_format_library_assets' );
   591 add_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_format_library_assets' );
   567 add_action( 'enqueue_block_editor_assets', 'wp_enqueue_global_styles_css_custom_properties' );
   592 add_action( 'enqueue_block_editor_assets', 'wp_enqueue_global_styles_css_custom_properties' );
   568 add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
   593 add_action( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
   569 add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
   594 add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
   570 add_filter( 'customize_controls_print_styles', 'wp_resource_hints', 1 );
   595 add_action( 'customize_controls_print_styles', 'wp_resource_hints', 1 );
   571 add_action( 'admin_head', 'wp_check_widget_editor_deps' );
   596 add_action( 'admin_head', 'wp_check_widget_editor_deps' );
       
   597 add_filter( 'block_editor_settings_all', 'wp_add_editor_classic_theme_styles' );
   572 
   598 
   573 // Global styles can be enqueued in both the header and the footer. See https://core.trac.wordpress.org/ticket/53494.
   599 // Global styles can be enqueued in both the header and the footer. See https://core.trac.wordpress.org/ticket/53494.
   574 add_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
   600 add_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
   575 add_action( 'wp_footer', 'wp_enqueue_global_styles', 1 );
   601 add_action( 'wp_footer', 'wp_enqueue_global_styles', 1 );
   576 
   602 
   577 // SVG filters like duotone have to be loaded at the beginning of the body in both admin and the front-end.
   603 // Global styles custom CSS.
   578 add_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' );
   604 add_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles_custom_css' );
   579 add_action( 'in_admin_header', 'wp_global_styles_render_svg_filters' );
   605 
       
   606 // Block supports, and other styles parsed and stored in the Style Engine.
       
   607 add_action( 'wp_enqueue_scripts', 'wp_enqueue_stored_styles' );
       
   608 add_action( 'wp_footer', 'wp_enqueue_stored_styles', 1 );
   580 
   609 
   581 add_action( 'wp_default_styles', 'wp_default_styles' );
   610 add_action( 'wp_default_styles', 'wp_default_styles' );
   582 add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
   611 add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
   583 
   612 
   584 add_action( 'wp_head', 'wp_maybe_inline_styles', 1 ); // Run for styles enqueued in <head>.
   613 add_action( 'wp_head', 'wp_maybe_inline_styles', 1 ); // Run for styles enqueued in <head>.
   585 add_action( 'wp_footer', 'wp_maybe_inline_styles', 1 ); // Run for late-loaded styles in the footer.
   614 add_action( 'wp_footer', 'wp_maybe_inline_styles', 1 ); // Run for late-loaded styles in the footer.
       
   615 
       
   616 /*
       
   617  * Block specific actions and filters.
       
   618  */
       
   619 
       
   620 // Footnotes Block.
       
   621 add_action( 'init', '_wp_footnotes_kses_init' );
       
   622 add_action( 'set_current_user', '_wp_footnotes_kses_init' );
       
   623 add_filter( 'force_filtered_html_on_import', '_wp_footnotes_force_filtered_html_on_import_filter', 999 );
   586 
   624 
   587 /*
   625 /*
   588  * Disable "Post Attributes" for wp_navigation post type. The attributes are
   626  * Disable "Post Attributes" for wp_navigation post type. The attributes are
   589  * also conditionally enabled when a site has custom templates. Block Theme
   627  * also conditionally enabled when a site has custom templates. Block Theme
   590  * templates can be available for every post type.
   628  * templates can be available for every post type.
   597 
   635 
   598 // Canonical.
   636 // Canonical.
   599 add_action( 'template_redirect', 'redirect_canonical' );
   637 add_action( 'template_redirect', 'redirect_canonical' );
   600 add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
   638 add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
   601 
   639 
   602 // Shortcodes.
       
   603 add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop().
       
   604 
       
   605 // Media.
   640 // Media.
   606 add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' );
   641 add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' );
   607 add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' );
   642 add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' );
   608 add_action( 'plugins_loaded', '_wp_add_additional_image_sizes', 0 );
   643 add_action( 'plugins_loaded', '_wp_add_additional_image_sizes', 0 );
   609 add_filter( 'plupload_default_settings', 'wp_show_heic_upload_error' );
   644 add_filter( 'plupload_default_settings', 'wp_show_heic_upload_error' );
   610 
   645 
   611 // Nav menu.
   646 // Nav menu.
   612 add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
   647 add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
       
   648 add_filter( 'nav_menu_css_class', 'wp_nav_menu_remove_menu_item_has_children_class', 10, 4 );
   613 
   649 
   614 // Widgets.
   650 // Widgets.
   615 add_action( 'after_setup_theme', 'wp_setup_widgets_block_editor', 1 );
   651 add_action( 'after_setup_theme', 'wp_setup_widgets_block_editor', 1 );
   616 add_action( 'init', 'wp_widgets_init', 1 );
   652 add_action( 'init', 'wp_widgets_init', 1 );
   617 add_action( 'change_locale', array( 'WP_Widget_Media', 'reset_default_labels' ) );
   653 add_action( 'change_locale', array( 'WP_Widget_Media', 'reset_default_labels' ) );
       
   654 add_action( 'widgets_init', '_wp_block_theme_register_classic_sidebars', 1 );
   618 
   655 
   619 // Admin Bar.
   656 // Admin Bar.
   620 // Don't remove. Wrong way to disable.
   657 // Don't remove. Wrong way to disable.
   621 add_action( 'template_redirect', '_wp_admin_bar_init', 0 );
   658 add_action( 'template_redirect', '_wp_admin_bar_init', 0 );
   622 add_action( 'admin_init', '_wp_admin_bar_init' );
   659 add_action( 'admin_init', '_wp_admin_bar_init' );
       
   660 add_action( 'wp_enqueue_scripts', 'wp_enqueue_admin_bar_bump_styles' );
       
   661 add_action( 'wp_enqueue_scripts', 'wp_enqueue_admin_bar_header_styles' );
       
   662 add_action( 'admin_enqueue_scripts', 'wp_enqueue_admin_bar_header_styles' );
   623 add_action( 'before_signup_header', '_wp_admin_bar_init' );
   663 add_action( 'before_signup_header', '_wp_admin_bar_init' );
   624 add_action( 'activate_header', '_wp_admin_bar_init' );
   664 add_action( 'activate_header', '_wp_admin_bar_init' );
   625 add_action( 'wp_body_open', 'wp_admin_bar_render', 0 );
   665 add_action( 'wp_body_open', 'wp_admin_bar_render', 0 );
   626 add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); // Back-compat for themes not using `wp_body_open`.
   666 add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); // Back-compat for themes not using `wp_body_open`.
   627 add_action( 'in_admin_header', 'wp_admin_bar_render', 0 );
   667 add_action( 'in_admin_header', 'wp_admin_bar_render', 0 );
   639 add_action( 'wp_head', 'wp_oembed_add_host_js' ); // Back-compat for sites disabling oEmbed host JS by removing action.
   679 add_action( 'wp_head', 'wp_oembed_add_host_js' ); // Back-compat for sites disabling oEmbed host JS by removing action.
   640 add_filter( 'embed_oembed_html', 'wp_maybe_enqueue_oembed_host_js' );
   680 add_filter( 'embed_oembed_html', 'wp_maybe_enqueue_oembed_host_js' );
   641 
   681 
   642 add_action( 'embed_head', 'enqueue_embed_scripts', 1 );
   682 add_action( 'embed_head', 'enqueue_embed_scripts', 1 );
   643 add_action( 'embed_head', 'print_emoji_detection_script' );
   683 add_action( 'embed_head', 'print_emoji_detection_script' );
   644 add_action( 'embed_head', 'print_embed_styles' );
   684 add_action( 'embed_head', 'wp_enqueue_embed_styles', 9 );
       
   685 add_action( 'embed_head', 'print_embed_styles' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_embed_styles().
   645 add_action( 'embed_head', 'wp_print_head_scripts', 20 );
   686 add_action( 'embed_head', 'wp_print_head_scripts', 20 );
   646 add_action( 'embed_head', 'wp_print_styles', 20 );
   687 add_action( 'embed_head', 'wp_print_styles', 20 );
   647 add_action( 'embed_head', 'wp_robots' );
   688 add_action( 'embed_head', 'wp_robots' );
   648 add_action( 'embed_head', 'rel_canonical' );
   689 add_action( 'embed_head', 'rel_canonical' );
   649 add_action( 'embed_head', 'locale_stylesheet', 30 );
   690 add_action( 'embed_head', 'locale_stylesheet', 30 );
       
   691 add_action( 'enqueue_embed_scripts', 'wp_enqueue_emoji_styles' );
   650 
   692 
   651 add_action( 'embed_content_meta', 'print_embed_comments_button' );
   693 add_action( 'embed_content_meta', 'print_embed_comments_button' );
   652 add_action( 'embed_content_meta', 'print_embed_sharing_button' );
   694 add_action( 'embed_content_meta', 'print_embed_sharing_button' );
   653 
   695 
   654 add_action( 'embed_footer', 'print_embed_sharing_dialog' );
   696 add_action( 'embed_footer', 'print_embed_sharing_dialog' );
   674 
   716 
   675 // Block templates post type and rendering.
   717 // Block templates post type and rendering.
   676 add_filter( 'render_block_context', '_block_template_render_without_post_block_context' );
   718 add_filter( 'render_block_context', '_block_template_render_without_post_block_context' );
   677 add_filter( 'pre_wp_unique_post_slug', 'wp_filter_wp_template_unique_post_slug', 10, 5 );
   719 add_filter( 'pre_wp_unique_post_slug', 'wp_filter_wp_template_unique_post_slug', 10, 5 );
   678 add_action( 'save_post_wp_template_part', 'wp_set_unique_slug_on_create_template_part' );
   720 add_action( 'save_post_wp_template_part', 'wp_set_unique_slug_on_create_template_part' );
   679 add_action( 'wp_footer', 'the_block_template_skip_link' );
   721 add_action( 'wp_enqueue_scripts', 'wp_enqueue_block_template_skip_link' );
   680 add_action( 'setup_theme', 'wp_enable_block_templates' );
   722 add_action( 'wp_footer', 'the_block_template_skip_link' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_block_template_skip_link().
       
   723 add_action( 'after_setup_theme', 'wp_enable_block_templates', 1 );
   681 add_action( 'wp_loaded', '_add_template_loader_filters' );
   724 add_action( 'wp_loaded', '_add_template_loader_filters' );
   682 
   725 
       
   726 // wp_navigation post type.
       
   727 add_filter( 'rest_wp_navigation_item_schema', array( 'WP_Navigation_Fallback', 'update_wp_navigation_post_schema' ) );
       
   728 
       
   729 // Fluid typography.
       
   730 add_filter( 'render_block', 'wp_render_typography_support', 10, 2 );
       
   731 
       
   732 // User preferences.
       
   733 add_action( 'init', 'wp_register_persisted_preferences_meta' );
       
   734 
       
   735 // CPT wp_block custom postmeta field.
       
   736 add_action( 'init', 'wp_create_initial_post_meta' );
       
   737 
       
   738 // Include revisioned meta when considering whether a post revision has changed.
       
   739 add_filter( 'wp_save_post_revision_post_has_changed', 'wp_check_revisioned_meta_fields_have_changed', 10, 3 );
       
   740 
       
   741 // Save revisioned post meta immediately after a revision is saved
       
   742 add_action( '_wp_put_post_revision', 'wp_save_revisioned_meta_fields', 10, 2 );
       
   743 
       
   744 // Include revisioned meta when creating or updating an autosave revision.
       
   745 add_action( 'wp_creating_autosave', 'wp_autosave_post_revisioned_meta_fields' );
       
   746 
       
   747 // When restoring revisions, also restore revisioned meta.
       
   748 add_action( 'wp_restore_post_revision', 'wp_restore_post_revision_meta', 10, 2 );
       
   749 
       
   750 // Font management.
       
   751 add_action( 'wp_head', 'wp_print_font_faces', 50 );
       
   752 add_action( 'deleted_post', '_wp_after_delete_font_family', 10, 2 );
       
   753 add_action( 'before_delete_post', '_wp_before_delete_font_face', 10, 2 );
       
   754 add_action( 'init', '_wp_register_default_font_collections' );
       
   755 
       
   756 // Add ignoredHookedBlocks metadata attribute to the template and template part post types.
       
   757 add_filter( 'rest_pre_insert_wp_template', 'inject_ignored_hooked_blocks_metadata_attributes' );
       
   758 add_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes' );
       
   759 
       
   760 // Update ignoredHookedBlocks postmeta for wp_navigation post type.
       
   761 add_filter( 'rest_pre_insert_wp_navigation', 'update_ignored_hooked_blocks_postmeta' );
       
   762 
       
   763 // Inject hooked blocks into the wp_navigation post type REST response.
       
   764 add_filter( 'rest_prepare_wp_navigation', 'insert_hooked_blocks_into_rest_response', 10, 2 );
       
   765 
   683 unset( $filter, $action );
   766 unset( $filter, $action );