Make WordPress Core

Changeset 56932

Timestamp:
10/13/2023 05:19:31 PM (10 months ago)
Author:
westonruter
Message:

Script Loader: Enqueue inline style for block template skip link in head instead of footer.

  • Introduce wp_enqueue_block_template_skip_link() to replace the_block_template_skip_link(). Add to wp_enqueue_scripts action instead of wp_footer.
  • Keep inline script for skip link in footer.
  • Restore original the_block_template_skip_link() from 6.3 and move to deprecated.php.
  • Preserve back-compat for unhooking skip-link by removing the_block_template_skip_link from wp_footer action.

Follow-up to [56682] and [56687].

Props sabernhardt, plugindevs, westonruter, spacedmonkey.
Fixes #59505.
See #58775.
See #58664.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r56845 r56932  
    717717add_filter( 'pre_wp_unique_post_slug', 'wp_filter_wp_template_unique_post_slug', 10, 5 );
    718718add_action( 'save_post_wp_template_part', 'wp_set_unique_slug_on_create_template_part' );
    719 add_action( 'wp_footer', 'the_block_template_skip_link' );
     719add_action( 'wp_enqueue_scripts', 'wp_enqueue_block_template_skip_link' );
     720add_action( 'wp_footer', 'the_block_template_skip_link' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_block_template_skip_link().
    720721add_action( 'setup_theme', 'wp_enable_block_templates' );
    721722add_action( 'wp_loaded', '_add_template_loader_filters' );
  • trunk/src/wp-includes/deprecated.php

    r56751 r56932  
    61256125    return $new_content;
    61266126}
     6127
     6128
     6129
     6130
     6131
     6132
     6133
     6134
     6135
     6136
     6137
     6138
     6139
     6140
     6141
     6142
     6143
     6144
     6145
     6146
     6147
     6148
     6149
     6150
     6151
     6152
     6153
     6154
     6155
     6156
     6157
     6158
     6159
     6160
     6161
     6162
     6163
     6164
     6165
     6166
     6167
     6168
     6169
     6170
     6171
     6172
     6173
     6174
     6175
     6176
     6177
     6178
     6179
     6180
     6181
     6182
     6183
     6184
     6185
     6186
     6187
     6188
     6189
     6190
     6191
     6192
     6193
     6194
     6195
     6196
     6197
     6198
     6199
     6200
     6201
     6202
     6203
     6204
     6205
     6206
     6207
     6208
     6209
     6210
     6211
     6212
     6213
     6214
     6215
     6216
     6217
     6218
     6219
     6220
     6221
     6222
     6223
     6224
     6225
     6226
     6227
     6228
     6229
     6230
     6231
     6232
     6233
     6234
     6235
  • trunk/src/wp-includes/theme-templates.php

    r56748 r56932  
    100100
    101101/**
    102  * Prints the skip-link script & styles.
     102 * s the skip-link script & styles.
    103103 *
    104104 * @access private
    105  * @since 5.8.0
     105 * @since .0
    106106 *
    107107 * @global string $_wp_current_template_content
    108108 */
    109 function the_block_template_skip_link() {
     109function e_block_template_skip_link() {
    110110    global $_wp_current_template_content;
     111
     112
     113
     114
     115
     116
    111117
    112118    // Early exit if not a block theme.
     
    208214    $skip_link_script = wp_remove_surrounding_empty_script_tags( ob_get_clean() );
    209215    $script_handle    = 'wp-block-template-skip-link';
    210     wp_register_script( $script_handle, false );
     216    wp_register_script( $script_handle, false );
    211217    wp_add_inline_script( $script_handle, $skip_link_script );
    212218    wp_enqueue_script( $script_handle );
Note: See TracChangeset for help on using the changeset viewer.