Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use inline styles. #4824

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fad2631
Use inline styles.
spacedmonkey Jul 10, 2023
a768486
Use inline styles for admin bar.
spacedmonkey Jul 10, 2023
0f4f4af
Merge branch 'trunk' into fix/inline-styles
spacedmonkey Sep 8, 2023
96b225e
Remove inline styles
spacedmonkey Sep 8, 2023
be4867c
Change custom background as well.
spacedmonkey Sep 8, 2023
9be777c
Tweek action proity.
spacedmonkey Sep 8, 2023
4e67c1d
Add spaces.
spacedmonkey Sep 8, 2023
d02a47a
Change selector.
spacedmonkey Sep 8, 2023
68e9d17
Apply suggestions from code review
spacedmonkey Sep 11, 2023
8ea7c2c
Change formatting.
spacedmonkey Sep 11, 2023
89ddbfc
Merge branch 'trunk' into fix/inline-styles
spacedmonkey Sep 12, 2023
ff00df3
Revert some of the changes.
spacedmonkey Sep 12, 2023
c89bed2
Another approach.
spacedmonkey Sep 12, 2023
8fd1ec8
Depreacte functions.
spacedmonkey Sep 13, 2023
3dbd386
More depreacte functions.
spacedmonkey Sep 13, 2023
05b09c3
Remove filters to fix tests.
spacedmonkey Sep 13, 2023
b35cd2e
Apply suggestions from code review
spacedmonkey Sep 19, 2023
ee514b2
Merge branch 'trunk' into fix/inline-styles
spacedmonkey Sep 19, 2023
988b3bd
Change function names.
spacedmonkey Sep 19, 2023
db6733f
Feedback.
spacedmonkey Sep 19, 2023
ab32c36
Add some comments.
spacedmonkey Sep 19, 2023
c7e7815
Add deprecated comments.
spacedmonkey Sep 19, 2023
21cbfb7
Formatting.
spacedmonkey Sep 19, 2023
40bcb76
Comment.
spacedmonkey Sep 19, 2023
96270b0
Merge branch 'trunk' into fix/inline-styles
spacedmonkey Sep 19, 2023
56640f3
Fix lints.
spacedmonkey Sep 19, 2023
baa01b7
Change handle name.
spacedmonkey Sep 19, 2023
800fe53
Use `wp_add_inline_style` to be safe.
spacedmonkey Sep 19, 2023
77ca89a
Apply suggestions from code review
spacedmonkey Sep 21, 2023
95d3f9a
Support custom callbacks.
spacedmonkey Sep 21, 2023
3982bd9
Apply suggestions from code review
spacedmonkey Sep 21, 2023
7732aaa
Apply suggestions from code review
spacedmonkey Sep 21, 2023
91c0d51
Apply suggestions from code review
spacedmonkey Sep 21, 2023
9fdc0f1
Merge branch 'trunk' into fix/inline-styles
spacedmonkey Sep 25, 2023
5b8bc3c
Remove IDE hints.
spacedmonkey Sep 25, 2023
6dffef3
Merge branch 'trunk' into fix/inline-styles
spacedmonkey Sep 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/wp-includes/admin-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,39 @@ function _admin_bar_bump_cb() {
<?php
}

