| @@ -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 | */ |
| @@ -118,11 +119,9 @@ | ||
| 118 | 119 | (bool) use_block_editor_for_post($this->getCurrentPostId()) : |
| 119 | 120 | false, |
| 120 | 121 | 'isOnEditorOrFSE' => $this->isGutenbergOrFse(), |
| 121 | 122 | 'activePlugins' => array_values(\get_option('active_plugins', [])), |
| 122 | - // Whether the user is using the vibes experience or not. | |
| 123 | - 'isUsingVibes' => (bool) file_exists(EXTENDIFY_PATH . 'src/Launch/_data/block-style-variations.json') && | |
| 124 | - 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', '>='), | |
| 125 | 124 | 'siteTitle' => \esc_attr(\get_bloginfo('name')), |
| 126 | 125 | 'siteDescription' => \esc_attr(\get_bloginfo('description')), |
| 127 | 126 | 'themePresets' => $this->getThemePresets(), |
| 128 | 127 | 'presetSlugs' => $this->getPresetSlugs(), |
| @@ -141,8 +140,10 @@ | ||
| 141 | 140 | }, $pluginRecommendations)); |
| 142 | 141 | $agentContext = [ |
| 143 | 142 | 'availableAdminPages' => get_option('_transient_extendify_admin_pages_menu', []), |
| 144 | 143 | 'pluginRecommendations' => $mappedPluginRecommendations, |
| 144 | + 'sitePublished' => SiteVisibility::isPublished(), | |
| 145 | + 'comingSoonEnabled' => (bool) PartnerData::setting('useComingSoon'), | |
| 145 | 146 | ]; |
| 146 | 147 | $abilities = [ |
| 147 | 148 | 'canEditPost' => (bool) \current_user_can('edit_post', \get_queried_object_id()), |
| 148 | 149 | // TODO: this may be true for a user, while they still can't edit every post |
| @@ -313,12 +314,39 @@ | ||
| 313 | 314 | $typography = \wp_get_global_settings(['typography']); |
| 314 | 315 | |
| 315 | 316 | return [ |
| 316 | 317 | 'color' => $this->originSlugs($color, 'palette', 'defaultPalette'), |
| 318 | + 'colorValues' => $this->originValues($color, 'palette', 'defaultPalette', 'color'), | |
| 317 | 319 | 'gradient' => $this->originSlugs($color, 'gradients', 'defaultGradients'), |
| 318 | 320 | 'fontSize' => $this->originSlugs($typography, 'fontSizes', 'defaultFontSizes'), |
| 319 | 321 | 'fontFamily' => $this->originSlugs($typography, 'fontFamilies', 'defaultFontFamilies'), |
| 320 | 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; | |
| 321 | 349 | } |
| 322 | 350 | |
| 323 | 351 | /** |
| 324 | 352 | * Preset slugs from a settings node's origin buckets; drops the `default` |