Skip to content

Commit f28b16c

Browse files
committed
Migrate WP_Query performance optimizations
1 parent 1ff63af commit f28b16c

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

‎src/wp-includes/class-wp-theme-json-resolver.php‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,16 @@ public static function get_user_data_from_wp_global_styles( $theme, $create_post
425425
$post_type_filter = 'wp_global_styles';
426426
$stylesheet = $theme->get_stylesheet();
427427
$args = array(
428-
'posts_per_page' => 1,
429-
'orderby' => 'date',
430-
'order' => 'desc',
431-
'post_type' => $post_type_filter,
432-
'post_status' => $post_status_filter,
433-
'ignore_sticky_posts' => true,
434-
'no_found_rows' => true,
435-
'tax_query' => array(
428+
'posts_per_page' => 1,
429+
'orderby' => 'date',
430+
'order' => 'desc',
431+
'post_type' => $post_type_filter,
432+
'post_status' => $post_status_filter,
433+
'ignore_sticky_posts' => true,
434+
'no_found_rows' => true,
435+
'update_post_meta_cache' => false,
436+
'update_post_term_cache' => false,
437+
'tax_query' => array(
436438
array(
437439
'taxonomy' => 'wp_theme',
438440
'field' => 'name',
@@ -444,7 +446,7 @@ public static function get_user_data_from_wp_global_styles( $theme, $create_post
444446
$global_style_query = new WP_Query();
445447
$recent_posts = $global_style_query->query( $args );
446448
if ( count( $recent_posts ) === 1 ) {
447-
$user_cpt = get_post( $recent_posts[0], ARRAY_A );
449+
$user_cpt = get_object_vars( $recent_posts[0] );
448450
} elseif ( $create_post ) {
449451
$cpt_post_id = wp_insert_post(
450452
array(
@@ -460,7 +462,7 @@ public static function get_user_data_from_wp_global_styles( $theme, $create_post
460462
true
461463
);
462464
if ( ! is_wp_error( $cpt_post_id ) ) {
463-
$user_cpt = get_post( $cpt_post_id, ARRAY_A );
465+
$user_cpt = get_object_vars( get_post( $cpt_post_id ) );
464466
}
465467
}
466468

0 commit comments

Comments
 (0)