[wp-trac] [WordPress Trac] #56812: `wp_get_global_settings` returns default color.palette.theme colors with style variation applied in Version 6.1-RC1-54506

WordPress Trac noreply at wordpress.org
Thu Oct 13 04:43:11 UTC 2022


#56812: `wp_get_global_settings` returns default color.palette.theme colors with
style variation applied in Version 6.1-RC1-54506
----------------------------+------------------------------
 Reporter:  dufresnesteven  |       Owner:  (none)
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+------------------------------

Comment (by dufresnesteven):

 More information:

 1. We apply the style variation using the `theme_json_user` filter.
 Something that looks like:


 {{{

  function filter_theme_json_user() {

     $variations = \WP_Theme_JSON_Resolver::get_style_variations();

     $variation_details = someFunctionThatReturnsOneVariation()

     $new_data = array();

     if ( ! empty( $variation_details['settings'] ) ) {
         $new_data['settings'] = $variation_details['settings'];
     }

     if ( ! empty( $variation_details['styles'] ) ) {
         $new_data['styles'] = $variation_details['styles'];
     }

     return $theme_json->update_with( $new_data );
 }

 add_filter( 'theme_json_user', __NAMESPACE__ . '\filter_theme_json_user'
 );

 }}}

 When you load any default theme page, the styles are applied as expected.
 However, we use `template_redirect` to inject our own page:

 {{{
 function redirect_to_style_page() {
         ...some criteria

         include dirname( __DIR__ ) . '/views/our-template.php';
         die;

 }

 add_action( 'template_redirect', __NAMESPACE__ . '\redirect_to_style_page'
 );
 }}}

 This used to work, accessing `wp_get_global_settings` in our template
 would return the settings with style variations applied. It no longer does
 so... hmmm.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56812#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list