Skip to content

Commit 22056fb

Browse files
authored
Merge pull request #3886 from ampproject/add/2199-site-health
Integrate with Site Health
2 parents b406b5e + d1c4d05 commit 22056fb

7 files changed

Lines changed: 800 additions & 37 deletions

File tree

amp.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,7 @@ function amp_init() {
368368
AMP_Service_Worker::init();
369369
add_action( 'admin_init', 'AMP_Options_Manager::register_settings' );
370370
add_action( 'wp_loaded', 'amp_add_options_menu' );
371-
add_action( 'wp_loaded', 'amp_admin_pointer' );
372-
add_action( 'wp_loaded', 'amp_post_meta_box' ); // Used in both Website and Stories experiences.
371+
add_action( 'wp_loaded', 'amp_bootstrap_admin' );
373372

374373
if ( AMP_Options_Manager::is_website_experience_enabled() ) {
375374
add_rewrite_endpoint( amp_get_slug(), EP_PERMALINK );

includes/admin/functions.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* @package AMP
66
*/
77

8+
use Amp\AmpWP\Admin\SiteHealth;
9+
810
/**
911
* Obsolete constant for flagging when Customizer is opened for AMP.
1012
*
@@ -169,18 +171,6 @@ function amp_add_custom_analytics( $analytics = [] ) {
169171
return $analytics;
170172
}
171173

172-
/**
173-
* Bootstrap AMP post meta box.
174-
*
175-
* This function must be invoked only once through the 'wp_loaded' action.
176-
*
177-
* @since 0.6
178-
*/
179-
function amp_post_meta_box() {
180-
$post_meta_box = new AMP_Post_Meta_Box();
181-
$post_meta_box->init();
182-
}
183-
184174
/**
185175
* Bootstrap AMP Editor core blocks.
186176
*/
@@ -190,13 +180,19 @@ function amp_editor_core_blocks() {
190180
}
191181

192182
/**
193-
* Bootstrap the AMP admin pointer class.
183+
* Bootstraps AMP admin classes.
194184
*
195-
* @since 1.0
185+
* @since 1.5.0
196186
*/
197-
function amp_admin_pointer() {
187+
function amp_bootstrap_admin() {
198188
$admin_pointers = new AMP_Admin_Pointers();
199189
$admin_pointers->init();
190+
191+
$post_meta_box = new AMP_Post_Meta_Box();
192+
$post_meta_box->init();
193+
194+
$site_health = new SiteHealth();
195+
$site_health->init();
200196
}
201197

202198
/**

includes/deprecated.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,25 @@ function amp_post_template_add_schemaorg_metadata() {
221221
_deprecated_function( __FUNCTION__, '0.7', 'amp_print_schemaorg_metadata' );
222222
amp_print_schemaorg_metadata();
223223
}
224+
225+
/**
226+
* Bootstrap AMP post meta box.
227+
*
228+
* This function must be invoked only once through the 'wp_loaded' action.
229+
*
230+
* @since 0.6
231+
* @deprecated Since 1.5.0, as admin class bootstrapping is moved to amp_bootstrap_admin().
232+
*/
233+
function amp_post_meta_box() {
234+
_deprecated_function( __FUNCTION__, '1.5.0' );
235+
}
236+
237+
/**
238+
* Bootstrap the AMP admin pointer class.
239+
*
240+
* @since 1.0
241+
* @deprecated Since 1.5.0, as admin class bootstrapping is moved to amp_bootstrap_admin().
242+
*/
243+
function amp_admin_pointer() {
244+
_deprecated_function( __FUNCTION__, '1.5.0' );
245+
}

includes/options/class-amp-options-manager.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -550,17 +550,15 @@ public static function render_welcome_notice() {
550550
*/
551551
public static function persistent_object_caching_notice() {
552552
if ( ! wp_using_ext_object_cache() && 'toplevel_page_' . self::OPTION_NAME === get_current_screen()->id ) {
553+
echo '<div class="notice notice-warning"><p>';
554+
esc_html_e( 'The AMP plugin performs at its best when persistent object cache is enabled. Object caching is used to more effectively store image dimensions and parsed CSS. It also allows for post-processor caching to be used.', 'amp' );
555+
echo ' ';
553556
printf(
554-
'<div class="notice notice-warning"><p>%s</p></div>',
555-
wp_kses(
556-
sprintf(
557-
/* translators: %s: Persistent object cache support URL */
558-
__( 'The AMP plugin performs at its best when persistent object cache is enabled. <a href="%s">More details</a>', 'amp' ),
559-
esc_url( __( 'https://codex.wordpress.org/Class_Reference/WP_Object_Cache#Persistent_Caching', 'amp' ) )
560-
),
561-
[ 'a' => [ 'href' => true ] ]
562-
)
557+
'<a href="%s">%s</a>',
558+
esc_url( __( 'https://codex.wordpress.org/Class_Reference/WP_Object_Cache#Persistent_Caching', 'amp' ) ),
559+
esc_html__( 'More details', 'amp' )
563560
);
561+
echo '</p></div>';
564562
}
565563
}
566564

@@ -578,17 +576,15 @@ public static function render_cache_miss_notice() {
578576
return;
579577
}
580578

579+
echo '<div class="notice notice-warning is-dismissible"><p>';
580+
esc_html_e( 'The AMP plugin&lsquo;s post-processor cache was disabled due to the detection of highly-variable content.', 'amp' );
581+
echo ' ';
581582
printf(
582-
'<div class="notice notice-warning is-dismissible"><p>%s</p></div>',
583-
wp_kses(
584-
sprintf(
585-
/* translators: %s: post-processor cache support URL */
586-
__( 'The AMP plugin&lsquo;s post-processor cache was disabled due to the detection of highly-variable content. <a href="%s">More details</a>', 'amp' ),
587-
esc_url( __( 'https://github.com/ampproject/amp-wp/wiki/Post-Processor-Cache', 'amp' ) )
588-
),
589-
[ 'a' => [ 'href' => true ] ]
590-
)
583+
'<a href="%s">%s</a>',
584+
esc_url( __( 'https://github.com/ampproject/amp-wp/wiki/Post-Processor-Cache', 'amp' ) ),
585+
esc_html__( 'More details', 'amp' )
591586
);
587+
echo '</p></div>';
592588
}
593589

594590
/**

0 commit comments

Comments
 (0)