PluginProbe
Extendify / 3.2.1
Extendify v3.2.1
3.2.1 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 All 127 releases
← All changes | app/Assist/Admin.php +123 -63 0.11.13.2.1 View file →
@@ -1,5 +1,6 @@
1 1 <?php
2 +
2 3 /**
3 4 * Admin.
4 5 */
5 6
@@ -4,99 +5,158 @@
4 5 */
5 6
6 7 namespace Extendify\Assist;
7 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;
8 14 use Extendify\Config;
15 +use Extendify\PartnerData;
9 16
10 17 /**
11 18 * This class handles any file loading for the admin area.
12 19 */
20 +
13 21 class Admin
14 22 {
15 -
16 23 /**
17 - * The instance
24 + * Adds various actions to set up the page
18 25 *
19 - * @var $instance
26 + * @return self|void
20 27 */
21 - public static $instance = null;
28 + public function __construct()
29 + {
30 + \add_action('admin_enqueue_scripts', [$this, 'loadPageScripts']);
31 + }
22 32
23 33 /**
24 - * Adds various actions to set up the page
34 + * Adds scripts to the main admin page
25 35 *
26 - * @return self|void
36 + * @return void
27 37 */
28 - public function __construct()
38 + public function loadPageScripts()
29 39 {
30 - if (self::$instance) {
31 - return self::$instance;
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);
32 50 }
33 51
34 - self::$instance = $this;
35 - $this->loadScripts();
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 + );
36 104 }
37 105
38 106 /**
39 - * Adds scripts to the admin
107 + * Check to see if the user can re-run Launch
40 108 *
41 - * @return void
109 + * @return boolean
42 110 */
43 - public function loadScripts()
111 + public function canRunLaunchAgain()
44 112 {
45 - \add_action(
46 - 'admin_enqueue_scripts',
47 - function () {
48 - if (!current_user_can(Config::$requiredCapability)) {
49 - return;
50 - }
113 + $launchCompleted = \get_option('extendify_onboarding_completed', false);
114 + return (!$launchCompleted || $launchCompleted === 'false') ? false : true;
115 + }
51 116
52 - if (!Config::$showAssist) {
53 - return;
54 - }
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;
55 126
56 - $version = Config::$environment === 'PRODUCTION' ? Config::$version : uniqid();
127 + $woo = \get_option('woocommerce_onboarding_profile', false);
128 + $completedWoocommerceStore = (
129 + isset($woo['completed']) && $woo['completed']
130 + ) || (
131 + isset($woo['skipped']) && $woo['skipped']
132 + );
57 133
58 - \wp_enqueue_script(
59 - Config::$slug . '-assist-scripts',
60 - EXTENDIFY_BASE_URL . 'public/build/extendify-assist.js',
61 - [
62 - 'wp-components',
63 - 'wp-element',
64 - 'wp-data',
65 - 'wp-core-data',
66 - 'wp-html-entities',
67 - 'wp-i18n',
68 - 'wp-polyfill',
69 - ],
70 - $version,
71 - true
72 - );
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 + }
73 141
74 - $assistState = get_option('extendify_assist_globals');
75 - $dismissed = isset($assistState['state']['dismissedNotices']) ? $assistState['state']['dismissedNotices'] : [];
76 - \wp_add_inline_script(
77 - Config::$slug . '-assist-scripts',
78 - 'window.extAssistData = ' . wp_json_encode([
79 - 'devbuild' => \esc_attr(Config::$environment === 'DEVELOPMENT'),
80 - 'root' => \esc_url_raw(\rest_url(Config::$slug . '/' . Config::$apiVersion)),
81 - 'nonce' => \wp_create_nonce('wp_rest'),
82 - 'adminUrl' => \esc_url_raw(\admin_url()),
83 - 'asset_path' => \esc_url(EXTENDIFY_URL . 'public/assets'),
84 - 'launchCompleted' => Config::$launchCompleted,
85 - 'dismissedNotices' => $dismissed,
86 - ]),
87 - 'before'
88 - );
142 + $completedWPFormsLite = (bool) \get_option('wpforms_forms_first_created', false)
143 + || (bool) (\wp_count_posts('wpforms')->publish ?? 0);
89 144
90 - \wp_set_script_translations(Config::$slug . '-assist-scripts', 'extendify');
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'];
91 149
92 - \wp_enqueue_style(
93 - Config::$slug . '-assist-styles',
94 - EXTENDIFY_BASE_URL . 'public/build/extendify-assist.css',
95 - [],
96 - $version,
97 - 'all'
98 - );
99 - }
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'
100 160 );
101 161 }
102 162 }