PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / trunk
Search Atlas SEO – OTTO AI SEO Automation for WordPress vtrunk
2.6.26 2.6.25 2.6.24 2.6.23 2.6.22 2.6.21 2.6.20 2.6.19 2.6.18 2.6.17 2.6.16 2.6.15 2.6.14 2.6.13 2.6.12 2.6.11 2.6.10 2.6.9 2.6.8 2.6.7 2.6.6 2.6.5 2.6.4 2.6.3 2.5.23 All 138 releases
metasync / includes / class-metasync-setup-wizard.php

class-metasync-setup-wizard.php in Search Atlas SEO – OTTO AI SEO Automation for WordPress trunk, at includes/class-metasync-setup-wizard.php

548 lines 16.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The setup wizard functionality of the plugin
5 *
6 * @link https://searchatlas.com
7 * @since 1.0.0
8 *
9 * @package Metasync
10 * @subpackage Metasync/includes
11 */
12
13 /**
14 * The setup wizard class.
15 *
16 * This class handles the setup wizard functionality for first-time plugin setup.
17 * Guides users through connecting the platform, importing from other SEO plugins,
18 * and configuring basic SEO settings.
19 *
20 * @since 1.0.0
21 * @package Metasync
22 * @subpackage Metasync/includes
23 * @author Engineering Team <support@searchatlas.com>
24 */
25 class Metasync_Setup_Wizard
26 {
27 /**
28 * The ID of this plugin.
29 *
30 * @since 1.0.0
31 * @access private
32 * @var string $plugin_name The ID of this plugin.
33 */
34 private $plugin_name;
35
36 /**
37 * The version of this plugin.
38 *
39 * @since 1.0.0
40 * @access private
41 * @var string $version The current version of this plugin.
42 */
43 private $version;
44
45 /**
46 * Total number of wizard steps
47 *
48 * @since 1.0.0
49 * @access private
50 * @var int
51 */
52 private $total_steps = 6;
53
54 /**
55 * Initialize the class and set its properties.
56 *
57 * @since 1.0.0
58 * @param string $plugin_name The name of this plugin.
59 * @param string $version The version of this plugin.
60 */
61 public function __construct($plugin_name, $version)
62 {
63 $this->plugin_name = $plugin_name;
64 $this->version = $version;
65 }
66
67 /**
68 * Check if wizard should auto-launch
69 *
70 * @since 1.0.0
71 * @return boolean
72 */
73 public function should_auto_launch_wizard()
74 {
75 // Check if wizard has been completed
76 $wizard_completed = get_option('metasync_wizard_completed', false);
77
78 if ($wizard_completed && !empty($wizard_completed['completed'])) {
79 return false;
80 }
81
82 // Check if first activation flag is set
83 return get_option('metasync_show_wizard', false);
84 }
85
86 /**
87 * Render the setup wizard page
88 *
89 * @since 1.0.0
90 */
91 public function render_wizard_page()
92 {
93 // Check user has access
94 if (!Metasync::current_user_has_plugin_access()) {
95 wp_die(__('You do not have sufficient permissions to access this page.'));
96 }
97
98 // Get current wizard state
99 $user_id = get_current_user_id();
100 $wizard_state = get_transient("metasync_wizard_state_{$user_id}");
101
102 if (!$wizard_state) {
103 // Initialize wizard state
104 $wizard_state = array(
105 'current_step' => 1,
106 'completed_steps' => array(),
107 'started_at' => time(),
108 'user_id' => $user_id
109 );
110 set_transient("metasync_wizard_state_{$user_id}", $wizard_state, DAY_IN_SECONDS);
111 }
112
113 // Load wizard template
114 require_once plugin_dir_path(dirname(__FILE__)) . 'views/metasync-setup-wizard.php';
115 }
116
117 /**
118 * Get all wizard steps configuration
119 *
120 * @since 1.0.0
121 * @return array
122 */
123 private function get_wizard_steps()
124 {
125 return array(
126 1 => array(
127 'id' => 'welcome',
128 'title' => 'Welcome',
129 'description' => 'Welcome to MetaSync'
130 ),
131 2 => array(
132 'id' => 'connection',
133 'title' => 'Connect',
134 'description' => 'Connect to platform'
135 ),
136 3 => array(
137 'id' => 'import',
138 'title' => 'Import',
139 'description' => 'Import from other plugins'
140 ),
141 4 => array(
142 'id' => 'seo_settings',
143 'title' => 'SEO Settings',
144 'description' => 'Configure indexation'
145 ),
146 5 => array(
147 'id' => 'schema',
148 'title' => 'Schema',
149 'description' => 'Schema preferences'
150 ),
151 6 => array(
152 'id' => 'complete',
153 'title' => 'Complete',
154 'description' => 'Setup complete'
155 )
156 );
157 }
158
159 /**
160 * Render Step 1: Welcome Screen
161 *
162 * @since 1.0.0
163 */
164 public function render_step_welcome()
165 {
166 $plugin_name = Metasync::get_effective_plugin_name();
167 ?>
168 <div class="wizard-step wizard-step-welcome active" data-step="1">
169 <div class="wizard-step-header">
170 <h2>🎉 Welcome to <?php echo esc_html($plugin_name); ?>!</h2>
171 <p>Let's get your site optimized for search engines in just a few minutes.</p>
172 </div>
173
174 <div class="wizard-step-content">
175 <div class="wizard-benefits">
176 <div class="wizard-benefit-card">
177 <span class="benefit-icon"><span class="dashicons dashicons-performance" style="font-size:24px;width:24px;height:24px;"></span></span>
178 <h3>Automated SEO</h3>
179 <p>Automatically optimize your content for search engines</p>
180 </div>
181 <div class="wizard-benefit-card">
182 <span class="benefit-icon"><span class="dashicons dashicons-chart-bar" style="font-size:24px;width:24px;height:24px;"></span></span>
183 <h3>Performance Tracking</h3>
184 <p>Monitor your site's search performance in real-time</p>
185 </div>
186 <div class="wizard-benefit-card">
187 <span class="benefit-icon"><span class="dashicons dashicons-admin-links" style="font-size:24px;width:24px;height:24px;"></span></span>
188 <h3>Seamless Integration</h3>
189 <p>Connect with <?php echo esc_html($plugin_name); ?> for advanced features</p>
190 </div>
191 </div>
192
193 <div class="wizard-time-estimate">
194 <span>Estimated time: 3-5 minutes</span>
195 </div>
196 </div>
197 </div>
198 <?php
199 }
200
201 /**
202 * Render Step 2: Connection
203 *
204 * @since 1.0.0
205 */
206 public function render_step_connection()
207 {
208 $plugin_name = Metasync::get_effective_plugin_name();
209 $general_settings = Metasync::get_option('general');
210 $is_connected = !empty($general_settings['searchatlas_api_key']);
211 ?>
212 <div class="wizard-step wizard-step-connection" data-step="2">
213 <div class="wizard-step-header">
214 <h2>Connect to <?php echo esc_html($plugin_name); ?></h2>
215 <p>Link your WordPress site to your <?php echo esc_html($plugin_name); ?> account for advanced features.</p>
216 </div>
217
218 <div class="wizard-step-content">
219 <?php if (!$is_connected): ?>
220 <div class="wizard-connection-box">
221 <p><strong>Why connect?</strong></p>
222 <ul>
223 <li>Access OTTO AI-powered SEO assistant</li>
224 <li>Get real-time search ranking data</li>
225 <li>Receive automated optimization suggestions</li>
226 </ul>
227
228 <button id="wizard-connect-btn" class="wizard-primary-btn">
229 Connect with <?php echo esc_html($plugin_name); ?>
230 </button>
231 </div>
232 <?php else: ?>
233 <div class="wizard-connection-success">
234 <span class="success-icon"></span>
235 <h3>Successfully Connected!</h3>
236 <p>Your site is linked to <?php echo esc_html($plugin_name); ?>.</p>
237 </div>
238 <?php endif; ?>
239 </div>
240 </div>
241 <?php
242 }
243
244 /**
245 * Render Step 3: Plugin Import
246 *
247 * @since 1.0.0
248 */
249 public function render_step_import()
250 {
251 $installed_plugins = $this->detect_seo_plugins();
252 ?>
253 <div class="wizard-step wizard-step-import" data-step="3">
254 <div class="wizard-step-header">
255 <h2>Import from Other SEO Plugins</h2>
256 <p>We detected other SEO plugins. Import your existing settings to save time.</p>
257 </div>
258
259 <div class="wizard-step-content">
260 <?php if (!empty($installed_plugins)): ?>
261 <div class="wizard-import-grid">
262 <?php foreach ($installed_plugins as $plugin): ?>
263 <div class="wizard-import-card">
264 <div class="import-card-header">
265 <h3><?php echo esc_html($plugin['name']); ?></h3>
266 <span class="import-badge">Detected</span>
267 </div>
268
269 <div class="import-card-options">
270 <label>
271 <input type="checkbox" class="import-option"
272 data-plugin="<?php echo esc_attr($plugin['slug']); ?>"
273 data-type="robots">
274 Robots.txt
275 </label>
276 <label>
277 <input type="checkbox" class="import-option"
278 data-plugin="<?php echo esc_attr($plugin['slug']); ?>"
279 data-type="sitemap">
280 Sitemap Settings
281 </label>
282 <label>
283 <input type="checkbox" class="import-option"
284 data-plugin="<?php echo esc_attr($plugin['slug']); ?>"
285 data-type="redirections">
286 Redirections
287 </label>
288 <label>
289 <input type="checkbox" class="import-option"
290 data-plugin="<?php echo esc_attr($plugin['slug']); ?>"
291 data-type="indexation">
292 Indexation/Robots Meta
293 </label>
294 <label>
295 <input type="checkbox" class="import-option"
296 data-plugin="<?php echo esc_attr($plugin['slug']); ?>"
297 data-type="schema">
298 Schema Markup
299 </label>
300 </div>
301
302 <div class="import-card-footer">
303 <button class="wizard-import-btn"
304 data-plugin="<?php echo esc_attr($plugin['slug']); ?>">
305 Import Selected
306 </button>
307 <div class="import-progress" style="display:none;">
308 <div class="import-progress-bar"></div>
309 <span class="import-progress-text">Importing...</span>
310 </div>
311 </div>
312 </div>
313 <?php endforeach; ?>
314 </div>
315 <?php else: ?>
316 <div class="wizard-no-imports">
317 <p>No compatible SEO plugins detected. You can skip this step.</p>
318 </div>
319 <?php endif; ?>
320 </div>
321 </div>
322 <?php
323 }
324
325
326 /**
327 * Render Step 4: SEO Settings (Indexation Controls)
328 *
329 * @since 1.0.0
330 */
331 public function render_step_seo_settings()
332 {
333 $seo_controls = Metasync::get_option('seo_controls') ?: array();
334 ?>
335 <div class="wizard-step wizard-step-seo" data-step="4">
336 <div class="wizard-step-header">
337 <h2>Basic SEO Settings</h2>
338 <p>Choose which archive types should be indexed by search engines.</p>
339 </div>
340
341 <div class="wizard-step-content">
342 <div class="wizard-seo-grid">
343 <div class="wizard-seo-card">
344 <h3>Archive Types</h3>
345 <p>Control which WordPress archives are visible to search engines.</p>
346
347 <div class="wizard-toggle-group">
348 <label class="wizard-toggle-label">
349 <input type="checkbox" name="seo_date_archives"
350 <?php checked(!isset($seo_controls['index_date_archives']) || $seo_controls['index_date_archives'] !== 'true'); ?>>
351 <span>Index Date Archives</span>
352 </label>
353
354 <label class="wizard-toggle-label">
355 <input type="checkbox" name="seo_author_archives"
356 <?php checked(!isset($seo_controls['index_author_archives']) || $seo_controls['index_author_archives'] !== 'true'); ?>>
357 <span>Index Author Archives</span>
358 </label>
359
360 <label class="wizard-toggle-label">
361 <input type="checkbox" name="seo_category_archives"
362 <?php checked(!isset($seo_controls['index_category_archives']) || $seo_controls['index_category_archives'] !== 'true'); ?>>
363 <span>Index Category Archives</span>
364 </label>
365
366 <label class="wizard-toggle-label">
367 <input type="checkbox" name="seo_tag_archives"
368 <?php checked(!isset($seo_controls['index_tag_archives']) || $seo_controls['index_tag_archives'] !== 'true'); ?>>
369 <span>Index Tag Archives</span>
370 </label>
371 </div>
372 </div>
373
374 <div class="wizard-recommendation-box">
375 <h4>Recommended Settings</h4>
376 <p>For most sites, we recommend:</p>
377 <ul>
378 <li> Index Category and Tag archives (helps with SEO)</li>
379 <li> Noindex Date archives (usually duplicate content)</li>
380 <li> Noindex Author archives (unless multi-author blog)</li>
381 </ul>
382 <button class="wizard-apply-recommended">Apply Recommended</button>
383 </div>
384 </div>
385 </div>
386 </div>
387 <?php
388 }
389
390 /**
391 * Render Step 5: Schema Preferences
392 *
393 * @since 1.0.0
394 */
395 public function render_step_schema()
396 {
397 $general_settings = Metasync::get_option('general');
398 $schema_enabled = !empty($general_settings['enable_schema_markup']);
399 ?>
400 <div class="wizard-step wizard-step-schema" data-step="5">
401 <div class="wizard-step-header">
402 <h2>Schema Markup Preferences</h2>
403 <p>Configure structured data to help search engines understand your content.</p>
404 </div>
405
406 <div class="wizard-step-content">
407 <div class="wizard-schema-enable">
408 <label class="wizard-toggle-label-large">
409 <input type="checkbox" id="schema-enabled" name="schema_enabled"
410 <?php checked($schema_enabled); ?>>
411 <span>Enable Automatic Schema Markup</span>
412 </label>
413 <p class="wizard-field-help">
414 Schema markup helps search engines display rich snippets in search results.
415 </p>
416 </div>
417
418 <div class="wizard-schema-settings" style="display: <?php echo $schema_enabled ? 'block' : 'none'; ?>;">
419 <h3>Default Schema Types</h3>
420
421 <div class="wizard-schema-types">
422 <label class="wizard-schema-type-card">
423 <input type="radio" name="default_schema_type" value="article"
424 <?php checked(($general_settings['default_schema_type'] ?? 'article') === 'article'); ?>>
425 <div class="schema-type-content">
426 <span class="schema-type-icon"><span class="dashicons dashicons-media-text" style="font-size:24px;width:24px;height:24px;"></span></span>
427 <h4>Article</h4>
428 <p>Best for blog posts and news articles</p>
429 </div>
430 </label>
431
432 <label class="wizard-schema-type-card">
433 <input type="radio" name="default_schema_type" value="webpage"
434 <?php checked(($general_settings['default_schema_type'] ?? '') === 'webpage'); ?>>
435 <div class="schema-type-content">
436 <span class="schema-type-icon"><span class="dashicons dashicons-media-default" style="font-size:24px;width:24px;height:24px;"></span></span>
437 <h4>WebPage</h4>
438 <p>Best for general website pages</p>
439 </div>
440 </label>
441
442 <label class="wizard-schema-type-card">
443 <input type="radio" name="default_schema_type" value="product"
444 <?php checked(($general_settings['default_schema_type'] ?? '') === 'product'); ?>>
445 <div class="schema-type-content">
446 <span class="schema-type-icon"><span class="dashicons dashicons-cart" style="font-size:24px;width:24px;height:24px;"></span></span>
447 <h4>Product</h4>
448 <p>Best for e-commerce sites</p>
449 </div>
450 </label>
451 </div>
452 </div>
453 </div>
454 </div>
455 <?php
456 }
457
458 /**
459 * Render Step 7: Completion Screen
460 *
461 * @since 1.0.0
462 */
463 public function render_step_complete()
464 {
465 $menu_slug = 'searchatlas';
466 $data = Metasync::get_option('general');
467 if (!empty($data['white_label_plugin_menu_slug'])) {
468 $menu_slug = $data['white_label_plugin_menu_slug'];
469 }
470 ?>
471 <div class="wizard-step wizard-step-complete" data-step="6">
472 <div class="wizard-step-header">
473 <div class="wizard-complete-icon">🎉</div>
474 <h2>Setup Complete!</h2>
475 <p>Your site is now optimized for search engines.</p>
476 </div>
477
478 <div class="wizard-step-content">
479 <div class="wizard-complete-summary">
480 <h3>What's Next?</h3>
481
482 <div class="wizard-next-steps">
483 <div class="wizard-next-step-card">
484 <span class="next-step-number">1</span>
485 <div class="next-step-content">
486 <h4>Explore the Dashboard</h4>
487 <p>View your SEO performance metrics and insights</p>
488 <a href="?page=<?php echo esc_attr($menu_slug); ?>-dashboard"
489 class="wizard-next-step-link">View Dashboard →</a>
490 </div>
491 </div>
492
493 <div class="wizard-next-step-card">
494 <span class="next-step-number">2</span>
495 <div class="next-step-content">
496 <h4>Optimize Your Content</h4>
497 <p>Start optimizing individual posts and pages</p>
498 <a href="<?php echo esc_url(admin_url('edit.php')); ?>"
499 class="wizard-next-step-link">View Posts →</a>
500 </div>
501 </div>
502
503 <div class="wizard-next-step-card">
504 <span class="next-step-number">3</span>
505 <div class="next-step-content">
506 <h4>Fine-Tune Settings</h4>
507 <p>Adjust advanced SEO settings for your specific needs</p>
508 <a href="?page=<?php echo esc_attr($menu_slug); ?>"
509 class="wizard-next-step-link">View Settings →</a>
510 </div>
511 </div>
512 </div>
513 </div>
514
515 <div class="wizard-complete-actions">
516 <button class="wizard-primary-btn wizard-complete-btn">
517 Get Started with <?php echo esc_html(Metasync::get_effective_plugin_name()); ?>
518 </button>
519 </div>
520 </div>
521 </div>
522 <?php
523 }
524
525 /**
526 * Detect installed SEO plugins
527 *
528 * @since 1.0.0
529 * @return array
530 */
531 private function detect_seo_plugins()
532 {
533 $detected = array();
534
535 if (defined('WPSEO_VERSION')) {
536 $detected[] = array('name' => 'Yoast SEO', 'slug' => 'yoast');
537 }
538 if (defined('RANK_MATH_VERSION')) {
539 $detected[] = array('name' => 'Rank Math', 'slug' => 'rankmath');
540 }
541 if (defined('AIOSEO_VERSION')) {
542 $detected[] = array('name' => 'All in One SEO', 'slug' => 'aioseo');
543 }
544
545 return $detected;
546 }
547 }
548