Skip to content

Commit

Permalink
Ensure rewrite rules are flushed properly when toggling website exper…
Browse files Browse the repository at this point in the history
…ience
  • Loading branch information
westonruter committed Jun 10, 2019
1 parent 98efeb0 commit 6f8a8d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ function amp_deactivate() {
}
}

flush_rewrite_rules();
flush_rewrite_rules( false );
}

/*
Expand Down
15 changes: 12 additions & 3 deletions includes/options/class-amp-options-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static function register_settings() {
}

/**
* Flush rewrite rules if the supported_post_types have changed.
* Flush rewrite rules if the supported_post_types or experiences have changed.
*
* @since 0.6.2
*
Expand All @@ -80,8 +80,17 @@ public static function maybe_flush_rewrite_rules( $old_options, $new_options ) {
$new_post_types = isset( $new_options['supported_post_types'] ) ? $new_options['supported_post_types'] : array();
sort( $old_post_types );
sort( $new_post_types );
if ( $old_post_types !== $new_post_types ) {
flush_rewrite_rules( false );
$old_experiences = isset( $old_options['experiences'] ) ? $old_options['experiences'] : array();
$new_experiences = isset( $new_options['experiences'] ) ? $new_options['experiences'] : array();
sort( $old_experiences );
sort( $new_experiences );
if ( $old_post_types !== $new_post_types || $old_experiences !== $new_experiences ) {
if ( self::is_website_experience_enabled() ) {
add_rewrite_endpoint( amp_get_slug(), EP_PERMALINK );
flush_rewrite_rules( false );
} else {
amp_deactivate();
}
}
}

Expand Down

0 comments on commit 6f8a8d8

Please sign in to comment.