PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / trunk
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress vtrunk
4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / Admin / SettingsPages / FuseWP.php
wp-user-avatar / src / Admin / SettingsPages Last commit date
DragDropBuilder 1 month ago EmailSettings 1 year ago Membership 1 month ago AbstractSettingsPage.php 2 years ago AddNewForm.php 1 year ago AdminFooter.php 4 years ago ExtensionsSettingsPage.php 1 year ago FormList.php 4 months ago Forms.php 1 year ago FuseWP.php 3 years ago GeneralSettings.php 9 months ago IDUserColumn.php 5 years ago LicenseUpgrader.php 3 years ago MailOptin.php 3 years ago MemberDirectories.php 1 year ago MembersDirectoryList.php 5 years ago ToolsSettingsPage.php 4 years ago index.php 3 years ago
FuseWP.php
698 lines
1 <?php
2
3 namespace ProfilePress\Core\Admin\SettingsPages;
4
5 use ProfilePress\Core\Classes\Installer\PluginSilentUpgrader;
6 use ProfilePress\Core\Classes\Installer\PPress_Install_Skin;
7
8 class FuseWP
9 {
10 const SLUG = 'ppress-fusewp';
11
12 private $config = array(
13 'lite_plugin' => 'fusewp/fusewp.php',
14 'lite_download_url' => 'https://downloads.wordpress.org/plugin/fusewp.latest-stable.zip',
15 'fusewp_settings' => 'admin.php?page=fusewp-sync',
16 );
17
18 private $output_data = array();
19
20 public function __construct()
21 {
22 if ( ! $this->is_activated()) {
23 add_action('ppress_admin_hooks', function () {
24 add_action('ppress_register_menu_page', array($this, 'register_settings_page'));
25 });
26 }
27
28 add_action('wp_ajax_ppress_activate_plugin', [$this, 'ppress_activate_plugin']);
29 add_action('wp_ajax_ppress_install_plugin', [$this, 'ppress_install_plugin']);
30
31 if (wp_doing_ajax()) {
32 add_action('wp_ajax_ppress_fusewp_page_check_plugin_status', array($this, 'ajax_check_plugin_status'));
33 }
34
35 // Check what page we are on.
36 $page = isset($_GET['page']) ? \sanitize_key(\wp_unslash($_GET['page'])) : '';
37
38 if (self::SLUG !== $page) return;
39
40 add_action('admin_init', array($this, 'redirect_to_fusewp_settings'));
41 add_action('admin_enqueue_scripts', array($this, 'enqueue_assets'));
42 }
43
44 public function ppress_install_plugin()
45 {
46 // Run a security check.
47 check_ajax_referer('ppress-admin-nonce', 'nonce');
48
49 $generic_error = esc_html__('There was an error while performing your request.', 'wp-user-avatar');
50 $type = ! empty($_POST['type']) ? sanitize_key($_POST['type']) : 'plugin';
51
52 if ( ! current_user_can('install_plugins')) {
53 wp_send_json_error($generic_error);
54 }
55
56 // Determine whether file modifications are allowed.
57 if ( ! wp_is_file_mod_allowed('ppress_can_install')) {
58 wp_send_json_error($generic_error);
59 }
60
61 $error = $type === 'plugin' ? esc_html__('Could not install plugin. Please download and install manually.', 'wp-user-avatar') : esc_html__('Could not install addon. Please download from wpforms.com and install manually.', 'wp-user-avatar');
62
63 if (empty($_POST['plugin'])) {
64 wp_send_json_error($error);
65 }
66
67 // Set the current screen to avoid undefined notices.
68 set_current_screen('ppress_page_ppress-fusewp');
69
70 // Prepare variables.
71 $url = esc_url_raw(
72 add_query_arg(
73 ['page' => 'ppress-settings'],
74 admin_url('admin.php')
75 )
76 );
77
78 ob_start();
79 $creds = request_filesystem_credentials($url, '', false, false, null);
80
81 // Hide the filesystem credentials form.
82 ob_end_clean();
83
84 // Check for file system permissions.
85 if ($creds === false) {
86 wp_send_json_error($error);
87 }
88
89 if ( ! WP_Filesystem($creds)) {
90 wp_send_json_error($error);
91 }
92
93 /*
94 * We do not need any extra credentials if we have gotten this far, so let's install the plugin.
95 */
96
97 // Do not allow WordPress to search/download translations, as this will break JS output.
98 remove_action('upgrader_process_complete', ['Language_Pack_Upgrader', 'async_upgrade'], 20);
99
100 // Create the plugin upgrader with our custom skin.
101 $installer = new PluginSilentUpgrader(new PPress_Install_Skin());
102
103 // Error check.
104 if ( ! method_exists($installer, 'install') || empty($_POST['plugin'])) {
105 wp_send_json_error($error);
106 }
107
108 $installer->install($_POST['plugin']); // phpcs:ignore
109
110 // Flush the cache and return the newly installed plugin basename.
111 wp_cache_flush();
112
113 $plugin_basename = $installer->plugin_info();
114
115 if (empty($plugin_basename)) {
116 wp_send_json_error($error);
117 }
118
119 $result = [
120 'msg' => $generic_error,
121 'is_activated' => false,
122 'basename' => $plugin_basename,
123 ];
124
125 // Check for permissions.
126 if ( ! current_user_can('activate_plugins')) {
127 $result['msg'] = $type === 'plugin' ? esc_html__('Plugin installed.', 'wp-user-avatar') : esc_html__('Addon installed.', 'wp-user-avatar');
128
129 wp_send_json_success($result);
130 }
131
132 // Activate the plugin silently.
133 $activated = activate_plugin($plugin_basename);
134
135 if ( ! is_wp_error($activated)) {
136 $result['is_activated'] = true;
137 $result['msg'] = $type === 'plugin' ? esc_html__('Plugin installed & activated.', 'wp-user-avatar') : esc_html__('Addon installed & activated.', 'wp-user-avatar');
138
139 wp_send_json_success($result);
140 }
141
142 // Fallback error just in case.
143 wp_send_json_error($result);
144 }
145
146 public function ppress_activate_plugin()
147 {
148 // Run a security check.
149 check_ajax_referer('ppress-admin-nonce', 'nonce');
150
151 // Check for permissions.
152 if ( ! current_user_can('activate_plugins')) {
153 wp_send_json_error(esc_html__('Plugin activation is disabled for you on this site.', 'wp-user-avatar'));
154 }
155
156 if (isset($_POST['plugin'])) {
157
158 $plugin = sanitize_text_field(wp_unslash($_POST['plugin']));
159 $activate = activate_plugins($plugin);
160
161 if ( ! is_wp_error($activate)) {
162 wp_send_json_success(esc_html__('Plugin activated.', 'wp-user-avatar'));
163 }
164 }
165
166 wp_send_json_error(esc_html__('Could not activate plugin. Please activate from the Plugins page.', 'wp-user-avatar'));
167 }
168
169 public function register_settings_page()
170 {
171 $newIndicator = sprintf(
172 '<span class="ppress-menu-new-indicator">&nbsp;%s</span>',
173 __('NEW', 'wp-user-avatar')
174 );
175
176 add_submenu_page(
177 PPRESS_DASHBOARD_SETTINGS_SLUG,
178 'User Sync',
179 esc_html__('User Sync', 'wp-user-avatar') . $newIndicator,
180 'manage_options',
181 self::SLUG,
182 array($this, 'output')
183 );
184 }
185
186 public function enqueue_assets()
187 {
188 wp_enqueue_script(
189 'ppress-admin-page-fusewp',
190 PPRESS_ASSETS_URL . "/js/admin/fusewp.js",
191 array('jquery'),
192 PPRESS_VERSION_NUMBER,
193 true
194 );
195
196 \wp_localize_script(
197 'ppress-admin-page-fusewp',
198 'ppress_pluginlanding',
199 $this->get_js_strings()
200 );
201
202 \wp_localize_script('ppress-admin-page-fusewp', 'ppress_installer_globals', [
203 'nonce' => wp_create_nonce('ppress-admin-nonce')
204 ]);
205 }
206
207 /**
208 * JS Strings.
209 */
210 protected function get_js_strings()
211 {
212 $error_could_not_install = sprintf(
213 wp_kses( /* translators: %s - Lite plugin download URL. */
214 __('Could not install plugin. Please <a href="%s">download</a> and install manually.', 'wp-user-avatar'),
215 array(
216 'a' => array(
217 'href' => true,
218 ),
219 )
220 ),
221 esc_url_raw($this->config['lite_download_url'])
222 );
223
224 $error_could_not_activate = sprintf(
225 wp_kses( /* translators: %s - Lite plugin download URL. */
226 __('Could not activate plugin. Please activate from the <a href="%s">Plugins page</a>.', 'wp-user-avatar'),
227 array(
228 'a' => array(
229 'href' => true,
230 ),
231 )
232 ),
233 esc_url_raw(admin_url('plugins.php'))
234 );
235
236 return array(
237 'installing' => esc_html__('Installing...', 'wp-user-avatar'),
238 'activating' => esc_html__('Activating...', 'wp-user-avatar'),
239 'activated' => esc_html__('FuseWP Installed & Activated', 'wp-user-avatar'),
240 'install_now' => esc_html__('Install Now', 'wp-user-avatar'),
241 'activate_now' => esc_html__('Activate Now', 'wp-user-avatar'),
242 'download_now' => esc_html__('Download Now', 'wp-user-avatar'),
243 'plugins_page' => esc_html__('Go to Plugins page', 'wp-user-avatar'),
244 'error_could_not_install' => $error_could_not_install,
245 'error_could_not_activate' => $error_could_not_activate,
246 'manual_install_url' => $this->config['lite_download_url'],
247 'manual_activate_url' => admin_url('plugins.php'),
248 'fusewp_settings_button' => esc_html__('Go to FuseWP Settings', 'wp-user-avatar'),
249 );
250 }
251
252 /**
253 * Generate and output page HTML.
254 */
255 public function output()
256 {
257 ?>
258 <style>
259 #ppress-admin-fusewp {
260 width: 700px;
261 margin: 0 auto;
262 }
263
264 #ppress-admin-fusewp .notice,
265 #ppress-admin-fusewp .error {
266 display: none
267 }
268
269 #ppress-admin-fusewp *, #ppress-admin-fusewp *::before, #ppress-admin-fusewp *::after {
270 -webkit-box-sizing: border-box;
271 -moz-box-sizing: border-box;
272 box-sizing: border-box;
273 }
274
275 #ppress-admin-fusewp section {
276 margin: 50px 0;
277 text-align: left;
278 clear: both;
279 }
280
281 #ppress-admin-fusewp section.screenshot {
282 text-align: center;
283 }
284
285 #ppress-admin-fusewp .top {
286 text-align: center;
287 }
288
289 #ppress-admin-fusewp .top img {
290 margin-bottom: 38px;
291 width: 480px;
292 height: auto;
293 }
294
295 #ppress-admin-fusewp .top h1 {
296 font-size: 26px;
297 font-weight: 600;
298 margin-bottom: 0;
299 padding: 0;
300 }
301
302 #ppress-admin-fusewp .top p {
303 font-size: 17px;
304 color: #777777;
305 margin-top: .5em;
306 }
307
308 #ppress-admin-fusewp p {
309 font-size: 15px;
310 }
311
312 #ppress-admin-fusewp .cont {
313 display: inline-block;
314 position: relative;
315 width: 100%;
316 padding: 5px;
317 background-color: #ffffff;
318 -webkit-box-shadow: 0px 2px 5px 0px rgb(0 0 0 / 5%);
319 -moz-box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
320 box-shadow: 0px 2px 5px 0px rgb(0 0 0 / 5%);
321 border-radius: 3px;
322 box-sizing: border-box;
323 }
324
325 #ppress-admin-fusewp .screenshot > * {
326 vertical-align: middle;
327 }
328
329 #ppress-admin-fusewp .screenshot .cont img {
330 max-width: 100%;
331 display: block;
332 }
333
334 #ppress-admin-fusewp .screenshot ul {
335 display: inline-block;
336 margin: 0 0 0 30px;
337 list-style-type: none;
338 max-width: 100%;
339 }
340
341 #ppress-admin-fusewp .screenshot li {
342 margin: 16px 0;
343 padding: 0 0 0 24px;
344 font-size: 15px;
345 color: #777777;
346 }
347
348 #ppress-admin-fusewp .step {
349 background-color: #F9F9F9;
350 -webkit-box-shadow: 0px 2px 5px 0px rgb(0 0 0 / 5%);
351 -moz-box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
352 box-shadow: 0px 2px 5px 0px rgb(0 0 0 / 5%);
353 border: 1px solid #E5E5E5;
354 margin: 0 0 25px 0;
355 }
356
357 #ppress-admin-fusewp .step .num {
358 display: inline-block;
359 position: relative;
360 width: 100px;
361 height: 50px;
362 text-align: center;
363 }
364
365 .ppress-admin-plugin-landing .loader {
366 margin: 0 auto;
367 position: relative;
368 text-indent: -9999em;
369 border-top: 4px solid #969696;
370 border-right: 4px solid #969696;
371 border-bottom: 4px solid #969696;
372 border-left: 4px solid #404040;
373 -webkit-transform: translateZ(0);
374 -ms-transform: translateZ(0);
375 transform: translateZ(0);
376 -webkit-animation: load8 1.1s infinite linear;
377 animation: load8 1.1s infinite linear;
378 background-color: transparent;
379 }
380
381 .ppress-admin-plugin-landing .loader, .ppress-admin-plugin-landing .loader:after {
382 display: block;
383 border-radius: 50%;
384 width: 50px;
385 height: 50px
386 }
387
388 @-webkit-keyframes load8 {
389 0% {
390 -webkit-transform: rotate(0deg);
391 transform: rotate(0deg)
392 }
393
394 100% {
395 -webkit-transform: rotate(360deg);
396 transform: rotate(360deg)
397 }
398 }
399
400 @keyframes load8 {
401 0% {
402 -webkit-transform: rotate(0deg);
403 transform: rotate(0deg)
404 }
405
406 100% {
407 -webkit-transform: rotate(360deg);
408 transform: rotate(360deg)
409 }
410 }
411
412 #ppress-admin-fusewp .step .loader {
413 margin-top: -54px;
414 transition: all .3s;
415 opacity: 1;
416 }
417
418 #ppress-admin-fusewp .step .hidden {
419 opacity: 0;
420 transition: all .3s;
421 }
422
423 #ppress-admin-fusewp .step div {
424 display: inline-block;
425 width: calc(100% - 104px);
426 background-color: #ffffff;
427 padding: 30px;
428 border-left: 1px solid #eeeeee;
429 }
430
431 #ppress-admin-fusewp .step h2 {
432 font-size: 24px;
433 line-height: 22px;
434 margin-top: 0;
435 margin-bottom: 15px;
436 }
437
438 #ppress-admin-fusewp .step p {
439 font-size: 16px;
440 color: #777777;
441 }
442
443
444 #ppress-admin-fusewp .step .button {
445 font-weight: 500;
446 box-shadow: none;
447 padding: 12px;
448 min-width: 200px;
449 height: auto;
450 line-height: 13px;
451 text-align: center;
452 font-size: 15px;
453 transition: all .3s;
454 }
455
456 #ppress-admin-fusewp .grey {
457 opacity: 0.5;
458 }
459 </style>
460 <?php
461 echo '<div id="ppress-admin-fusewp" class="wrap ppress-admin-wrap ppress-admin-plugin-landing">';
462
463 $this->output_section_heading();
464 $this->output_section_screenshot();
465 $this->output_section_step_install();
466 $this->output_section_step_setup();
467
468 echo '</div>';
469 }
470
471 /**
472 * Generate and output heading section HTML.
473 */
474 protected function output_section_heading()
475 {
476 // Heading section.
477 printf(
478 '<section class="top">
479 <img class="img-top" src="%1$s" alt="%2$s"/>
480 <h1>%3$s</h1>
481 <p>%4$s</p>
482 </section>',
483 esc_url(PPRESS_ASSETS_URL . '/images/profilepressXfusewp.png'),
484 esc_attr__('ProfilePress ♥ FuseWP', 'wp-user-avatar'),
485 esc_html__('WordPress User Sync & Automation Plugin', 'wp-user-avatar'),
486 esc_html__('FuseWP connect WordPress to your email marketing platform and CRM so you can automatically sync users & profile updates to your email list.', 'wp-user-avatar')
487 );
488 }
489
490 /**
491 * Generate and output screenshot section HTML.
492 */
493 protected function output_section_screenshot()
494 {
495 printf(
496 '<section class="screenshot">
497 <div class="cont">
498 <img src="%1$s" alt="%2$s"/>
499 </div>
500 </section>',
501 PPRESS_ASSETS_URL . '/images/fusewp-user-sync-edit-screen.png',
502 esc_attr__('FuseWP screenshot', 'wp-user-avatar')
503 );
504 }
505
506 /**
507 * Generate and output step 'Install' section HTML.
508 */
509 protected function output_section_step_install()
510 {
511 $step = $this->get_data_step_install();
512
513 if (empty($step)) {
514 return;
515 }
516
517 printf(
518 '<section class="step step-install">
519 <aside class="num">
520 <img src="%1$s" alt="%2$s" />
521 <i class="loader hidden"></i>
522 </aside>
523 <div>
524 <h2>%3$s</h2>
525 <p>%4$s</p>
526 <button class="button %5$s" data-plugin="%6$s" data-action="%7$s">%8$s</button>
527 </div>
528 </section>',
529 esc_url(PPRESS_ASSETS_URL . '/images/' . $step['icon']),
530 esc_attr__('Step 1', 'wp-user-avatar'),
531 esc_html__('Install and Activate FuseWP', 'wp-user-avatar'),
532 esc_html__('Install FuseWP from the WordPress.org plugin repository.', 'wp-user-avatar'),
533 esc_attr($step['button_class']),
534 esc_attr($step['plugin']),
535 esc_attr($step['button_action']),
536 esc_html($step['button_text'])
537 );
538 }
539
540 /**
541 * Generate and output step 'Setup' section HTML.
542 */
543 protected function output_section_step_setup()
544 {
545 $step = $this->get_data_step_setup();
546
547 if (empty($step)) {
548 return;
549 }
550
551 printf(
552 '<section class="step step-setup %1$s">
553 <aside class="num">
554 <img src="%2$s" alt="%3$s" />
555 <i class="loader hidden"></i>
556 </aside>
557 <div>
558 <h2>%4$s</h2>
559 <p>%5$s</p>
560 <button class="button %6$s" data-url="%7$s">%8$s</button>
561 </div>
562 </section>',
563 esc_attr($step['section_class']),
564 esc_url(PPRESS_ASSETS_URL . '/images/' . $step['icon']),
565 esc_attr__('Step 2', 'wp-user-avatar'),
566 esc_html__('Set Up FuseWP', 'wp-user-avatar'),
567 esc_html__('Configure and create your first sync rule.', 'wp-user-avatar'),
568 esc_attr($step['button_class']),
569 esc_url(admin_url($this->config['fusewp_settings'])),
570 esc_html($step['button_text'])
571 );
572 }
573
574 /**
575 * Step 'Install' data.
576 */
577 protected function get_data_step_install()
578 {
579 $step = array();
580
581 $this->output_data['all_plugins'] = get_plugins();
582 $this->output_data['plugin_installed'] = array_key_exists($this->config['lite_plugin'], $this->output_data['all_plugins']);
583 $this->output_data['plugin_activated'] = false;
584 $this->output_data['plugin_setup'] = false;
585
586 if ( ! $this->output_data['plugin_installed']) {
587 $step['icon'] = 'step-1.svg';
588 $step['button_text'] = esc_html__('Install FuseWP', 'wp-user-avatar');
589 $step['button_class'] = '';
590 $step['button_action'] = 'install';
591 $step['plugin'] = $this->config['lite_download_url'];
592 } else {
593 $this->output_data['plugin_activated'] = $this->is_activated();
594 $this->output_data['plugin_setup'] = $this->is_configured();
595 $step['icon'] = $this->output_data['plugin_activated'] ? 'step-complete.svg' : 'step-1.svg';
596 $step['button_text'] = $this->output_data['plugin_activated'] ? esc_html__('FuseWP Installed & Activated', 'wp-user-avatar') : esc_html__('Activate FuseWP', 'wp-user-avatar');
597 $step['button_class'] = $this->output_data['plugin_activated'] ? 'grey disabled' : '';
598 $step['button_action'] = $this->output_data['plugin_activated'] ? '' : 'activate';
599 $step['plugin'] = $this->config['lite_plugin'];
600 }
601
602 return $step;
603 }
604
605 /**
606 * Step 'Setup' data.
607 */
608 protected function get_data_step_setup()
609 {
610 $step = array();
611
612 $step['icon'] = 'step-2.svg';
613 $step['section_class'] = $this->output_data['plugin_activated'] ? '' : 'grey';
614 $step['button_text'] = esc_html__('Start Setup', 'wp-user-avatar');
615 $step['button_class'] = 'grey disabled';
616
617 if ($this->output_data['plugin_setup']) {
618 $step['icon'] = 'step-complete.svg';
619 $step['section_class'] = '';
620 $step['button_text'] = esc_html__('Go to FuseWP settings', 'wp-user-avatar');
621 } else {
622 $step['button_class'] = $this->output_data['plugin_activated'] ? '' : 'grey disabled';
623 }
624
625 return $step;
626 }
627
628 /**
629 * Ajax endpoint. Check plugin setup status.
630 * Used to properly init step 'Setup' section after completing step 'Install'.
631 */
632 public function ajax_check_plugin_status()
633 {
634 // Security checks.
635 if (
636 ! check_ajax_referer('ppress-admin-nonce', 'nonce', false) ||
637 ! current_user_can('activate_plugins')
638 ) {
639 wp_send_json_error(
640 array(
641 'error' => esc_html__('You do not have permission.', 'wp-user-avatar'),
642 )
643 );
644 }
645
646 $result = array();
647
648 if ( ! $this->is_activated()) {
649 wp_send_json_error(
650 array(
651 'error' => esc_html__('Plugin unavailable.', 'wp-user-avatar'),
652 )
653 );
654 }
655
656 $result['setup_status'] = (int)$this->is_configured();
657
658 wp_send_json_success($result);
659 }
660
661 /**
662 * Whether FuseWP plugin configured or not.
663 */
664 protected function is_configured()
665 {
666 return $this->is_activated();
667 }
668
669 /**
670 * Whether FuseWP plugin active or not.
671 */
672 protected function is_activated()
673 {
674 return class_exists('\FuseWP\Core\Base');
675 }
676
677 public function redirect_to_fusewp_settings()
678 {
679 if ($this->is_configured()) {
680 wp_safe_redirect(admin_url($this->config['fusewp_settings']));
681 exit;
682 }
683 }
684
685 /**
686 * @return self
687 */
688 public static function get_instance()
689 {
690 static $instance = null;
691
692 if (is_null($instance)) {
693 $instance = new self();
694 }
695
696 return $instance;
697 }
698 }