@@ -31,7 +31,6 @@ public function register_hooks() {
3131 if ( ! \progress_planner ()->get_license_key () && ! \get_option ( 'progress_planner_demo_data_generated ' , false ) ) {
3232 $ this ->generate_data ();
3333 \update_option ( 'progress_planner_license_key ' , \str_replace ( ' ' , '- ' , $ this ->create_random_string ( 20 ) ) );
34- \update_option ( 'progress_planner_force_show_onboarding ' , false );
3534 \update_option (
3635 'progress_planner_todo ' ,
3736 [
@@ -48,7 +47,6 @@ public function register_hooks() {
4847 \update_option ( 'progress_planner_demo_data_generated ' , true );
4948 }
5049 \add_action ( 'progress_planner_admin_page_header_before ' , [ $ this , 'show_header_notice ' ] );
51- \add_action ( 'wp_ajax_progress_planner_hide_onboarding ' , [ $ this , 'hide_onboarding ' ] );
5250 \add_action ( 'wp_ajax_progress_planner_show_onboarding ' , [ $ this , 'show_onboarding ' ] );
5351
5452 \progress_planner ()->get_settings ()->set ( 'activation_date ' , ( new \DateTime () )->modify ( '-2 months ' )->format ( 'Y-m-d ' ) );
@@ -80,48 +78,23 @@ public function enable_debug_tools() {
8078 }
8179
8280 /**
83- * Toggle the onboarding visibility in the Playground environment.
84- *
85- * @param string $action Either 'show' or 'hide'.
81+ * Show the onboarding in the Playground environment.
8682 *
8783 * @return void
8884 */
89- private function toggle_onboarding ( $ action ) {
90- $ nonce_action = "progress_planner_ {$ action }_onboarding " ;
91- \check_ajax_referer ( $ nonce_action , 'nonce ' );
85+ public function show_onboarding () {
86+ \check_ajax_referer ( 'progress_planner_show_onboarding ' , 'nonce ' );
9287
9388 if ( ! \current_user_can ( 'manage_options ' ) ) {
9489 \wp_die ( \esc_html__ ( 'You do not have sufficient permissions to access this page. ' , 'progress-planner ' ) );
9590 }
9691
97- if ( $ action === 'hide ' ) {
98- \add_option ( 'progress_planner_license_key ' , \str_replace ( ' ' , '- ' , $ this ->create_random_string ( 20 ) ) );
99- $ message = \esc_html__ ( 'Onboarding hidden successfully ' , 'progress-planner ' );
100- } else {
101- \delete_option ( 'progress_planner_license_key ' );
102- $ message = \esc_html__ ( 'Onboarding shown successfully ' , 'progress-planner ' );
103- }
104- \update_option ( 'progress_planner_force_show_onboarding ' , $ action !== 'hide ' );
105-
106- \wp_send_json_success ( [ 'message ' => $ message ] );
107- }
108-
109- /**
110- * Hide the onboarding in the Playground environment.
111- *
112- * @return void
113- */
114- public function hide_onboarding () {
115- $ this ->toggle_onboarding ( 'hide ' );
116- }
92+ // Delete onboarding progress to trigger fresh onboarding.
93+ \Progress_Planner \Onboard_Wizard::delete_progress ();
94+ // Delete the license key to trigger onboarding (privacy not accepted).
95+ \delete_option ( 'progress_planner_license_key ' );
11796
118- /**
119- * Show the onboarding in the Playground environment.
120- *
121- * @return void
122- */
123- public function show_onboarding () {
124- $ this ->toggle_onboarding ( 'show ' );
97+ \wp_send_json_success ( [ 'message ' => \esc_html__ ( 'Onboarding shown successfully ' , 'progress-planner ' ) ] );
12598 }
12699
127100 /**
@@ -135,10 +108,7 @@ public function show_header_notice() {
135108 return ;
136109 }
137110
138- $ show_onboarding = \get_option ( 'progress_planner_force_show_onboarding ' , false );
139- $ button_text = $ show_onboarding ? \__ ( 'Hide onboarding ' , 'progress-planner ' ) : \__ ( 'Show onboarding ' , 'progress-planner ' );
140- $ action = $ show_onboarding ? 'hide ' : 'show ' ;
141- $ nonce = \wp_create_nonce ( "progress_planner_ {$ action }_onboarding " );
111+ $ nonce = \wp_create_nonce ( 'progress_planner_show_onboarding ' );
142112 ?>
143113
144114 <div class="prpl-widget-wrapper prpl-top-notice" id="prpl-playground-notice">
@@ -150,16 +120,16 @@ public function show_header_notice() {
150120 <div class="inner-content">
151121 <h1><?php \esc_html_e ( 'Progress Planner demo ' , 'progress-planner ' ); ?> </h1>
152122
153- <button id="progress-planner-toggle -onboarding" class="prpl-button-primary" style="margin-top: 20px; width:250px; float:right;">
154- <?php echo \esc_html ( $ button_text ); ?>
123+ <button id="progress-planner-show -onboarding" class="prpl-button-primary" style="margin-top: 20px; width:250px; float:right;">
124+ <?php \esc_html_e ( ' Show onboarding ' , ' progress-planner ' ); ?>
155125 </button>
156126
157127 <p style="max-width:680px;">
158128 <?php \esc_html_e ( 'This is a demo of Progress Planner. We \'ve prefilled this site with some content to show you what the reports in Progress Planner look like. We \'ve also added a few to-do \'s for you, you can see these here and on your dashoard. ' , 'progress-planner ' ); ?>
159129 </p>
160130 <script>
161- document.getElementById( 'progress-planner-toggle -onboarding' ).addEventListener( 'click', function() {
162- const request = wp.ajax.post( 'progress_planner_ <?php echo \esc_attr ( $ action ); ?> _onboarding ', {
131+ document.getElementById( 'progress-planner-show -onboarding' ).addEventListener( 'click', function() {
132+ const request = wp.ajax.post( 'progress_planner_show_onboarding ', {
163133 _ajax_nonce: '<?php echo \esc_attr ( $ nonce ); ?> ',
164134 } );
165135 request.done( () => {
0 commit comments