PluginProbe
Extendify / 3.1.5
Extendify v3.1.5
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / app / Assist / Admin.php

Admin.php in Extendify 3.1.5, at app/Assist/Admin.php

163 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Admin.
5 */
6
7 namespace Extendify\Assist;
8
9 defined('ABSPATH') || die('No direct access.');
10
11 use Extendify\Assist\Controllers\GlobalsController;
12 use Extendify\Assist\Controllers\RouterController;
13 use Extendify\Assist\Controllers\TasksController;
14 use Extendify\Config;
15 use Extendify\PartnerData;
16
17 /**
18 * This class handles any file loading for the admin area.
19 */
20
21 class Admin
22 {
23 /**
24 * Adds various actions to set up the page
25 *
26 * @return self|void
27 */
28 public function __construct()
29 {
30 \add_action('admin_enqueue_scripts', [$this, 'loadPageScripts']);
31 }
32
33 /**
34 * Adds scripts to the main admin page
35 *
36 * @return void
37 */
38 public function loadPageScripts()
39 {
40 $version = constant('EXTENDIFY_DEVMODE') ? uniqid() : Config::$version;
41 $scriptAssetPath = EXTENDIFY_PATH . 'public/build/' . Config::$assetManifest['extendify-assist-page.php'];
42 $fallback = [
43 'dependencies' => [],
44 'version' => $version,
45 ];
46 $scriptAsset = file_exists($scriptAssetPath) ? require $scriptAssetPath : $fallback;
47
48 foreach ($scriptAsset['dependencies'] as $style) {
49 \wp_enqueue_style($style);
50 }
51
52 \wp_enqueue_script(
53 Config::$slug . '-assist-page-scripts',
54 EXTENDIFY_BASE_URL . 'public/build/' . Config::$assetManifest['extendify-assist-page.js'],
55 array_merge([Config::$slug . '-shared-scripts'], $scriptAsset['dependencies']),
56 $scriptAsset['version'],
57 true
58 );
59
60 \wp_add_inline_script(
61 Config::$slug . '-assist-page-scripts',
62 'window.extAssistData = ' . \wp_json_encode([
63 'launchCompleted' => (bool) Config::$launchCompleted,
64 'hasCustomizer' => (bool) \has_action('customize_register'),
65 'domainsSuggestionSettings' => [
66 'showBanner' => (bool) PartnerData::setting('showDomainBanner'),
67 'showTask' => (bool) PartnerData::setting('showDomainTask'),
68 'showSecondaryBanner' => (bool) PartnerData::setting('showSecondaryDomainBanner'),
69 'showSecondaryTask' => (bool) PartnerData::setting('showSecondaryDomainTask'),
70 'stagingSites' => array_map('esc_attr', PartnerData::setting('stagingSites')),
71 'searchUrl' => \esc_attr(PartnerData::setting('domainSearchURL')),
72 ],
73 'userData' => [
74 'taskData' => \wp_json_encode(TasksController::get()->get_data()),
75 'globalData' => \wp_json_encode(GlobalsController::get()->get_data()),
76 'routerData' => \wp_json_encode(RouterController::get()->get_data()),
77 'recommendationData' => \wp_json_encode(RouterController::get()->get_data()),
78 'tasksDependencies' => \wp_json_encode($this->getTasksDependencies()),
79 'domainsRecommendationsActivities' => \wp_json_encode(
80 get_option('extendify_domains_recommendations_activities', null)
81 ),
82 ],
83 'canSeeRestartLaunch' => (bool) $this->canRunLaunchAgain(),
84 'editSiteNavigationMenuLink' => \current_theme_supports('menus')
85 ? \esc_url(\admin_url('nav-menus.php'))
86 : \esc_url(\admin_url('site-editor.php?path=%2Fnavigation')),
87 ]),
88 'before'
89 );
90
91 \wp_set_script_translations(
92 Config::$slug . '-assist-page-scripts',
93 'extendify-local',
94 EXTENDIFY_PATH . 'languages/js'
95 );
96
97 \wp_enqueue_style(
98 Config::$slug . '-assist-page-styles',
99 EXTENDIFY_BASE_URL . 'public/build/' . Config::$assetManifest['extendify-assist-page.css'],
100 [],
101 Config::$version,
102 'all'
103 );
104 }
105
106 /**
107 * Check to see if the user can re-run Launch
108 *
109 * @return boolean
110 */
111 public function canRunLaunchAgain()
112 {
113 $launchCompleted = \get_option('extendify_onboarding_completed', false);
114 return (!$launchCompleted || $launchCompleted === 'false') ? false : true;
115 }
116
117 /**
118 * Check to see if specific tasks are completed or not.
119 *
120 * @return array
121 */
122 public function getTasksDependencies()
123 {
124 $give = \get_option('give_onboarding', false);
125 $completedSetupGivewp = isset($give['form_id']) && $give['form_id'] > 0;
126
127 $woo = \get_option('woocommerce_onboarding_profile', false);
128 $completedWoocommerceStore = (
129 isset($woo['completed']) && $woo['completed']
130 ) || (
131 isset($woo['skipped']) && $woo['skipped']
132 );
133
134 $aioseo = \get_option('aioseo_blc_options_internal', false);
135 $completedSetupAIOSeo = false;
136 if ($aioseo) {
137 $aioseo = \json_decode($aioseo, true);
138 $completedSetupAIOSeo = isset($aioseo['internal'])
139 && array_key_exists('firstActivated', $aioseo['internal']);
140 }
141
142 $completedWPFormsLite = (bool) \get_option('wpforms_forms_first_created', false)
143 || (bool) (\wp_count_posts('wpforms')->publish ?? 0);
144
145 // The two extra keys that will be added after connecting the store
146 // are the `admin_menu` and `hide_out_of_stock`.
147 $yourWebShop = \get_option('ecwid_plugin_data', false);
148 $completedYourWebShop = isset($yourWebShop['admin_menu']) && $yourWebShop['admin_menu'];
149
150 $monsterInsightsSiteProfile = \get_option('monsterinsights_site_profile', false);
151 $completedMonsterInsights = isset($monsterInsightsSiteProfile['token']) && $monsterInsightsSiteProfile['token'];
152
153 return compact(
154 'completedSetupGivewp',
155 'completedWoocommerceStore',
156 'completedSetupAIOSeo',
157 'completedWPFormsLite',
158 'completedYourWebShop',
159 'completedMonsterInsights'
160 );
161 }
162 }
163