Script Loader: Replace hardcoded output of style tags with calls to wp_add_inline_style.
In this commit, enhancements have been made by replacing manually constructed style tags with calls to `wp_add_inline_style`. Previously, numerous style tags were generated and output directly in the header, resulting in redundant code and bypassing the core's style enqueueing system. This approach made it challenging for third-party developers to manage and control the output of these style tags. To ensure backward compatibility, the following functions have been deprecated and replaced: - print_embed_styles - print_emoji_styles - wp_admin_bar_header - _admin_bar_bump_cb Backward compatibility shims have also been added, ensuring that if these functions were previously unhooked from there actions, they will continue to not output a style tag. However, for the following functions, conversion to use inline styles was not feasible due to the potential disruption it might cause by changing the style tag IDs, potentially breaking JavaScript functionality for a number of plugins in the repository: - custom-background - wp-custom These changes improve code maintainability and enhance the flexibility and control available to developers when managing style outputs within WordPress core. Props spacedmonkey, hlunter, westonruter, flixos90. Fixes #58775. Built from https://develop.svn.wordpress.org/trunk@56682 git-svn-id: http://core.svn.wordpress.org/trunk@56194 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -5858,36 +5858,34 @@ function wp_spaces_regexp() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the important emoji-related styles.
|
||||
* Enqueues the important emoji-related styles.
|
||||
*
|
||||
* @since 4.2.0
|
||||
* @since 6.4.0
|
||||
*/
|
||||
function print_emoji_styles() {
|
||||
static $printed = false;
|
||||
|
||||
if ( $printed ) {
|
||||
function wp_enqueue_emoji_styles() {
|
||||
// Back-compat for plugins that disable functionality by unhooking this action.
|
||||
$action = is_admin() ? 'admin_print_styles' : 'wp_print_styles';
|
||||
if ( ! has_action( $action, 'print_emoji_styles' ) ) {
|
||||
return;
|
||||
}
|
||||
remove_action( $action, 'print_emoji_styles' );
|
||||
|
||||
$printed = true;
|
||||
|
||||
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
|
||||
?>
|
||||
<style<?php echo $type_attr; ?>>
|
||||
img.wp-smiley,
|
||||
img.emoji {
|
||||
display: inline !important;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
height: 1em !important;
|
||||
width: 1em !important;
|
||||
margin: 0 0.07em !important;
|
||||
vertical-align: -0.1em !important;
|
||||
background: none !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
$emoji_styles = '
|
||||
img.wp-smiley, img.emoji {
|
||||
display: inline !important;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
height: 1em !important;
|
||||
width: 1em !important;
|
||||
margin: 0 0.07em !important;
|
||||
vertical-align: -0.1em !important;
|
||||
background: none !important;
|
||||
padding: 0 !important;
|
||||
}';
|
||||
$handle = 'wp-emoji-styles';
|
||||
wp_register_style( $handle, false );
|
||||
wp_add_inline_style( $handle, $emoji_styles );
|
||||
wp_enqueue_style( $handle );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user