-
Notifications
You must be signed in to change notification settings - Fork 11
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? |
js/customize-snapshots.js
Outdated
queryVars.scroll = parseInt( api.previewer.scroll, 10 ) || 0; | ||
queryVars.device = api.previewedDevice.get(); | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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']
.
php/class-post-type.php
Outdated
|
||
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'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra tab here?
Not ready yet, need to test and may be few changes. Trying to finish today. |
Ready for review. |
@@ -255,6 +266,7 @@ | |||
dialogElement; | |||
|
|||
snapshot.statusButton.disableSelect.set( false ); | |||
snapshot.statusButton.disbleButton.set( false ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -106,7 +101,7 @@ public function enqueue_controls_scripts() { | |||
'initialServerDate' => current_time( 'mysql', false ), | |||
'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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@westonruter This is breaking my condition here
snapshot.isNotSavedPreviewingTheme = savedPreviewingTheme && savedPreviewingTheme !== currentTheme; |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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'] : '',
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
@@ -225,7 +226,7 @@ public function add_snapshot_uuid_to_return_url() { | |||
&& | |||
$this->current_snapshot_uuid | |||
&& | |||
$this->is_theme_active() | |||
$this->customize_manager->is_theme_active() | |||
&& |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed in 52694b6.
…:$original_stylesheet will be set
Fixes #131