-
Notifications
You must be signed in to change notification settings - Fork 384
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
Call to _admin_bar_bump_cb
causes deprecation error in WordPress 6.4+
#7619
Labels
Milestone
Comments
This was referenced Sep 29, 2023
Closed
_admin_bar_bump_cb
causes deprecation error in WordPress 8+_admin_bar_bump_cb
causes deprecation error in WordPress 6.4+
Yes, this is result of https://core.trac.wordpress.org/ticket/58775 We'll need to fix by the time WordPress 6.4 is released. As for the fix, the code in question is: amp-wp/includes/class-amp-theme-support.php Lines 1228 to 1241 in 2c4df9e
I believe it can be rewritten as follows, or something like it: if ( ! function_exists( 'wp_enqueue_admin_bar_header_styles' ) ) {
remove_action( 'wp_head', $header_callback );
}
if ( '__return_false' !== $header_callback ) {
if ( ! function_exists( 'wp_enqueue_admin_bar_header_styles' ) ) {
ob_start();
$header_callback();
$style = ob_get_clean();
$data = trim( preg_replace( '#<style[^>]*>(.*)</style>#is', '$1', $style ) ); // See wp_add_inline_style().
} else {
$data = '';
}
// Override AMP's position:relative on the body for the sake of the AMP viewer, which is not relevant an an Admin Bar context.
if ( amp_is_dev_mode() ) {
$data .= 'html:not(#_) > body { position:unset !important; }';
}
wp_add_inline_style( 'admin-bar', $data );
} |
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug Description
The call to
_admin_bar_bump_cb
at https://github.com/ampproject/amp-wp/blob/2c4df9e1dec74c798e11f06cd02e470f1f988705/includes/class-amp-theme-support.php#L1226C9-L1226C9 causes PHP Deprecation notices to appear when using the AMP plugin with WordPress 6.4+.The entire notice is:
It seems using
wp_enqueue_admin_bar_bump_styles
instead will fix the issue, when the version of WordPress is equal-to/above6.4.0
.Expected Behaviour
No deprecation errors appear in the WordPress debug log/elsewhere when using the AMP plugin with WordPress 6.4+.
Screenshots
PHP Version
7.4
Plugin Version
2.4.2
AMP plugin template mode
Standard
WordPress Version
6.4.0 (Nightly)
Site Health
No response
Gutenberg Version
No response
OS(s) Affected
No response
Browser(s) Affected
No response
Device(s) Affected
No response
Acceptance Criteria
No response
Implementation Brief
No response
QA Testing Instructions
No response
Demo
No response
Changelog Entry
No response
The text was updated successfully, but these errors were encountered: