| 1 |
<?php |
| 2 |
/** |
| 3 |
* Updates the script-loader.php file |
| 4 |
* |
| 5 |
* @package gutenberg |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Registers vendor JavaScript files to be used as dependencies of the editor |
| 10 |
* and plugins. |
| 11 |
* |
| 12 |
* This function is called from a script during the plugin build process, so it |
| 13 |
* should not call any WordPress PHP functions. |
| 14 |
* |
| 15 |
* @since 13.0 |
| 16 |
* |
| 17 |
* @param WP_Scripts $scripts WP_Scripts instance. |
| 18 |
*/ |
| 19 |
function gutenberg_register_vendor_scripts_62( $scripts ) { |
| 20 |
$extension = SCRIPT_DEBUG ? '.js' : '.min.js'; |
| 21 |
|
| 22 |
$script = $scripts->query( 'wp-inert-polyfill', 'registered' ); |
| 23 |
if ( ! $script ) { |
| 24 |
$scripts->add( 'wp-inert-polyfill', gutenberg_url( 'build/vendors/inert-polyfill' . $extension ), array() ); |
| 25 |
} |
| 26 |
|
| 27 |
$script = $scripts->query( 'wp-polyfill', 'registered' ); |
| 28 |
$script->deps = array_merge( $script->deps, array( 'wp-inert-polyfill' ) ); |
| 29 |
} |
| 30 |
add_action( 'wp_default_scripts', 'gutenberg_register_vendor_scripts_62' ); |
| 31 |
|
| 32 |
/** |
| 33 |
* This function takes care of adding inline styles |
| 34 |
* in the proper place, depending on the theme in use. |
| 35 |
* |
| 36 |
* This method was added to core in 5.9.1, but with a single param ($style). The second param ($priority) was |
| 37 |
* added post 6.0, so the 6.1 release needs to have wp_enqueue_block_support_styles updated to include this param. |
| 38 |
* |
| 39 |
* For block themes, it's loaded in the head. |
| 40 |
* For classic ones, it's loaded in the body |
| 41 |
* because the wp_head action happens before |
| 42 |
* the render_block. |
| 43 |
* |
| 44 |
* @link https://core.trac.wordpress.org/ticket/53494. |
| 45 |
* |
| 46 |
* @deprecated 6.2 Block supports styles are now stored for enqueuing via the style engine API. See: packages/style-engine/README.md. |
| 47 |
* |
| 48 |
* @param string $style String containing the CSS styles to be added. |
| 49 |
* @param int $priority To set the priority for the add_action. |
| 50 |
*/ |
| 51 |
function gutenberg_enqueue_block_support_styles( $style, $priority = 10 ) { |
| 52 |
_deprecated_function( __FUNCTION__, '6.2' ); |
| 53 |
|
| 54 |
$action_hook_name = 'wp_footer'; |
| 55 |
if ( wp_is_block_theme() ) { |
| 56 |
$action_hook_name = 'wp_head'; |
| 57 |
} |
| 58 |
add_action( |
| 59 |
$action_hook_name, |
| 60 |
static function () use ( $style ) { |
| 61 |
echo "<style>$style</style>\n"; |
| 62 |
}, |
| 63 |
$priority |
| 64 |
); |
| 65 |
} |
| 66 |
|
| 67 |
add_filter( |
| 68 |
'block_editor_settings_all', |
| 69 |
static function( $settings ) { |
| 70 |
// We must override what core is passing now. |
| 71 |
$settings['__unstableIsBlockBasedTheme'] = wp_is_block_theme(); |
| 72 |
return $settings; |
| 73 |
}, |
| 74 |
100 |
| 75 |
); |
| 76 |
|