/**
* Remove the `_admin_bar_bump_cb` and `wp_admin_bar_header` actions
* and use `wp_add_inline_style` function to render inline styles.
*
* @since 6.4.0
*/
function wp_enqueue_admin_bar_styles() {
spacedmonkey marked this conversation as resolved.
Show resolved Hide resolved
if ( has_action( 'wp_head', '_admin_bar_bump_cb' ) ) {
remove_action( 'wp_head', '_admin_bar_bump_cb' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See note below about how I think this would do well to have an explanatory comment explaining what the action is all about.

$css = '@media screen { html { margin-top: 32px !important; } }
@media screen and ( max-width: 782px ) { html { margin-top: 46px !important; } }';
spacedmonkey marked this conversation as resolved.
Show resolved Hide resolved
wp_add_inline_style( 'admin-bar', $css );
}

if ( has_action( 'wp_head', 'wp_admin_bar_header' ) ) {
remove_action( 'wp_head', 'wp_admin_bar_header' );
wp_add_inline_style( 'admin-bar', /* language=CSS */ '@media print { #wpadminbar { display:none; } }' );
}
}

/**
* Remove the `wp_admin_bar_header` actions
* and use `wp_add_inline_style` function to render inline styles.
*
* @since 6.4.0
*/
function admin_enqueue_admin_bar_styles() {
if ( has_action( 'admin_head', 'wp_admin_bar_header' ) ) {
remove_action( 'admin_head', 'wp_admin_bar_header' );
wp_add_inline_style( 'admin-bar', /* language=CSS */ '@media print { #wpadminbar { display:none; } }' );
}
}

/**
* Sets the display status of the admin bar.
*
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,8 @@
// 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_styles');

Check failure on line 655 in src/wp-includes/default-filters.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Expected 1 spaces before closing parenthesis; 0 found
add_action( 'admin_enqueue_scripts', 'admin_enqueue_admin_bar_styles');

Check failure on line 656 in src/wp-includes/default-filters.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Expected 1 spaces before closing parenthesis; 0 found
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 );
Expand Down
8 changes: 1 addition & 7 deletions src/wp-includes/embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -1064,13 +1064,7 @@ function enqueue_embed_scripts() {
* @since 4.4.0
*/
function print_embed_styles() {
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
$suffix = SCRIPT_DEBUG ? '' : '.min';
?>
<style<?php echo $type_attr; ?>>
<?php echo file_get_contents( ABSPATH . WPINC . "/css/wp-embed-template$suffix.css" ); ?>
</style>
<?php
wp_enqueue_style( 'wp-embed-template' );
spacedmonkey marked this conversation as resolved.
Show resolved Hide resolved
spacedmonkey marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
42 changes: 17 additions & 25 deletions src/wp-includes/formatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -5852,31 +5852,23 @@ function wp_spaces_regexp() {
* @since 4.2.0
*/
function print_emoji_styles() {
static $printed = false;

if ( $printed ) {
return;
}

$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 );
spacedmonkey marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,8 @@ function wp_default_styles( $styles ) {
$styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) );
$styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) );
$styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) );
$styles->add( 'wp-embed-template', "/wp-includes/css/wp-embed-template$suffix.css" );
$styles->add_data( 'wp-embed-template', 'path', ABSPATH . "/wp-includes/css/wp-embed-template$suffix.css" );
$styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" );
$styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' );

Expand Down
19 changes: 10 additions & 9 deletions src/wp-includes/theme-templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,8 @@ function the_block_template_skip_link() {
if ( ! $_wp_current_template_content ) {
return;
}
?>

<?php
/**
* Print the skip-link styles.
*/
?>
<style id="skip-link-styles">
$skip_link_styles = '
spacedmonkey marked this conversation as resolved.
Show resolved Hide resolved
.skip-link.screen-reader-text {
border: 0;
clip: rect(1px,1px,1px,1px);
Expand Down Expand Up @@ -154,8 +148,15 @@ function the_block_template_skip_link() {
top: 5px;
width: auto;
z-index: 100000;
}
</style>
}';

$handle = 'skip-link-styles';

wp_register_style( $handle, false );
wp_add_inline_style( $handle, $skip_link_styles );
wp_enqueue_style( $handle );
felixarntz marked this conversation as resolved.
Show resolved Hide resolved
spacedmonkey marked this conversation as resolved.
Show resolved Hide resolved
?>
spacedmonkey marked this conversation as resolved.
Show resolved Hide resolved

<?php
spacedmonkey marked this conversation as resolved.
Show resolved Hide resolved
/**
* Print the skip-link script.
Expand Down
Loading