Changeset 3487719
- Timestamp:
- 03/21/2026 10:35:41 AM (7 days ago)
- Location:
- smart-content-sync
- Files:
-
- 4 added
- 10 deleted
- 28 edited
- 1 copied
-
tags/1.0.1 (copied) (copied from smart-content-sync/trunk)
-
tags/1.0.1/composer.json (modified) (1 diff)
-
tags/1.0.1/readme.txt (modified) (2 diffs)
-
tags/1.0.1/smart-content-sync.php (modified) (2 diffs)
-
tags/1.0.1/src/ContentBlocks/Renderer/ContextBuilder.php (modified) (4 diffs)
-
tags/1.0.1/src/ContentBlocks/SmartContentCustomPostType.php (modified) (1 diff)
-
tags/1.0.1/src/Domains/AutoInsert/Storage/AutoInsertMetaBox.php (modified) (3 diffs)
-
tags/1.0.1/src/Infrastructure/Admin/Settings/SettingsManager.php (modified) (1 diff)
-
tags/1.0.1/src/Infrastructure/Client (added)
-
tags/1.0.1/src/Infrastructure/Client/ClientConfigBuilder.php (added)
-
tags/1.0.1/src/Infrastructure/Platform/WooCommerce/WooCommerceHelper.php (modified) (5 diffs)
-
tags/1.0.1/src/Infrastructure/Platform/WordPress/WordPressHelper.php (modified) (3 diffs)
-
tags/1.0.1/src/Plugin.php (modified) (2 diffs)
-
tags/1.0.1/vendor/autoload.php (modified) (1 diff)
-
tags/1.0.1/vendor/bin (deleted)
-
tags/1.0.1/vendor/composer/InstalledVersions.php (deleted)
-
tags/1.0.1/vendor/composer/autoload_classmap.php (modified) (1 diff)
-
tags/1.0.1/vendor/composer/autoload_real.php (modified) (2 diffs)
-
tags/1.0.1/vendor/composer/autoload_static.php (modified) (3 diffs)
-
tags/1.0.1/vendor/composer/installed.json (deleted)
-
tags/1.0.1/vendor/composer/installed.php (deleted)
-
tags/1.0.1/vendor/php-stubs (deleted)
-
trunk/composer.json (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/smart-content-sync.php (modified) (2 diffs)
-
trunk/src/ContentBlocks/Renderer/ContextBuilder.php (modified) (4 diffs)
-
trunk/src/ContentBlocks/SmartContentCustomPostType.php (modified) (1 diff)
-
trunk/src/Domains/AutoInsert/Storage/AutoInsertMetaBox.php (modified) (3 diffs)
-
trunk/src/Infrastructure/Admin/Settings/SettingsManager.php (modified) (1 diff)
-
trunk/src/Infrastructure/Client (added)
-
trunk/src/Infrastructure/Client/ClientConfigBuilder.php (added)
-
trunk/src/Infrastructure/Platform/WooCommerce/WooCommerceHelper.php (modified) (5 diffs)
-
trunk/src/Infrastructure/Platform/WordPress/WordPressHelper.php (modified) (3 diffs)
-
trunk/src/Plugin.php (modified) (2 diffs)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/bin (deleted)
-
trunk/vendor/composer/InstalledVersions.php (deleted)
-
trunk/vendor/composer/autoload_classmap.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_real.php (modified) (2 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (3 diffs)
-
trunk/vendor/composer/installed.json (deleted)
-
trunk/vendor/composer/installed.php (deleted)
-
trunk/vendor/php-stubs (deleted)
Legend:
- Unmodified
- Added
- Removed
-
smart-content-sync/tags/1.0.1/composer.json
r3454742 r3487719 21 21 "require-dev": { 22 22 "php-stubs/wordpress-stubs": "dev-master", 23 "php-stubs/woocommerce-stubs": "^3.8" 23 "php-stubs/woocommerce-stubs": "^3.8", 24 "wp-cli/wp-cli": "^2.13@dev" 24 25 } 25 26 } -
smart-content-sync/tags/1.0.1/readme.txt
r3454742 r3487719 5 5 Requires at least: 5.8 6 6 Tested up to: 6.9 7 Stable tag: 1.0. 07 Stable tag: 1.0.1 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 140 140 141 141 == Changelog == 142 = 1.0.1 = 143 * Added support for the renamed Gutenberg block registration and migration from the previous block name 144 * Refined SEO integration and editor detection behavior for analysis previews 145 * Added extensibility hooks for settings sections and improved admin/client configuration plumbing 146 * Updated compatibility metadata and release packaging details 147 142 148 = 1.0.0 = 143 149 * Initial stable release -
smart-content-sync/tags/1.0.1/smart-content-sync.php
r3454742 r3487719 4 4 * Plugin Name: Smart Content Sync 5 5 * Description: Stop Copy-Pasting. Create Once. Sync Everywhere. 6 * Version: 1.0. 06 * Version: 1.0.1 7 7 * Author: Andale Plugins 8 8 * Author: Andale Technologies, SARL … … 32 32 define('SMART_CONTENT_SYNC_DIST_URL', plugin_dir_url(__FILE__) . 'dist/'); 33 33 define('SMART_CONTENT_SYNC_BASENAME', plugin_basename(__FILE__)); 34 define('SMART_CONTENT_SYNC_VERSION', '1.0. 0');34 define('SMART_CONTENT_SYNC_VERSION', '1.0.1'); 35 35 36 36 // Initialize the plugin -
smart-content-sync/tags/1.0.1/src/ContentBlocks/Renderer/ContextBuilder.php
r3454742 r3487719 33 33 // Post-related context (this block) 34 34 if ($smartContentPost instanceof WP_Post) { 35 $postAuthorName = ''; 36 $postAuthorId = (int) $smartContentPost->post_author; 37 if ($postAuthorId > 0) { 38 $author = get_userdata($postAuthorId); 39 if ($author instanceof \WP_User) { 40 $postAuthorName = $author->display_name; 41 } 42 } 43 35 44 $context['post'] = [ 36 45 'id' => $smartContentPost->ID, … … 39 48 'excerpt' => $smartContentPost->post_excerpt, 40 49 'url' => get_permalink($smartContentPost), 41 'type' => $smartContentPost->post_type, // add this 50 'type' => $smartContentPost->post_type, 51 'date' => get_the_date('', $smartContentPost), 52 'author' => $postAuthorName, 53 'categories' => $this->getJoinedTermNames($smartContentPost->ID, 'category'), 42 54 ]; 43 55 … … 107 119 'stock_quantity' => $stockQty, 108 120 'is_on_sale' => $isOnSale ? 'yes' : 'no', 121 'categories' => ($id ? $this->getJoinedTermNames((int) $id, 'product_cat') : ''), 122 'tags' => ($id ? $this->getJoinedTermNames((int) $id, 'product_tag') : ''), 109 123 ]; 110 124 } … … 182 196 return $flat; 183 197 } 198 199 /** 200 * Return a comma-separated list of term names for a given object/taxonomy pair. 201 * 202 * @param int $objectId 203 * @param string $taxonomy 204 * @return string 205 */ 206 protected function getJoinedTermNames(int $objectId, string $taxonomy): string 207 { 208 if ($objectId <= 0 || $taxonomy === '') { 209 return ''; 210 } 211 212 $terms = get_the_terms($objectId, $taxonomy); 213 if (is_wp_error($terms) || !is_array($terms) || empty($terms)) { 214 return ''; 215 } 216 217 $names = []; 218 foreach ($terms as $term) { 219 if ($term instanceof \WP_Term && $term->name !== '') { 220 $names[] = $term->name; 221 } 222 } 223 224 return implode(', ', $names); 225 } 184 226 } -
smart-content-sync/tags/1.0.1/src/ContentBlocks/SmartContentCustomPostType.php
r3454742 r3487719 35 35 'labels' => $labels, 36 36 'public' => false, 37 // 'publicly_queryable' => true, // needed for REST API access 37 38 'show_ui' => true, 38 39 'show_in_menu' => true, -
smart-content-sync/tags/1.0.1/src/Domains/AutoInsert/Storage/AutoInsertMetaBox.php
r3454742 r3487719 153 153 echo '</p>'; 154 154 155 do_action('smart_content_sync_auto_insert_metabox_before_locations', $post, [ 156 'enabled' => $enabled, 157 'locations' => $locations, 158 ]); 159 155 160 // Default open group: WooCommerce (if active), otherwise WordPress. 156 161 $defaultOpenGroup = $isWooCommerceActive ? 'WooCommerce' : 'WordPress'; … … 242 247 } 243 248 249 do_action('smart_content_sync_auto_insert_metabox_after_locations', $post, [ 250 'enabled' => $enabled, 251 'locations' => $locations, 252 ]); 253 244 254 echo '</div>'; 245 255 } … … 304 314 $clean = array_values(array_unique($clean)); 305 315 update_post_meta($postId, self::META_LOCATIONS, $clean); 316 317 do_action('smart_content_sync_auto_insert_metabox_save', $postId, $post, [ 318 'enabled' => $enabled, // '1'|'0' as stored 319 'locations' => $clean, // validated array 320 ]); 306 321 } 307 322 } -
smart-content-sync/tags/1.0.1/src/Infrastructure/Admin/Settings/SettingsManager.php
r3454742 r3487719 119 119 private function getSections(): array 120 120 { 121 return[121 $sections = [ 122 122 new UninstallSettingsSection($this), 123 123 ]; 124 125 /** 126 * Allow extensions (e.g. Pro plugin) to add settings sections. 127 * 128 * @param array<int, object> $sections 129 * @param SettingsManager $manager 130 */ 131 $sections = (array) apply_filters('smart_content_sync_settings_sections', $sections, $this); 132 133 return $sections; 124 134 } 125 135 -
smart-content-sync/tags/1.0.1/src/Infrastructure/Platform/WooCommerce/WooCommerceHelper.php
r3454742 r3487719 14 14 * 15 15 * Notes on payload size: 16 * - Use buildWooCommerce SettingsBasic() for most SmartContentSync needs.17 * - Use buildWooCommerce SettingsExtended() only when you truly need currency formatting16 * - Use buildWooCommerceClientConfig() for most SmartContentSync needs. 17 * - Use buildWooCommerceClientConfigExtended() only when you truly need currency formatting 18 18 * or Store API nonce data. 19 19 * … … 178 178 179 179 /** 180 * Build a minimal WooCommerce settings array suitable for script localization. 181 * 182 * This is the recommended method for SmartContentSync: it exposes only what you 183 * typically need client-side (presence + basic context), and nothing expensive. 184 * 185 * Intended use: 186 * - wp_localize_script(..., 'smartContentSyncWoo', WooCommerceHelper::buildWooCommerceSettingsBasic()) 180 * Build an extended WooCommerce settings array suitable for script localization. 181 * 182 * This includes currency formatting details and (optionally) Store API nonce. 183 * Use this only for admin UIs or frontend UIs that explicitly need these values. 187 184 * 188 185 * @param array<string, mixed> $overrides Optional overrides merged into the base settings. 189 186 * @return array<string, mixed> 190 187 */ 191 public static function buildWooCommerce SettingsBasic(array $overrides = []): array188 public static function buildWooCommerceClientConfigExtended(array $overrides = []): array 192 189 { 193 190 $active = self::isWooCommerceActive(); 194 191 $installed = self::isWooCommerceInstalled(); 195 192 196 $settings = [197 'active' => $active,198 'installed' => $installed,199 'isSingleProduct' => $active ? self::isSingleProductPage() : false,200 'isWooRest' => $active ? self::isWooCommerceRestRequest() : false,201 'currentProductId' => $active ? self::getCurrentProductId() : null,202 203 // Currency code is small and commonly useful for UI labels.204 'currency' => ($active && function_exists('get_woocommerce_currency')) ? (string) get_woocommerce_currency() : '',205 206 // Keep URLs minimal; add more only when a concrete UI needs them.207 'urls' => [208 'shop' => ($active && function_exists('wc_get_page_permalink')) ? (string) wc_get_page_permalink('shop') : '',209 ],210 211 'features' => [],212 ];213 214 /**215 * Filter the basic WooCommerce settings array.216 *217 * @param array<string, mixed> $settings Base settings.218 * @param array<string, mixed> $overrides Caller overrides.219 */220 $settings = (array) apply_filters('smart_content_sync_woocommerce_settings_basic', $settings, $overrides);221 222 if (!empty($overrides)) {223 $settings = self::mergeDeep($settings, $overrides);224 }225 226 return $settings;227 }228 229 /**230 * Build an extended WooCommerce settings array suitable for script localization.231 *232 * This includes currency formatting details and (optionally) Store API nonce.233 * Use this only for admin UIs or frontend UIs that explicitly need these values.234 *235 * @param array<string, mixed> $overrides Optional overrides merged into the base settings.236 * @return array<string, mixed>237 */238 public static function buildWooCommerceSettingsExtended(array $overrides = []): array239 {240 $active = self::isWooCommerceActive();241 $installed = self::isWooCommerceInstalled();242 243 193 // Start from the minimal base. 244 $settings = self::buildWooCommerceSettingsBasic(); 194 // DO NOT pass the overrides here because: 195 // 1- The filter below may override it. So, wait until just before return, and do a deep merge. 196 // 2- We want to keep the basic payload stable and filterable on its own. 197 $settings = self::buildWooCommerceClientConfig(); 245 198 246 199 if (!$active) { … … 251 204 * @param array<string, mixed> $overrides Caller overrides. 252 205 */ 253 $settings = (array) apply_filters('smart_content_sync_woocommerce_ settings_extended', $settings, $overrides);206 $settings = (array) apply_filters('smart_content_sync_woocommerce_client_config_extended', $settings, $overrides); 254 207 255 208 if (!empty($overrides)) { … … 288 241 * @param array<string, mixed> $overrides Caller overrides. 289 242 */ 290 $settings = (array) apply_filters('smart_content_sync_woocommerce_ settings_extended', $settings, $overrides);243 $settings = (array) apply_filters('smart_content_sync_woocommerce_client_config_extended', $settings, $overrides); 291 244 292 245 if (!empty($overrides)) { … … 304 257 * Back-compat alias. 305 258 * 306 * If existing call-sites already use buildWooCommerceSettings(), keep it working 307 * but return the BASIC payload by default (lean and safe). 259 * Builds the WooCommerce config payload. Use buildWooCommerceClientConfigExtended() if you need the extra any of the following: 260 * - currencySymbol 261 * - decimals 262 * - decimalSeparator 263 * - thousandSeparator 264 * - priceFormat. 308 265 * 309 266 * @param array<string, mixed> $overrides Optional overrides. 310 267 * @return array<string, mixed> 311 268 */ 312 public static function buildWooCommerceSettings(array $overrides = []): array 313 { 314 $settings = self::buildWooCommerceSettingsBasic($overrides); 315 316 /** 317 * Filter the WooCommerce settings array (legacy alias). 318 * 319 * @param array<string, mixed> $settings Settings (basic by default). 320 * @param array<string, mixed> $overrides Caller overrides. 321 */ 322 return (array) apply_filters('smart_content_sync_woocommerce_settings', $settings, $overrides); 269 public static function buildWooCommerceClientConfig(array $overrides = []): array 270 { 271 $active = self::isWooCommerceActive(); 272 $installed = self::isWooCommerceInstalled(); 273 274 $config = [ 275 'active' => $active, 276 'installed' => $installed, 277 'isSingleProduct' => $active ? self::isSingleProductPage() : false, 278 'isWooRest' => $active ? self::isWooCommerceRestRequest() : false, 279 'currentProductId' => $active ? self::getCurrentProductId() : null, 280 'currency' => ($active && function_exists('get_woocommerce_currency')) ? (string) get_woocommerce_currency() : '', 281 'urls' => [ 282 'shop' => ($active && function_exists('wc_get_page_permalink')) ? (string) wc_get_page_permalink('shop') : '', 283 ], 284 ]; 285 286 if (!empty($overrides)) { 287 $config = self::mergeDeep($config, $overrides); 288 } 289 290 return $config; 323 291 } 324 292 -
smart-content-sync/tags/1.0.1/src/Infrastructure/Platform/WordPress/WordPressHelper.php
r3454742 r3487719 107 107 * 108 108 * Intended use: 109 * - wp_localize_script(..., 'smartContentSyncWp', WordPressHelper::buildWordPress Settings(...))109 * - wp_localize_script(..., 'smartContentSyncWp', WordPressHelper::buildWordPressClientConfig(...)) 110 110 * - or wp_add_inline_script with JSON. 111 111 * … … 118 118 * @return array<string, mixed> 119 119 */ 120 public static function buildWordPress Settings(array $overrides = []): array120 public static function buildWordPressClientConfig(array $overrides = []): array 121 121 { 122 122 $locale = self::resolveLocale(); … … 157 157 'canManageOptions' => function_exists('current_user_can') ? (bool) current_user_can('manage_options') : false, 158 158 ], 159 160 // Feature switches / flags you may want client-side.161 // Keep these additive and conservative for v1.162 'features' => [],163 159 ]; 164 165 /**166 * Filter the base WordPress settings array.167 *168 * @param array<string, mixed> $settings Base settings.169 * @param array<string, mixed> $overrides Caller overrides.170 */171 $settings = (array) apply_filters('smart_content_sync_wordpress_settings', $settings, $overrides);172 160 173 161 if (!empty($overrides)) { -
smart-content-sync/tags/1.0.1/src/Plugin.php
r3454742 r3487719 13 13 use AndalePlugins\SmartContentSync\ContentBlocks\Renderer\RenderingGateway; 14 14 use AndalePlugins\SmartContentSync\ContentBlocks\SmartContentCustomPostType; 15 use AndalePlugins\SmartContentSync\Infrastructure\Client\ClientConfigBuilder; 15 16 use AndalePlugins\SmartContentSync\Domains\AutoInsert\Services\AutoInsertIndex; 16 17 use AndalePlugins\SmartContentSync\Domains\AutoInsert\Services\AutoInsertManager; … … 141 142 public function localizeAdminScripts(): void 142 143 { 143 $data = [ 144 'ajaxUrl' => admin_url('admin-ajax.php'), 145 'nonce' => wp_create_nonce('smart_content_sync_admin_nonce'), 146 'wordPress' => WordPressHelper::buildWordPressSettings(), 147 'wooCommerce' => WooCommerceHelper::buildWooCommerceSettings(), 144 // $data = [ 145 // 'ajaxUrl' => admin_url('admin-ajax.php'), 146 // 'nonce' => wp_create_nonce('smart_content_sync_admin_nonce'), 147 // 'wordPress' => WordPressHelper::buildWordPressClientConfig(), 148 // 'wooCommerce' => WooCommerceHelper::buildWooCommerceClientConfig(), 149 // 'localization' => $this->buildLocalizationPayload(), 150 // ]; 151 // wp_localize_script( 152 // 'smart-content-sync-admin-script', 153 // 'smartContentSyncAdminData', 154 // $data 155 // ); 156 157 $data = ClientConfigBuilder::buildAdminClientConfig([ 158 // This stays here because it is plugin-owned localization, 159 // not platform context. 148 160 'localization' => $this->buildLocalizationPayload(), 149 ]; 161 ]); 162 150 163 wp_localize_script( 151 164 'smart-content-sync-admin-script', -
smart-content-sync/tags/1.0.1/vendor/autoload.php
r3454742 r3487719 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit 15c4633b3346ac34866474b910a7bcfb::getLoader();25 return ComposerAutoloaderInit645f9213d6e358ccf3bfe148e9b7f768::getLoader(); -
smart-content-sync/tags/1.0.1/vendor/composer/autoload_classmap.php
r3454742 r3487719 33 33 'AndalePlugins\\SmartContentSync\\Infrastructure\\Admin\\Settings\\Sections\\UninstallSettingsSection' => $baseDir . '/src/Infrastructure/Admin/Settings/Sections/UninstallSettingsSection.php', 34 34 'AndalePlugins\\SmartContentSync\\Infrastructure\\Admin\\Settings\\SettingsManager' => $baseDir . '/src/Infrastructure/Admin/Settings/SettingsManager.php', 35 'AndalePlugins\\SmartContentSync\\Infrastructure\\Client\\ClientConfigBuilder' => $baseDir . '/src/Infrastructure/Client/ClientConfigBuilder.php', 35 36 'AndalePlugins\\SmartContentSync\\Infrastructure\\Platform\\WooCommerce\\WooCommerceHelper' => $baseDir . '/src/Infrastructure/Platform/WooCommerce/WooCommerceHelper.php', 36 37 'AndalePlugins\\SmartContentSync\\Infrastructure\\Platform\\WordPress\\WordPressHelper' => $baseDir . '/src/Infrastructure/Platform/WordPress/WordPressHelper.php', -
smart-content-sync/tags/1.0.1/vendor/composer/autoload_real.php
r3454742 r3487719 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 15c4633b3346ac34866474b910a7bcfb5 class ComposerAutoloaderInit645f9213d6e358ccf3bfe148e9b7f768 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit 15c4633b3346ac34866474b910a7bcfb', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInit645f9213d6e358ccf3bfe148e9b7f768', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit 15c4633b3346ac34866474b910a7bcfb', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInit645f9213d6e358ccf3bfe148e9b7f768', 'loadClassLoader')); 28 28 29 29 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit 15c4633b3346ac34866474b910a7bcfb::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInit645f9213d6e358ccf3bfe148e9b7f768::getInitializer($loader)); 31 31 32 32 $loader->register(true); -
smart-content-sync/tags/1.0.1/vendor/composer/autoload_static.php
r3454742 r3487719 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 15c4633b3346ac34866474b910a7bcfb7 class ComposerStaticInit645f9213d6e358ccf3bfe148e9b7f768 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 48 48 'AndalePlugins\\SmartContentSync\\Infrastructure\\Admin\\Settings\\Sections\\UninstallSettingsSection' => __DIR__ . '/../..' . '/src/Infrastructure/Admin/Settings/Sections/UninstallSettingsSection.php', 49 49 'AndalePlugins\\SmartContentSync\\Infrastructure\\Admin\\Settings\\SettingsManager' => __DIR__ . '/../..' . '/src/Infrastructure/Admin/Settings/SettingsManager.php', 50 'AndalePlugins\\SmartContentSync\\Infrastructure\\Client\\ClientConfigBuilder' => __DIR__ . '/../..' . '/src/Infrastructure/Client/ClientConfigBuilder.php', 50 51 'AndalePlugins\\SmartContentSync\\Infrastructure\\Platform\\WooCommerce\\WooCommerceHelper' => __DIR__ . '/../..' . '/src/Infrastructure/Platform/WooCommerce/WooCommerceHelper.php', 51 52 'AndalePlugins\\SmartContentSync\\Infrastructure\\Platform\\WordPress\\WordPressHelper' => __DIR__ . '/../..' . '/src/Infrastructure/Platform/WordPress/WordPressHelper.php', … … 60 61 { 61 62 return \Closure::bind(function () use ($loader) { 62 $loader->prefixLengthsPsr4 = ComposerStaticInit 15c4633b3346ac34866474b910a7bcfb::$prefixLengthsPsr4;63 $loader->prefixDirsPsr4 = ComposerStaticInit 15c4633b3346ac34866474b910a7bcfb::$prefixDirsPsr4;64 $loader->classMap = ComposerStaticInit 15c4633b3346ac34866474b910a7bcfb::$classMap;63 $loader->prefixLengthsPsr4 = ComposerStaticInit645f9213d6e358ccf3bfe148e9b7f768::$prefixLengthsPsr4; 64 $loader->prefixDirsPsr4 = ComposerStaticInit645f9213d6e358ccf3bfe148e9b7f768::$prefixDirsPsr4; 65 $loader->classMap = ComposerStaticInit645f9213d6e358ccf3bfe148e9b7f768::$classMap; 65 66 66 67 }, null, ClassLoader::class); -
smart-content-sync/trunk/composer.json
r3454742 r3487719 21 21 "require-dev": { 22 22 "php-stubs/wordpress-stubs": "dev-master", 23 "php-stubs/woocommerce-stubs": "^3.8" 23 "php-stubs/woocommerce-stubs": "^3.8", 24 "wp-cli/wp-cli": "^2.13@dev" 24 25 } 25 26 } -
smart-content-sync/trunk/readme.txt
r3454742 r3487719 5 5 Requires at least: 5.8 6 6 Tested up to: 6.9 7 Stable tag: 1.0. 07 Stable tag: 1.0.1 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 140 140 141 141 == Changelog == 142 = 1.0.1 = 143 * Added support for the renamed Gutenberg block registration and migration from the previous block name 144 * Refined SEO integration and editor detection behavior for analysis previews 145 * Added extensibility hooks for settings sections and improved admin/client configuration plumbing 146 * Updated compatibility metadata and release packaging details 147 142 148 = 1.0.0 = 143 149 * Initial stable release -
smart-content-sync/trunk/smart-content-sync.php
r3454742 r3487719 4 4 * Plugin Name: Smart Content Sync 5 5 * Description: Stop Copy-Pasting. Create Once. Sync Everywhere. 6 * Version: 1.0. 06 * Version: 1.0.1 7 7 * Author: Andale Plugins 8 8 * Author: Andale Technologies, SARL … … 32 32 define('SMART_CONTENT_SYNC_DIST_URL', plugin_dir_url(__FILE__) . 'dist/'); 33 33 define('SMART_CONTENT_SYNC_BASENAME', plugin_basename(__FILE__)); 34 define('SMART_CONTENT_SYNC_VERSION', '1.0. 0');34 define('SMART_CONTENT_SYNC_VERSION', '1.0.1'); 35 35 36 36 // Initialize the plugin -
smart-content-sync/trunk/src/ContentBlocks/Renderer/ContextBuilder.php
r3454742 r3487719 33 33 // Post-related context (this block) 34 34 if ($smartContentPost instanceof WP_Post) { 35 $postAuthorName = ''; 36 $postAuthorId = (int) $smartContentPost->post_author; 37 if ($postAuthorId > 0) { 38 $author = get_userdata($postAuthorId); 39 if ($author instanceof \WP_User) { 40 $postAuthorName = $author->display_name; 41 } 42 } 43 35 44 $context['post'] = [ 36 45 'id' => $smartContentPost->ID, … … 39 48 'excerpt' => $smartContentPost->post_excerpt, 40 49 'url' => get_permalink($smartContentPost), 41 'type' => $smartContentPost->post_type, // add this 50 'type' => $smartContentPost->post_type, 51 'date' => get_the_date('', $smartContentPost), 52 'author' => $postAuthorName, 53 'categories' => $this->getJoinedTermNames($smartContentPost->ID, 'category'), 42 54 ]; 43 55 … … 107 119 'stock_quantity' => $stockQty, 108 120 'is_on_sale' => $isOnSale ? 'yes' : 'no', 121 'categories' => ($id ? $this->getJoinedTermNames((int) $id, 'product_cat') : ''), 122 'tags' => ($id ? $this->getJoinedTermNames((int) $id, 'product_tag') : ''), 109 123 ]; 110 124 } … … 182 196 return $flat; 183 197 } 198 199 /** 200 * Return a comma-separated list of term names for a given object/taxonomy pair. 201 * 202 * @param int $objectId 203 * @param string $taxonomy 204 * @return string 205 */ 206 protected function getJoinedTermNames(int $objectId, string $taxonomy): string 207 { 208 if ($objectId <= 0 || $taxonomy === '') { 209 return ''; 210 } 211 212 $terms = get_the_terms($objectId, $taxonomy); 213 if (is_wp_error($terms) || !is_array($terms) || empty($terms)) { 214 return ''; 215 } 216 217 $names = []; 218 foreach ($terms as $term) { 219 if ($term instanceof \WP_Term && $term->name !== '') { 220 $names[] = $term->name; 221 } 222 } 223 224 return implode(', ', $names); 225 } 184 226 } -
smart-content-sync/trunk/src/ContentBlocks/SmartContentCustomPostType.php
r3454742 r3487719 35 35 'labels' => $labels, 36 36 'public' => false, 37 // 'publicly_queryable' => true, // needed for REST API access 37 38 'show_ui' => true, 38 39 'show_in_menu' => true, -
smart-content-sync/trunk/src/Domains/AutoInsert/Storage/AutoInsertMetaBox.php
r3454742 r3487719 153 153 echo '</p>'; 154 154 155 do_action('smart_content_sync_auto_insert_metabox_before_locations', $post, [ 156 'enabled' => $enabled, 157 'locations' => $locations, 158 ]); 159 155 160 // Default open group: WooCommerce (if active), otherwise WordPress. 156 161 $defaultOpenGroup = $isWooCommerceActive ? 'WooCommerce' : 'WordPress'; … … 242 247 } 243 248 249 do_action('smart_content_sync_auto_insert_metabox_after_locations', $post, [ 250 'enabled' => $enabled, 251 'locations' => $locations, 252 ]); 253 244 254 echo '</div>'; 245 255 } … … 304 314 $clean = array_values(array_unique($clean)); 305 315 update_post_meta($postId, self::META_LOCATIONS, $clean); 316 317 do_action('smart_content_sync_auto_insert_metabox_save', $postId, $post, [ 318 'enabled' => $enabled, // '1'|'0' as stored 319 'locations' => $clean, // validated array 320 ]); 306 321 } 307 322 } -
smart-content-sync/trunk/src/Infrastructure/Admin/Settings/SettingsManager.php
r3454742 r3487719 119 119 private function getSections(): array 120 120 { 121 return[121 $sections = [ 122 122 new UninstallSettingsSection($this), 123 123 ]; 124 125 /** 126 * Allow extensions (e.g. Pro plugin) to add settings sections. 127 * 128 * @param array<int, object> $sections 129 * @param SettingsManager $manager 130 */ 131 $sections = (array) apply_filters('smart_content_sync_settings_sections', $sections, $this); 132 133 return $sections; 124 134 } 125 135 -
smart-content-sync/trunk/src/Infrastructure/Platform/WooCommerce/WooCommerceHelper.php
r3454742 r3487719 14 14 * 15 15 * Notes on payload size: 16 * - Use buildWooCommerce SettingsBasic() for most SmartContentSync needs.17 * - Use buildWooCommerce SettingsExtended() only when you truly need currency formatting16 * - Use buildWooCommerceClientConfig() for most SmartContentSync needs. 17 * - Use buildWooCommerceClientConfigExtended() only when you truly need currency formatting 18 18 * or Store API nonce data. 19 19 * … … 178 178 179 179 /** 180 * Build a minimal WooCommerce settings array suitable for script localization. 181 * 182 * This is the recommended method for SmartContentSync: it exposes only what you 183 * typically need client-side (presence + basic context), and nothing expensive. 184 * 185 * Intended use: 186 * - wp_localize_script(..., 'smartContentSyncWoo', WooCommerceHelper::buildWooCommerceSettingsBasic()) 180 * Build an extended WooCommerce settings array suitable for script localization. 181 * 182 * This includes currency formatting details and (optionally) Store API nonce. 183 * Use this only for admin UIs or frontend UIs that explicitly need these values. 187 184 * 188 185 * @param array<string, mixed> $overrides Optional overrides merged into the base settings. 189 186 * @return array<string, mixed> 190 187 */ 191 public static function buildWooCommerce SettingsBasic(array $overrides = []): array188 public static function buildWooCommerceClientConfigExtended(array $overrides = []): array 192 189 { 193 190 $active = self::isWooCommerceActive(); 194 191 $installed = self::isWooCommerceInstalled(); 195 192 196 $settings = [197 'active' => $active,198 'installed' => $installed,199 'isSingleProduct' => $active ? self::isSingleProductPage() : false,200 'isWooRest' => $active ? self::isWooCommerceRestRequest() : false,201 'currentProductId' => $active ? self::getCurrentProductId() : null,202 203 // Currency code is small and commonly useful for UI labels.204 'currency' => ($active && function_exists('get_woocommerce_currency')) ? (string) get_woocommerce_currency() : '',205 206 // Keep URLs minimal; add more only when a concrete UI needs them.207 'urls' => [208 'shop' => ($active && function_exists('wc_get_page_permalink')) ? (string) wc_get_page_permalink('shop') : '',209 ],210 211 'features' => [],212 ];213 214 /**215 * Filter the basic WooCommerce settings array.216 *217 * @param array<string, mixed> $settings Base settings.218 * @param array<string, mixed> $overrides Caller overrides.219 */220 $settings = (array) apply_filters('smart_content_sync_woocommerce_settings_basic', $settings, $overrides);221 222 if (!empty($overrides)) {223 $settings = self::mergeDeep($settings, $overrides);224 }225 226 return $settings;227 }228 229 /**230 * Build an extended WooCommerce settings array suitable for script localization.231 *232 * This includes currency formatting details and (optionally) Store API nonce.233 * Use this only for admin UIs or frontend UIs that explicitly need these values.234 *235 * @param array<string, mixed> $overrides Optional overrides merged into the base settings.236 * @return array<string, mixed>237 */238 public static function buildWooCommerceSettingsExtended(array $overrides = []): array239 {240 $active = self::isWooCommerceActive();241 $installed = self::isWooCommerceInstalled();242 243 193 // Start from the minimal base. 244 $settings = self::buildWooCommerceSettingsBasic(); 194 // DO NOT pass the overrides here because: 195 // 1- The filter below may override it. So, wait until just before return, and do a deep merge. 196 // 2- We want to keep the basic payload stable and filterable on its own. 197 $settings = self::buildWooCommerceClientConfig(); 245 198 246 199 if (!$active) { … … 251 204 * @param array<string, mixed> $overrides Caller overrides. 252 205 */ 253 $settings = (array) apply_filters('smart_content_sync_woocommerce_ settings_extended', $settings, $overrides);206 $settings = (array) apply_filters('smart_content_sync_woocommerce_client_config_extended', $settings, $overrides); 254 207 255 208 if (!empty($overrides)) { … … 288 241 * @param array<string, mixed> $overrides Caller overrides. 289 242 */ 290 $settings = (array) apply_filters('smart_content_sync_woocommerce_ settings_extended', $settings, $overrides);243 $settings = (array) apply_filters('smart_content_sync_woocommerce_client_config_extended', $settings, $overrides); 291 244 292 245 if (!empty($overrides)) { … … 304 257 * Back-compat alias. 305 258 * 306 * If existing call-sites already use buildWooCommerceSettings(), keep it working 307 * but return the BASIC payload by default (lean and safe). 259 * Builds the WooCommerce config payload. Use buildWooCommerceClientConfigExtended() if you need the extra any of the following: 260 * - currencySymbol 261 * - decimals 262 * - decimalSeparator 263 * - thousandSeparator 264 * - priceFormat. 308 265 * 309 266 * @param array<string, mixed> $overrides Optional overrides. 310 267 * @return array<string, mixed> 311 268 */ 312 public static function buildWooCommerceSettings(array $overrides = []): array 313 { 314 $settings = self::buildWooCommerceSettingsBasic($overrides); 315 316 /** 317 * Filter the WooCommerce settings array (legacy alias). 318 * 319 * @param array<string, mixed> $settings Settings (basic by default). 320 * @param array<string, mixed> $overrides Caller overrides. 321 */ 322 return (array) apply_filters('smart_content_sync_woocommerce_settings', $settings, $overrides); 269 public static function buildWooCommerceClientConfig(array $overrides = []): array 270 { 271 $active = self::isWooCommerceActive(); 272 $installed = self::isWooCommerceInstalled(); 273 274 $config = [ 275 'active' => $active, 276 'installed' => $installed, 277 'isSingleProduct' => $active ? self::isSingleProductPage() : false, 278 'isWooRest' => $active ? self::isWooCommerceRestRequest() : false, 279 'currentProductId' => $active ? self::getCurrentProductId() : null, 280 'currency' => ($active && function_exists('get_woocommerce_currency')) ? (string) get_woocommerce_currency() : '', 281 'urls' => [ 282 'shop' => ($active && function_exists('wc_get_page_permalink')) ? (string) wc_get_page_permalink('shop') : '', 283 ], 284 ]; 285 286 if (!empty($overrides)) { 287 $config = self::mergeDeep($config, $overrides); 288 } 289 290 return $config; 323 291 } 324 292 -
smart-content-sync/trunk/src/Infrastructure/Platform/WordPress/WordPressHelper.php
r3454742 r3487719 107 107 * 108 108 * Intended use: 109 * - wp_localize_script(..., 'smartContentSyncWp', WordPressHelper::buildWordPress Settings(...))109 * - wp_localize_script(..., 'smartContentSyncWp', WordPressHelper::buildWordPressClientConfig(...)) 110 110 * - or wp_add_inline_script with JSON. 111 111 * … … 118 118 * @return array<string, mixed> 119 119 */ 120 public static function buildWordPress Settings(array $overrides = []): array120 public static function buildWordPressClientConfig(array $overrides = []): array 121 121 { 122 122 $locale = self::resolveLocale(); … … 157 157 'canManageOptions' => function_exists('current_user_can') ? (bool) current_user_can('manage_options') : false, 158 158 ], 159 160 // Feature switches / flags you may want client-side.161 // Keep these additive and conservative for v1.162 'features' => [],163 159 ]; 164 165 /**166 * Filter the base WordPress settings array.167 *168 * @param array<string, mixed> $settings Base settings.169 * @param array<string, mixed> $overrides Caller overrides.170 */171 $settings = (array) apply_filters('smart_content_sync_wordpress_settings', $settings, $overrides);172 160 173 161 if (!empty($overrides)) { -
smart-content-sync/trunk/src/Plugin.php
r3454742 r3487719 13 13 use AndalePlugins\SmartContentSync\ContentBlocks\Renderer\RenderingGateway; 14 14 use AndalePlugins\SmartContentSync\ContentBlocks\SmartContentCustomPostType; 15 use AndalePlugins\SmartContentSync\Infrastructure\Client\ClientConfigBuilder; 15 16 use AndalePlugins\SmartContentSync\Domains\AutoInsert\Services\AutoInsertIndex; 16 17 use AndalePlugins\SmartContentSync\Domains\AutoInsert\Services\AutoInsertManager; … … 141 142 public function localizeAdminScripts(): void 142 143 { 143 $data = [ 144 'ajaxUrl' => admin_url('admin-ajax.php'), 145 'nonce' => wp_create_nonce('smart_content_sync_admin_nonce'), 146 'wordPress' => WordPressHelper::buildWordPressSettings(), 147 'wooCommerce' => WooCommerceHelper::buildWooCommerceSettings(), 144 // $data = [ 145 // 'ajaxUrl' => admin_url('admin-ajax.php'), 146 // 'nonce' => wp_create_nonce('smart_content_sync_admin_nonce'), 147 // 'wordPress' => WordPressHelper::buildWordPressClientConfig(), 148 // 'wooCommerce' => WooCommerceHelper::buildWooCommerceClientConfig(), 149 // 'localization' => $this->buildLocalizationPayload(), 150 // ]; 151 // wp_localize_script( 152 // 'smart-content-sync-admin-script', 153 // 'smartContentSyncAdminData', 154 // $data 155 // ); 156 157 $data = ClientConfigBuilder::buildAdminClientConfig([ 158 // This stays here because it is plugin-owned localization, 159 // not platform context. 148 160 'localization' => $this->buildLocalizationPayload(), 149 ]; 161 ]); 162 150 163 wp_localize_script( 151 164 'smart-content-sync-admin-script', -
smart-content-sync/trunk/vendor/autoload.php
r3454742 r3487719 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit 15c4633b3346ac34866474b910a7bcfb::getLoader();25 return ComposerAutoloaderInit645f9213d6e358ccf3bfe148e9b7f768::getLoader(); -
smart-content-sync/trunk/vendor/composer/autoload_classmap.php
r3454742 r3487719 33 33 'AndalePlugins\\SmartContentSync\\Infrastructure\\Admin\\Settings\\Sections\\UninstallSettingsSection' => $baseDir . '/src/Infrastructure/Admin/Settings/Sections/UninstallSettingsSection.php', 34 34 'AndalePlugins\\SmartContentSync\\Infrastructure\\Admin\\Settings\\SettingsManager' => $baseDir . '/src/Infrastructure/Admin/Settings/SettingsManager.php', 35 'AndalePlugins\\SmartContentSync\\Infrastructure\\Client\\ClientConfigBuilder' => $baseDir . '/src/Infrastructure/Client/ClientConfigBuilder.php', 35 36 'AndalePlugins\\SmartContentSync\\Infrastructure\\Platform\\WooCommerce\\WooCommerceHelper' => $baseDir . '/src/Infrastructure/Platform/WooCommerce/WooCommerceHelper.php', 36 37 'AndalePlugins\\SmartContentSync\\Infrastructure\\Platform\\WordPress\\WordPressHelper' => $baseDir . '/src/Infrastructure/Platform/WordPress/WordPressHelper.php', -
smart-content-sync/trunk/vendor/composer/autoload_real.php
r3454742 r3487719 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 15c4633b3346ac34866474b910a7bcfb5 class ComposerAutoloaderInit645f9213d6e358ccf3bfe148e9b7f768 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit 15c4633b3346ac34866474b910a7bcfb', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInit645f9213d6e358ccf3bfe148e9b7f768', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit 15c4633b3346ac34866474b910a7bcfb', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInit645f9213d6e358ccf3bfe148e9b7f768', 'loadClassLoader')); 28 28 29 29 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit 15c4633b3346ac34866474b910a7bcfb::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInit645f9213d6e358ccf3bfe148e9b7f768::getInitializer($loader)); 31 31 32 32 $loader->register(true); -
smart-content-sync/trunk/vendor/composer/autoload_static.php
r3454742 r3487719 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 15c4633b3346ac34866474b910a7bcfb7 class ComposerStaticInit645f9213d6e358ccf3bfe148e9b7f768 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 48 48 'AndalePlugins\\SmartContentSync\\Infrastructure\\Admin\\Settings\\Sections\\UninstallSettingsSection' => __DIR__ . '/../..' . '/src/Infrastructure/Admin/Settings/Sections/UninstallSettingsSection.php', 49 49 'AndalePlugins\\SmartContentSync\\Infrastructure\\Admin\\Settings\\SettingsManager' => __DIR__ . '/../..' . '/src/Infrastructure/Admin/Settings/SettingsManager.php', 50 'AndalePlugins\\SmartContentSync\\Infrastructure\\Client\\ClientConfigBuilder' => __DIR__ . '/../..' . '/src/Infrastructure/Client/ClientConfigBuilder.php', 50 51 'AndalePlugins\\SmartContentSync\\Infrastructure\\Platform\\WooCommerce\\WooCommerceHelper' => __DIR__ . '/../..' . '/src/Infrastructure/Platform/WooCommerce/WooCommerceHelper.php', 51 52 'AndalePlugins\\SmartContentSync\\Infrastructure\\Platform\\WordPress\\WordPressHelper' => __DIR__ . '/../..' . '/src/Infrastructure/Platform/WordPress/WordPressHelper.php', … … 60 61 { 61 62 return \Closure::bind(function () use ($loader) { 62 $loader->prefixLengthsPsr4 = ComposerStaticInit 15c4633b3346ac34866474b910a7bcfb::$prefixLengthsPsr4;63 $loader->prefixDirsPsr4 = ComposerStaticInit 15c4633b3346ac34866474b910a7bcfb::$prefixDirsPsr4;64 $loader->classMap = ComposerStaticInit 15c4633b3346ac34866474b910a7bcfb::$classMap;63 $loader->prefixLengthsPsr4 = ComposerStaticInit645f9213d6e358ccf3bfe148e9b7f768::$prefixLengthsPsr4; 64 $loader->prefixDirsPsr4 = ComposerStaticInit645f9213d6e358ccf3bfe148e9b7f768::$prefixDirsPsr4; 65 $loader->classMap = ComposerStaticInit645f9213d6e358ccf3bfe148e9b7f768::$classMap; 65 66 66 67 }, null, ClassLoader::class);
Note: See TracChangeset
for help on using the changeset viewer.