Skip to content

Commit

Permalink
Remove migration
Browse files Browse the repository at this point in the history
  • Loading branch information
david-szabo97 committed Nov 18, 2020
1 parent a9c24a3 commit 2e70dd3
Showing 1 changed file with 0 additions and 57 deletions.
57 changes: 0 additions & 57 deletions lib/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,63 +108,6 @@ function gutenberg_register_wp_theme_taxonomy() {
}
add_action( 'init', 'gutenberg_register_wp_theme_taxonomy' );

/**
* Migrates old meta based theme storage to taxonomy
* for wp_template and wp_template_part posts.
*/
function gutenberg_migrate_theme_meta_to_taxonomy() {
if ( ! gutenberg_is_fse_theme() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
return;
}

$terms = get_terms(
array(
'taxonomy' => 'wp_theme',
'posts_per_page' => 1,
'hide_empty' => false,
'fields' => 'ids',
)
);
if ( $terms ) {
return;
}

$query = new WP_Query(
array(
'post_type' => array( 'wp_template', 'wp_template_part' ),
'posts_per_page' => -1,
'post_status' => array( 'publish', 'auto-draft', 'draft', 'trash' ),
)
);
if ( ! $query->have_posts() ) {
return;
}

while ( $query->have_posts() ) {
$query->the_post();
$post = get_post();
$terms = array();

$theme = get_post_meta( $post->ID, 'theme', true );
if ( ! $theme ) {
$theme = wp_get_theme()->get_stylesheet();
}
$terms[] = $theme;

if ( 'auto-draft' === $post->post_status ) {
$terms[] = 'wp_file_based';
}

wp_set_post_terms( $post->ID, $terms, 'wp_theme', true );
}
wp_reset_postdata();

global $wp;
wp_redirect( add_query_arg( $wp->query_vars, home_url( $wp->request ) ) );
exit;
}
add_action( 'init', 'gutenberg_migrate_theme_meta_to_taxonomy' );

/**
* Automatically set the theme meta for templates.
*
Expand Down

0 comments on commit 2e70dd3

Please sign in to comment.