Changeset 3257859
- Timestamp:
- 03/18/2025 01:44:00 PM (11 months ago)
- Location:
- atlas-search
- Files:
-
- 14 added
- 16 deleted
- 26 edited
- 1 copied
-
tags/0.2.74 (copied) (copied from atlas-search/trunk)
-
tags/0.2.74/README.txt (modified) (2 diffs)
-
tags/0.2.74/atlas-search.php (modified) (2 diffs)
-
tags/0.2.74/build/blocks-callbacks.php (modified) (2 diffs)
-
tags/0.2.74/build/filter-facet/view.asset.php (modified) (1 diff)
-
tags/0.2.74/build/filter-facet/view.js (modified) (1 diff)
-
tags/0.2.74/build/search-facet (deleted)
-
tags/0.2.74/includes/class-wpe-content-engine.php (modified) (1 diff)
-
tags/0.2.74/includes/smart-search-settings/build/asset-manifest.json (modified) (3 diffs)
-
tags/0.2.74/includes/smart-search-settings/build/index.html (modified) (1 diff)
-
tags/0.2.74/includes/smart-search-settings/build/static/js/main.56be2d56.js (added)
-
tags/0.2.74/includes/smart-search-settings/build/static/js/main.56be2d56.js.LICENSE.txt (added)
-
tags/0.2.74/includes/smart-search-settings/build/static/js/main.56be2d56.js.map (added)
-
tags/0.2.74/includes/smart-search-settings/build/static/js/main.b72487ed.js (deleted)
-
tags/0.2.74/includes/smart-search-settings/build/static/js/main.b72487ed.js.LICENSE.txt (deleted)
-
tags/0.2.74/includes/smart-search-settings/build/static/js/main.b72487ed.js.map (deleted)
-
tags/0.2.74/includes/smart-search-settings/build/static/media/search-icon.7b56790bb86248cd5b0e3c085efd77f7.svg (deleted)
-
tags/0.2.74/includes/smart-search-settings/build/static/media/search-icon.c40611ace22f5c84017e1c5f61765d9c.svg (added)
-
tags/0.2.74/includes/smart-search-settings/build/static/media/wpengine-logo.40f3a1215fbea4708a6a4bff9624fece.svg (deleted)
-
tags/0.2.74/includes/smart-search-settings/build/static/media/wpengine-logo.f4b93ff2e9c94a93817d81f14e73235a.svg (added)
-
tags/0.2.74/includes/smart-search-settings/src (deleted)
-
tags/0.2.74/src/blocks/blocks-callbacks.php (modified) (2 diffs)
-
tags/0.2.74/src/blocks/search-facet (deleted)
-
tags/0.2.74/src/blocks/stores/facets.store.js (modified) (4 diffs)
-
tags/0.2.74/src/blocks/stores/facets.store.test.js (modified) (1 diff)
-
tags/0.2.74/src/blocks/utils/getFiltersFromURL.test.js (modified) (1 diff)
-
tags/0.2.74/src/support/gravitysmtp (added)
-
tags/0.2.74/src/support/gravitysmtp/filters.php (added)
-
tags/0.2.74/src/support/woocommerce/fields.php (modified) (2 diffs)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/atlas-search.php (modified) (2 diffs)
-
trunk/build/blocks-callbacks.php (modified) (2 diffs)
-
trunk/build/filter-facet/view.asset.php (modified) (1 diff)
-
trunk/build/filter-facet/view.js (modified) (1 diff)
-
trunk/build/search-facet (deleted)
-
trunk/includes/class-wpe-content-engine.php (modified) (1 diff)
-
trunk/includes/smart-search-settings/build/asset-manifest.json (modified) (3 diffs)
-
trunk/includes/smart-search-settings/build/index.html (modified) (1 diff)
-
trunk/includes/smart-search-settings/build/static/js/main.56be2d56.js (added)
-
trunk/includes/smart-search-settings/build/static/js/main.56be2d56.js.LICENSE.txt (added)
-
trunk/includes/smart-search-settings/build/static/js/main.56be2d56.js.map (added)
-
trunk/includes/smart-search-settings/build/static/js/main.b72487ed.js (deleted)
-
trunk/includes/smart-search-settings/build/static/js/main.b72487ed.js.LICENSE.txt (deleted)
-
trunk/includes/smart-search-settings/build/static/js/main.b72487ed.js.map (deleted)
-
trunk/includes/smart-search-settings/build/static/media/search-icon.7b56790bb86248cd5b0e3c085efd77f7.svg (deleted)
-
trunk/includes/smart-search-settings/build/static/media/search-icon.c40611ace22f5c84017e1c5f61765d9c.svg (added)
-
trunk/includes/smart-search-settings/build/static/media/wpengine-logo.40f3a1215fbea4708a6a4bff9624fece.svg (deleted)
-
trunk/includes/smart-search-settings/build/static/media/wpengine-logo.f4b93ff2e9c94a93817d81f14e73235a.svg (added)
-
trunk/includes/smart-search-settings/src (deleted)
-
trunk/src/blocks/blocks-callbacks.php (modified) (2 diffs)
-
trunk/src/blocks/search-facet (deleted)
-
trunk/src/blocks/stores/facets.store.js (modified) (4 diffs)
-
trunk/src/blocks/stores/facets.store.test.js (modified) (1 diff)
-
trunk/src/blocks/utils/getFiltersFromURL.test.js (modified) (1 diff)
-
trunk/src/support/gravitysmtp (added)
-
trunk/src/support/gravitysmtp/filters.php (added)
-
trunk/src/support/woocommerce/fields.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
atlas-search/tags/0.2.74/README.txt
r3247243 r3257859 3 3 Tested up to: 6.7.1 4 4 Requires PHP: 7.4 5 Stable tag: 0.2.7 25 Stable tag: 0.2.74 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 56 56 57 57 == Changelog == 58 = 0.2.74 = 59 * **Updated:** Drop search facet in favour of the built in search inputs for WordPress and WooCommerce 60 * **Fixed:** Support for gravitysmtp plugin 61 62 = 0.2.73 = 63 * **Updated:** Removed Feature Flag for Recommendations Block 64 * **Fixed:** Dont send woo attributes with empty name 65 * **Updated:** Update header logos 66 58 67 = 0.2.72 = 59 68 * **Added:** Checkbox Facet -
atlas-search/tags/0.2.74/atlas-search.php
r3247243 r3257859 16 16 * Plugin URI: https://developers.wpengine.com/ 17 17 * Description: Searching WordPress data with WP Engine Smart Search. 18 * Version: 0.2.7 218 * Version: 0.2.74 19 19 * Author: WP Engine 20 20 * Author URI: https://wpengine.com/ … … 41 41 * Rename this for your plugin and update it as you release new versions. 42 42 */ 43 define( 'WPE_SMART_SEARCH_VERSION', '0.2.7 2' );43 define( 'WPE_SMART_SEARCH_VERSION', '0.2.74' ); 44 44 45 45 /** -
atlas-search/tags/0.2.74/build/blocks-callbacks.php
r3247243 r3257859 2 2 3 3 namespace AtlasSearch\Blocks\WordPress; 4 5 use WP_HTML_Tag_Processor; 4 6 5 7 /** … … 20 22 $this->loader->add_action( 'init', $this, 'register_facet_blocks' ); 21 23 $this->loader->add_filter( 'block_categories_all', $this, 'register_block_categories', 10, 2 ); 24 $this->loader->add_filter( 'render_block', $this, 'core_search', 10, 2 ); 25 } 26 27 public function core_search( $block_content, $block ) { 28 if ( 'core/search' !== $block['blockName'] ) { 29 return $block_content; 30 } 31 32 // Use WP_HTML_Tag_Processor to modify the button's HTML output. 33 $p = new WP_HTML_Tag_Processor( $block_content ); 34 $p->next_tag(); // Move to the first tag in block_content (should be <form>). 35 36 // Attach Interactivity API directives. 37 $p->set_attribute( 'data-wp-interactive', '{ "namespace": "wpengine-smart-search-facets__store" }' ); 38 $p->set_attribute( 'data-wp-on--submit', 'actions.performSearch' ); 39 $p->set_attribute( 'data-wp-init', 'actions.initFacets' ); 40 41 $p->next_tag( array( 'tag_name' => 'input' ) ); 42 $p->set_attribute( 'data-wp-on--input', 'actions.setSearchValue' ); 43 44 // Return the modified button block content. 45 return $p->get_updated_html(); 22 46 } 23 47 24 48 public function register_facet_blocks() { 25 49 if ( ! get_option( self::SMART_SEARCH_BLOCKS_SUPPORT_ENABLED_OPTION, false ) ) { 26 return; 50 $blocks = array( 51 'recommendations-block', 52 ); 53 } else { 54 $blocks = array( 55 'filter-facet', 56 'recommendations-block', 57 ); 27 58 } 28 29 $blocks = array(30 'search-facet',31 'filter-facet',32 'recommendations-block',33 );34 59 35 60 foreach ( $blocks as $block ) { -
atlas-search/tags/0.2.74/build/filter-facet/view.asset.php
r3247243 r3257859 1 <?php return array('dependencies' => array('@wordpress/interactivity'), 'version' => ' 743cba50d4149080fcc1', 'type' => 'module');1 <?php return array('dependencies' => array('@wordpress/interactivity'), 'version' => '0f28e1b1e27b7252eae1', 'type' => 'module'); -
atlas-search/tags/0.2.74/build/filter-facet/view.js
r3247243 r3257859 1 import*as e from"@wordpress/interactivity";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},r={};t.d(r,{o:()=>b,w:()=> m});const n=(a={getContext:()=>e.getContext,getElement:()=>e.getElement,store:()=>e.store},c={},t.d(c,a),c),o="wpengine-smart-search-facets__store";var a,c;function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function s(e,t,r){return(t=function(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}const f="__wpengine-smart-search_FacetsStoreInstance__";function p(){return globalThis[f]}var y;p()||(y=(0,n.store)(o,{state:{filters:[],get allFilters(){return p().state.filters}},actions:{updateFilter(e){let{filterName:t,value:r}=e;""===r?delete p().state.filters[t]:p().state.filters[t]=r},setSearchValue(){const{ref:e}=(0,n.getElement)(),{value:t}=e;p().state.searchValue=t},*performSearch(e){e.preventDefault();const t=u(u({},p().state.filters),{},{s:p().state.searchValue});yield(async e=>{const t="".concat(window.location.origin,"/"),r=new URL(t);Object.keys(e).forEach((t=>{void 0!==e[t]&&null!==e[t]&&r.searchParams.set(t,e[t])})),window.location.assign(r.toString())})(t)}}}),globalThis[f]=y),p();const{actions:b,state:m}=(0,n.store)(o,{actions:{initDropdownFacet:function(){const e=(0,n.getContext)(),t=function(){const e={};return new URLSearchParams(window.location.search).forEach(((t,r)=>{t.includes(",")&&(t=t.split(",")),e[r]=t})),e}();t[e.selected_data_source_mapped]&&!Array.isArray(t[e.selected_data_source_mapped])&&(e.value=t[e.selected_data_source_mapped])},setDropdownValue:function(e){e.preventDefault();const{value:t,name:r}=e.target;b.updateFilter({filterName:r,value:t})},setCheckboxValue:function(e){e.preventDefault();const{value:t,name:r,checked:n}=e.target,o=[].concat(m.allFilters[r]||[]);n?o.includes(t)||o.push(t):o.splice(o.indexOf(t),1),b.updateFilter({filterName:r,value:o})}}});var d=r.o,v=r.w;export{d as actions,vas state};1 import*as e from"@wordpress/interactivity";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},r={};t.d(r,{o:()=>b,w:()=>d});const n=(a={getContext:()=>e.getContext,getElement:()=>e.getElement,store:()=>e.store},c={},t.d(c,a),c),o="wpengine-smart-search-facets__store";var a,c;function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function i(e,t,r){return(t=function(e){var t=function(e){if("object"!=s(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=s(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==s(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function f(){const e={};return new URLSearchParams(window.location.search).forEach(((t,r)=>{t.includes(",")&&(t=t.split(",")),e[r]=t})),e}const p="__wpengine-smart-search_FacetsStoreInstance__";function y(){return globalThis[p]}var m;y()||(m=(0,n.store)(o,{state:{filters:[],get allFilters(){return y().state.filters}},actions:{initFacets:function(){const{actions:e,state:t}=y(),r=f();for(const n in r)if(r[n]){const o=r[n];"s"===n&&(t.searchValue=o),e.updateFilter({filterName:n,value:o})}},updateFilter(e){let{filterName:t,value:r}=e;""===r?delete y().state.filters[t]:y().state.filters[t]=r},setSearchValue(){const{ref:e}=(0,n.getElement)(),{value:t}=e;y().state.searchValue=t},*performSearch(e){e.preventDefault();const t=e.target.querySelectorAll('input[type="hidden"]'),r={};t.forEach((e=>{r[e.name]=e.value}));const n=u(u({},y().state.filters),{},{s:y().state.searchValue},r);yield(async e=>{const t=new URL(window.location.href);Object.keys(e).forEach((r=>{void 0!==e[r]&&null!==e[r]&&t.searchParams.set(r,e[r])})),window.location.assign(t.toString())})(n)}}}),globalThis[p]=m),y();const{actions:b,state:d}=(0,n.store)(o,{actions:{initDropdownFacet:function(){const e=(0,n.getContext)(),t=f();t[e.selected_data_source_mapped]&&!Array.isArray(t[e.selected_data_source_mapped])&&(e.value=t[e.selected_data_source_mapped])},setDropdownValue:function(e){e.preventDefault();const{value:t,name:r}=e.target;b.updateFilter({filterName:r,value:t})},setCheckboxValue:function(e){e.preventDefault();const{value:t,name:r,checked:n}=e.target,o=[].concat(d.allFilters[r]||[]);n?o.includes(t)||o.push(t):o.splice(o.indexOf(t),1),b.updateFilter({filterName:r,value:o})}}});var v=r.o,g=r.w;export{v as actions,g as state}; -
atlas-search/tags/0.2.74/includes/class-wpe-content-engine.php
r3247243 r3257859 228 228 require_once plugin_dir_path( __DIR__ ) . 'src/support/woocommerce/queries.php'; 229 229 require_once plugin_dir_path( __DIR__ ) . 'src/support/fusion/filters.php'; 230 require_once plugin_dir_path( __DIR__ ) . 'src/support/gravitysmtp/filters.php'; 230 231 } 231 232 -
atlas-search/tags/0.2.74/includes/smart-search-settings/build/asset-manifest.json
r3239389 r3257859 2 2 "files": { 3 3 "main.css": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.4b9ef208.css", 4 "main.js": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.b72487ed.js", 5 "static/media/wpengine-logo.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/wpengine-logo.40f3a1215fbea4708a6a4bff9624fece.svg", 4 "main.js": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.56be2d56.js", 5 "static/media/wpengine-logo.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/wpengine-logo.f4b93ff2e9c94a93817d81f14e73235a.svg", 6 "static/media/search-icon.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/search-icon.553693483eece21ac1f02866dbcf436b.svg", 6 7 "static/media/content-copy.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/content-copy.e50f17791e757794684afc63d5d4cb00.svg", 7 8 "static/media/delete-icon.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/delete-icon.8fe170c40cab65513a25239b397ceb99.svg", … … 12 13 "static/media/info-icon.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/info-icon.30042d2143dbaf9927d68a3c375ea5e2.svg", 13 14 "static/media/success-icon.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/success-icon.1fbd8c959e7200e8770179c3482d0471.svg", 14 "static/media/search-icon.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/search-icon.553693483eece21ac1f02866dbcf436b.svg",15 15 "static/media/reload-icon.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/reload-icon.ce27213a21c8637e2aff195d52baa50f.svg", 16 16 "static/media/expand-more.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/expand-more.a67cb7a584a759832f8e699e45b044f5.svg", … … 18 18 "index.html": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/index.html", 19 19 "main.4b9ef208.css.map": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.4b9ef208.css.map", 20 "main. b72487ed.js.map": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.b72487ed.js.map"20 "main.56be2d56.js.map": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.56be2d56.js.map" 21 21 }, 22 22 "entrypoints": [ 23 23 "static/css/main.4b9ef208.css", 24 "static/js/main. b72487ed.js"24 "static/js/main.56be2d56.js" 25 25 ] 26 26 } -
atlas-search/tags/0.2.74/includes/smart-search-settings/build/index.html
r3239389 r3257859 1 <head><script defer="defer" src="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main. b72487ed.js"></script><link href="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.4b9ef208.css" rel="stylesheet"></head>1 <head><script defer="defer" src="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.56be2d56.js"></script><link href="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.4b9ef208.css" rel="stylesheet"></head> -
atlas-search/tags/0.2.74/src/blocks/blocks-callbacks.php
r3247243 r3257859 2 2 3 3 namespace AtlasSearch\Blocks\WordPress; 4 5 use WP_HTML_Tag_Processor; 4 6 5 7 /** … … 20 22 $this->loader->add_action( 'init', $this, 'register_facet_blocks' ); 21 23 $this->loader->add_filter( 'block_categories_all', $this, 'register_block_categories', 10, 2 ); 24 $this->loader->add_filter( 'render_block', $this, 'core_search', 10, 2 ); 25 } 26 27 public function core_search( $block_content, $block ) { 28 if ( 'core/search' !== $block['blockName'] ) { 29 return $block_content; 30 } 31 32 // Use WP_HTML_Tag_Processor to modify the button's HTML output. 33 $p = new WP_HTML_Tag_Processor( $block_content ); 34 $p->next_tag(); // Move to the first tag in block_content (should be <form>). 35 36 // Attach Interactivity API directives. 37 $p->set_attribute( 'data-wp-interactive', '{ "namespace": "wpengine-smart-search-facets__store" }' ); 38 $p->set_attribute( 'data-wp-on--submit', 'actions.performSearch' ); 39 $p->set_attribute( 'data-wp-init', 'actions.initFacets' ); 40 41 $p->next_tag( array( 'tag_name' => 'input' ) ); 42 $p->set_attribute( 'data-wp-on--input', 'actions.setSearchValue' ); 43 44 // Return the modified button block content. 45 return $p->get_updated_html(); 22 46 } 23 47 24 48 public function register_facet_blocks() { 25 49 if ( ! get_option( self::SMART_SEARCH_BLOCKS_SUPPORT_ENABLED_OPTION, false ) ) { 26 return; 50 $blocks = array( 51 'recommendations-block', 52 ); 53 } else { 54 $blocks = array( 55 'filter-facet', 56 'recommendations-block', 57 ); 27 58 } 28 29 $blocks = array(30 'search-facet',31 'filter-facet',32 'recommendations-block',33 );34 59 35 60 foreach ( $blocks as $block ) { -
atlas-search/tags/0.2.74/src/blocks/stores/facets.store.js
r3247243 r3257859 1 1 import { store, getElement } from '@wordpress/interactivity'; 2 2 import { config } from '../config'; 3 import { getFiltersFromURL } from '../utils/getFiltersFromURL'; 3 4 4 5 export const updateURL = async (params) => { 5 const baseUrl = `${window.location.origin}/`; 6 const url = new URL(baseUrl); 6 const url = new URL(window.location.href); 7 7 8 8 // Set search parameters … … 15 15 }; 16 16 17 const FACETS_STORE_KEY = '__wpengine-smart-search_FacetsStoreInstance__';17 export const FACETS_STORE_KEY = '__wpengine-smart-search_FacetsStoreInstance__'; 18 18 19 19 // Method to get the singleton instance … … 38 38 }, 39 39 actions: { 40 initFacets: function () { 41 const { actions, state } = getInstance(); 42 const filters = getFiltersFromURL(); 43 for (const key in filters) { 44 if (filters[key]) { 45 const value = filters[key]; 46 if (key === 's') { 47 state.searchValue = value; // Set the state to the search query 48 } 49 actions.updateFilter({ filterName: key, value }); 50 } 51 } 52 }, 40 53 updateFilter({ filterName, value }) { 41 54 if (value === '') { … … 52 65 *performSearch(e) { 53 66 e.preventDefault(); 67 const hiddenInputs = e.target.querySelectorAll( 68 'input[type="hidden"]' 69 ); 70 const hiddenParams = {}; 71 hiddenInputs.forEach((input) => { 72 hiddenParams[input.name] = input.value; 73 }); 74 54 75 const params = { 55 76 ...getInstance().state.filters, 56 77 s: getInstance().state.searchValue, 78 ...hiddenParams, 57 79 }; 58 80 yield updateURL(params); -
atlas-search/tags/0.2.74/src/blocks/stores/facets.store.test.js
r3139847 r3257859 1 import { updateURL } from './facets.store'; 1 import { describe } from 'node:test'; 2 import { FACETS_STORE_KEY, getFacetsStore, updateURL } from './facets.store'; 3 import { store } from '@wordpress/interactivity'; 2 4 // Mocking @wordpress/interactivity module 3 5 jest.mock('@wordpress/interactivity', () => ({ 4 store: () => ({ state: jest.fn() }),5 getElement: jest.fn( ),6 store: jest.fn(), 7 getElement: jest.fn(() => ({ ref: { value: 'test search value' } })), 6 8 })); 7 9 8 describe('updateURL function', () => { 9 beforeEach(() => { 10 // Mock window.location.origin and window.location.assign 11 delete window.location; 12 window.location = { 13 origin: 'http://localhost:8000', 14 assign: jest.fn(), 15 }; 10 jest.mock('../config', () => ({ 11 config: { facetsStoreName: 'testFacetsStore' }, 12 })); 13 14 jest.mock('../utils/getFiltersFromURL', () => ({ 15 getFiltersFromURL: jest.fn(() => ({ s: 'test', category: 'test-category' })), 16 })); 17 18 describe('facets.store.js', () => { 19 describe('initFacets', () => { 20 beforeEach(() => { 21 globalThis[FACETS_STORE_KEY] = undefined; 22 store.mockImplementation((name, storeConfig) => { 23 return { 24 state: storeConfig.state, 25 actions: storeConfig.actions, 26 }; 27 }); 28 }); 29 30 it('should initialize facets with filters from URL', () => { 31 const facetsStore = getFacetsStore(); 32 facetsStore.actions.initFacets(); 33 34 const filters = facetsStore.state.filters; 35 36 expect(filters['s']).toEqual('test'); 37 expect(filters['category']).toEqual('test-category'); 38 expect(facetsStore.state.searchValue).toBe('test'); 39 }); 16 40 }); 17 41 18 afterEach(() => { 19 jest.clearAllMocks(); 20 }); 42 describe('updateURL function', () => { 43 beforeEach(() => { 44 // Mock window.location.origin and window.location.assign 45 delete window.location; 46 window.location = { 47 origin: 'http://localhost:8000', 48 href: 'http://localhost:8000', 49 assign: jest.fn(), 50 }; 51 }); 21 52 22 it('should update the URL with given parameters', async () => { 23 const params = { 24 category_name: 'uncategorized', 25 search: 'example', 26 }; 53 afterEach(() => { 54 jest.clearAllMocks(); 55 }); 27 56 28 await updateURL(params); 57 it('should update the URL with given parameters', async () => { 58 const params = { 59 category_name: 'uncategorized', 60 search: 'example', 61 }; 29 62 30 expect(window.location.assign).toHaveBeenCalledWith( 31 'http://localhost:8000/?category_name=uncategorized&search=example' 32 ); 33 }); 63 await updateURL(params); 34 64 35 it('should handle undefined and null values in parameters', async () => { 36 const params = { 37 category_name: 'uncategorized', 38 search: null, 39 anotherParam: undefined, 40 }; 65 expect(window.location.assign).toHaveBeenCalledWith( 66 'http://localhost:8000/?category_name=uncategorized&search=example' 67 ); 68 }); 41 69 42 await updateURL(params); 70 it('should handle undefined and null values in parameters', async () => { 71 const params = { 72 category_name: 'uncategorized', 73 search: null, 74 anotherParam: undefined, 75 }; 43 76 44 // Should only include 'category_name' in the URL 45 expect(window.location.assign).toHaveBeenCalledWith( 46 'http://localhost:8000/?category_name=uncategorized' 47 ); 48 }); 77 await updateURL(params); 49 78 50 it('should handle empty parameters', async () => { 51 await updateURL({}); 79 // Should only include 'category_name' in the URL 80 expect(window.location.assign).toHaveBeenCalledWith( 81 'http://localhost:8000/?category_name=uncategorized' 82 ); 83 }); 52 84 53 expect(window.location.assign).toHaveBeenCalledWith( 54 'http://localhost:8000/' 55 ); 56 }); 85 it('should handle empty parameters', async () => { 86 await updateURL({}); 57 87 58 it('should handle parameters with empty strings', async () => { 59 const params = { 60 category_name: '', 61 search: 'test', 62 }; 88 expect(window.location.assign).toHaveBeenCalledWith( 89 'http://localhost:8000/' 90 ); 91 }); 63 92 64 await updateURL(params); 93 it('should handle parameters with empty strings', async () => { 94 const params = { 95 category_name: '', 96 search: 'test', 97 }; 65 98 66 // Should set category_name to an empty string and include 'search' in the URL 67 expect(window.location.assign).toHaveBeenCalledWith( 68 'http://localhost:8000/?category_name=&search=test' 69 ); 99 await updateURL(params); 100 101 // Should set category_name to an empty string and include 'search' in the URL 102 expect(window.location.assign).toHaveBeenCalledWith( 103 'http://localhost:8000/?category_name=&search=test' 104 ); 105 }); 70 106 }); 71 107 }); -
atlas-search/tags/0.2.74/src/blocks/utils/getFiltersFromURL.test.js
r3139847 r3257859 7 7 window.location = { 8 8 origin: 'http://localhost:8000', 9 href: 'http://localhost:8000', 9 10 search: '', 10 11 }; -
atlas-search/tags/0.2.74/src/support/woocommerce/fields.php
r3239389 r3257859 60 60 $attributes = array(); 61 61 foreach ( $data['attributes'] as $attribute ) { 62 if ( isset( $attribute['name'] ) && taxonomy_exists( $attribute['name'] ) ) {62 if ( ! empty( $attribute['name'] ) && taxonomy_exists( $attribute['name'] ) ) { 63 63 // Fetch terms for the attribute. 64 64 // We need to treat these as taxonomies. … … 70 70 wp_get_post_terms( $wc_product->get_id(), $attribute['name'] ) 71 71 ); 72 } elseif ( isset( $attribute['name'],$attribute['options'] ) ) {72 } elseif ( ! empty( $attribute['name'] ) && isset( $attribute['options'] ) ) { 73 73 $attributes[ $attribute['name'] ] = $attribute['options']; 74 74 } -
atlas-search/trunk/README.txt
r3247243 r3257859 3 3 Tested up to: 6.7.1 4 4 Requires PHP: 7.4 5 Stable tag: 0.2.7 25 Stable tag: 0.2.74 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 56 56 57 57 == Changelog == 58 = 0.2.74 = 59 * **Updated:** Drop search facet in favour of the built in search inputs for WordPress and WooCommerce 60 * **Fixed:** Support for gravitysmtp plugin 61 62 = 0.2.73 = 63 * **Updated:** Removed Feature Flag for Recommendations Block 64 * **Fixed:** Dont send woo attributes with empty name 65 * **Updated:** Update header logos 66 58 67 = 0.2.72 = 59 68 * **Added:** Checkbox Facet -
atlas-search/trunk/atlas-search.php
r3247243 r3257859 16 16 * Plugin URI: https://developers.wpengine.com/ 17 17 * Description: Searching WordPress data with WP Engine Smart Search. 18 * Version: 0.2.7 218 * Version: 0.2.74 19 19 * Author: WP Engine 20 20 * Author URI: https://wpengine.com/ … … 41 41 * Rename this for your plugin and update it as you release new versions. 42 42 */ 43 define( 'WPE_SMART_SEARCH_VERSION', '0.2.7 2' );43 define( 'WPE_SMART_SEARCH_VERSION', '0.2.74' ); 44 44 45 45 /** -
atlas-search/trunk/build/blocks-callbacks.php
r3247243 r3257859 2 2 3 3 namespace AtlasSearch\Blocks\WordPress; 4 5 use WP_HTML_Tag_Processor; 4 6 5 7 /** … … 20 22 $this->loader->add_action( 'init', $this, 'register_facet_blocks' ); 21 23 $this->loader->add_filter( 'block_categories_all', $this, 'register_block_categories', 10, 2 ); 24 $this->loader->add_filter( 'render_block', $this, 'core_search', 10, 2 ); 25 } 26 27 public function core_search( $block_content, $block ) { 28 if ( 'core/search' !== $block['blockName'] ) { 29 return $block_content; 30 } 31 32 // Use WP_HTML_Tag_Processor to modify the button's HTML output. 33 $p = new WP_HTML_Tag_Processor( $block_content ); 34 $p->next_tag(); // Move to the first tag in block_content (should be <form>). 35 36 // Attach Interactivity API directives. 37 $p->set_attribute( 'data-wp-interactive', '{ "namespace": "wpengine-smart-search-facets__store" }' ); 38 $p->set_attribute( 'data-wp-on--submit', 'actions.performSearch' ); 39 $p->set_attribute( 'data-wp-init', 'actions.initFacets' ); 40 41 $p->next_tag( array( 'tag_name' => 'input' ) ); 42 $p->set_attribute( 'data-wp-on--input', 'actions.setSearchValue' ); 43 44 // Return the modified button block content. 45 return $p->get_updated_html(); 22 46 } 23 47 24 48 public function register_facet_blocks() { 25 49 if ( ! get_option( self::SMART_SEARCH_BLOCKS_SUPPORT_ENABLED_OPTION, false ) ) { 26 return; 50 $blocks = array( 51 'recommendations-block', 52 ); 53 } else { 54 $blocks = array( 55 'filter-facet', 56 'recommendations-block', 57 ); 27 58 } 28 29 $blocks = array(30 'search-facet',31 'filter-facet',32 'recommendations-block',33 );34 59 35 60 foreach ( $blocks as $block ) { -
atlas-search/trunk/build/filter-facet/view.asset.php
r3247243 r3257859 1 <?php return array('dependencies' => array('@wordpress/interactivity'), 'version' => ' 743cba50d4149080fcc1', 'type' => 'module');1 <?php return array('dependencies' => array('@wordpress/interactivity'), 'version' => '0f28e1b1e27b7252eae1', 'type' => 'module'); -
atlas-search/trunk/build/filter-facet/view.js
r3247243 r3257859 1 import*as e from"@wordpress/interactivity";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},r={};t.d(r,{o:()=>b,w:()=> m});const n=(a={getContext:()=>e.getContext,getElement:()=>e.getElement,store:()=>e.store},c={},t.d(c,a),c),o="wpengine-smart-search-facets__store";var a,c;function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function s(e,t,r){return(t=function(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}const f="__wpengine-smart-search_FacetsStoreInstance__";function p(){return globalThis[f]}var y;p()||(y=(0,n.store)(o,{state:{filters:[],get allFilters(){return p().state.filters}},actions:{updateFilter(e){let{filterName:t,value:r}=e;""===r?delete p().state.filters[t]:p().state.filters[t]=r},setSearchValue(){const{ref:e}=(0,n.getElement)(),{value:t}=e;p().state.searchValue=t},*performSearch(e){e.preventDefault();const t=u(u({},p().state.filters),{},{s:p().state.searchValue});yield(async e=>{const t="".concat(window.location.origin,"/"),r=new URL(t);Object.keys(e).forEach((t=>{void 0!==e[t]&&null!==e[t]&&r.searchParams.set(t,e[t])})),window.location.assign(r.toString())})(t)}}}),globalThis[f]=y),p();const{actions:b,state:m}=(0,n.store)(o,{actions:{initDropdownFacet:function(){const e=(0,n.getContext)(),t=function(){const e={};return new URLSearchParams(window.location.search).forEach(((t,r)=>{t.includes(",")&&(t=t.split(",")),e[r]=t})),e}();t[e.selected_data_source_mapped]&&!Array.isArray(t[e.selected_data_source_mapped])&&(e.value=t[e.selected_data_source_mapped])},setDropdownValue:function(e){e.preventDefault();const{value:t,name:r}=e.target;b.updateFilter({filterName:r,value:t})},setCheckboxValue:function(e){e.preventDefault();const{value:t,name:r,checked:n}=e.target,o=[].concat(m.allFilters[r]||[]);n?o.includes(t)||o.push(t):o.splice(o.indexOf(t),1),b.updateFilter({filterName:r,value:o})}}});var d=r.o,v=r.w;export{d as actions,vas state};1 import*as e from"@wordpress/interactivity";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},r={};t.d(r,{o:()=>b,w:()=>d});const n=(a={getContext:()=>e.getContext,getElement:()=>e.getElement,store:()=>e.store},c={},t.d(c,a),c),o="wpengine-smart-search-facets__store";var a,c;function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function i(e,t,r){return(t=function(e){var t=function(e){if("object"!=s(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=s(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==s(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function f(){const e={};return new URLSearchParams(window.location.search).forEach(((t,r)=>{t.includes(",")&&(t=t.split(",")),e[r]=t})),e}const p="__wpengine-smart-search_FacetsStoreInstance__";function y(){return globalThis[p]}var m;y()||(m=(0,n.store)(o,{state:{filters:[],get allFilters(){return y().state.filters}},actions:{initFacets:function(){const{actions:e,state:t}=y(),r=f();for(const n in r)if(r[n]){const o=r[n];"s"===n&&(t.searchValue=o),e.updateFilter({filterName:n,value:o})}},updateFilter(e){let{filterName:t,value:r}=e;""===r?delete y().state.filters[t]:y().state.filters[t]=r},setSearchValue(){const{ref:e}=(0,n.getElement)(),{value:t}=e;y().state.searchValue=t},*performSearch(e){e.preventDefault();const t=e.target.querySelectorAll('input[type="hidden"]'),r={};t.forEach((e=>{r[e.name]=e.value}));const n=u(u({},y().state.filters),{},{s:y().state.searchValue},r);yield(async e=>{const t=new URL(window.location.href);Object.keys(e).forEach((r=>{void 0!==e[r]&&null!==e[r]&&t.searchParams.set(r,e[r])})),window.location.assign(t.toString())})(n)}}}),globalThis[p]=m),y();const{actions:b,state:d}=(0,n.store)(o,{actions:{initDropdownFacet:function(){const e=(0,n.getContext)(),t=f();t[e.selected_data_source_mapped]&&!Array.isArray(t[e.selected_data_source_mapped])&&(e.value=t[e.selected_data_source_mapped])},setDropdownValue:function(e){e.preventDefault();const{value:t,name:r}=e.target;b.updateFilter({filterName:r,value:t})},setCheckboxValue:function(e){e.preventDefault();const{value:t,name:r,checked:n}=e.target,o=[].concat(d.allFilters[r]||[]);n?o.includes(t)||o.push(t):o.splice(o.indexOf(t),1),b.updateFilter({filterName:r,value:o})}}});var v=r.o,g=r.w;export{v as actions,g as state}; -
atlas-search/trunk/includes/class-wpe-content-engine.php
r3247243 r3257859 228 228 require_once plugin_dir_path( __DIR__ ) . 'src/support/woocommerce/queries.php'; 229 229 require_once plugin_dir_path( __DIR__ ) . 'src/support/fusion/filters.php'; 230 require_once plugin_dir_path( __DIR__ ) . 'src/support/gravitysmtp/filters.php'; 230 231 } 231 232 -
atlas-search/trunk/includes/smart-search-settings/build/asset-manifest.json
r3239389 r3257859 2 2 "files": { 3 3 "main.css": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.4b9ef208.css", 4 "main.js": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.b72487ed.js", 5 "static/media/wpengine-logo.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/wpengine-logo.40f3a1215fbea4708a6a4bff9624fece.svg", 4 "main.js": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.56be2d56.js", 5 "static/media/wpengine-logo.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/wpengine-logo.f4b93ff2e9c94a93817d81f14e73235a.svg", 6 "static/media/search-icon.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/search-icon.553693483eece21ac1f02866dbcf436b.svg", 6 7 "static/media/content-copy.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/content-copy.e50f17791e757794684afc63d5d4cb00.svg", 7 8 "static/media/delete-icon.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/delete-icon.8fe170c40cab65513a25239b397ceb99.svg", … … 12 13 "static/media/info-icon.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/info-icon.30042d2143dbaf9927d68a3c375ea5e2.svg", 13 14 "static/media/success-icon.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/success-icon.1fbd8c959e7200e8770179c3482d0471.svg", 14 "static/media/search-icon.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/search-icon.553693483eece21ac1f02866dbcf436b.svg",15 15 "static/media/reload-icon.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/reload-icon.ce27213a21c8637e2aff195d52baa50f.svg", 16 16 "static/media/expand-more.svg": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/media/expand-more.a67cb7a584a759832f8e699e45b044f5.svg", … … 18 18 "index.html": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/index.html", 19 19 "main.4b9ef208.css.map": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.4b9ef208.css.map", 20 "main. b72487ed.js.map": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.b72487ed.js.map"20 "main.56be2d56.js.map": "/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.56be2d56.js.map" 21 21 }, 22 22 "entrypoints": [ 23 23 "static/css/main.4b9ef208.css", 24 "static/js/main. b72487ed.js"24 "static/js/main.56be2d56.js" 25 25 ] 26 26 } -
atlas-search/trunk/includes/smart-search-settings/build/index.html
r3239389 r3257859 1 <head><script defer="defer" src="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main. b72487ed.js"></script><link href="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.4b9ef208.css" rel="stylesheet"></head>1 <head><script defer="defer" src="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/js/main.56be2d56.js"></script><link href="/wp-content/plugins/atlas-search/includes/smart-search-settings/build/static/css/main.4b9ef208.css" rel="stylesheet"></head> -
atlas-search/trunk/src/blocks/blocks-callbacks.php
r3247243 r3257859 2 2 3 3 namespace AtlasSearch\Blocks\WordPress; 4 5 use WP_HTML_Tag_Processor; 4 6 5 7 /** … … 20 22 $this->loader->add_action( 'init', $this, 'register_facet_blocks' ); 21 23 $this->loader->add_filter( 'block_categories_all', $this, 'register_block_categories', 10, 2 ); 24 $this->loader->add_filter( 'render_block', $this, 'core_search', 10, 2 ); 25 } 26 27 public function core_search( $block_content, $block ) { 28 if ( 'core/search' !== $block['blockName'] ) { 29 return $block_content; 30 } 31 32 // Use WP_HTML_Tag_Processor to modify the button's HTML output. 33 $p = new WP_HTML_Tag_Processor( $block_content ); 34 $p->next_tag(); // Move to the first tag in block_content (should be <form>). 35 36 // Attach Interactivity API directives. 37 $p->set_attribute( 'data-wp-interactive', '{ "namespace": "wpengine-smart-search-facets__store" }' ); 38 $p->set_attribute( 'data-wp-on--submit', 'actions.performSearch' ); 39 $p->set_attribute( 'data-wp-init', 'actions.initFacets' ); 40 41 $p->next_tag( array( 'tag_name' => 'input' ) ); 42 $p->set_attribute( 'data-wp-on--input', 'actions.setSearchValue' ); 43 44 // Return the modified button block content. 45 return $p->get_updated_html(); 22 46 } 23 47 24 48 public function register_facet_blocks() { 25 49 if ( ! get_option( self::SMART_SEARCH_BLOCKS_SUPPORT_ENABLED_OPTION, false ) ) { 26 return; 50 $blocks = array( 51 'recommendations-block', 52 ); 53 } else { 54 $blocks = array( 55 'filter-facet', 56 'recommendations-block', 57 ); 27 58 } 28 29 $blocks = array(30 'search-facet',31 'filter-facet',32 'recommendations-block',33 );34 59 35 60 foreach ( $blocks as $block ) { -
atlas-search/trunk/src/blocks/stores/facets.store.js
r3247243 r3257859 1 1 import { store, getElement } from '@wordpress/interactivity'; 2 2 import { config } from '../config'; 3 import { getFiltersFromURL } from '../utils/getFiltersFromURL'; 3 4 4 5 export const updateURL = async (params) => { 5 const baseUrl = `${window.location.origin}/`; 6 const url = new URL(baseUrl); 6 const url = new URL(window.location.href); 7 7 8 8 // Set search parameters … … 15 15 }; 16 16 17 const FACETS_STORE_KEY = '__wpengine-smart-search_FacetsStoreInstance__';17 export const FACETS_STORE_KEY = '__wpengine-smart-search_FacetsStoreInstance__'; 18 18 19 19 // Method to get the singleton instance … … 38 38 }, 39 39 actions: { 40 initFacets: function () { 41 const { actions, state } = getInstance(); 42 const filters = getFiltersFromURL(); 43 for (const key in filters) { 44 if (filters[key]) { 45 const value = filters[key]; 46 if (key === 's') { 47 state.searchValue = value; // Set the state to the search query 48 } 49 actions.updateFilter({ filterName: key, value }); 50 } 51 } 52 }, 40 53 updateFilter({ filterName, value }) { 41 54 if (value === '') { … … 52 65 *performSearch(e) { 53 66 e.preventDefault(); 67 const hiddenInputs = e.target.querySelectorAll( 68 'input[type="hidden"]' 69 ); 70 const hiddenParams = {}; 71 hiddenInputs.forEach((input) => { 72 hiddenParams[input.name] = input.value; 73 }); 74 54 75 const params = { 55 76 ...getInstance().state.filters, 56 77 s: getInstance().state.searchValue, 78 ...hiddenParams, 57 79 }; 58 80 yield updateURL(params); -
atlas-search/trunk/src/blocks/stores/facets.store.test.js
r3139847 r3257859 1 import { updateURL } from './facets.store'; 1 import { describe } from 'node:test'; 2 import { FACETS_STORE_KEY, getFacetsStore, updateURL } from './facets.store'; 3 import { store } from '@wordpress/interactivity'; 2 4 // Mocking @wordpress/interactivity module 3 5 jest.mock('@wordpress/interactivity', () => ({ 4 store: () => ({ state: jest.fn() }),5 getElement: jest.fn( ),6 store: jest.fn(), 7 getElement: jest.fn(() => ({ ref: { value: 'test search value' } })), 6 8 })); 7 9 8 describe('updateURL function', () => { 9 beforeEach(() => { 10 // Mock window.location.origin and window.location.assign 11 delete window.location; 12 window.location = { 13 origin: 'http://localhost:8000', 14 assign: jest.fn(), 15 }; 10 jest.mock('../config', () => ({ 11 config: { facetsStoreName: 'testFacetsStore' }, 12 })); 13 14 jest.mock('../utils/getFiltersFromURL', () => ({ 15 getFiltersFromURL: jest.fn(() => ({ s: 'test', category: 'test-category' })), 16 })); 17 18 describe('facets.store.js', () => { 19 describe('initFacets', () => { 20 beforeEach(() => { 21 globalThis[FACETS_STORE_KEY] = undefined; 22 store.mockImplementation((name, storeConfig) => { 23 return { 24 state: storeConfig.state, 25 actions: storeConfig.actions, 26 }; 27 }); 28 }); 29 30 it('should initialize facets with filters from URL', () => { 31 const facetsStore = getFacetsStore(); 32 facetsStore.actions.initFacets(); 33 34 const filters = facetsStore.state.filters; 35 36 expect(filters['s']).toEqual('test'); 37 expect(filters['category']).toEqual('test-category'); 38 expect(facetsStore.state.searchValue).toBe('test'); 39 }); 16 40 }); 17 41 18 afterEach(() => { 19 jest.clearAllMocks(); 20 }); 42 describe('updateURL function', () => { 43 beforeEach(() => { 44 // Mock window.location.origin and window.location.assign 45 delete window.location; 46 window.location = { 47 origin: 'http://localhost:8000', 48 href: 'http://localhost:8000', 49 assign: jest.fn(), 50 }; 51 }); 21 52 22 it('should update the URL with given parameters', async () => { 23 const params = { 24 category_name: 'uncategorized', 25 search: 'example', 26 }; 53 afterEach(() => { 54 jest.clearAllMocks(); 55 }); 27 56 28 await updateURL(params); 57 it('should update the URL with given parameters', async () => { 58 const params = { 59 category_name: 'uncategorized', 60 search: 'example', 61 }; 29 62 30 expect(window.location.assign).toHaveBeenCalledWith( 31 'http://localhost:8000/?category_name=uncategorized&search=example' 32 ); 33 }); 63 await updateURL(params); 34 64 35 it('should handle undefined and null values in parameters', async () => { 36 const params = { 37 category_name: 'uncategorized', 38 search: null, 39 anotherParam: undefined, 40 }; 65 expect(window.location.assign).toHaveBeenCalledWith( 66 'http://localhost:8000/?category_name=uncategorized&search=example' 67 ); 68 }); 41 69 42 await updateURL(params); 70 it('should handle undefined and null values in parameters', async () => { 71 const params = { 72 category_name: 'uncategorized', 73 search: null, 74 anotherParam: undefined, 75 }; 43 76 44 // Should only include 'category_name' in the URL 45 expect(window.location.assign).toHaveBeenCalledWith( 46 'http://localhost:8000/?category_name=uncategorized' 47 ); 48 }); 77 await updateURL(params); 49 78 50 it('should handle empty parameters', async () => { 51 await updateURL({}); 79 // Should only include 'category_name' in the URL 80 expect(window.location.assign).toHaveBeenCalledWith( 81 'http://localhost:8000/?category_name=uncategorized' 82 ); 83 }); 52 84 53 expect(window.location.assign).toHaveBeenCalledWith( 54 'http://localhost:8000/' 55 ); 56 }); 85 it('should handle empty parameters', async () => { 86 await updateURL({}); 57 87 58 it('should handle parameters with empty strings', async () => { 59 const params = { 60 category_name: '', 61 search: 'test', 62 }; 88 expect(window.location.assign).toHaveBeenCalledWith( 89 'http://localhost:8000/' 90 ); 91 }); 63 92 64 await updateURL(params); 93 it('should handle parameters with empty strings', async () => { 94 const params = { 95 category_name: '', 96 search: 'test', 97 }; 65 98 66 // Should set category_name to an empty string and include 'search' in the URL 67 expect(window.location.assign).toHaveBeenCalledWith( 68 'http://localhost:8000/?category_name=&search=test' 69 ); 99 await updateURL(params); 100 101 // Should set category_name to an empty string and include 'search' in the URL 102 expect(window.location.assign).toHaveBeenCalledWith( 103 'http://localhost:8000/?category_name=&search=test' 104 ); 105 }); 70 106 }); 71 107 }); -
atlas-search/trunk/src/blocks/utils/getFiltersFromURL.test.js
r3139847 r3257859 7 7 window.location = { 8 8 origin: 'http://localhost:8000', 9 href: 'http://localhost:8000', 9 10 search: '', 10 11 }; -
atlas-search/trunk/src/support/woocommerce/fields.php
r3239389 r3257859 60 60 $attributes = array(); 61 61 foreach ( $data['attributes'] as $attribute ) { 62 if ( isset( $attribute['name'] ) && taxonomy_exists( $attribute['name'] ) ) {62 if ( ! empty( $attribute['name'] ) && taxonomy_exists( $attribute['name'] ) ) { 63 63 // Fetch terms for the attribute. 64 64 // We need to treat these as taxonomies. … … 70 70 wp_get_post_terms( $wc_product->get_id(), $attribute['name'] ) 71 71 ); 72 } elseif ( isset( $attribute['name'],$attribute['options'] ) ) {72 } elseif ( ! empty( $attribute['name'] ) && isset( $attribute['options'] ) ) { 73 73 $attributes[ $attribute['name'] ] = $attribute['options']; 74 74 }
Note: See TracChangeset
for help on using the changeset viewer.