Enable status button if current theme is not active.#132
Conversation
|
@westonruter We have a param |
|
@sayedtaqui oh yes, absolutely! That param can be included in the customizer state query params only when saving a changeset for a theme that is not active. If the theme is active, then the param should be omitted from being saved. |
…tch back to the original theme.
|
Is this out of WIP and ready for review? |
| queryVars.url = api.previewer.previewUrl.get(); | ||
|
|
||
| if ( ! api.state( 'activated' ).get() || snapshot.data.theme !== currentTheme ) { | ||
| queryVars.previewingTheme = true; |
There was a problem hiding this comment.
Since this is going to be sent with the POST request, I think it should be previewing_theme instead. Then below in PHP, you'd read $query_vars['previewing_theme'].
|
|
||
| if ( isset( $preview_url_query_vars['theme'] ) && $current_theme !== $preview_url_query_vars['theme'] ) { | ||
| $args = array_merge( $args, array( | ||
| 'theme' => $preview_url_query_vars['theme'], |
|
Not ready yet, need to test and may be few changes. Trying to finish today. |
|
Ready for review. |
| dialogElement; | ||
|
|
||
| snapshot.statusButton.disableSelect.set( false ); | ||
| snapshot.statusButton.disbleButton.set( false ); |
There was a problem hiding this comment.
I'm glad you caught this. It's something I was noticing in the case of setting validation errors, where I'd get a validation error message with a control but the Publish button would remain disabled.
…ches The 'customize_theme' param is used on the frontend, whereas just 'theme' is used in the admin.
| 'initialServerTimestamp' => floor( microtime( true ) * 1000 ), | ||
| 'theme' => $this->original_stylesheet, | ||
| 'previewingTheme' => isset( $preview_url_query_vars['theme'] ) ? $preview_url_query_vars['theme']: '', | ||
| 'previewingTheme' => ! $this->customize_manager->is_theme_active(), |
There was a problem hiding this comment.
@westonruter This is breaking my condition here
There are several use cases where the button has to be enabled or disabled.
- When they switch theme ( Has to enable ) ( Working )
- After saving the previewing theme, reload the page, ( Has to disable ) ( Not working now )
- After saving the previewing theme they switch to a third theme ( Has to enable ) ( Working )
- After travelling through the themes and saving the last one, they come back to the original theme ( Should be enable ) ( Not working now ).
I was not able to satisfy these conditions with only boolean value of previewingTheme . This is as good as api.state( 'activated' ).get()
There was a problem hiding this comment.
Thanks for pointing this out. So this can be fixed by reverting back to:
'previewingTheme' => isset( $preview_url_query_vars['theme'] ) ? $preview_url_query_vars['theme'] : '',?
| && | ||
| $this->is_theme_active() | ||
| $this->customize_manager->is_theme_active() | ||
| && |
There was a problem hiding this comment.
@westonruter Not sure why $this->customize_manager->is_theme_active() is returning false in 4.6.1 which is failing phpunit test. I mean inside phpunit test.
There was a problem hiding this comment.
It's because the setup_theme action wasn't triggered in the test case, and so \WP_Customize_Manager::$original_stylesheet didn't get set. In 4.7 this variable gets set in \WP_Customize_Manager::__construct() whereas in 4.6 it got set in \WP_Customize_Manager::setup_theme().
…:$original_stylesheet will be set

Fixes #131