wp-rocket
wp-rocket copied to clipboard
Restore settings after Safe Mode
Is your feature request related to a problem? Please describe. Once you enable Safe Mode, there is no way to restore the old settings. This can cause the loss of multiple exclusions across multiple features.
Describe the solution you'd like There is a way to restore the old settings after enabling Safe Mode instead of starting over and create double work in tricky configuration and exclusions.
Describe alternatives you've considered These are the options I have in mind:
- Adding a download link to export the current settings in the Safe Mode option in the Deactivation form
- Adding a Revert Safe Mode option in the plugins page:
- Not related to Safe Mode, but the deactivation form could have a Export settings link/button, just in case anyone wants to save current settings before deleting WP Rocket.
Additional context Ticket: https://secure.helpscout.net/conversation/1898851114/345290/
Thanks!
This is related: https://github.com/wp-media/wp-rocket/issues/5037
Related ticket: https://secure.helpscout.net/conversation/1910733609/346845?folderId=2135277 The request is in the video sent by the customer.
Related: https://secure.helpscout.net/conversation/1921475913/348681/
https://secure.helpscout.net/conversation/1922616083/348892?folderId=377611
Related - https://secure.helpscout.net/conversation/1930196188/350454
Related: https://secure.helpscout.net/conversation/1940815032/354058/
Related: https://secure.helpscout.net/conversation/1960171738/358167/
Related: https://secure.helpscout.net/conversation/1963065900/358738/
Related https://secure.helpscout.net/conversation/2003206887/367177/
Related https://secure.helpscout.net/conversation/2046099120/376624/
related https://secure.helpscout.net/conversation/2053599939/378432
related https://secure.helpscout.net/conversation/2054232260/378555/
To solve this problem we'll add a checkbox under Yes, apply "Safe Mode"
.
Acceptance criteria:
- Additional checkbox is checked by default
- When it's checked and customer click
Confirm
, export file will be downloaded - When it's unchecked, the export file won't be downloaded
- When customer switches to
No, deactivate and snooze this message for
radio, the checkbox won't be displayed - When checkbox was checked and customer switches to
No, deactivate and snooze this message for
and click onConfirm
, the file won't be downloaded. - Wording for the checkbox
and export WP Rocket settings **(Recommended as current settings will be deleted)**
Related: https://secure.helpscout.net/conversation/2068256522/381670/
We will add a checkbox after this line https://github.com/wp-media/wp-rocket/blob/0918f5017d02fcc9d438c6419af5e891a589d848/views/deactivation-intent/form.php#L49 and set a checked
attribute in it to be checked by default with name attribute maybe export_settings
and id as export_settings
too.
Then we will make some changes to our rocket_do_options_export
https://github.com/wp-media/wp-rocket/blob/0918f5017d02fcc9d438c6419af5e891a589d848/inc/admin/admin.php#L214 to put 223-227
https://github.com/wp-media/wp-rocket/blob/0918f5017d02fcc9d438c6419af5e891a589d848/inc/admin/admin.php#L223-L227 in a new function maybe rocket_get_current_options_to_be_exported
and this new function will return the options in the json encoded format, then we can pass it back down to the rocket_do_options_export
.
We will check if the checkbox is set here: https://github.com/wp-media/wp-rocket/blob/0918f5017d02fcc9d438c6419af5e891a589d848/inc/Engine/Admin/Deactivation/Subscriber.php#L80 $export_settings = isset( $_POST['export_settings'] ) ? true : false;
We will then call this new function rocket_get_current_options_to_be_exported
with a check here just before this line: https://github.com/wp-media/wp-rocket/blob/0918f5017d02fcc9d438c6419af5e891a589d848/inc/Engine/Admin/Deactivation/Subscriber.php#L82
if ( export_settings ) {
$options = rocket_get_current_options_to_be_exported();
}
just before we update safe mode options that way we still have last state of option then we will set our headers after this line: https://github.com/wp-media/wp-rocket/blob/0918f5017d02fcc9d438c6419af5e891a589d848/inc/Engine/Admin/Deactivation/Subscriber.php#L82
if ( export_settings ) {
nocache_headers();
@header( 'Content-Type: application/json' );
@header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
@header( 'Content-Transfer-Encoding: binary' );
@header( 'Content-Length: ' . strlen( $options ) );
@header( 'Connection: close' );
echo $options;
exit();
}
When customer switches to No, deactivate and snooze this message for radio, the checkbox won't be displayed.
For this we can update https://github.com/wp-media/wp-rocket/blob/develop/assets/js/wpr-admin-common.js to add:
$('#deactivate').click(function(){
$('#export_settings').prop('checked', false);
$('#export_settings').hide();
})
$('#safe_mode').click(function(){
$('#export_settings').show();
$('#export_settings').prop('checked', true);
})
Maybe update tests also.
Estimate the effort
[S]
@Tabrisrp @engahmeds3ed what do you think of this grooming?
We will add a checkbox after this line
https://github.com/wp-media/wp-rocket/blob/0918f5017d02fcc9d438c6419af5e891a589d848/views/deactivation-intent/form.php#L49 and set a
checked
attribute in it to be checked by default with name attribute maybeexport_settings
and id asexport_settings
too. Then we will make some changes to ourrocket_do_options_export
https://github.com/wp-media/wp-rocket/blob/0918f5017d02fcc9d438c6419af5e891a589d848/inc/admin/admin.php#L214 to put
223-227
https://github.com/wp-media/wp-rocket/blob/0918f5017d02fcc9d438c6419af5e891a589d848/inc/admin/admin.php#L223-L227 in a new function maybe
rocket_get_current_options_to_be_exported
and this new function will return the options in the json encoded format, then we can pass it back down to therocket_do_options_export
. We will check if the checkbox is set here:https://github.com/wp-media/wp-rocket/blob/0918f5017d02fcc9d438c6419af5e891a589d848/inc/Engine/Admin/Deactivation/Subscriber.php#L80
$export_settings = isset( $_POST['export_settings'] ) ? true : false;
We will then call this new function
rocket_get_current_options_to_be_exported
with a check here just before this line:https://github.com/wp-media/wp-rocket/blob/0918f5017d02fcc9d438c6419af5e891a589d848/inc/Engine/Admin/Deactivation/Subscriber.php#L82
if ( export_settings ) { $options = rocket_get_current_options_to_be_exported(); }
just before we update safe mode options that way we still have last state of option then we will set our headers after this line:
https://github.com/wp-media/wp-rocket/blob/0918f5017d02fcc9d438c6419af5e891a589d848/inc/Engine/Admin/Deactivation/Subscriber.php#L82
if ( export_settings ) { nocache_headers(); @header( 'Content-Type: application/json' ); @header( 'Content-Disposition: attachment; filename="' . $filename . '"' ); @header( 'Content-Transfer-Encoding: binary' ); @header( 'Content-Length: ' . strlen( $options ) ); @header( 'Connection: close' ); echo $options; exit(); }
When customer switches to No, deactivate and snooze this message for radio, the checkbox won't be displayed.
For this we can update https://github.com/wp-media/wp-rocket/blob/develop/assets/js/wpr-admin-common.js to add:
$('#deactivate').click(function(){ $('#export_settings').prop('checked', false); $('#export_settings').hide(); }) $('#safe_mode').click(function(){ $('#export_settings').show(); $('#export_settings').prop('checked', true); })
Maybe update tests also.
Estimate the effort
[S]
@Tabrisrp @engahmeds3ed what do you think of this grooming?
@jeawhanlee the only problem with this grooming is that we block the user on the popup page as we don't redirect him anymore.
I think we should search a way to send two requests when we need to export.