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/Agent/Admin.php +48 -4 3.1.43.2.1 View file →
@@ -20,8 +20,9 @@
20 20 use Extendify\Agent\AbilitiesDiscovery;
21 21 use Extendify\Agent\Controllers\SiteNavigationController;
22 22 use Extendify\PartnerData;
23 23 use Extendify\Shared\DataProvider\ProductsData;
24 +use Extendify\SiteVisibility;
24 25
25 26 /**
26 27 * This class handles any file loading for the admin area.
27 28 */
@@ -44,8 +45,10 @@
44 45
45 46 // Add the site navigation ids to the navigation blocks
46 47 SiteNavigationController::init();
47 48
49 + Skeleton::init();
50 +
48 51 WooProductImages::init();
49 52
50 53 \add_action('extendify_agent_suggestions_refresh', [$this, 'refreshSuggestions']);
51 54 }
@@ -50,8 +53,22 @@
50 53 \add_action('extendify_agent_suggestions_refresh', [$this, 'refreshSuggestions']);
51 54 }
52 55
53 56 /**
57 + * Where the agent panel mounts — docked-left only on the onboarding front end.
58 + *
59 + * @return string
60 + */
61 + public static function agentPosition()
62 + {
63 + $agentOnboarding = PartnerData::setting('useAgentOnboarding') ||
64 + Config::preview('agent-onboarding') ||
65 + constant('EXTENDIFY_DEVMODE');
66 +
67 + return $agentOnboarding && !is_admin() ? 'docked-left' : 'floating';
68 + }
69 +
70 + /**
54 71 * Adds various JS scripts and styles
55 72 *
56 73 * @return void
57 74 */
@@ -102,11 +119,9 @@
102 119 (bool) use_block_editor_for_post($this->getCurrentPostId()) :
103 120 false,
104 121 'isOnEditorOrFSE' => $this->isGutenbergOrFse(),
105 122 'activePlugins' => array_values(\get_option('active_plugins', [])),
106 - // Whether the user is using the vibes experience or not.
107 - 'isUsingVibes' => (bool) file_exists(EXTENDIFY_PATH . 'src/Launch/_data/block-style-variations.json') &&
108 - version_compare(wp_get_theme("extendable")->get('Version'), '2.0.32', '>='),
123 + 'isUsingVibes' => version_compare((string) wp_get_theme('extendable')->get('Version'), '2.0.32', '>='),
109 124 'siteTitle' => \esc_attr(\get_bloginfo('name')),
110 125 'siteDescription' => \esc_attr(\get_bloginfo('description')),
111 126 'themePresets' => $this->getThemePresets(),
112 127 'presetSlugs' => $this->getPresetSlugs(),
@@ -125,8 +140,10 @@
125 140 }, $pluginRecommendations));
126 141 $agentContext = [
127 142 'availableAdminPages' => get_option('_transient_extendify_admin_pages_menu', []),
128 143 'pluginRecommendations' => $mappedPluginRecommendations,
144 + 'sitePublished' => SiteVisibility::isPublished(),
145 + 'comingSoonEnabled' => (bool) PartnerData::setting('useComingSoon'),
129 146 ];
130 147 $abilities = [
131 148 'canEditPost' => (bool) \current_user_can('edit_post', \get_queried_object_id()),
132 149 // TODO: this may be true for a user, while they still can't edit every post
@@ -149,9 +166,9 @@
149 166 Config::$slug . '-agent-scripts',
150 167 'window.extAgentData = ' . \wp_json_encode([
151 168 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
152 169 'startOnboarding' => isset($_GET['extendify-launch-success']) && $agentOnboarding,
153 - 'agentPosition' => $agentOnboarding && !is_admin() ? 'docked-left' : 'floating',
170 + 'agentPosition' => self::agentPosition(),
154 171 // Add context about where they are
155 172 'context' => $context,
156 173 // Material a workflow may want; each declares the keys it reads.
157 174 'agentContext' => $agentContext,
@@ -297,12 +314,39 @@
297 314 $typography = \wp_get_global_settings(['typography']);
298 315
299 316 return [
300 317 'color' => $this->originSlugs($color, 'palette', 'defaultPalette'),
318 + 'colorValues' => $this->originValues($color, 'palette', 'defaultPalette', 'color'),
301 319 'gradient' => $this->originSlugs($color, 'gradients', 'defaultGradients'),
302 320 'fontSize' => $this->originSlugs($typography, 'fontSizes', 'defaultFontSizes'),
303 321 'fontFamily' => $this->originSlugs($typography, 'fontFamilies', 'defaultFontFamilies'),
304 322 ];
323 + }
324 +
325 + /**
326 + * Slug => value, so a colour written as its own hex finds the token naming it.
327 + *
328 + * @return array<string, string>
329 + */
330 + private function originValues($node, $listKey, $defaultKey, $valueKey)
331 + {
332 + $list = $node[$listKey] ?? [];
333 +
334 + $origins = ['custom', 'theme'];
335 + if (($node[$defaultKey] ?? true) !== false) {
336 + $origins[] = 'default';
337 + }
338 +
339 + $values = [];
340 + foreach ($origins as $origin) {
341 + foreach ($list[$origin] ?? [] as $item) {
342 + if (isset($item['slug'], $item[$valueKey])) {
343 + $values[(string) $item['slug']] = (string) $item[$valueKey];
344 + }
345 + }
346 + }
347 +
348 + return $values;
305 349 }
306 350
307 351 /**
308 352 * Preset slugs from a settings node's origin buckets; drops the `default`