PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.0.3
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.0.3
3.4.6 3.4.5 3.4.4 3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 All 199 releases
← All changes | admin/class-convertkit-admin-setup-wizard.php +27 -67 2.3.2 → 2.0.3 View file →
@@ -64,18 +64,8 @@
64 64 */
65 65 public $page_name = false;
66 66
67 67 /**
68 - * Whether the wizard is being served within a modal or
69 - * new window.
70 - *
71 - * @since 2.2.6
72 - *
73 - * @var bool
74 - */
75 - public $is_modal = false;
76 -
77 - /**
78 68 * The URL to take the user to when they click the Exit link.
79 69 *
80 70 * @since 1.9.8.4
81 71 *
@@ -89,9 +79,9 @@
89 79 * @since 1.9.8.4
90 80 *
91 81 * @var bool|string
92 82 */
93 - public $current_step_url = false;
83 + private $current_step_url = false; // @phpstan-ignore-line
94 84
95 85 /**
96 86 * Holds the URL to the next step in the setup process.
97 87 *
@@ -98,9 +88,9 @@
98 88 * @since 1.9.8.4
99 89 *
100 90 * @var bool|string
101 91 */
102 - public $next_step_url = false;
92 + private $next_step_url = false; // @phpstan-ignore-line
103 93
104 94 /**
105 95 * Holds the URL to the previous step in the setup process.
106 96 *
@@ -107,9 +97,9 @@
107 97 * @since 1.9.8.4
108 98 *
109 99 * @var bool|string
110 100 */
111 - public $previous_step_url = false;
101 + private $previous_step_url = false; // @phpstan-ignore-line
112 102
113 103 /**
114 104 * Registers action and filter hooks.
115 105 *
@@ -123,23 +113,34 @@
123 113 }
124 114
125 115 // Define actions to register the setup screen.
126 116 add_action( 'admin_menu', array( $this, 'register_screen' ) );
117 + add_action( 'admin_head', array( $this, 'hide_screen_from_menu' ) );
127 118 add_action( 'admin_init', array( $this, 'maybe_load_setup_screen' ) );
128 119
129 120 }
130 121
131 122 /**
132 - * Register the wizard screen in WordPress' Dashboard, so that options.php?page={$this->page_name}
123 + * Register the setup screen in WordPress' Dashboard, so that index.php?page={$this->page_name}
133 124 * does not 404 when in the WordPress Admin interface.
134 125 *
135 - * Ensures the WordPress user has the given required_capability to access this screen.
126 + * @since 1.9.8.4
127 + */
128 + public function register_screen() {
129 +
130 + add_dashboard_page( '', '', 'edit_posts', $this->page_name, '__return_false' );
131 +
132 + }
133 +
134 + /**
135 + * Hides the menu registered when register_screen() above is called, otherwise
136 + * we would have a blank submenu entry below the Dashboard menu.
136 137 *
137 138 * @since 1.9.8.4
138 139 */
139 - public function register_screen() {
140 + public function hide_screen_from_menu() {
140 141
141 - add_submenu_page( '', '', '', $this->required_capability, $this->page_name, '__return_false' );
142 + remove_submenu_page( 'index.php', $this->page_name );
142 143
143 144 }
144 145
145 146 /**
@@ -162,14 +163,8 @@
162 163
163 164 // Define current screen, so that calls to get_current_screen() tell Plugins which screen is loaded.
164 165 set_current_screen( $this->page_name );
165 166
166 - // If the convertkit-modal parameter exists and is 1, set the flag to denote
167 - // this wizard is served in a modal.
168 - if ( array_key_exists( 'convertkit-modal', $_REQUEST ) && $_REQUEST['convertkit-modal'] === '1' ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
169 - $this->is_modal = true;
170 - }
171 -
172 167 // Define the step the user is on in the setup process.
173 168 $this->step = ( isset( $_REQUEST['step'] ) ? absint( $_REQUEST['step'] ) : 1 ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
174 169
175 170 // Process any posted form data.
@@ -231,13 +226,12 @@
231 226
232 227 // Define the current step URL.
233 228 $this->current_step_url = add_query_arg(
234 229 array(
235 - 'page' => $this->page_name,
236 - 'convertkit-modal' => $this->is_modal(),
237 - 'step' => $this->step,
230 + 'page' => $this->page_name,
231 + 'step' => $this->step,
238 232 ),
239 - admin_url( 'options.php' )
233 + admin_url( 'index.php' )
240 234 );
241 235
242 236 // Define the previous step URL if we're not on the first or last step.
243 237 if ( $this->step > 1 && $this->step < count( $this->steps ) ) {
@@ -242,13 +236,12 @@
242 236 // Define the previous step URL if we're not on the first or last step.
243 237 if ( $this->step > 1 && $this->step < count( $this->steps ) ) {
244 238 $this->previous_step_url = add_query_arg(
245 239 array(
246 - 'page' => $this->page_name,
247 - 'convertkit-modal' => $this->is_modal(),
248 - 'step' => ( $this->step - 1 ),
240 + 'page' => $this->page_name,
241 + 'step' => ( $this->step - 1 ),
249 242 ),
250 - admin_url( 'options.php' )
243 + admin_url( 'index.php' )
251 244 );
252 245 }
253 246
254 247 // Define the next step URL if we're not on the last page.
@@ -254,13 +247,12 @@
254 247 // Define the next step URL if we're not on the last page.
255 248 if ( $this->step < count( $this->steps ) ) {
256 249 $this->next_step_url = add_query_arg(
257 250 array(
258 - 'page' => $this->page_name,
259 - 'convertkit-modal' => $this->is_modal(),
260 - 'step' => ( $this->step + 1 ),
251 + 'page' => $this->page_name,
252 + 'step' => ( $this->step + 1 ),
261 253 ),
262 - admin_url( 'options.php' )
254 + admin_url( 'index.php' )
263 255 );
264 256 }
265 257
266 258 }
@@ -361,40 +353,8 @@
361 353 do_action( 'admin_print_footer_scripts' );
362 354
363 355 // Load footer view.
364 356 include_once CONVERTKIT_PLUGIN_PATH . '/views/backend/setup-wizard/footer.php';
365 -
366 - }
367 -
368 - /**
369 - * Whether this wizard is served in a modal window.
370 - *
371 - * @since 2.2.6
372 - *
373 - * @return bool
374 - */
375 - public function is_modal() {
376 -
377 - return $this->is_modal;
378 -
379 - }
380 -
381 - /**
382 - * Outputs HTML to close the current window, due to it being opened
383 - * by window.open().
384 - *
385 - * @since 2.2.6
386 - */
387 - public function maybe_close_modal() {
388 -
389 - // Sanity check we requested a modal.
390 - if ( ! $this->is_modal() ) {
391 - return;
392 - }
393 -
394 - // Load HTML to close the modal.
395 - include_once CONVERTKIT_PLUGIN_PATH . '/views/backend/setup-wizard/close-modal.php';
396 - exit;
397 357
398 358 }
399 359
400 360 /**