File tree Expand file tree Collapse file tree 3 files changed +24
-9
lines changed Expand file tree Collapse file tree 3 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,13 @@ public function enqueue_admin_assets() {
217
217
public function enqueue_block_assets () {
218
218
$ post = get_post ();
219
219
220
+ // Block validation script uses features only available beginning with WP 5.6.
221
+ $ dependency_support = Services::get ( 'dependency_support ' );
222
+ if ( ! $ dependency_support ->has_support () ) {
223
+ return ; // @codeCoverageIgnore
224
+ }
225
+
226
+ // Only enqueue scripts on the block editor for AMP-enabled posts.
220
227
$ editor_support = Services::get ( 'editor.editor_support ' );
221
228
if ( ! $ editor_support ->is_current_screen_supported_block_editor_for_amp_enabled_post_type () ) {
222
229
return ;
Original file line number Diff line number Diff line change @@ -2175,13 +2175,18 @@ public static function enqueue_block_validation() {
2175
2175
return ;
2176
2176
}
2177
2177
2178
- $ editor_support = Services::get ( 'editor.editor_support ' );
2179
-
2180
2178
// Block validation script uses features only available beginning with WP 5.6.
2181
- if ( ! $ editor_support ->is_current_screen_supported_block_editor_for_amp_enabled_post_type () ) {
2179
+ $ dependency_support = Services::get ( 'dependency_support ' );
2180
+ if ( ! $ dependency_support ->has_support () ) {
2182
2181
return ; // @codeCoverageIgnore
2183
2182
}
2184
2183
2184
+ // Only enqueue scripts on the block editor for AMP-enabled posts.
2185
+ $ editor_support = Services::get ( 'editor.editor_support ' );
2186
+ if ( ! $ editor_support ->is_current_screen_supported_block_editor_for_amp_enabled_post_type () ) {
2187
+ return ;
2188
+ }
2189
+
2185
2190
$ slug = 'amp-block-validation ' ;
2186
2191
2187
2192
$ asset_file = AMP__DIR__ . '/assets/js/ ' . $ slug . '.asset.php ' ;
Original file line number Diff line number Diff line change @@ -44,7 +44,11 @@ public function register() {
44
44
* Shows a notice in the editor if the Gutenberg or WP version prevents plugin features from working.
45
45
*/
46
46
public function maybe_show_notice () {
47
- if ( $ this ->is_current_screen_supported_block_editor_for_amp_enabled_post_type () ) {
47
+ if ( $ this ->dependency_support ->has_support () ) {
48
+ return ;
49
+ }
50
+
51
+ if ( ! $ this ->is_current_screen_supported_block_editor_for_amp_enabled_post_type () ) {
48
52
return ;
49
53
}
50
54
@@ -66,19 +70,18 @@ function () {
66
70
}
67
71
68
72
/**
69
- * Returns whether the current environment is supported by the plugin
70
- * and the current screen is using the block editor.
73
+ * Returns whether the current screen is using the block editor and the post being edited supports AMP.
71
74
*
72
75
* @return bool
73
76
*/
74
77
public function is_current_screen_supported_block_editor_for_amp_enabled_post_type () {
75
78
$ screen = get_current_screen ();
76
- return $ this ->dependency_support ->has_support ()
77
- &&
79
+ return (
78
80
$ screen
79
81
&&
80
82
! empty ( $ screen ->is_block_editor )
81
83
&&
82
- in_array ( get_post_type (), AMP_Post_Type_Support::get_supported_post_types (), true );
84
+ in_array ( get_post_type (), AMP_Post_Type_Support::get_supported_post_types (), true )
85
+ );
83
86
}
84
87
}
You can’t perform that action at this time.
0 commit comments