@@ -278,7 +278,7 @@ function amp_deactivate() {
278
278
}
279
279
}
280
280
281
- flush_rewrite_rules ();
281
+ flush_rewrite_rules ( false );
282
282
}
283
283
284
284
/*
@@ -333,38 +333,42 @@ function amp_init() {
333
333
*/
334
334
do_action ( 'amp_init ' );
335
335
336
- add_rewrite_endpoint ( amp_get_slug (), EP_PERMALINK );
337
-
338
336
add_filter ( 'allowed_redirect_hosts ' , array ( 'AMP_HTTP ' , 'filter_allowed_redirect_hosts ' ) );
339
337
AMP_HTTP ::purge_amp_query_vars ();
340
338
AMP_HTTP ::send_cors_headers ();
341
339
AMP_HTTP ::handle_xhr_request ();
342
340
AMP_Theme_Support::init ();
343
341
AMP_Validation_Manager::init ();
344
- AMP_Post_Type_Support::add_post_type_support ();
345
- AMP_Story_Post_Type::register ();
346
342
AMP_Service_Worker::init ();
347
- add_action ( 'init ' , array ( 'AMP_Post_Type_Support ' , 'add_post_type_support ' ), 1000 ); // After post types have been defined.
348
-
349
- if ( defined ( 'WP_CLI ' ) && WP_CLI ) {
350
- WP_CLI ::add_command ( 'amp ' , new AMP_CLI () );
351
- }
352
-
353
- add_filter ( 'request ' , 'amp_force_query_var_value ' );
354
343
add_action ( 'admin_init ' , 'AMP_Options_Manager::register_settings ' );
355
- add_action ( 'wp_loaded ' , 'amp_editor_core_blocks ' );
356
- add_action ( 'wp_loaded ' , 'amp_post_meta_box ' );
357
- add_action ( 'wp_loaded ' , 'amp_story_templates ' );
358
344
add_action ( 'wp_loaded ' , 'amp_add_options_menu ' );
359
345
add_action ( 'wp_loaded ' , 'amp_admin_pointer ' );
360
- add_action ( 'parse_query ' , 'amp_correct_query_when_is_front_page ' );
361
- add_action ( 'admin_bar_menu ' , 'amp_add_admin_bar_view_link ' , 100 );
346
+ add_action ( 'wp_loaded ' , 'amp_post_meta_box ' ); // Used in both Website and Stories experiences.
347
+
348
+ if ( AMP_Options_Manager::is_website_experience_enabled () ) {
349
+ add_rewrite_endpoint ( amp_get_slug (), EP_PERMALINK );
350
+ AMP_Post_Type_Support::add_post_type_support ();
351
+ add_action ( 'init ' , array ( 'AMP_Post_Type_Support ' , 'add_post_type_support ' ), 1000 ); // After post types have been defined.
352
+ add_action ( 'parse_query ' , 'amp_correct_query_when_is_front_page ' );
353
+ add_action ( 'admin_bar_menu ' , 'amp_add_admin_bar_view_link ' , 100 );
354
+ add_action ( 'wp_loaded ' , 'amp_editor_core_blocks ' );
355
+ add_filter ( 'request ' , 'amp_force_query_var_value ' );
356
+
357
+ // Add actions for reader mode templates.
358
+ add_action ( 'wp ' , 'amp_maybe_add_actions ' );
359
+
360
+ // Redirect the old url of amp page to the updated url.
361
+ add_filter ( 'old_slug_redirect_url ' , 'amp_redirect_old_slug_to_new_url ' );
362
+ }
362
363
363
- // Redirect the old url of amp page to the updated url.
364
- add_filter ( 'old_slug_redirect_url ' , 'amp_redirect_old_slug_to_new_url ' );
364
+ if ( AMP_Options_Manager::is_stories_experience_enabled () ) {
365
+ AMP_Story_Post_Type::register ();
366
+ add_action ( 'wp_loaded ' , 'amp_story_templates ' );
367
+ }
365
368
366
- // Add actions for legacy post templates.
367
- add_action ( 'wp ' , 'amp_maybe_add_actions ' );
369
+ if ( defined ( 'WP_CLI ' ) && WP_CLI ) {
370
+ WP_CLI ::add_command ( 'amp ' , new AMP_CLI () );
371
+ }
368
372
369
373
/*
370
374
* Broadcast plugin updates.
@@ -513,7 +517,7 @@ function amp_correct_query_when_is_front_page( WP_Query $query ) {
513
517
*
514
518
* add_theme_support( AMP_Theme_Support::SLUG );
515
519
*
516
- * This will serve templates in native AMP, allowing you to use AMP components in your theme templates.
520
+ * This will serve templates in AMP-first , allowing you to use AMP components in your theme templates.
517
521
* If you want to make available in transitional mode, where templates are served in AMP or non-AMP documents, do:
518
522
*
519
523
* add_theme_support( AMP_Theme_Support::SLUG, array(
@@ -526,7 +530,7 @@ function amp_correct_query_when_is_front_page( WP_Query $query ) {
526
530
* 'template_dir' => 'amp',
527
531
* ) );
528
532
*
529
- * If you want to have AMP-specific templates in addition to serving native AMP, do:
533
+ * If you want to have AMP-specific templates in addition to serving AMP-first , do:
530
534
*
531
535
* add_theme_support( AMP_Theme_Support::SLUG, array(
532
536
* 'paired' => false,
@@ -549,16 +553,16 @@ function amp_correct_query_when_is_front_page( WP_Query $query ) {
549
553
* ) );
550
554
*
551
555
* @see AMP_Theme_Support::read_theme_support()
552
- * @return boolean Whether this is in AMP 'canonical' mode, that is whether it is native and there is not separate AMP URL current URL.
556
+ * @return boolean Whether this is in AMP 'canonical' mode, that is whether it is AMP-first and there is not a separate (paired) AMP URL.
553
557
*/
554
558
function amp_is_canonical () {
555
559
if ( ! current_theme_supports ( AMP_Theme_Support::SLUG ) ) {
556
560
return false ;
557
561
}
558
562
559
563
$ args = AMP_Theme_Support::get_theme_support_args ();
560
- if ( isset ( $ args [' paired ' ] ) ) {
561
- return empty ( $ args [' paired ' ] );
564
+ if ( isset ( $ args [ AMP_Theme_Support:: PAIRED_FLAG ] ) ) {
565
+ return empty ( $ args [ AMP_Theme_Support:: PAIRED_FLAG ] );
562
566
}
563
567
564
568
// If there is a template_dir, then transitional mode is implied.
0 commit comments