Changeset 3775162
- Timestamp:
- 10/30/2026 12:00:06 PM (33 hours ago)
- Location:
- swiftsearch-for-algolia
- Files:
-
- 55 added
- 13 edited
-
tags/1.0.2 (added)
-
tags/1.0.2/CHANGELOG.md (added)
-
tags/1.0.2/assets (added)
-
tags/1.0.2/assets/css (added)
-
tags/1.0.2/assets/css/admin.css (added)
-
tags/1.0.2/assets/css/search.css (added)
-
tags/1.0.2/assets/fonts (added)
-
tags/1.0.2/assets/images (added)
-
tags/1.0.2/assets/images/loopstates.png (added)
-
tags/1.0.2/assets/images/menu-icon.png (added)
-
tags/1.0.2/assets/images/swift-search-algolia-version-2.png (added)
-
tags/1.0.2/assets/images/swift-search-algolia.png (added)
-
tags/1.0.2/assets/js (added)
-
tags/1.0.2/assets/js/admin.js (added)
-
tags/1.0.2/assets/js/search.js (added)
-
tags/1.0.2/assets/vendor (added)
-
tags/1.0.2/assets/vendor/algoliasearch-lite.js (added)
-
tags/1.0.2/assets/vendor/chart.js (added)
-
tags/1.0.2/languages (added)
-
tags/1.0.2/readme.txt (added)
-
tags/1.0.2/src (added)
-
tags/1.0.2/src/Admin (added)
-
tags/1.0.2/src/Admin/AdminController.php (added)
-
tags/1.0.2/src/Api (added)
-
tags/1.0.2/src/Api/RestController.php (added)
-
tags/1.0.2/src/CLI (added)
-
tags/1.0.2/src/CLI/IndexCommand.php (added)
-
tags/1.0.2/src/Client (added)
-
tags/1.0.2/src/Client/Client.php (added)
-
tags/1.0.2/src/Core (added)
-
tags/1.0.2/src/Core/Autoloader.php (added)
-
tags/1.0.2/src/Core/Cron.php (added)
-
tags/1.0.2/src/Core/DB.php (added)
-
tags/1.0.2/src/Core/Gatekeeper.php (added)
-
tags/1.0.2/src/Core/Plugin.php (added)
-
tags/1.0.2/src/Core/SettingsIntegrity.php (added)
-
tags/1.0.2/src/Engine (added)
-
tags/1.0.2/src/Engine/BackgroundIndexer.php (added)
-
tags/1.0.2/src/Engine/BackgroundProcess.php (added)
-
tags/1.0.2/src/Engine/ConfigLoader.php (added)
-
tags/1.0.2/src/Engine/DocumentBuilder.php (added)
-
tags/1.0.2/src/Engine/EngineController.php (added)
-
tags/1.0.2/src/Engine/Indexer.php (added)
-
tags/1.0.2/src/Engine/Schema.php (added)
-
tags/1.0.2/src/Engine/TermIndexer.php (added)
-
tags/1.0.2/src/Engine/UserIndexer.php (added)
-
tags/1.0.2/src/Frontend (added)
-
tags/1.0.2/src/Frontend/SearchController.php (added)
-
tags/1.0.2/src/Integrations (added)
-
tags/1.0.2/src/Integrations/IntegrationManager.php (added)
-
tags/1.0.2/swift-search-algolia.php (added)
-
tags/1.0.2/templates (added)
-
tags/1.0.2/templates/admin (added)
-
tags/1.0.2/templates/admin/app.php (added)
-
tags/1.0.2/uninstall.php (added)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Admin/AdminController.php (modified) (2 diffs)
-
trunk/src/Api/RestController.php (modified) (5 diffs)
-
trunk/src/CLI/IndexCommand.php (modified) (2 diffs)
-
trunk/src/Engine/BackgroundIndexer.php (modified) (1 diff)
-
trunk/src/Engine/ConfigLoader.php (modified) (2 diffs)
-
trunk/src/Engine/DocumentBuilder.php (modified) (1 diff)
-
trunk/src/Engine/Indexer.php (modified) (4 diffs)
-
trunk/src/Engine/Schema.php (modified) (1 diff)
-
trunk/src/Engine/TermIndexer.php (modified) (3 diffs)
-
trunk/src/Frontend/SearchController.php (modified) (2 diffs)
-
trunk/swift-search-algolia.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
swiftsearch-for-algolia/trunk/CHANGELOG.md
r3725773 r3775162 5 5 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 6 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 8 ## [1.0.2] - 2026-10-30 9 10 ### Added 11 - **WooCommerce HPOS Compatibility**: Declared official compatibility with WooCommerce High-Performance Order Storage (`custom_order_tables`) and Cart/Checkout Blocks (`cart_checkout_blocks`). 12 - **Extensibility Hooks**: Added `swift_search_algolia_term_document`, `swift_search_algolia_default_post_types`, `swift_search_algolia_default_taxonomies`, and `swift_search_algolia_default_sort_options` filter hooks. 13 14 ### Enhanced 15 - **Administrative Query Hygiene**: Applied `'suppress_filters' => true` to all bulk indexing queries in WP-CLI, Background Indexer, and REST API controllers to ensure smooth database queries alongside multilingual plugins (Polylang, WPML) and custom query interceptors. 16 - **Centralized Safe Defaults**: Unified default post type, taxonomy, and replica sort definitions into `ConfigLoader` as a single source of truth with automatic WooCommerce detection. 17 - **Algolia Replica Quota Optimization**: Avoided generating unnecessary price-sorting replica indices on standard content sites without WooCommerce. 18 19 ### Fixed 20 - **Defensive Option Management**: Added defensive typing during connection testing to ensure settings are preserved safely without data loss. 7 21 8 22 ## [1.0.1] - 2026-09-25 -
swiftsearch-for-algolia/trunk/readme.txt
r3725773 r3775162 3 3 Tags: algolia, woocommerce search, instant search, autocomplete, facets 4 4 Requires at least: 5.8 5 Tested up to: 7.1 6 Stable tag: 1.0. 15 Tested up to: 7.1.4 6 Stable tag: 1.0.2 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 225 225 == Changelog == 226 226 227 = 1.0.2 = 228 * Enhancement: Declared full compatibility with WooCommerce High-Performance Order Storage (HPOS) and cart/checkout blocks. 229 * Enhancement: Centralized default post types and taxonomies with WooCommerce detection and developer filter hooks. 230 * Enhancement: Isolated administrative batch indexing queries (`suppress_filters => true`) across WP-CLI, background workers, and REST endpoints for full compatibility with multilingual plugins (Polylang, WPML). 231 * Enhancement: Added `swift_search_algolia_term_document` filter hook for custom taxonomy term transformations. 232 * Optimization: Made sorting replica indices WooCommerce-aware to conserve Algolia index quotas on standard content sites. 233 * Fix: Ensured defensive option management during connection tests to preserve existing configuration. 234 227 235 = 1.0.1 = 228 236 * Fix: Defer recurring cron event scheduling to the init action to prevent early translation loading notices in WordPress 6.7+. -
swiftsearch-for-algolia/trunk/src/Admin/AdminController.php
r3725773 r3775162 4 4 use SwiftSearchAlgolia\Core\Gatekeeper; 5 5 use SwiftSearchAlgolia\Client\Client; 6 use SwiftSearchAlgolia\Engine\ConfigLoader; 6 7 7 8 if (!defined('ABSPATH')) { … … 119 120 'search_key' => $settings['search_api_key'] ?? ($settings['search_key'] ?? ''), 120 121 ), 121 'indexed_post_types' => isset($settings['indexed_post_types']) ? $settings['indexed_post_types'] : array('product', 'post', 'page'),122 'indexed_taxonomies' => isset($settings['indexed_taxonomies']) ? $settings['indexed_taxonomies'] : array('category', 'post_tag', 'product_cat'),122 'indexed_post_types' => isset($settings['indexed_post_types']) ? $settings['indexed_post_types'] : ConfigLoader::get_default_post_types(), 123 'indexed_taxonomies' => isset($settings['indexed_taxonomies']) ? $settings['indexed_taxonomies'] : ConfigLoader::get_default_taxonomies(), 123 124 'indexed_users' => isset($settings['indexed_users']) ? (bool) $settings['indexed_users'] : false, 124 125 'custom_fields' => isset($settings['custom_fields']) ? $settings['custom_fields'] : array(), -
swiftsearch-for-algolia/trunk/src/Api/RestController.php
r3725773 r3775162 167 167 168 168 $existing_settings = get_option('swift_search_algolia_settings', array()); 169 if (!is_array($existing_settings)) { 170 $existing_settings = array(); 171 } 169 172 $config = array_merge($existing_settings, array( 170 173 'app_id' => $app_id, … … 322 325 323 326 if ($type === 'terms') { 324 $taxonomies = isset($config['indexed_taxonomies']) ? $config['indexed_taxonomies'] : array('category', 'post_tag');327 $taxonomies = isset($config['indexed_taxonomies']) ? $config['indexed_taxonomies'] : ConfigLoader::get_default_taxonomies(); 325 328 326 329 if (empty($taxonomies)) { … … 332 335 333 336 $args = array( 334 'taxonomy' => $taxonomies, 335 'hide_empty' => false, 336 'number' => $per_page, 337 'offset' => $offset, 338 'fields' => 'ids', 337 'taxonomy' => $taxonomies, 338 'hide_empty' => false, 339 'number' => $per_page, 340 'offset' => $offset, 341 'fields' => 'ids', 342 'suppress_filters' => true, 339 343 ); 340 344 … … 419 423 } else { 420 424 // Posts (Default) 421 $post_types = isset($config['indexed_post_types']) ? $config['indexed_post_types'] : array('post', 'page', 'product');425 $post_types = isset($config['indexed_post_types']) ? $config['indexed_post_types'] : ConfigLoader::get_default_post_types(); 422 426 423 427 $args = array( 424 'post_type' => $post_types, 425 'post_status' => 'publish', 426 'posts_per_page' => $per_page, 427 'paged' => $page, 428 'fields' => 'ids', 429 'orderby' => 'ID', 430 'order' => 'ASC', 428 'post_type' => $post_types, 429 'post_status' => 'publish', 430 'posts_per_page' => $per_page, 431 'paged' => $page, 432 'fields' => 'ids', 433 'orderby' => 'ID', 434 'order' => 'ASC', 435 'suppress_filters' => true, 431 436 ); 432 437 … … 853 858 854 859 $args = array( 855 'post_type' => array('product', 'post', 'page'), 856 'post_status' => 'publish', 857 's' => $term, 858 'posts_per_page' => 10, 860 'post_type' => ConfigLoader::get_default_post_types(), 861 'post_status' => 'publish', 862 's' => $term, 863 'posts_per_page' => 10, 864 'suppress_filters' => true, 859 865 ); 860 866 -
swiftsearch-for-algolia/trunk/src/CLI/IndexCommand.php
r3725773 r3775162 53 53 $config = $config_loader->get_config(); 54 54 55 $post_types = isset($config['indexed_post_types']) ? (array) $config['indexed_post_types'] : array('product', 'post', 'page');55 $post_types = isset($config['indexed_post_types']) ? (array) $config['indexed_post_types'] : ConfigLoader::get_default_post_types(); 56 56 57 57 WP_CLI::line('Querying post IDs to index...'); … … 59 59 60 60 $query_args = array( 61 'post_type' => $post_types, 62 'post_status' => 'publish', 63 'fields' => 'ids', 64 'posts_per_page' => -1, 61 'post_type' => $post_types, 62 'post_status' => 'publish', 63 'fields' => 'ids', 64 'posts_per_page' => -1, 65 'suppress_filters' => true, 65 66 ); 66 67 -
swiftsearch-for-algolia/trunk/src/Engine/BackgroundIndexer.php
r3725773 r3775162 50 50 51 51 $args = array( 52 'post_type' => 'any', // Or configured types 53 'post_status' => 'publish', 54 'posts_per_page' => self::BATCH_SIZE, 55 'offset' => $offset, 56 'fields' => 'ids', 57 'orderby' => 'ID', 58 'order' => 'ASC', 52 'post_type' => 'any', // Or configured types 53 'post_status' => 'publish', 54 'posts_per_page' => self::BATCH_SIZE, 55 'offset' => $offset, 56 'fields' => 'ids', 57 'orderby' => 'ID', 58 'order' => 'ASC', 59 'suppress_filters' => true, 59 60 ); 60 61 -
swiftsearch-for-algolia/trunk/src/Engine/ConfigLoader.php
r3725773 r3775162 14 14 class ConfigLoader 15 15 { 16 /** 17 * Centralized default post types. 18 * Core WordPress defaults to ['post', 'page']. Adds 'product' only if WooCommerce is active. 19 * 20 * @return array 21 */ 22 public static function get_default_post_types() 23 { 24 $defaults = array('post', 'page'); 25 if (class_exists('WooCommerce')) { 26 $defaults[] = 'product'; 27 } 28 return apply_filters('swift_search_algolia_default_post_types', $defaults); 29 } 30 31 /** 32 * Centralized default taxonomies. 33 * Core WordPress defaults to ['category', 'post_tag']. Adds 'product_cat' only if WooCommerce is active. 34 * 35 * @return array 36 */ 37 public static function get_default_taxonomies() 38 { 39 $defaults = array('category', 'post_tag'); 40 if (class_exists('WooCommerce')) { 41 $defaults[] = 'product_cat'; 42 } 43 return apply_filters('swift_search_algolia_default_taxonomies', $defaults); 44 } 45 46 /** 47 * Centralized default sort options. 48 * Core WordPress defaults to ['date_desc']. Adds 'price_asc' and 'price_desc' only if WooCommerce is active. 49 * 50 * @return array 51 */ 52 public static function get_default_sort_options() 53 { 54 $defaults = array('date_desc'); 55 if (class_exists('WooCommerce')) { 56 $defaults = array('price_asc', 'price_desc', 'date_desc'); 57 } 58 return apply_filters('swift_search_algolia_default_sort_options', $defaults); 59 } 60 16 61 /** 17 62 * Get the unified configuration. … … 37 82 'enable_facets' => true, 38 83 'show_algolia_badge' => true, 39 'indexed_post_types' => array('product', 'post', 'page'),40 'indexed_taxonomies' => array('category', 'post_tag', 'product_cat'),41 'sort_options' => array('price_asc', 'price_desc', 'date_desc'),84 'indexed_post_types' => self::get_default_post_types(), 85 'indexed_taxonomies' => self::get_default_taxonomies(), 86 'sort_options' => self::get_default_sort_options(), 42 87 'typo_tolerance' => true, 43 88 ); -
swiftsearch-for-algolia/trunk/src/Engine/DocumentBuilder.php
r3725773 r3775162 37 37 // 1. Strict Whitelist Check 38 38 $settings = get_option('swift_search_algolia_settings', array()); 39 $allowed_types = isset($settings['indexed_post_types']) ? (array) $settings['indexed_post_types'] : array('product', 'post', 'page');39 $allowed_types = isset($settings['indexed_post_types']) ? (array) $settings['indexed_post_types'] : ConfigLoader::get_default_post_types(); 40 40 41 41 if (!in_array($post->post_type, $allowed_types)) { -
swiftsearch-for-algolia/trunk/src/Engine/Indexer.php
r3725773 r3775162 79 79 80 80 // 2. Calculate Totals 81 $post_types = isset($config['indexed_post_types']) ? (array) $config['indexed_post_types'] : array('product', 'post', 'page');81 $post_types = isset($config['indexed_post_types']) ? (array) $config['indexed_post_types'] : ConfigLoader::get_default_post_types(); 82 82 83 83 $args = array( 84 'post_type' => $post_types, 85 'post_status' => 'publish', 86 'fields' => 'ids', 87 'posts_per_page' => -1, 84 'post_type' => $post_types, 85 'post_status' => 'publish', 86 'fields' => 'ids', 87 'posts_per_page' => -1, 88 'suppress_filters' => true, 88 89 ); 89 90 … … 122 123 { 123 124 $config = $this->config_loader->get_config(); 124 $post_types = isset($config['indexed_post_types']) ? (array) $config['indexed_post_types'] : array('product', 'post', 'page');125 $post_types = isset($config['indexed_post_types']) ? (array) $config['indexed_post_types'] : ConfigLoader::get_default_post_types(); 125 126 126 127 $args = array( 127 'post_type' => $post_types, 128 'post_status' => 'publish', 129 'fields' => 'ids', 130 'posts_per_page' => $limit, 131 'offset' => $offset, 132 'orderby' => 'ID', 133 'order' => 'ASC', 128 'post_type' => $post_types, 129 'post_status' => 'publish', 130 'fields' => 'ids', 131 'posts_per_page' => $limit, 132 'offset' => $offset, 133 'orderby' => 'ID', 134 'order' => 'ASC', 135 'suppress_filters' => true, 134 136 ); 135 137 … … 458 460 459 461 // 3. Configure replicas ranking 460 $sort_options = $config['sort_options'] ?? array('price_asc', 'price_desc', 'date_desc');462 $sort_options = $config['sort_options'] ?? ConfigLoader::get_default_sort_options(); 461 463 foreach ($sort_options as $sort_key) { 462 464 $replica_name = Schema::get_replica_index_name($base_index, $sort_key); … … 486 488 487 489 $config = $this->config_loader->get_config(); 488 $sort_options = $config['sort_options'] ?? array('price_asc', 'price_desc', 'date_desc');490 $sort_options = $config['sort_options'] ?? ConfigLoader::get_default_sort_options(); 489 491 foreach ($sort_options as $sort_key) { 490 492 $replica_name = Schema::get_replica_index_name($base_index, $sort_key); -
swiftsearch-for-algolia/trunk/src/Engine/Schema.php
r3725773 r3775162 112 112 $sort_options = isset($config['sort_options']) && is_array($config['sort_options']) 113 113 ? $config['sort_options'] 114 : array('price_asc', 'price_desc', 'date_desc');114 : ConfigLoader::get_default_sort_options(); 115 115 116 116 $replicas = array(); -
swiftsearch-for-algolia/trunk/src/Engine/TermIndexer.php
r3725773 r3775162 42 42 $allowed_taxonomies = isset($this->config['indexed_taxonomies']) 43 43 ? $this->config['indexed_taxonomies'] 44 : array('category', 'post_tag', 'product_cat');44 : ConfigLoader::get_default_taxonomies(); 45 45 46 46 if (!in_array($term->taxonomy, $allowed_taxonomies)) { … … 53 53 } 54 54 55 return a rray(55 return apply_filters('swift_search_algolia_term_document', array( 56 56 'objectID' => 'term_' . $term->term_id, 57 57 'id' => (string) $term->term_id, … … 62 62 'count' => (int) $term->count, 63 63 'url' => (string) $url, 64 ) ;64 ), $term); 65 65 } 66 66 } -
swiftsearch-for-algolia/trunk/src/Frontend/SearchController.php
r3725773 r3775162 4 4 5 5 use SwiftSearchAlgolia\Engine\Schema; 6 use SwiftSearchAlgolia\Engine\ConfigLoader; 6 7 use SwiftSearchAlgolia\Client\Client; 7 8 … … 114 115 'replicas' => $replicas, 115 116 'showAlgoliaBadge' => isset($settings['show_algolia_badge']) ? (bool) $settings['show_algolia_badge'] : true, 116 'indexed_taxonomies' => isset($settings['indexed_taxonomies']) ? $settings['indexed_taxonomies'] : array(), 117 'indexed_post_types' => isset($settings['indexed_post_types']) ? $settings['indexed_post_types'] : ConfigLoader::get_default_post_types(), 118 'indexed_taxonomies' => isset($settings['indexed_taxonomies']) ? $settings['indexed_taxonomies'] : ConfigLoader::get_default_taxonomies(), 117 119 'indexed_users' => isset($settings['indexed_users']) ? (bool) $settings['indexed_users'] : false, 118 120 'experience' => isset($settings['experience']) ? $settings['experience'] : array(), -
swiftsearch-for-algolia/trunk/swift-search-algolia.php
r3725773 r3775162 4 4 * Plugin URI: https://docs.loopstates.com/swiftsearch-for-algolia/ 5 5 * Description: Lightning-fast, intelligent search for WordPress & WooCommerce powered by Algolia. Features instant modal search, visual facets builder, field weighting, synonyms, visual merchandising & pinning, and local search analytics. 6 * Version: 1.0. 16 * Version: 1.0.2 7 7 * Requires at least: 5.8 8 8 * Requires PHP: 7.4 … … 20 20 21 21 // Define Constants 22 define('SWIFT_SEARCH_ALGOLIA_VERSION', '1.0. 1');22 define('SWIFT_SEARCH_ALGOLIA_VERSION', '1.0.2'); 23 23 define('SWIFT_SEARCH_ALGOLIA_DB_VERSION', '1.0.0'); 24 24 define('SWIFT_SEARCH_ALGOLIA_FILE', __FILE__); … … 37 37 } 38 38 39 // Declare WooCommerce HPOS Compatibility 40 add_action('before_woocommerce_init', function () { 41 if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) { 42 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true); 43 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('cart_checkout_blocks', __FILE__, true); 44 } 45 }); 46 39 47 // Activation Hook 40 48 register_activation_hook(__FILE__, array(\SwiftSearchAlgolia\Core\DB::class, 'install'));
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)