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

Add initial canonical AMP support #857

Merged
merged 9 commits into from Jan 12, 2018

Disable admin bar because it alone surpasses 50K limit for amp-custom…

… style
  • Loading branch information...
westonruter committed Jan 12, 2018
commit 4c1fa638bafe8fdf32b1a7d57fae15127df96310
@@ -37,8 +37,11 @@ public static function register_hooks() {
add_action( 'wp_head', array( __CLASS__, 'print_amp_scripts' ), 4 );
add_action( 'wp_head', array( __CLASS__, 'print_amp_custom_style' ), 5 );

This comment has been minimized.

Copy link
@ThierryA

ThierryA Jan 12, 2018

Collaborator

Thinks like add_schemaorg_metadata(), add_analytics_data() or add_generator_metadata() added in paired mode are not added in canonical mode, is that intentional?

This comment has been minimized.

Copy link
@westonruter

westonruter Jan 12, 2018

Author Member

Just not implemented yet.

add_action( 'admin_bar_init', array( __CLASS__, 'admin_bar_init' ) );
add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );
/*
* Disable admin bar because admin-bar.css (28K) and Dashicons (48K) alone
* combine to surpass the 50K limit imposed for the amp-custom style.
*/
add_filter( 'show_admin_bar', '__return_false', 100 );
// @todo Add output buffering.
// @todo Add character conversion.
@@ -152,40 +155,4 @@ public static function print_amp_custom_style() {
}
echo '</style>';
}
/**
* Fix up admin bar.
*/
public static function admin_bar_init() {
remove_action( 'wp_head', 'wp_admin_bar_header' );
add_action( 'admin_bar_menu', array( __CLASS__, 'remove_customize_support_script' ), 100 ); // See WP_Admin_Bar::add_menus().
add_filter( 'body_class', array( __CLASS__, array( __CLASS__, 'filter_body_class_to_force_customize_support' ) ) );
}
/**
* Let the body class include customize-support by default since support script won't be able to dynamically add it.
*
* @see wp_customize_support_script()
*
* @param array $classes Body classes.
* @return array Classes.
*/
public static function filter_body_class_to_force_customize_support( $classes ) {
$i = array_search( 'no-customize-support', $classes, true );
if ( false !== $i ) {
array_splice( $classes, $i, 1 );
}
$classes[] = 'customize-support';
return $classes;
}
/**
* Remove Customizer support script.
*
* @see WP_Admin_Bar::add_menus()
* @see wp_customize_support_script()
*/
public static function remove_customize_support_script() {
remove_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.