diff --git a/backport-changelog/6.9/8063.md b/backport-changelog/6.9/8063.md index 6f880a29a90e59..0ace9df3963a10 100644 --- a/backport-changelog/6.9/8063.md +++ b/backport-changelog/6.9/8063.md @@ -2,6 +2,7 @@ https://github.com/WordPress/wordpress-develop/pull/8063 * https://github.com/WordPress/gutenberg/pull/67125 * https://github.com/WordPress/gutenberg/pull/71840 +* https://github.com/WordPress/gutenberg/pull/72156 * https://github.com/WordPress/gutenberg/pull/71811 * https://github.com/WordPress/gutenberg/pull/72003 * https://github.com/WordPress/gutenberg/pull/72029 diff --git a/lib/compat/wordpress-6.9/template-activate.php b/lib/compat/wordpress-6.9/template-activate.php index 0506a45129f536..216d65f9bf5a5c 100644 --- a/lib/compat/wordpress-6.9/template-activate.php +++ b/lib/compat/wordpress-6.9/template-activate.php @@ -450,6 +450,11 @@ function gutenberg_set_active_template_theme( $changes, $request ) { $changes->tax_input = array( 'wp_theme' => isset( $request['theme'] ) ? $request['theme'] : get_stylesheet(), ); + // All new templates saved will receive meta so we can distinguish between + // templates created the old way as edits and templates created the new way. + $changes->meta_input = array( + 'is_inactive_by_default' => true, + ); return $changes; } @@ -477,6 +482,19 @@ function gutenberg_migrate_existing_templates() { 'terms' => get_stylesheet(), ), ), + // Only get templates that are not inactive by default. + 'meta_query' => array( + 'relation' => 'OR', + array( + 'key' => 'is_inactive_by_default', + 'compare' => 'NOT EXISTS', + ), + array( + 'key' => 'is_inactive_by_default', + 'value' => false, + 'compare' => '=', + ), + ), ); $template_query = new WP_Query( $wp_query_args );