PluginProbe
Extendify / 3.2.2
Extendify v3.2.2
3.2.2 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 All 128 releases
← All changes | app/Agent/Admin.php +110 -12 3.1.0 → 3.2.2 View file →
@@ -11,15 +11,18 @@
11 11 use Extendify\Agent\Controllers\ChatHistoryController;
12 12 use Extendify\Agent\Controllers\TourController;
13 13 use Extendify\Config;
14 14 use Extendify\Constants;
15 +use Extendify\Mcp\Profile as McpProfile;
15 16 use Extendify\Shared\Services\Escaper;
16 17 use Extendify\Shared\Services\HttpClient;
17 18 use Extendify\Agent\TagBlocks;
18 19 use Extendify\Agent\TagTemplateParts;
19 -use Extendify\Agent\Controllers\SiteNavigationController;
20 +use Extendify\Agent\WooProductImages;
21 +use Extendify\Agent\AbilitiesDiscovery;
20 22 use Extendify\PartnerData;
21 23 use Extendify\Shared\DataProvider\ProductsData;
24 +use Extendify\SiteVisibility;
22 25
23 26 /**
24 27 * This class handles any file loading for the admin area.
25 28 */
@@ -39,15 +42,30 @@
39 42 // Tag blocks so we can identify them later
40 43 TagBlocks::init();
41 44 TagTemplateParts::init();
42 45
43 - // Add the site navigation ids to the navigation blocks
44 - SiteNavigationController::init();
46 + Skeleton::init();
45 47
48 + WooProductImages::init();
49 +
46 50 \add_action('extendify_agent_suggestions_refresh', [$this, 'refreshSuggestions']);
47 51 }
48 52
49 53 /**
54 + * Where the agent panel mounts — docked-left only on the onboarding front end.
55 + *
56 + * @return string
57 + */
58 + public static function agentPosition()
59 + {
60 + $agentOnboarding = PartnerData::setting('useAgentOnboarding') ||
61 + Config::preview('agent-onboarding') ||
62 + constant('EXTENDIFY_DEVMODE');
63 +
64 + return $agentOnboarding && !is_admin() ? 'docked-left' : 'floating';
65 + }
66 +
67 + /**
50 68 * Adds various JS scripts and styles
51 69 *
52 70 * @return void
53 71 */
@@ -54,9 +72,9 @@
54 72 public function loadScriptsAndStyles()
55 73 {
56 74 // The Customizer preview iframe is a front-end render, so this fires
57 75 // there too — but the Agent only belongs on the live, top-level page.
58 - if (is_customize_preview()) {
76 + if (is_customize_preview() || McpProfile::isOwnScreen()) {
59 77 return;
60 78 }
61 79
62 80 $version = constant('EXTENDIFY_DEVMODE') ? uniqid() : Config::$version;
@@ -98,14 +116,15 @@
98 116 (bool) use_block_editor_for_post($this->getCurrentPostId()) :
99 117 false,
100 118 'isOnEditorOrFSE' => $this->isGutenbergOrFse(),
101 119 'activePlugins' => array_values(\get_option('active_plugins', [])),
102 - // Whether the user is using the vibes experience or not.
103 - 'isUsingVibes' => (bool) file_exists(EXTENDIFY_PATH . 'src/Launch/_data/block-style-variations.json') &&
104 - version_compare(wp_get_theme("extendable")->get('Version'), '2.0.32', '>='),
120 + // The accessor also reads a key set by the IMAGIFY_API_KEY constant.
121 + 'hasImagifyApiKey' => function_exists('get_imagify_option') && (bool) \get_imagify_option('api_key'),
122 + 'isUsingVibes' => version_compare((string) wp_get_theme('extendable')->get('Version'), '2.0.32', '>='),
105 123 'siteTitle' => \esc_attr(\get_bloginfo('name')),
106 124 'siteDescription' => \esc_attr(\get_bloginfo('description')),
107 125 'themePresets' => $this->getThemePresets(),
126 + 'presetSlugs' => $this->getPresetSlugs(),
108 127 ];
109 128 $recommendations = ProductsData::get() ?? [];
110 129 $pluginRecommendations = array_filter($recommendations, function ($item) {
111 130 return in_array('ai-agent', $item['slots'] ?? [], true) && $item['ctaType'] === 'plugin';
@@ -120,8 +139,10 @@
120 139 }, $pluginRecommendations));
121 140 $agentContext = [
122 141 'availableAdminPages' => get_option('_transient_extendify_admin_pages_menu', []),
123 142 'pluginRecommendations' => $mappedPluginRecommendations,
143 + 'sitePublished' => SiteVisibility::isPublished(),
144 + 'comingSoonEnabled' => (bool) PartnerData::setting('useComingSoon'),
124 145 ];
125 146 $abilities = [
126 147 'canEditPost' => (bool) \current_user_can('edit_post', \get_queried_object_id()),
127 148 // TODO: this may be true for a user, while they still can't edit every post
@@ -144,19 +165,19 @@
144 165 Config::$slug . '-agent-scripts',
145 166 'window.extAgentData = ' . \wp_json_encode([
146 167 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
147 168 'startOnboarding' => isset($_GET['extendify-launch-success']) && $agentOnboarding,
148 - 'agentPosition' => $agentOnboarding && !is_admin() ? 'docked-left' : 'floating',
169 + 'agentPosition' => self::agentPosition(),
149 170 // Add context about where they are
150 171 'context' => $context,
151 - // Context that the Agent might need when returning a response,
152 - // but not for handling the workflow.
172 + // Material a workflow may want; each declares the keys it reads.
153 173 'agentContext' => $agentContext,
154 174 // List of abilities the AI can perform for this user.
155 175 // For example, we could check whether their theme has variations.
156 176 'abilities' => $abilities,
157 - // List of suggestions the AI can make for this user.
158 - // For example, we could check whether they need to set up a specific plugin.
177 + // Registered WordPress Abilities (6.9+) this user may run.
178 + 'wpAbilities' => AbilitiesDiscovery::discover(),
179 + // The domain card reads only the register-domain record.
159 180 'suggestions' => $this->getSuggestions(),
160 181 'domainsSuggestionSettings' => [
161 182 'showPrimary' => (bool) PartnerData::setting('showPrimaryDomainRecommendationAgent'),
162 183 'showSecondary' => (bool) PartnerData::setting('showSecondaryDomainRecommendationAgent'),
@@ -272,8 +293,85 @@
272 293 'fontSizes' => $fontSizes,
273 294 'fontFamilies' => $fontFamilies,
274 295 'colorPairs' => $colorPairs,
275 296 ];
297 + }
298 +
299 + /**
300 + * Preset slugs per design-token family across every origin. Feeds the Agent's
301 + * block-attribute schema so the model picks named tokens, not raw CSS.
302 + *
303 + * @return array<string,string[]>
304 + */
305 + private function getPresetSlugs()
306 + {
307 + if (!function_exists('wp_get_global_settings')) {
308 + return [];
309 + }
310 +
311 + $color = \wp_get_global_settings(['color']);
312 + $typography = \wp_get_global_settings(['typography']);
313 +
314 + return [
315 + 'color' => $this->originSlugs($color, 'palette', 'defaultPalette'),
316 + 'colorValues' => $this->originValues($color, 'palette', 'defaultPalette', 'color'),
317 + 'gradient' => $this->originSlugs($color, 'gradients', 'defaultGradients'),
318 + 'fontSize' => $this->originSlugs($typography, 'fontSizes', 'defaultFontSizes'),
319 + 'fontFamily' => $this->originSlugs($typography, 'fontFamilies', 'defaultFontFamilies'),
320 + ];
321 + }
322 +
323 + /**
324 + * Slug => value, so a colour written as its own hex finds the token naming it.
325 + *
326 + * @return array<string, string>
327 + */
328 + private function originValues($node, $listKey, $defaultKey, $valueKey)
329 + {
330 + $list = $node[$listKey] ?? [];
331 +
332 + $origins = ['custom', 'theme'];
333 + if (($node[$defaultKey] ?? true) !== false) {
334 + $origins[] = 'default';
335 + }
336 +
337 + $values = [];
338 + foreach ($origins as $origin) {
339 + foreach ($list[$origin] ?? [] as $item) {
340 + if (isset($item['slug'], $item[$valueKey])) {
341 + $values[(string) $item['slug']] = (string) $item[$valueKey];
342 + }
343 + }
344 + }
345 +
346 + return $values;
347 + }
348 +
349 + /**
350 + * Preset slugs from a settings node's origin buckets; drops the `default`
351 + * origin when the theme opted the family out.
352 + *
353 + * @return string[]
354 + */
355 + private function originSlugs($node, $listKey, $defaultKey)
356 + {
357 + $list = $node[$listKey] ?? [];
358 +
359 + $origins = ['custom', 'theme'];
360 + if (($node[$defaultKey] ?? true) !== false) {
361 + $origins[] = 'default';
362 + }
363 +
364 + $slugs = [];
365 + foreach ($origins as $origin) {
366 + foreach ($list[$origin] ?? [] as $item) {
367 + if (isset($item['slug'])) {
368 + $slugs[] = (string) $item['slug'];
369 + }
370 + }
371 + }
372 +
373 + return array_values(array_unique($slugs));
276 374 }
277 375
278 376 private static function extractColorSlug(string $value)
279 377 {