diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-includes/default-filters.php --- a/wp/wp-includes/default-filters.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-includes/default-filters.php Fri Sep 05 18:40:08 2025 +0200 @@ -72,7 +72,7 @@ 'pre_post_guid', ) as $filter ) { add_filter( $filter, 'wp_strip_all_tags' ); - add_filter( $filter, 'esc_url_raw' ); + add_filter( $filter, 'sanitize_url' ); add_filter( $filter, 'wp_filter_kses' ); } @@ -115,6 +115,14 @@ add_action( 'updated_post_meta', 'wp_cache_set_posts_last_changed' ); add_action( 'deleted_post_meta', 'wp_cache_set_posts_last_changed' ); +// User meta. +add_action( 'added_user_meta', 'wp_cache_set_users_last_changed' ); +add_action( 'updated_user_meta', 'wp_cache_set_users_last_changed' ); +add_action( 'deleted_user_meta', 'wp_cache_set_users_last_changed' ); +add_action( 'add_user_role', 'wp_cache_set_users_last_changed' ); +add_action( 'set_user_role', 'wp_cache_set_users_last_changed' ); +add_action( 'remove_user_role', 'wp_cache_set_users_last_changed' ); + // Term meta. add_action( 'added_term_meta', 'wp_cache_set_terms_last_changed' ); add_action( 'updated_term_meta', 'wp_cache_set_terms_last_changed' ); @@ -187,16 +195,17 @@ add_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'shortcode_unautop' ); add_filter( 'the_content', 'prepend_attachment' ); -add_filter( 'the_content', 'wp_filter_content_tags' ); add_filter( 'the_content', 'wp_replace_insecure_home_url' ); +add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop(). +add_filter( 'the_content', 'wp_filter_content_tags', 12 ); // Runs after do_shortcode(). add_filter( 'the_excerpt', 'wptexturize' ); add_filter( 'the_excerpt', 'convert_smilies' ); add_filter( 'the_excerpt', 'convert_chars' ); add_filter( 'the_excerpt', 'wpautop' ); add_filter( 'the_excerpt', 'shortcode_unautop' ); -add_filter( 'the_excerpt', 'wp_filter_content_tags' ); add_filter( 'the_excerpt', 'wp_replace_insecure_home_url' ); +add_filter( 'the_excerpt', 'wp_filter_content_tags', 12 ); add_filter( 'get_the_excerpt', 'wp_trim_excerpt', 10, 2 ); add_filter( 'the_post_thumbnail_caption', 'wptexturize' ); @@ -222,13 +231,13 @@ add_filter( 'widget_text_content', 'convert_smilies', 20 ); add_filter( 'widget_text_content', 'wpautop' ); add_filter( 'widget_text_content', 'shortcode_unautop' ); -add_filter( 'widget_text_content', 'wp_filter_content_tags' ); add_filter( 'widget_text_content', 'wp_replace_insecure_home_url' ); add_filter( 'widget_text_content', 'do_shortcode', 11 ); // Runs after wpautop(); note that $post global will be null when shortcodes run. +add_filter( 'widget_text_content', 'wp_filter_content_tags', 12 ); // Runs after do_shortcode(). add_filter( 'widget_block_content', 'do_blocks', 9 ); -add_filter( 'widget_block_content', 'wp_filter_content_tags' ); add_filter( 'widget_block_content', 'do_shortcode', 11 ); +add_filter( 'widget_block_content', 'wp_filter_content_tags', 12 ); // Runs after do_shortcode(). add_filter( 'block_type_metadata', 'wp_migrate_old_typography_shape' ); @@ -277,6 +286,7 @@ } // Misc filters. +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. add_filter( 'option_ping_sites', 'privacy_ping_filter' ); add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop. add_filter( 'option_blog_charset', '_canonical_charset' ); @@ -324,10 +334,10 @@ add_action( 'wp_head', '_wp_render_title_tag', 1 ); add_action( 'wp_head', 'wp_enqueue_scripts', 1 ); add_action( 'wp_head', 'wp_resource_hints', 2 ); +add_action( 'wp_head', 'wp_preload_resources', 1 ); add_action( 'wp_head', 'feed_links', 2 ); add_action( 'wp_head', 'feed_links_extra', 3 ); add_action( 'wp_head', 'rsd_link' ); -add_action( 'wp_head', 'wlwmanifest_link' ); add_action( 'wp_head', 'locale_stylesheet' ); add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 ); add_action( 'wp_head', 'wp_robots', 1 ); @@ -345,12 +355,12 @@ add_action( 'init', '_register_core_block_patterns_and_categories' ); add_action( 'init', 'check_theme_switched', 99 ); add_action( 'init', array( 'WP_Block_Supports', 'init' ), 22 ); -add_action( 'switch_theme', array( 'WP_Theme_JSON_Resolver', 'clean_cached_data' ) ); -add_action( 'start_previewing_theme', array( 'WP_Theme_JSON_Resolver', 'clean_cached_data' ) ); +add_action( 'switch_theme', 'wp_clean_theme_json_cache' ); +add_action( 'start_previewing_theme', 'wp_clean_theme_json_cache' ); add_action( 'after_switch_theme', '_wp_menus_changed' ); add_action( 'after_switch_theme', '_wp_sidebars_changed' ); -add_action( 'wp_print_styles', 'print_emoji_styles' ); -add_action( 'plugins_loaded', '_wp_theme_json_webfonts_handler' ); +add_action( 'wp_enqueue_scripts', 'wp_enqueue_emoji_styles' ); +add_action( 'wp_print_styles', 'print_emoji_styles' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_emoji_styles(). if ( isset( $_GET['replytocom'] ) ) { add_filter( 'wp_robots', 'wp_robots_no_robots' ); @@ -380,11 +390,6 @@ add_action( 'init', 'wp_cron' ); } -// HTTPS detection. -add_action( 'init', 'wp_schedule_https_detection' ); -add_action( 'wp_https_detection', 'wp_update_https_detection_errors' ); -add_filter( 'cron_request', 'wp_cron_conditionally_prevent_sslverify', 9999 ); - // HTTPS migration. add_action( 'update_option_home', 'wp_update_https_migration_required', 10, 2 ); @@ -407,6 +412,7 @@ add_action( 'plugins_loaded', 'wp_maybe_load_embeds', 0 ); add_action( 'shutdown', 'wp_ob_end_flush_all', 1 ); // Create a revision whenever a post is updated. +add_action( 'wp_after_insert_post', 'wp_save_post_revision_on_insert', 9, 3 ); add_action( 'post_updated', 'wp_save_post_revision', 10, 1 ); add_action( 'publish_post', '_publish_post_hook', 5, 1 ); add_action( 'transition_post_status', '_transition_post_status', 5, 3 ); @@ -436,9 +442,11 @@ add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3 ); add_action( 'delete_post', '_wp_delete_customize_changeset_dependent_auto_drafts' ); -// Post Thumbnail CSS class filtering. +// Post Thumbnail specific image filtering. add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add' ); add_action( 'end_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_remove' ); +add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_context_filter_add' ); +add_action( 'end_fetch_post_thumbnail_html', '_wp_post_thumbnail_context_filter_remove' ); // Redirect old slugs. add_action( 'template_redirect', 'wp_old_slug_redirect' ); @@ -514,7 +522,7 @@ */ // Theme. add_action( 'setup_theme', 'create_initial_theme_features', 0 ); -add_action( 'setup_theme', '_add_default_theme_supports', 1 ); +add_action( 'after_setup_theme', '_add_default_theme_supports', 1 ); add_action( 'wp_loaded', '_custom_header_background_just_in_time' ); add_action( 'wp_head', '_custom_logo_header_styles' ); add_action( 'plugins_loaded', '_wp_customize_include' ); @@ -523,6 +531,9 @@ add_action( 'delete_attachment', '_delete_attachment_theme_mod' ); add_action( 'transition_post_status', '_wp_keep_alive_customize_changeset_dependent_auto_drafts', 20, 3 ); +// Block Theme Previews. +add_action( 'plugins_loaded', 'wp_initialize_theme_preview_hooks', 1 ); + // Calendar widget cache. add_action( 'save_post', 'delete_get_calendar_cache' ); add_action( 'delete_post', 'delete_get_calendar_cache' ); @@ -556,27 +567,45 @@ add_action( 'wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 ); add_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' ); +add_action( 'wp_enqueue_scripts', 'wp_enqueue_classic_theme_styles' ); add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 ); add_action( 'admin_enqueue_scripts', 'wp_common_block_scripts_and_styles' ); add_action( 'enqueue_block_assets', 'wp_enqueue_registered_block_scripts_and_styles' ); add_action( 'enqueue_block_assets', 'enqueue_block_styles_assets', 30 ); +/* + * `wp_enqueue_registered_block_scripts_and_styles` is bound to both + * `enqueue_block_editor_assets` and `enqueue_block_assets` hooks + * since the introduction of the block editor in WordPress 5.0. + * + * The way this works is that the block assets are loaded before any other assets. + * For example, this is the order of styles for the editor: + * + * - front styles registered for blocks, via `styles` handle (block.json) + * - editor styles registered for blocks, via `editorStyles` handle (block.json) + * - editor styles enqueued via `enqueue_block_editor_assets` hook + * - front styles enqueued via `enqueue_block_assets` hook + */ add_action( 'enqueue_block_editor_assets', 'wp_enqueue_registered_block_scripts_and_styles' ); add_action( 'enqueue_block_editor_assets', 'enqueue_editor_block_styles_assets' ); add_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' ); add_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_format_library_assets' ); add_action( 'enqueue_block_editor_assets', 'wp_enqueue_global_styles_css_custom_properties' ); -add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); +add_action( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); -add_filter( 'customize_controls_print_styles', 'wp_resource_hints', 1 ); +add_action( 'customize_controls_print_styles', 'wp_resource_hints', 1 ); add_action( 'admin_head', 'wp_check_widget_editor_deps' ); +add_filter( 'block_editor_settings_all', 'wp_add_editor_classic_theme_styles' ); // Global styles can be enqueued in both the header and the footer. See https://core.trac.wordpress.org/ticket/53494. add_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' ); add_action( 'wp_footer', 'wp_enqueue_global_styles', 1 ); -// SVG filters like duotone have to be loaded at the beginning of the body in both admin and the front-end. -add_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' ); -add_action( 'in_admin_header', 'wp_global_styles_render_svg_filters' ); +// Global styles custom CSS. +add_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles_custom_css' ); + +// Block supports, and other styles parsed and stored in the Style Engine. +add_action( 'wp_enqueue_scripts', 'wp_enqueue_stored_styles' ); +add_action( 'wp_footer', 'wp_enqueue_stored_styles', 1 ); add_action( 'wp_default_styles', 'wp_default_styles' ); add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 ); @@ -585,6 +614,15 @@ add_action( 'wp_footer', 'wp_maybe_inline_styles', 1 ); // Run for late-loaded styles in the footer. /* + * Block specific actions and filters. + */ + +// Footnotes Block. +add_action( 'init', '_wp_footnotes_kses_init' ); +add_action( 'set_current_user', '_wp_footnotes_kses_init' ); +add_filter( 'force_filtered_html_on_import', '_wp_footnotes_force_filtered_html_on_import_filter', 999 ); + +/* * Disable "Post Attributes" for wp_navigation post type. The attributes are * also conditionally enabled when a site has custom templates. Block Theme * templates can be available for every post type. @@ -599,9 +637,6 @@ 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' ); @@ -610,16 +645,21 @@ // Nav menu. add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 ); +add_filter( 'nav_menu_css_class', 'wp_nav_menu_remove_menu_item_has_children_class', 10, 4 ); // Widgets. add_action( 'after_setup_theme', 'wp_setup_widgets_block_editor', 1 ); add_action( 'init', 'wp_widgets_init', 1 ); add_action( 'change_locale', array( 'WP_Widget_Media', 'reset_default_labels' ) ); +add_action( 'widgets_init', '_wp_block_theme_register_classic_sidebars', 1 ); // 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_enqueue_scripts', 'wp_enqueue_admin_bar_bump_styles' ); +add_action( 'wp_enqueue_scripts', 'wp_enqueue_admin_bar_header_styles' ); +add_action( 'admin_enqueue_scripts', 'wp_enqueue_admin_bar_header_styles' ); add_action( 'before_signup_header', '_wp_admin_bar_init' ); add_action( 'activate_header', '_wp_admin_bar_init' ); add_action( 'wp_body_open', 'wp_admin_bar_render', 0 ); @@ -641,12 +681,14 @@ add_action( 'embed_head', 'enqueue_embed_scripts', 1 ); add_action( 'embed_head', 'print_emoji_detection_script' ); -add_action( 'embed_head', 'print_embed_styles' ); +add_action( 'embed_head', 'wp_enqueue_embed_styles', 9 ); +add_action( 'embed_head', 'print_embed_styles' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_embed_styles(). add_action( 'embed_head', 'wp_print_head_scripts', 20 ); add_action( 'embed_head', 'wp_print_styles', 20 ); add_action( 'embed_head', 'wp_robots' ); add_action( 'embed_head', 'rel_canonical' ); add_action( 'embed_head', 'locale_stylesheet', 30 ); +add_action( 'enqueue_embed_scripts', 'wp_enqueue_emoji_styles' ); add_action( 'embed_content_meta', 'print_embed_comments_button' ); add_action( 'embed_content_meta', 'print_embed_sharing_button' ); @@ -676,8 +718,49 @@ add_filter( 'render_block_context', '_block_template_render_without_post_block_context' ); add_filter( 'pre_wp_unique_post_slug', 'wp_filter_wp_template_unique_post_slug', 10, 5 ); add_action( 'save_post_wp_template_part', 'wp_set_unique_slug_on_create_template_part' ); -add_action( 'wp_footer', 'the_block_template_skip_link' ); -add_action( 'setup_theme', 'wp_enable_block_templates' ); +add_action( 'wp_enqueue_scripts', 'wp_enqueue_block_template_skip_link' ); +add_action( 'wp_footer', 'the_block_template_skip_link' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_block_template_skip_link(). +add_action( 'after_setup_theme', 'wp_enable_block_templates', 1 ); add_action( 'wp_loaded', '_add_template_loader_filters' ); +// wp_navigation post type. +add_filter( 'rest_wp_navigation_item_schema', array( 'WP_Navigation_Fallback', 'update_wp_navigation_post_schema' ) ); + +// Fluid typography. +add_filter( 'render_block', 'wp_render_typography_support', 10, 2 ); + +// User preferences. +add_action( 'init', 'wp_register_persisted_preferences_meta' ); + +// CPT wp_block custom postmeta field. +add_action( 'init', 'wp_create_initial_post_meta' ); + +// Include revisioned meta when considering whether a post revision has changed. +add_filter( 'wp_save_post_revision_post_has_changed', 'wp_check_revisioned_meta_fields_have_changed', 10, 3 ); + +// Save revisioned post meta immediately after a revision is saved +add_action( '_wp_put_post_revision', 'wp_save_revisioned_meta_fields', 10, 2 ); + +// Include revisioned meta when creating or updating an autosave revision. +add_action( 'wp_creating_autosave', 'wp_autosave_post_revisioned_meta_fields' ); + +// When restoring revisions, also restore revisioned meta. +add_action( 'wp_restore_post_revision', 'wp_restore_post_revision_meta', 10, 2 ); + +// Font management. +add_action( 'wp_head', 'wp_print_font_faces', 50 ); +add_action( 'deleted_post', '_wp_after_delete_font_family', 10, 2 ); +add_action( 'before_delete_post', '_wp_before_delete_font_face', 10, 2 ); +add_action( 'init', '_wp_register_default_font_collections' ); + +// Add ignoredHookedBlocks metadata attribute to the template and template part post types. +add_filter( 'rest_pre_insert_wp_template', 'inject_ignored_hooked_blocks_metadata_attributes' ); +add_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes' ); + +// Update ignoredHookedBlocks postmeta for wp_navigation post type. +add_filter( 'rest_pre_insert_wp_navigation', 'update_ignored_hooked_blocks_postmeta' ); + +// Inject hooked blocks into the wp_navigation post type REST response. +add_filter( 'rest_prepare_wp_navigation', 'insert_hooked_blocks_into_rest_response', 10, 2 ); + unset( $filter, $action );