From 72949ff1cbbeab4f6366c56ce37682106a4c36d8 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 21 Jun 2022 22:58:43 +0530 Subject: [PATCH 01/73] Add tests for instant results feature --- .wp-env.json | 3 +- .../features/instant-results.spec.js | 52 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/cypress/integration/features/instant-results.spec.js diff --git a/.wp-env.json b/.wp-env.json index 790a395135..49159bf9bb 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -9,7 +9,8 @@ "https://downloads.wordpress.org/plugin/debug-bar.zip", "https://downloads.wordpress.org/plugin/debug-bar-elasticpress.zip", "https://downloads.wordpress.org/plugin/wordpress-importer.zip", - "https://downloads.wordpress.org/plugin/woocommerce.zip" + "https://downloads.wordpress.org/plugin/woocommerce.zip", + "10up/elasticpress-proxy#develop" ], "mappings": { "wp-content/mu-plugins/unique-index-name.php": "./tests/cypress/wordpress-files/test-mu-plugins/unique-index-name.php", diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js new file mode 100644 index 0000000000..35bedf5901 --- /dev/null +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -0,0 +1,52 @@ +describe('Instant Results Feature', () => { + before(() => { + cy.deactivatePlugin('elasticpress-proxy', 'wpCli'); + }); + + after(() => { + cy.deactivatePlugin('elasticpress-proxy', 'wpCli'); + }); + + it('Can activate the feature and sync automatically', () => { + cy.login(); + + cy.activatePlugin('elasticpress-proxy'); + + cy.visitAdminPage('admin.php?page=elasticpress'); + cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.ep-feature-instant-results [name="settings[active]"][value="1"]').click(); + cy.get('.ep-feature-instant-results .button-primary').click(); + cy.on('window:confirm', () => { + return true; + }); + + cy.get('.ep-sync-progress strong', { + timeout: Cypress.config('elasticPressIndexTimeout'), + }).should('contain.text', 'Sync complete'); + + cy.wpCli('elasticpress list-features').its('stdout').should('contain', 'instant-results'); + }); + + it('Can see instant results list', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('hello'); + cy.get('.wp-block-search__button').click(); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'Search results'); + }); + + it('Can click outside when instant results are shown', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('hello'); + cy.get('.wp-block-search__button').click(); + cy.get('.ep-search-modal').should('be.visible'); + + cy.get('#wpadminbar li#wp-admin-bar-debug-bar').click(); + cy.get('#querylist').should('be.visible'); + }); +}); From 59459d1d140dff0b6c35cbb116f92338a1bfd54a Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 14 Jul 2022 13:07:02 +0530 Subject: [PATCH 02/73] Change the activation to dashboard and test post name --- .../integration/features/instant-results.spec.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 35bedf5901..3d0c23dd98 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -1,17 +1,15 @@ describe('Instant Results Feature', () => { before(() => { - cy.deactivatePlugin('elasticpress-proxy', 'wpCli'); + cy.activatePlugin('elasticpress-proxy', 'dashboard'); }); after(() => { - cy.deactivatePlugin('elasticpress-proxy', 'wpCli'); + cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); }); it('Can activate the feature and sync automatically', () => { cy.login(); - cy.activatePlugin('elasticpress-proxy'); - cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); cy.get('.ep-feature-instant-results [name="settings[active]"][value="1"]').click(); @@ -32,9 +30,9 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('hello'); + cy.get('.wp-block-search__input').type('blog'); cy.get('.wp-block-search__button').click(); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'Search results'); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); }); it('Can click outside when instant results are shown', () => { @@ -42,7 +40,7 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('hello'); + cy.get('.wp-block-search__input').type('blog'); cy.get('.wp-block-search__button').click(); cy.get('.ep-search-modal').should('be.visible'); From b12fb4f601021b4d819d0095e05711f735479d03 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 4 Aug 2022 00:29:06 +0530 Subject: [PATCH 03/73] More test cases for instant results --- .../features/instant-results.spec.js | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 3d0c23dd98..53ff71d1a4 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -1,12 +1,55 @@ describe('Instant Results Feature', () => { before(() => { - cy.activatePlugin('elasticpress-proxy', 'dashboard'); + cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { + // Nothing needs to be done if EP.io. + if (epHost.stdout.match(/elasticpress\.io/)) { + return; + } + cy.activatePlugin('elasticpress-proxy', 'dashboard'); + }); }); after(() => { cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); }); + it("Can't activate the feature If not in ElasticPress.io nor using a custom PHP proxy", () => { + cy.login(); + + cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { + // Nothing needs to be done if EP.io. + if (epHost.stdout.match(/elasticpress\.io/)) { + return; + } + cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); + cy.visitAdminPage('admin.php?page=elasticpress'); + cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.requirements-status-notice').should( + 'contain.text', + 'To use this feature you need to be an ElasticPress.io customer or implement a custom proxy', + ); + cy.get('.ep-feature-instant-results .input-wrap').should('have.class', 'disabled'); + cy.activatePlugin('elasticpress-proxy', 'dashboard'); + }); + }); + + it('Can see a warning if using cusotom proxy', () => { + cy.login(); + cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { + // Nothing needs to be done if EP.io. + if (epHost.stdout.match(/elasticpress\.io/)) { + return; + } + cy.visitAdminPage('admin.php?page=elasticpress'); + cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.requirements-status-notice').should( + 'contain.text', + 'You are using a custom proxy. Make sure you implement all security measures needed', + ); + cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); + }); + }); + it('Can activate the feature and sync automatically', () => { cy.login(); From 159f86140d0b1b0cff59717d177d1f02faae9e8c Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Thu, 4 Aug 2022 13:44:30 +0500 Subject: [PATCH 04/73] Add E2E tests for WooCommerce --- .../integration/features/woocommerce.spec.js | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index a5b9ed6fd5..f33e86226f 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -42,6 +42,9 @@ describe('WooCommerce Feature', () => { cy.maybeEnableFeature('protected_content'); cy.maybeEnableFeature('woocommerce'); + // this is required to sync the orders to Elasticsearch. + cy.wpCli('elasticpress index --setup --yes'); + cy.visitAdminPage('edit.php?post_type=shop_order'); cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug').should( 'contain.text', @@ -85,4 +88,40 @@ describe('WooCommerce Feature', () => { 'Query Response Code: HTTP 200', ); }); + + it('Can search orders from ElasticPress in WP Dashboard', () => { + cy.login(); + + cy.maybeEnableFeature('protected_content'); + cy.maybeEnableFeature('woocommerce'); + + cy.visitAdminPage('edit.php?post_type=shop_order'); + + cy.get('#post-search-input').type('1988'); + cy.get('#search-submit').click(); + + cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug').should( + 'contain.text', + 'Query Response Code: HTTP 200', + ); + + cy.get('.order_number .order-view').should('contain.text', '#1988 Mozelle Davis'); + }); + + it('Can a user only see his orders on the My Account Order page', () => { + cy.login(); + + cy.maybeEnableFeature('protected_content'); + cy.maybeEnableFeature('woocommerce'); + + cy.visit('my-account/orders'); + + cy.get('.woocommerce-orders-table tbody tr').should('have.length', 3); + + // Test orderby parameter set to date in query. + cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug').should( + 'contain.text', + '["orderby"]=>\n string(4) "date"\n', + ); + }); }); From e1274d177d905547a23d5f93a7fd3c0844a2c567 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Thu, 4 Aug 2022 13:46:14 +0500 Subject: [PATCH 05/73] minor change --- tests/cypress/integration/features/woocommerce.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index f33e86226f..3a72b872d6 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -118,7 +118,7 @@ describe('WooCommerce Feature', () => { cy.get('.woocommerce-orders-table tbody tr').should('have.length', 3); - // Test orderby parameter set to date in query. + // Test orderby parameter set to `date` in query. cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug').should( 'contain.text', '["orderby"]=>\n string(4) "date"\n', From 0aa3bc87bafae10d3ff8689a48d799f2598c03fb Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 9 Aug 2022 14:47:18 +0500 Subject: [PATCH 06/73] Addressed feedback --- .../integration/features/woocommerce.spec.js | 80 ++++++++++++++++--- tests/cypress/support/commands.js | 10 +++ .../test-plugins/enable-debug-bar.php | 10 +++ 3 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 tests/cypress/wordpress-files/test-plugins/enable-debug-bar.php diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index 3a72b872d6..f29dd7ab99 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -1,5 +1,24 @@ describe('WooCommerce Feature', () => { + const userData = { + username: 'testuser', + email: 'testuser@example.com', + password: 'password', + firstName: 'John', + lastName: 'Cena', + address: '123 Main St', + city: 'Culver City', + postCode: '90230', + phoneNumber: '1234567890', + }; + before(() => { + // delete user if exists. + cy.wpCli(`wp user get ${userData.username} --field=ID`, true).then((wpCliResponse) => { + if (wpCliResponse.code === 0) { + cy.wpCli(`wp user delete ${userData.username} --yes --network`); + } + }); + cy.deactivatePlugin('woocommerce', 'wpCli'); }); @@ -89,39 +108,76 @@ describe('WooCommerce Feature', () => { ); }); - it('Can search orders from ElasticPress in WP Dashboard', () => { + it("can not display other users' orders on the My Account Order page", () => { cy.login(); + cy.activatePlugin('woocommerce'); + cy.activatePlugin('enable-debug-bar'); + cy.maybeEnableFeature('protected_content'); cy.maybeEnableFeature('woocommerce'); - cy.visitAdminPage('edit.php?post_type=shop_order'); + // enable payment gateway. + cy.visitAdminPage('admin.php?page=wc-settings&tab=checkout§ion=cod'); + cy.get('#woocommerce_cod_enabled').check(); + cy.get('.button-primary.woocommerce-save-button').click(); + + cy.logout(); - cy.get('#post-search-input').type('1988'); - cy.get('#search-submit').click(); + // create and login a new user. + cy.wpCli( + `wp user create ${userData.username} ${userData.email} --user_pass=${userData.password}`, + ); + cy.visit('my-account'); + cy.get('#username').type(userData.username); + cy.get('#password').type(`${userData.password}{enter}`); + + // add product to cart. + cy.visit('product/fantastic-silk-knife'); + cy.get('.single_add_to_cart_button').click(); + + // checkout and place order. + cy.visit('checkout'); + cy.get('#billing_first_name').type(userData.firstName); + cy.get('#billing_last_name').type(userData.lastName); + cy.get('#billing_address_1').type(userData.address); + cy.get('#billing_city').type(userData.city); + cy.get('#billing_postcode').type(userData.postCode); + cy.get('#billing_phone').type(userData.phoneNumber); + cy.get('#place_order').click(); + + // ensure order is placed. + cy.url().should('include', '/checkout/order-received'); + + // ensure order is visible to user. + cy.visit('my-account/orders'); + cy.get('.woocommerce-orders-table tbody tr').should('have.length', 1); + // Test orderby parameter set to `date` in query. cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug').should( 'contain.text', - 'Query Response Code: HTTP 200', + '["orderby"]=>\n string(4) "date"\n', ); - - cy.get('.order_number .order-view').should('contain.text', '#1988 Mozelle Davis'); }); - it('Can a user only see his orders on the My Account Order page', () => { + it('Can search orders from ElasticPress in WP Dashboard', () => { cy.login(); cy.maybeEnableFeature('protected_content'); cy.maybeEnableFeature('woocommerce'); - cy.visit('my-account/orders'); + cy.visitAdminPage('edit.php?post_type=shop_order'); - cy.get('.woocommerce-orders-table tbody tr').should('have.length', 3); + cy.get('#post-search-input').type(`${userData.firstName} ${userData.lastName}{enter}`); - // Test orderby parameter set to `date` in query. cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug').should( 'contain.text', - '["orderby"]=>\n string(4) "date"\n', + 'Query Response Code: HTTP 200', + ); + + cy.get('.order_number .order-view').should( + 'contain.text', + `${userData.firstName} ${userData.lastName}`, ); }); }); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 233db50237..d170aa19db 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -289,3 +289,13 @@ Cypress.Commands.add('deactivatePlugin', (slug, method = 'dashboard', mode = 'si } cy.wpCli(command); }); + +Cypress.Commands.add('logout', () => { + cy.visit('/wp-admin'); + cy.get('body').then(($body) => { + if ($body.find('#wpadminbar').length !== 0) { + cy.get('#wp-admin-bar-my-account').invoke('addClass', 'hover'); + cy.get('#wp-admin-bar-logout > a').click(); + } + }); +}); diff --git a/tests/cypress/wordpress-files/test-plugins/enable-debug-bar.php b/tests/cypress/wordpress-files/test-plugins/enable-debug-bar.php new file mode 100644 index 0000000000..1ecb271c3e --- /dev/null +++ b/tests/cypress/wordpress-files/test-plugins/enable-debug-bar.php @@ -0,0 +1,10 @@ + Date: Tue, 9 Aug 2022 17:11:19 +0530 Subject: [PATCH 07/73] Add search widget to test the results --- .../features/instant-results.spec.js | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 53ff71d1a4..e334836cfc 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -1,4 +1,18 @@ describe('Instant Results Feature', () => { + /** + * Create a Search widget. + */ + function createSearchWidget() { + cy.openWidgetsPage(); + + cy.get('.edit-widgets-header-toolbar__inserter-toggle').click(); + cy.get('.block-editor-inserter__panel-content [class*="search/default"]').click({ + force: true, + }); + + cy.get('.edit-widgets-header__actions .components-button.is-primary').click(); + cy.get('body').should('contain.text', 'Widgets saved.'); + } before(() => { cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { // Nothing needs to be done if EP.io. @@ -7,6 +21,8 @@ describe('Instant Results Feature', () => { } cy.activatePlugin('elasticpress-proxy', 'dashboard'); }); + // Add search widget that will be used for the tests. + createSearchWidget(); }); after(() => { @@ -73,7 +89,7 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); + cy.get('.wp-block-search__input').type('test'); cy.get('.wp-block-search__button').click(); cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); }); @@ -83,7 +99,7 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); + cy.get('.wp-block-search__input').type('test'); cy.get('.wp-block-search__button').click(); cy.get('.ep-search-modal').should('be.visible'); From ce7271d97ba6dfb91288a333112dc0a0ca2516a4 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 9 Aug 2022 17:25:25 +0500 Subject: [PATCH 08/73] Minor change --- tests/cypress/integration/features/woocommerce.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index f29dd7ab99..155affc927 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -108,7 +108,7 @@ describe('WooCommerce Feature', () => { ); }); - it("can not display other users' orders on the My Account Order page", () => { + it('Can not display other users orders on the My Account Order page', () => { cy.login(); cy.activatePlugin('woocommerce'); From 23bd7263d70ce142de35f7eb3442ff4b9292499d Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 9 Aug 2022 18:07:36 +0530 Subject: [PATCH 09/73] Proepr text to test against the search --- tests/cypress/integration/features/instant-results.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index e334836cfc..eb6a63d961 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -91,7 +91,7 @@ describe('Instant Results Feature', () => { cy.visit('/'); cy.get('.wp-block-search__input').type('test'); cy.get('.wp-block-search__button').click(); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); }); it('Can click outside when instant results are shown', () => { From 08f62e98dbb0bb8a64f402951bc41d6dea01f3f1 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Fri, 12 Aug 2022 16:04:33 +0500 Subject: [PATCH 10/73] Minor change --- tests/cypress/integration/features/woocommerce.spec.js | 2 +- .../cypress/wordpress-files/test-plugins/enable-debug-bar.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index 155affc927..b68ed70ed8 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -4,7 +4,7 @@ describe('WooCommerce Feature', () => { email: 'testuser@example.com', password: 'password', firstName: 'John', - lastName: 'Cena', + lastName: 'Doe', address: '123 Main St', city: 'Culver City', postCode: '90230', diff --git a/tests/cypress/wordpress-files/test-plugins/enable-debug-bar.php b/tests/cypress/wordpress-files/test-plugins/enable-debug-bar.php index 1ecb271c3e..261bc3b876 100644 --- a/tests/cypress/wordpress-files/test-plugins/enable-debug-bar.php +++ b/tests/cypress/wordpress-files/test-plugins/enable-debug-bar.php @@ -7,4 +7,5 @@ * License: GPLv2 or later */ -add_filter( 'pre_option_ep_last_sync', '__return_empty_array' ); +add_filter( 'debug_bar_enable', '__return_true' ); +add_filter( 'show_admin_bar', '__return_true' ); From 56b8a1092195abc3fff6b0f71de602b98e7948a2 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Fri, 12 Aug 2022 17:25:12 +0500 Subject: [PATCH 11/73] Update env file --- .wp-env.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.wp-env.json b/.wp-env.json index bbee30b2b1..dd0a47139d 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -18,6 +18,7 @@ "wp-content/plugins/unsupported-server-software.php": "./tests/cypress/wordpress-files/test-plugins/unsupported-server-software.php", "wp-content/plugins/unsupported-elasticsearch-version.php": "./tests/cypress/wordpress-files/test-plugins/unsupported-elasticsearch-version.php", "wp-content/plugins/shorten-autosave.php": "./tests/cypress/wordpress-files/test-plugins/shorten-autosave.php", + "wp-content/plugins/enable-debug-bar.php": "./tests/cypress/wordpress-files/test-plugins/enable-debug-bar.php", "wp-content/uploads/content-example.xml": "./tests/cypress/wordpress-files/test-docs/content-example.xml" } } From fabb9483438ebdc4d30e4704a4051d42c626eff4 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 16 Aug 2022 13:42:22 +0500 Subject: [PATCH 12/73] Set filter priority --- tests/cypress/integration/features/woocommerce.spec.js | 8 ++------ .../wordpress-files/test-plugins/enable-debug-bar.php | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index 2855ec3e8e..3d0cff27ce 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -12,12 +12,8 @@ describe('WooCommerce Feature', () => { }; before(() => { - // delete user if exists. - cy.wpCli(`wp user get ${userData.username} --field=ID`, true).then((wpCliResponse) => { - if (wpCliResponse.code === 0) { - cy.wpCli(`wp user delete ${userData.username} --yes --network`); - } - }); + // delete test user. + cy.wpCli(`wp user delete ${userData.username} --yes --network`, true); cy.deactivatePlugin('woocommerce', 'wpCli'); }); diff --git a/tests/cypress/wordpress-files/test-plugins/enable-debug-bar.php b/tests/cypress/wordpress-files/test-plugins/enable-debug-bar.php index 261bc3b876..005c7c7a24 100644 --- a/tests/cypress/wordpress-files/test-plugins/enable-debug-bar.php +++ b/tests/cypress/wordpress-files/test-plugins/enable-debug-bar.php @@ -8,4 +8,4 @@ */ add_filter( 'debug_bar_enable', '__return_true' ); -add_filter( 'show_admin_bar', '__return_true' ); +add_filter( 'show_admin_bar', '__return_true', 99 ); From fb94a6628c12b83148c4f976d1c3c7a4b7b99285 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 16 Aug 2022 17:22:25 +0500 Subject: [PATCH 13/73] Move delete user snippet to beforeEach --- tests/cypress/integration/features/woocommerce.spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index 3d0cff27ce..8d92e8c881 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -11,10 +11,12 @@ describe('WooCommerce Feature', () => { phoneNumber: '1234567890', }; - before(() => { + beforeEach(() => { // delete test user. cy.wpCli(`wp user delete ${userData.username} --yes --network`, true); + }); + before(() => { cy.deactivatePlugin('woocommerce', 'wpCli'); }); From 648d69bf132a20161ba4454ae75edc5887c8ebfb Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 16 Aug 2022 18:10:44 +0500 Subject: [PATCH 14/73] Minor change --- tests/cypress/integration/features/woocommerce.spec.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index 8d92e8c881..a33a5f7bf6 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -11,11 +11,6 @@ describe('WooCommerce Feature', () => { phoneNumber: '1234567890', }; - beforeEach(() => { - // delete test user. - cy.wpCli(`wp user delete ${userData.username} --yes --network`, true); - }); - before(() => { cy.deactivatePlugin('woocommerce', 'wpCli'); }); @@ -125,6 +120,9 @@ describe('WooCommerce Feature', () => { cy.logout(); + // delete test user. + cy.wpCli(`wp user delete ${userData.username} --yes --network`, true); + // create and login a new user. cy.wpCli( `wp user create ${userData.username} ${userData.email} --user_pass=${userData.password}`, @@ -157,7 +155,7 @@ describe('WooCommerce Feature', () => { // Test orderby parameter set to `date` in query. cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug').should( 'contain.text', - '["orderby"]=>\n string(4) "date"\n', + "'orderby' => 'date'", ); }); From 3da23cb8a40f531cb345513b1cef279b7a9aa214 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 18 Aug 2022 01:04:30 +0530 Subject: [PATCH 15/73] show the same modal after reload --- .../features/instant-results.spec.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index eb6a63d961..ce33140986 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -13,6 +13,7 @@ describe('Instant Results Feature', () => { cy.get('.edit-widgets-header__actions .components-button.is-primary').click(); cy.get('body').should('contain.text', 'Widgets saved.'); } + before(() => { cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { // Nothing needs to be done if EP.io. @@ -89,9 +90,21 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('test'); + cy.get('.wp-block-search__input').type('blog'); + cy.get('.wp-block-search__button').click(); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + }); + + it('Can show the modal in the same state after a reload', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('blog'); cy.get('.wp-block-search__button').click(); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.reload(); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); }); it('Can click outside when instant results are shown', () => { @@ -99,7 +112,7 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('test'); + cy.get('.wp-block-search__input').type('blog'); cy.get('.wp-block-search__button').click(); cy.get('.ep-search-modal').should('be.visible'); From c62f87e14349af73a9998270063a43265af5b93b Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 18 Aug 2022 15:39:10 +0530 Subject: [PATCH 16/73] add delay to test the results --- .../features/instant-results.spec.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index ce33140986..34ec4c3d36 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -91,8 +91,11 @@ describe('Instant Results Feature', () => { cy.visit('/'); cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button').click(); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('.wp-block-search__button') + .click() + .then(() => { + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + }); }); it('Can show the modal in the same state after a reload', () => { @@ -102,9 +105,17 @@ describe('Instant Results Feature', () => { cy.visit('/'); cy.get('.wp-block-search__input').type('blog'); cy.get('.wp-block-search__button').click(); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('.wp-block-search__button') + .click() + .then(() => { + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + }); cy.reload(); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('.wp-block-search__button') + .click() + .then(() => { + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + }); }); it('Can click outside when instant results are shown', () => { From ff12865ea4405f5519b672eb30747dc0164bbbfa Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Fri, 19 Aug 2022 15:35:52 +0530 Subject: [PATCH 17/73] Add more tests for Instant results --- .../features/instant-results.spec.js | 72 ++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 34ec4c3d36..6fa58ffd14 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -98,24 +98,94 @@ describe('Instant Results Feature', () => { }); }); + it('Can display the number of results', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('blog'); + cy.get('.wp-block-search__button') + .click() + .then(() => { + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('.ep-search-results__title').contains(/\d+/); + }); + }); + it('Can show the modal in the same state after a reload', () => { cy.login(); cy.maybeEnableFeature('instant-results'); cy.visit('/'); cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button').click(); cy.get('.wp-block-search__button') .click() .then(() => { cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); }); cy.reload(); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + }); + + it('Can update the results after changing the search term', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('blog'); + cy.get('.wp-block-search__button') + .click() + .then(() => { + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + }); + cy.get('#ep-instant-results .ep-search-input') + .clearThenType('test') + .then(() => { + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); + }); + }); + + it('Can update the URL after changing the filters', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('blog'); cy.get('.wp-block-search__button') .click() .then(() => { cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); }); + cy.get('ep-search-sidebar #ep-search-post-type-page') + .click() + .then(() => { + cy.url().should('include', 'ep-post_type=page'); + }); + }); + + it('Can show post type label alongside taxonomies', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + cy.visitAdminPage('admin.php?page=elasticpress'); + cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.ep-feature-instant-results .components-form-token-field__input') + .type('category') + .first() + .click() + .then((input) => { + input.type('category').first().click(); + }); + cy.get('.ep-feature-instant-results .button-primary').click(); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('test'); + cy.get('.wp-block-search__button') + .click() + .then(() => { + cy.get('.ep-search-modal ep-search-sidebar') + .last() + .should('contain.text', 'Category (Products)'); + }); }); it('Can click outside when instant results are shown', () => { From 524e91c4f9d9a05036c1eb8eb6b888d2ea2718d8 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Wed, 17 Aug 2022 19:04:16 +0500 Subject: [PATCH 18/73] E2E tests for Comments Add E2E tests for Comments Feature --- .../integration/features/comments.spec.js | 211 ++++++++++++++++++ tests/cypress/support/commands.js | 10 + 2 files changed, 221 insertions(+) create mode 100644 tests/cypress/integration/features/comments.spec.js diff --git a/tests/cypress/integration/features/comments.spec.js b/tests/cypress/integration/features/comments.spec.js new file mode 100644 index 0000000000..bda95f5082 --- /dev/null +++ b/tests/cypress/integration/features/comments.spec.js @@ -0,0 +1,211 @@ +describe('Comments Feature', () => { + const defaultApprovedComments = 26; + + before(() => { + cy.visitAdminPage('options-discussion.php'); + cy.get('#require_name_email').check(); + cy.get('#comment_moderation').check(); + cy.get('#comment_previously_approved').check(); + cy.get('#submit').click(); + }); + + it('Can automatically start a sync if activate the feature', () => { + cy.login(); + + cy.maybeDisableFeature('comments'); + + cy.visitAdminPage('admin.php?page=elasticpress'); + + cy.get('.ep-feature-comments .settings-button').click(); + cy.get('.ep-feature-comments [name="settings[active]"][value="1"]').click(); + cy.get('.ep-feature-comments .button-primary').click(); + cy.on('window:confirm', () => { + return true; + }); + + cy.get('.ep-sync-panel').last().as('syncPanel'); + cy.get('@syncPanel').find('.components-form-toggle').click(); + cy.get('@syncPanel') + .find('.ep-sync-messages', { timeout: Cypress.config('elasticPressIndexTimeout') }) + .should('contain.text', 'Mapping sent') + .should('contain.text', 'Sync complete'); + + cy.wpCli('elasticpress list-features').its('stdout').should('contain', 'comments'); + }); + + it('Can only sync approved comments', () => { + cy.login(); + cy.maybeEnableFeature('comments'); + + cy.visitAdminPage('admin.php?page=elasticpress-sync'); + + // start sync and test results. + cy.get('.ep-sync-button--sync').click(); + cy.get('.ep-sync-panel').first().as('syncPanel'); + cy.get('@syncPanel').find('.components-form-toggle').click(); + cy.get('@syncPanel') + .find('.ep-sync-messages', { timeout: Cypress.config('elasticPressIndexTimeout') }) + .should('contain.text', `Number of comments indexed: ${defaultApprovedComments}`); + }); + + it('Can not sync anonymous comments', () => { + cy.login(); + cy.maybeEnableFeature('comments'); + + // enable wordpress comments + cy.visitAdminPage('options-discussion.php'); + cy.get('#require_name_email').uncheck(); + cy.get('#submit').click(); + + cy.publishPost({ + title: 'Test Comment', + }); + + cy.logout(); + + // publish comment as a logged out user + cy.visit('/'); + cy.contains('#main .entry-title a', 'Test Comment').first().click(); + cy.get('#comment').type('This is a anonymous comment'); + cy.get('#submit').click(); + + // start sync and test results. + cy.visitAdminPage('admin.php?page=elasticpress-sync'); + cy.get('.ep-sync-button--sync').click(); + cy.get('.ep-sync-panel').first().as('syncPanel'); + cy.get('@syncPanel').find('.components-form-toggle').click(); + cy.get('@syncPanel') + .find('.ep-sync-messages', { + timeout: Cypress.config('elasticPressIndexTimeout'), + }) + .should('contain.text', `Number of comments indexed: ${defaultApprovedComments}`); + + // trash the comment + cy.visitAdminPage('edit-comments.php?comment_status=moderated'); + cy.get('.column-comment .trash a').first().click({ force: true }); + }); + + it('Can sync comments if approved manually', () => { + cy.login(); + cy.publishPost({ + title: 'Test Post', + }); + + cy.logout(); + + // publish comment as a logged out user + cy.visit('/'); + cy.contains('#main .entry-title a', 'Test Post').first().click(); + cy.get('#comment').type('This is a pending comment'); + cy.get('#author').type('Test Author'); + cy.get('#email').type('test@example.com'); + cy.get('#submit').click(); + + cy.visitAdminPage('edit-comments.php'); + cy.maybeEnableFeature('comments'); + + // approve the comment + cy.visitAdminPage('edit-comments.php?comment_status=moderated'); + cy.get('.approve a').first().click({ force: true }); + + // start sync and test results. + cy.visitAdminPage('admin.php?page=elasticpress-sync'); + cy.get('.ep-sync-button--sync').click(); + cy.get('.ep-sync-panel').first().as('syncPanel'); + cy.get('@syncPanel').find('.components-form-toggle').click(); + cy.get('@syncPanel') + .find('.ep-sync-messages', { + timeout: Cypress.config('elasticPressIndexTimeout'), + }) + .should('contain.text', `Number of comments indexed: ${defaultApprovedComments + 1}`); + + // trash the comment + cy.visitAdminPage('edit-comments.php?comment_status=approved'); + cy.get('.column-comment .trash a').first().click({ force: true }); + }); + + it('Can see ElasticPress - Comment widget in dashboard', () => { + cy.maybeEnableFeature('comments'); + cy.visitAdminPage('widgets.php'); + cy.get('.widget-title h3').should('contain', 'ElasticPress - Comments'); + }); + + it('Can sync woocommerce reviews', () => { + cy.login(); + cy.activatePlugin('woocommerce'); + cy.maybeEnableFeature('comments'); + cy.maybeEnableFeature('woocommerce'); + + // enable product reviews. + cy.visit('product/awesome-aluminum-shoes/'); + cy.get('#wp-admin-bar-edit a').click(); + cy.get('.advanced_options.advanced_tab').click(); + cy.get('#comment_status').check(); + cy.get('#publish').click(); + + // visit product page and leave a review + cy.get('#wp-admin-bar-view a').click(); + cy.get('#tab-title-reviews a').click(); + cy.get('.comment-form-rating .star-4').click(); + cy.get('#comment').type('This is a test review'); + cy.get('#submit').click(); + + // start sync and test results. + cy.visitAdminPage('admin.php?page=elasticpress-sync'); + cy.get('.ep-sync-button--sync').click(); + cy.get('.ep-sync-panel').first().as('syncPanel'); + cy.get('@syncPanel').find('.components-form-toggle').click(); + cy.get('@syncPanel') + .find('.ep-sync-messages', { timeout: Cypress.config('elasticPressIndexTimeout') }) + .should('contain.text', `Number of comments indexed: ${defaultApprovedComments + 1}`); + + // trash the review + cy.visitAdminPage( + 'edit.php?post_type=product&page=product-reviews&comment_status=approved', + ); + cy.get('.column-comment .trash a').first().click({ force: true }); + + cy.deactivatePlugin('woocommerce', 'wpCli'); + }); + + it('Can sync anonymous comments when settings are disabled', () => { + cy.login(); + cy.maybeEnableFeature('comments'); + + cy.visitAdminPage('options-discussion.php'); + + // disable settings. + cy.get('#require_name_email').uncheck(); + cy.get('#comment_moderation').uncheck(); + cy.get('#comment_previously_approved').uncheck(); + cy.get('#submit').click(); + + // create test post. + cy.publishPost({ + title: 'Test Comment', + }); + + cy.logout(); + + // publish comment as a logged out user + cy.visit('/'); + cy.contains('#main .entry-title a', 'Test Comment').first().click(); + cy.get('#comment').type('This is a anonymous comment'); + cy.get('#submit').click(); + + // start sync and test results. + cy.visitAdminPage('admin.php?page=elasticpress-sync'); + cy.get('.ep-sync-button--sync').click(); + cy.get('.ep-sync-panel').first().as('syncPanel'); + cy.get('@syncPanel').find('.components-form-toggle').click(); + cy.get('@syncPanel') + .find('.ep-sync-messages', { + timeout: Cypress.config('elasticPressIndexTimeout'), + }) + .should('contain.text', `Number of comments indexed: ${defaultApprovedComments + 1}`); + + // trash the comment + cy.visitAdminPage('edit-comments.php?comment_status=approved'); + cy.get('.column-comment .trash a').first().click({ force: true }); + }); +}); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index b584341b9d..b4213d32bc 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -414,3 +414,13 @@ Cypress.Commands.add('createAutosavePost', (postData) => { cy.wait(5000); cy.deactivatePlugin('shorten-autosave', 'wpCli'); }); + +Cypress.Commands.add('logout', () => { + cy.visit('/wp-admin'); + cy.get('body').then(($body) => { + if ($body.find('#wpadminbar').length !== 0) { + cy.get('#wp-admin-bar-my-account').invoke('addClass', 'hover'); + cy.get('#wp-admin-bar-logout > a').click(); + } + }); +}); From e13c6d570eb75f242ff5a989e1eec9f2badf5dc9 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Mon, 22 Aug 2022 13:28:57 +0500 Subject: [PATCH 19/73] Minor change --- tests/cypress/integration/features/comments.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/comments.spec.js b/tests/cypress/integration/features/comments.spec.js index bda95f5082..49b6c7f5c1 100644 --- a/tests/cypress/integration/features/comments.spec.js +++ b/tests/cypress/integration/features/comments.spec.js @@ -2,6 +2,7 @@ describe('Comments Feature', () => { const defaultApprovedComments = 26; before(() => { + // set default settings. cy.visitAdminPage('options-discussion.php'); cy.get('#require_name_email').check(); cy.get('#comment_moderation').check(); @@ -52,7 +53,7 @@ describe('Comments Feature', () => { cy.login(); cy.maybeEnableFeature('comments'); - // enable wordpress comments + // enable comments cy.visitAdminPage('options-discussion.php'); cy.get('#require_name_email').uncheck(); cy.get('#submit').click(); From def00fc49ab277f263492ecc6f79dbb1ef970190 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 23 Aug 2022 01:57:50 +0530 Subject: [PATCH 20/73] Change the filter --- .../features/instant-results.spec.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 6fa58ffd14..377610a942 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -150,16 +150,16 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); + cy.get('.wp-block-search__input').type('test'); cy.get('.wp-block-search__button') .click() .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); }); - cy.get('ep-search-sidebar #ep-search-post-type-page') + cy.get('ep-search-sidebar #ep-search-post-type-post') .click() .then(() => { - cy.url().should('include', 'ep-post_type=page'); + cy.url().should('include', 'ep-post_type=post'); }); }); @@ -168,14 +168,17 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.ep-feature-instant-results .components-form-token-field__input') + .type('category') + .first() + .click(); cy.get('.ep-feature-instant-results .components-form-token-field__input') .type('category') .first() .click() - .then((input) => { - input.type('category').first().click(); + .then(() => { + cy.get('.ep-feature-instant-results .button-primary').click(); }); - cy.get('.ep-feature-instant-results .button-primary').click(); cy.visit('/'); cy.get('.wp-block-search__input').type('test'); From 88cc2cda7c8193b84c8f1102a1957ee6ada875e4 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 23 Aug 2022 02:42:51 +0530 Subject: [PATCH 21/73] Proper class names --- tests/cypress/integration/features/instant-results.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 377610a942..f521341211 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -156,7 +156,7 @@ describe('Instant Results Feature', () => { .then(() => { cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); }); - cy.get('ep-search-sidebar #ep-search-post-type-post') + cy.get('.ep-search-sidebar #ep-search-post-type-post') .click() .then(() => { cy.url().should('include', 'ep-post_type=post'); @@ -185,7 +185,7 @@ describe('Instant Results Feature', () => { cy.get('.wp-block-search__button') .click() .then(() => { - cy.get('.ep-search-modal ep-search-sidebar') + cy.get('.ep-search-modal .ep-search-sidebar') .last() .should('contain.text', 'Category (Products)'); }); From 92cb69c3698bb595f2a05b9f97be28518ae2e119 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 23 Aug 2022 03:14:22 +0530 Subject: [PATCH 22/73] Search for a category --- .../cypress/integration/features/instant-results.spec.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index f521341211..b72b127165 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -181,13 +181,14 @@ describe('Instant Results Feature', () => { }); cy.visit('/'); - cy.get('.wp-block-search__input').type('test'); + cy.get('.wp-block-search__input').type('aciform'); cy.get('.wp-block-search__button') .click() .then(() => { - cy.get('.ep-search-modal .ep-search-sidebar') - .last() - .should('contain.text', 'Category (Products)'); + cy.get('.ep-search-modal .ep-search-sidebar').should( + 'contain.text', + 'Category (Posts)', + ); }); }); From affd195d1563c8615bf55a66617e9dedc22a0da2 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 23 Aug 2022 03:50:59 +0530 Subject: [PATCH 23/73] Search for a post with category --- tests/cypress/integration/features/instant-results.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index b72b127165..6bc6682b41 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -181,7 +181,7 @@ describe('Instant Results Feature', () => { }); cy.visit('/'); - cy.get('.wp-block-search__input').type('aciform'); + cy.get('.wp-block-search__input').type('Keyboard navigation'); cy.get('.wp-block-search__button') .click() .then(() => { From 23edea835a3e59750fc81835e0f40f6b118b4f81 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 23 Aug 2022 04:28:53 +0530 Subject: [PATCH 24/73] Remove the taxonomy label test for now --- .../features/instant-results.spec.js | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 6bc6682b41..5769fa81d4 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -163,35 +163,6 @@ describe('Instant Results Feature', () => { }); }); - it('Can show post type label alongside taxonomies', () => { - cy.login(); - cy.maybeEnableFeature('instant-results'); - cy.visitAdminPage('admin.php?page=elasticpress'); - cy.get('.ep-feature-instant-results .settings-button').click(); - cy.get('.ep-feature-instant-results .components-form-token-field__input') - .type('category') - .first() - .click(); - cy.get('.ep-feature-instant-results .components-form-token-field__input') - .type('category') - .first() - .click() - .then(() => { - cy.get('.ep-feature-instant-results .button-primary').click(); - }); - - cy.visit('/'); - cy.get('.wp-block-search__input').type('Keyboard navigation'); - cy.get('.wp-block-search__button') - .click() - .then(() => { - cy.get('.ep-search-modal .ep-search-sidebar').should( - 'contain.text', - 'Category (Posts)', - ); - }); - }); - it('Can click outside when instant results are shown', () => { cy.login(); cy.maybeEnableFeature('instant-results'); From cc4ce83e79a55c722ff12692d27d726cc52e39b0 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Thu, 25 Aug 2022 11:55:51 +0500 Subject: [PATCH 25/73] Addressed feedback --- .../integration/features/woocommerce.spec.js | 64 +++++++++++++++---- tests/cypress/support/commands.js | 25 ++++++++ 2 files changed, 77 insertions(+), 12 deletions(-) diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index a33a5f7bf6..0a2abb174a 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -2,7 +2,6 @@ describe('WooCommerce Feature', () => { const userData = { username: 'testuser', email: 'testuser@example.com', - password: 'password', firstName: 'John', lastName: 'Doe', address: '123 Main St', @@ -120,16 +119,12 @@ describe('WooCommerce Feature', () => { cy.logout(); - // delete test user. - cy.wpCli(`wp user delete ${userData.username} --yes --network`, true); - - // create and login a new user. - cy.wpCli( - `wp user create ${userData.username} ${userData.email} --user_pass=${userData.password}`, - ); - cy.visit('my-account'); - cy.get('#username').type(userData.username); - cy.get('#password').type(`${userData.password}{enter}`); + // create new user. + cy.createUser({ + username: userData.username, + email: userData.email, + login: true, + }); // add product to cart. cy.visit('product/fantastic-silk-knife'); @@ -157,18 +152,63 @@ describe('WooCommerce Feature', () => { 'contain.text', "'orderby' => 'date'", ); + + cy.logout(); + + cy.createUser({ + username: 'testuser2', + email: 'testuser2@example.com', + login: true, + }); + + // ensure no order is show. + cy.visit('my-account/orders'); + cy.get('.woocommerce-orders-table tbody tr').should('have.length', 0); + + cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug').should( + 'contain.text', + 'Query Response Code: HTTP 200', + ); }); it('Can search orders from ElasticPress in WP Dashboard', () => { cy.login(); + cy.activatePlugin('woocommerce'); cy.maybeEnableFeature('protected_content'); cy.maybeEnableFeature('woocommerce'); cy.visitAdminPage('edit.php?post_type=shop_order'); - cy.get('#post-search-input').type(`${userData.firstName} ${userData.lastName}{enter}`); + // search order by user's name. + cy.get('#post-search-input') + .clear() + .type(`${userData.firstName} ${userData.lastName}{enter}`); + + cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug').should( + 'contain.text', + 'Query Response Code: HTTP 200', + ); + + cy.get('.order_number .order-view').should( + 'contain.text', + `${userData.firstName} ${userData.lastName}`, + ); + + // search order by user's address. + cy.get('#post-search-input').clear().type(`${userData.address}{enter}`); + cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug').should( + 'contain.text', + 'Query Response Code: HTTP 200', + ); + + cy.get('.order_number .order-view').should( + 'contain.text', + `${userData.firstName} ${userData.lastName}`, + ); + // search order by product. + cy.get('#post-search-input').clear().type(`fantastic-silk-knife{enter}`); cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug').should( 'contain.text', 'Query Response Code: HTTP 200', diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index b4213d32bc..5c409c61d8 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -424,3 +424,28 @@ Cypress.Commands.add('logout', () => { } }); }); + +Cypress.Commands.add('createUser', (userData) => { + const newUserDate = { + username: 'testuser', + password: 'password', + email: 'testuser@example.com', + role: 'subscriber', + login: false, + ...userData, + }; + + // delete the user. + cy.wpCli(`wp user delete ${newUserDate.username} --yes --network`, true); + + // create the user + cy.wpCli( + `wp user create ${newUserDate.username} ${newUserDate.email} --user_pass=${newUserDate.password} --role=${newUserDate.role}`, + ); + + if (newUserDate.login) { + cy.visit('wp-login.php'); + cy.get('#user_login').clear().type(newUserDate.username); + cy.get('#user_pass').clear().type(`${newUserDate.password}{enter}`); + } +}); From 49dff57b13f5d69603d4b7a9194b8ed07ffbc2fb Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 25 Aug 2022 16:48:58 +0530 Subject: [PATCH 26/73] Merge small tests and improve code --- .../features/instant-results.spec.js | 115 ++++++------------ 1 file changed, 40 insertions(+), 75 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 5769fa81d4..79ecb43a70 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -1,43 +1,44 @@ describe('Instant Results Feature', () => { /** - * Create a Search widget. + * Check if it's Elasticpress.io. */ - function createSearchWidget() { - cy.openWidgetsPage(); - - cy.get('.edit-widgets-header-toolbar__inserter-toggle').click(); - cy.get('.block-editor-inserter__panel-content [class*="search/default"]').click({ - force: true, - }); - - cy.get('.edit-widgets-header__actions .components-button.is-primary').click(); - cy.get('body').should('contain.text', 'Widgets saved.'); - } - - before(() => { + function isEpIo() { cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { // Nothing needs to be done if EP.io. if (epHost.stdout.match(/elasticpress\.io/)) { - return; + return true; } + return false; + }); + } + + before(() => { + if (!isEpIo()) { cy.activatePlugin('elasticpress-proxy', 'dashboard'); + } + // Create a sample post and index + cy.publishPost({ + title: 'Blog post', + content: 'This is a sample Blog post.', + }); + cy.publishPost({ + title: 'Test Post', + content: 'This is a sample test post.', }); - // Add search widget that will be used for the tests. - createSearchWidget(); + cy.wpCli('elasticpress index --setup --yes'); }); after(() => { cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); }); - it("Can't activate the feature If not in ElasticPress.io nor using a custom PHP proxy", () => { + /** + * Test that the feature cannot be activted when not in ElasticPress.io nor using a custom PHP proxy. + * Also, it can show a warning when using a custom PHP proxy + */ + it("Can't activate the feature If not in ElasticPress.io nor using a custom PHP proxy and can see a warning if using cusotom proxy", () => { cy.login(); - - cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { - // Nothing needs to be done if EP.io. - if (epHost.stdout.match(/elasticpress\.io/)) { - return; - } + if (!isEpIo()) { cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); @@ -46,17 +47,8 @@ describe('Instant Results Feature', () => { 'To use this feature you need to be an ElasticPress.io customer or implement a custom proxy', ); cy.get('.ep-feature-instant-results .input-wrap').should('have.class', 'disabled'); + // Can see the warning if using custom proxy cy.activatePlugin('elasticpress-proxy', 'dashboard'); - }); - }); - - it('Can see a warning if using cusotom proxy', () => { - cy.login(); - cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { - // Nothing needs to be done if EP.io. - if (epHost.stdout.match(/elasticpress\.io/)) { - return; - } cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); cy.get('.requirements-status-notice').should( @@ -64,9 +56,12 @@ describe('Instant Results Feature', () => { 'You are using a custom proxy. Make sure you implement all security measures needed', ); cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); - }); + } }); + /** + * Test that the feature can be activted and it can sync automatically. + */ it('Can activate the feature and sync automatically', () => { cy.login(); @@ -85,20 +80,13 @@ describe('Instant Results Feature', () => { cy.wpCli('elasticpress list-features').its('stdout').should('contain', 'instant-results'); }); - it('Can see instant results list', () => { - cy.login(); - cy.maybeEnableFeature('instant-results'); - - cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button') - .click() - .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); - }); - }); - - it('Can display the number of results', () => { + /** + * Test that the instant results list is visible + * It can display the number of test results + * It can show the modal in the same state after a reload + * Can change the URL when search term is changed + */ + it('Can see instant results list, number of results, modal in the same state after reload, and updated result after changing the search term', () => { cy.login(); cy.maybeEnableFeature('instant-results'); @@ -108,36 +96,13 @@ describe('Instant Results Feature', () => { .click() .then(() => { cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + // Show the number of results cy.get('.ep-search-results__title').contains(/\d+/); }); - }); - - it('Can show the modal in the same state after a reload', () => { - cy.login(); - cy.maybeEnableFeature('instant-results'); - - cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button') - .click() - .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); - }); + // Show the modal in the same state after a reload cy.reload(); cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); - }); - - it('Can update the results after changing the search term', () => { - cy.login(); - cy.maybeEnableFeature('instant-results'); - - cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button') - .click() - .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); - }); + // Update the results when search term is changed cy.get('#ep-instant-results .ep-search-input') .clearThenType('test') .then(() => { From fc68cf5102e28c596236aa3c077c915d93b492fb Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 25 Aug 2022 17:21:36 +0530 Subject: [PATCH 27/73] Add search widget --- .../features/instant-results.spec.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 79ecb43a70..0031eb23ac 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -1,4 +1,19 @@ describe('Instant Results Feature', () => { + /** + * Create a Search widget. + */ + function createSearchWidget() { + cy.openWidgetsPage(); + + cy.get('.edit-widgets-header-toolbar__inserter-toggle').click(); + cy.get('.block-editor-inserter__panel-content [class*="search/default"]').click({ + force: true, + }); + + cy.get('.edit-widgets-header__actions .components-button.is-primary').click(); + cy.get('body').should('contain.text', 'Widgets saved.'); + } + /** * Check if it's Elasticpress.io. */ @@ -26,6 +41,8 @@ describe('Instant Results Feature', () => { content: 'This is a sample test post.', }); cy.wpCli('elasticpress index --setup --yes'); + // Add search widget that will be used for the tests. + createSearchWidget(); }); after(() => { From 227558d48935bb6e6274942b0566111b81bd7c22 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 25 Aug 2022 18:08:23 +0530 Subject: [PATCH 28/73] Should be able to enable the feature when in ep.io --- tests/cypress/integration/features/instant-results.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 0031eb23ac..7f0b930031 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -73,6 +73,8 @@ describe('Instant Results Feature', () => { 'You are using a custom proxy. Make sure you implement all security measures needed', ); cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); + } else { + cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); } }); From bb47c93f502ca5c9e3db5e1eba1c66907d6c45af Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Fri, 26 Aug 2022 02:48:41 +0530 Subject: [PATCH 29/73] Add wrap for the result --- .../features/instant-results.spec.js | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 7f0b930031..82f6a7dca0 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -20,10 +20,7 @@ describe('Instant Results Feature', () => { function isEpIo() { cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { // Nothing needs to be done if EP.io. - if (epHost.stdout.match(/elasticpress\.io/)) { - return true; - } - return false; + cy.wrap(epHost.stdout.match(/elasticpress\.io/)); }); } @@ -55,27 +52,26 @@ describe('Instant Results Feature', () => { */ it("Can't activate the feature If not in ElasticPress.io nor using a custom PHP proxy and can see a warning if using cusotom proxy", () => { cy.login(); - if (!isEpIo()) { - cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); - cy.visitAdminPage('admin.php?page=elasticpress'); - cy.get('.ep-feature-instant-results .settings-button').click(); - cy.get('.requirements-status-notice').should( - 'contain.text', - 'To use this feature you need to be an ElasticPress.io customer or implement a custom proxy', - ); - cy.get('.ep-feature-instant-results .input-wrap').should('have.class', 'disabled'); - // Can see the warning if using custom proxy - cy.activatePlugin('elasticpress-proxy', 'dashboard'); - cy.visitAdminPage('admin.php?page=elasticpress'); - cy.get('.ep-feature-instant-results .settings-button').click(); - cy.get('.requirements-status-notice').should( - 'contain.text', - 'You are using a custom proxy. Make sure you implement all security measures needed', - ); - cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); - } else { - cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); + if (isEpIo()) { + return; } + cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); + cy.visitAdminPage('admin.php?page=elasticpress'); + cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.requirements-status-notice').should( + 'contain.text', + 'To use this feature you need to be an ElasticPress.io customer or implement a custom proxy', + ); + cy.get('.ep-feature-instant-results .input-wrap').should('have.class', 'disabled'); + // Can see the warning if using custom proxy + cy.activatePlugin('elasticpress-proxy', 'dashboard'); + cy.visitAdminPage('admin.php?page=elasticpress'); + cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.requirements-status-notice').should( + 'contain.text', + 'You are using a custom proxy. Make sure you implement all security measures needed', + ); + cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); }); /** From 2b8585d3fa2451a2c90da697d6d48323a5c378f8 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Fri, 26 Aug 2022 12:24:29 +0500 Subject: [PATCH 30/73] Feedback Addressed --- .../integration/features/comments.spec.js | 43 ++----------------- 1 file changed, 4 insertions(+), 39 deletions(-) diff --git a/tests/cypress/integration/features/comments.spec.js b/tests/cypress/integration/features/comments.spec.js index 49b6c7f5c1..7c7fb7b285 100644 --- a/tests/cypress/integration/features/comments.spec.js +++ b/tests/cypress/integration/features/comments.spec.js @@ -29,26 +29,13 @@ describe('Comments Feature', () => { cy.get('@syncPanel') .find('.ep-sync-messages', { timeout: Cypress.config('elasticPressIndexTimeout') }) .should('contain.text', 'Mapping sent') - .should('contain.text', 'Sync complete'); + .should('contain.text', 'Sync complete') + // check that the number of approved comments is the same as the default. + .should('contain.text', `Number of comments indexed: ${defaultApprovedComments}`); cy.wpCli('elasticpress list-features').its('stdout').should('contain', 'comments'); }); - it('Can only sync approved comments', () => { - cy.login(); - cy.maybeEnableFeature('comments'); - - cy.visitAdminPage('admin.php?page=elasticpress-sync'); - - // start sync and test results. - cy.get('.ep-sync-button--sync').click(); - cy.get('.ep-sync-panel').first().as('syncPanel'); - cy.get('@syncPanel').find('.components-form-toggle').click(); - cy.get('@syncPanel') - .find('.ep-sync-messages', { timeout: Cypress.config('elasticPressIndexTimeout') }) - .should('contain.text', `Number of comments indexed: ${defaultApprovedComments}`); - }); - it('Can not sync anonymous comments', () => { cy.login(); cy.maybeEnableFeature('comments'); @@ -80,30 +67,13 @@ describe('Comments Feature', () => { timeout: Cypress.config('elasticPressIndexTimeout'), }) .should('contain.text', `Number of comments indexed: ${defaultApprovedComments}`); - - // trash the comment - cy.visitAdminPage('edit-comments.php?comment_status=moderated'); - cy.get('.column-comment .trash a').first().click({ force: true }); }); it('Can sync comments if approved manually', () => { cy.login(); - cy.publishPost({ - title: 'Test Post', - }); - - cy.logout(); - - // publish comment as a logged out user - cy.visit('/'); - cy.contains('#main .entry-title a', 'Test Post').first().click(); - cy.get('#comment').type('This is a pending comment'); - cy.get('#author').type('Test Author'); - cy.get('#email').type('test@example.com'); - cy.get('#submit').click(); + cy.maybeEnableFeature('comments'); cy.visitAdminPage('edit-comments.php'); - cy.maybeEnableFeature('comments'); // approve the comment cy.visitAdminPage('edit-comments.php?comment_status=moderated'); @@ -181,11 +151,6 @@ describe('Comments Feature', () => { cy.get('#comment_previously_approved').uncheck(); cy.get('#submit').click(); - // create test post. - cy.publishPost({ - title: 'Test Comment', - }); - cy.logout(); // publish comment as a logged out user From 544d318e964a936ff4892ca8b67b55b14cfa406c Mon Sep 17 00:00:00 2001 From: Jacob Peattie Date: Wed, 31 Aug 2022 22:32:40 +1000 Subject: [PATCH 31/73] Move Autosuggest script to directory. --- assets/js/{autosuggest.js => autosuggest/index.js} | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename assets/js/{autosuggest.js => autosuggest/index.js} (99%) diff --git a/assets/js/autosuggest.js b/assets/js/autosuggest/index.js similarity index 99% rename from assets/js/autosuggest.js rename to assets/js/autosuggest/index.js index 463fcef3b1..ccd9295354 100644 --- a/assets/js/autosuggest.js +++ b/assets/js/autosuggest/index.js @@ -9,7 +9,7 @@ import { replaceGlobally, debounce, domReady, -} from './utils/helpers'; +} from '../utils/helpers'; const { epas } = window; diff --git a/package.json b/package.json index 66119f6a3e..e970d0ed3a 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ }, "10up-toolkit": { "entry": { - "autosuggest-script.min": "./assets/js/autosuggest.js", + "autosuggest-script.min": "./assets/js/autosuggest/index.js", "comments-script.min": "./assets/js/comments.js", "dashboard-script.min": "./assets/js/dashboard.js", "facets-script.min": "./assets/js/facets.js", From e0adc071a934483af843df545c4f0ad997dc392f Mon Sep 17 00:00:00 2001 From: Jacob Peattie Date: Wed, 31 Aug 2022 23:34:08 +1000 Subject: [PATCH 32/73] Migrate Autosuggest filters to proper WordPress hooks --- assets/js/autosuggest/back-compat.js | 40 +++++++++ assets/js/autosuggest/index.js | 123 ++++++++++++++++++--------- 2 files changed, 122 insertions(+), 41 deletions(-) create mode 100644 assets/js/autosuggest/back-compat.js diff --git a/assets/js/autosuggest/back-compat.js b/assets/js/autosuggest/back-compat.js new file mode 100644 index 0000000000..1f26c9ab5e --- /dev/null +++ b/assets/js/autosuggest/back-compat.js @@ -0,0 +1,40 @@ +/** + * WordPress dependencies. + */ +import { addFilter } from '@wordpress/hooks'; + +if (typeof window.epDataFilter !== 'undefined') { + addFilter('ep.Autosuggest.data', 'ep/epDatafilter', window.epDatafilter); +} + +if (typeof window.epAutosuggestItemHTMLFilter !== 'undefined') { + addFilter( + 'ep.Autosuggest.itemHTML', + 'ep/epAutosuggestItemHTMLFilter', + window.epAutosuggestItemHTMLFilter, + ); +} + +if (typeof window.epAutosuggestListItemsHTMLFilter !== 'undefined') { + addFilter( + 'ep.Autosuggest.listHTML', + 'ep/epAutosuggestListItemsHTMLFilter', + window.epAutosuggestListItemsHTMLFilter, + ); +} + +if (typeof window.epAutosuggestQueryFilter !== 'undefined') { + addFilter( + 'ep.Autosuggest.query', + 'ep/epAutosuggestQueryFilter', + window.epAutosuggestQueryFilter, + ); +} + +if (typeof window.epAutosuggestElementFilter !== 'undefined') { + addFilter( + 'ep.Autosuggest.element', + 'ep/epAutosuggestElementFilter', + window.epAutosuggestElementFilter, + ); +} diff --git a/assets/js/autosuggest/index.js b/assets/js/autosuggest/index.js index ccd9295354..b70728c1ea 100644 --- a/assets/js/autosuggest/index.js +++ b/assets/js/autosuggest/index.js @@ -1,8 +1,14 @@ -/* eslint-disable camelcase, no-underscore-dangle, no-use-before-define */ +/* eslint-disable camelcase, no-underscore-dangle, no-use-before-define, jsdoc/check-tag-names */ + +/** + * WordPress dependencies. + */ +import { applyFilters } from '@wordpress/hooks'; /** * Internal dependencies. */ +import './back-compat'; import { findAncestorByClass, escapeDoubleQuotes, @@ -195,13 +201,16 @@ async function esSearch(query, searchTerm) { const data = await response.json(); - // allow for filtered data before returning it to - // be output on the front end - if (typeof window.epDataFilter !== 'undefined') { - return window.epDataFilter(data, searchTerm); - } - - return data; + /** + * Filter the Elasticsearch response data used for Autosuggest. + * + * @hook ep.Autosuggest.data + * @since 4.4.0 + * + * @param {object} data Response data. + * @returns {object} Response data. + */ + return applyFilters('ep.Autosuggest.data', data, searchTerm); } catch (error) { // eslint-disable-next-line no-console console.error(error); @@ -217,11 +226,10 @@ async function esSearch(query, searchTerm) { * @returns {boolean} return true */ function updateAutosuggestBox(options, input) { - let i; - let itemString = ''; + let listHTML = ''; // get the search term for use later on - const { value } = input; + const { value: searchText } = input; const container = findAncestorByClass(input, 'ep-autosuggest-container'); const resultsContainer = container.querySelector('.ep-autosuggest'); const suggestList = resultsContainer.querySelector('.autosuggest-list'); @@ -244,12 +252,13 @@ function updateAutosuggestBox(options, input) { // create markup for list items // eslint-disable-next-line - for ( i = 0; resultsLimit > i; ++i ) { - const text = options[i]._source.post_title; - const url = options[i]._source.permalink; + for ( let index = 0; resultsLimit > index; ++index ) { + const option = options[index]; + const text = option._source.post_title; + const url = option._source.permalink; const escapedText = escapeDoubleQuotes(text); - const searchParts = value.trim().split(' '); + const searchParts = searchText.trim().split(' '); let resultsText = escapedText; if (epas.highlightingEnabled) { @@ -262,25 +271,44 @@ function updateAutosuggestBox(options, input) { ); } - let itemHTML = `
  • + let itemHTML = `
  • ${resultsText}
  • `; - if (typeof window.epAutosuggestItemHTMLFilter !== 'undefined') { - itemHTML = window.epAutosuggestItemHTMLFilter(itemHTML, options[i], i, value); - } + /** + * Filter the HTML for an Autosuggest suggestion. + * + * @hook ep.Autosuggest.itemHTML + * @since 4.4.0 + * + * @param {string} itemHTML Item HTML. + * @param {object} option Elasticsearch record for suggestion. + * @param {number} index Suggestion index. + * @param {string} searchText Search term. + * @returns {string} Item HTML. + */ + itemHTML = applyFilters('ep.Autosuggest.itemHTML', itemHTML, option, index, searchText); - itemString += itemHTML; + listHTML += itemHTML; } - if (typeof window.epAutosuggestListItemsHTMLFilter !== 'undefined') { - itemString = window.epAutosuggestListItemsHTMLFilter(itemString, options, input); - } + /** + * Filter the HTML for the list of Autosuggest suggestions. + * + * @hook ep.Autosuggest.listHTML + * @since 4.4.0 + * + * @param {string} listHTML List HTML. + * @param {object[]} options Elasticsearch records for suggestions. + * @param {Element} input Input element that triggered Autosuggest. + * @returns {string} List HTML. + */ + listHTML = applyFilters('ep.Autosuggest.listHTML', listHTML, options, input); // append list items to the list - suggestList.innerHTML = itemString; + suggestList.innerHTML = listHTML; const autosuggestItems = Array.from(document.querySelectorAll('.autosuggest-link')); @@ -552,9 +580,9 @@ function init() { let query = buildSearchQuery(searchText, placeholder, queryJSON); - if (postTypes.length > 0) { - query = JSON.parse(query); + query = JSON.parse(query); + if (postTypes.length > 0) { if (typeof query.post_filter.bool.must !== 'undefined') { query.post_filter.bool.must.push({ terms: { @@ -562,16 +590,21 @@ function init() { }, }); } - - query = JSON.stringify(query); } - // Allow filtering the search query based on the input. - if (typeof window.epAutosuggestQueryFilter !== 'undefined') { - query = JSON.stringify( - window.epAutosuggestQueryFilter(JSON.parse(query), searchText, input), - ); - } + /** + * Filter the Elasticsearch query used for Autosuggest. + * + * @hook ep.Autosuggest.query + * @since 4.4.0 + * + * @param {object} query Elasticsearch query. + * @param {string} searchText Search term. + * @param {Element} input Input element that triggered Autosuggest. + * @returns {object} Elasticsearch query. + */ + query = applyFilters('ep.Autosuggest.query', query, searchText, input); + query = JSON.stringify(query); // fetch the results const response = await esSearch(query, searchText); @@ -643,10 +676,10 @@ function init() { /** * Insert an autosuggest list after an element. * - * @param {Element} element Element to add the autosuggest list after. + * @param {Element} previousElement Element to add the autosuggest list after. * @returns {void} */ - const insertAutosuggestElement = (element) => { + const insertAutosuggestElement = (previousElement) => { if (!autosuggestElement) { autosuggestElement = document.createElement('div'); autosuggestElement.classList.add('ep-autosuggest'); @@ -659,13 +692,21 @@ function init() { autosuggestElement.appendChild(autosuggestList); } - let clonedElement = autosuggestElement.cloneNode(true); + let element = autosuggestElement.cloneNode(true); - if (typeof window.epAutosuggestElementFilter !== 'undefined') { - clonedElement = window.epAutosuggestElementFilter(clonedElement, element); - } + /** + * Filter the Autosuggest container element before it is inserted. + * + * @hook ep.Autosuggest.element + * @since 4.4.0 + * + * @param {Element} element Autosuggest container element. + * @param {Element} previousElement Element the container will be inserted after. + * @returns {Element} Autosuggest container element. + */ + element = applyFilters('ep.Autosuggest.element', element, previousElement); - element.insertAdjacentElement('afterend', clonedElement); + previousElement.insertAdjacentElement('afterend', element); }; /** From 23b9474ab6b3a4be5b73aea479aa20a9eaa6c3f4 Mon Sep 17 00:00:00 2001 From: Daniel Kudwien Date: Wed, 31 Aug 2022 22:16:43 +0200 Subject: [PATCH 33/73] Fixed WooCommerc data privacy eraser query deletes all orders with ElasticPress. --- includes/classes/Indexable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/classes/Indexable.php b/includes/classes/Indexable.php index 5f15a97037..10dbdd9495 100644 --- a/includes/classes/Indexable.php +++ b/includes/classes/Indexable.php @@ -1038,7 +1038,7 @@ public function build_meta_query( $meta_queries ) { if ( false !== $terms_obj ) { $meta_filter[] = $terms_obj; } - } elseif ( is_array( $single_meta_query ) && isset( $single_meta_query[0] ) && is_array( $single_meta_query[0] ) ) { + } elseif ( is_array( $single_meta_query ) ) { /** * Handle multidimensional array. Something like: * From be277a62986f3fe43010571675707620640a0271 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 2 Sep 2022 15:11:58 -0300 Subject: [PATCH 34/73] Stop faceting feed queries --- includes/classes/Feature/Facets/Facets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/classes/Feature/Facets/Facets.php b/includes/classes/Feature/Facets/Facets.php index 58268b4291..2cb8f620ab 100644 --- a/includes/classes/Feature/Facets/Facets.php +++ b/includes/classes/Feature/Facets/Facets.php @@ -237,7 +237,7 @@ public function is_facetable( $query ) { return true; } - if ( is_admin() ) { + if ( is_admin() || is_feed() ) { return false; } From 1da17373382f64bf0bf6e56c7a7b4f81682ce9ac Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Mon, 5 Sep 2022 12:09:11 +0500 Subject: [PATCH 35/73] Fix: Persist WooCommerce sorting in Facet --- includes/classes/Feature/Facets/Facets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/classes/Feature/Facets/Facets.php b/includes/classes/Feature/Facets/Facets.php index 58268b4291..c5e6feb14d 100644 --- a/includes/classes/Feature/Facets/Facets.php +++ b/includes/classes/Feature/Facets/Facets.php @@ -499,7 +499,7 @@ public function output_feature_box_long() { * @since 3.6.0 */ public function get_allowed_query_args() { - $args = array( 's', 'post_type' ); + $args = array( 's', 'post_type', 'orderby' ); /** * Filter allowed query args From 009621b4820b8c6ced70f4cbd65eec4d9a696d62 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Mon, 5 Sep 2022 12:56:11 +0500 Subject: [PATCH 36/73] Fix Tests --- tests/cypress/integration/features/search/search.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/cypress/integration/features/search/search.spec.js b/tests/cypress/integration/features/search/search.spec.js index 104194509c..18f9c91c58 100644 --- a/tests/cypress/integration/features/search/search.spec.js +++ b/tests/cypress/integration/features/search/search.spec.js @@ -135,6 +135,8 @@ describe('Post Search Feature', () => { }, }).then(() => { cy.wpCli('elasticpress index --setup --yes').then(() => { + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(1000); cy.visit('/?s=awesome-aluminum-shoes-variation-sku'); cy.contains( '.site-content article:nth-of-type(1) h2', From a7b0e621cc68a79174e54e85e84220610f8c6ad9 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Mon, 5 Sep 2022 14:03:59 +0500 Subject: [PATCH 37/73] Fix Unit-tests --- includes/classes/Feature/SearchOrdering/SearchOrdering.php | 1 + tests/cypress/integration/features/search/search.spec.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/classes/Feature/SearchOrdering/SearchOrdering.php b/includes/classes/Feature/SearchOrdering/SearchOrdering.php index cb24056224..14f79de4cd 100644 --- a/includes/classes/Feature/SearchOrdering/SearchOrdering.php +++ b/includes/classes/Feature/SearchOrdering/SearchOrdering.php @@ -380,6 +380,7 @@ public function get_pointer_data_for_localize() { 'post_type' => 'any', 'post__in' => $post_ids, 'count' => count( $post_ids ), + 'orderby' => 'post__in', ] ); diff --git a/tests/cypress/integration/features/search/search.spec.js b/tests/cypress/integration/features/search/search.spec.js index 18f9c91c58..acdcb3c80b 100644 --- a/tests/cypress/integration/features/search/search.spec.js +++ b/tests/cypress/integration/features/search/search.spec.js @@ -136,7 +136,7 @@ describe('Post Search Feature', () => { }).then(() => { cy.wpCli('elasticpress index --setup --yes').then(() => { // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(1000); + cy.wait(2000); cy.visit('/?s=awesome-aluminum-shoes-variation-sku'); cy.contains( '.site-content article:nth-of-type(1) h2', From 997ce0bf3ea522fbcf86c67f22bb25c905152f31 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Mon, 5 Sep 2022 16:59:13 +0500 Subject: [PATCH 38/73] Fix terms e2e test --- tests/cypress/integration/features/terms.spec.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/cypress/integration/features/terms.spec.js b/tests/cypress/integration/features/terms.spec.js index 4e5b8e0124..494a3002a5 100644 --- a/tests/cypress/integration/features/terms.spec.js +++ b/tests/cypress/integration/features/terms.spec.js @@ -86,6 +86,9 @@ describe('Terms Feature', () => { .find('.row-actions .delete a') .click({ force: true }); + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(2000); + // Re-search for the term and make sure it's not there. cy.get('#search-submit').click(); cy.get('.wp-list-table tbody').should('contain.text', 'No categories found'); From 0580f7c8d1df2311a2c1b601416cee48c06c33fa Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 6 Sep 2022 11:51:33 +0500 Subject: [PATCH 39/73] Fix: Term search in admin panel for non public taxonomies --- .../Indexable/Term/QueryIntegration.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/includes/classes/Indexable/Term/QueryIntegration.php b/includes/classes/Indexable/Term/QueryIntegration.php index b061566666..5ecd64f0e4 100644 --- a/includes/classes/Indexable/Term/QueryIntegration.php +++ b/includes/classes/Indexable/Term/QueryIntegration.php @@ -79,6 +79,10 @@ public function maybe_filter_query( $results, WP_Term_Query $query ) { return $results; } + if ( ! $this->is_indexable_taxonomies( $query ) ) { + return $results; + } + $new_terms = apply_filters( 'ep_wp_query_cached_terms', null, $query ); if ( null === $new_terms ) { @@ -333,4 +337,18 @@ protected function format_hits_as_names( $terms, $new_terms ) { return $new_terms; } + /** + * Determine if all taxonomies are indexable. + * + * @param \WP_Term_Query $query The WP_Term_Query object. + * @return boolean + */ + protected function is_indexable_taxonomies( $query ) { + + $taxonomies = $query->query_vars['taxonomy']; + $indexable_taxonomies = Indexables::factory()->get( 'term' )->get_indexable_taxonomies(); + + return empty( array_diff( $taxonomies, $indexable_taxonomies ) ); + } + } From 055b4965e5b1f64ac1569e4f85c25f6d8801702c Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 6 Sep 2022 12:31:39 +0500 Subject: [PATCH 40/73] fix tests --- .../classes/Indexable/Term/QueryIntegration.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/includes/classes/Indexable/Term/QueryIntegration.php b/includes/classes/Indexable/Term/QueryIntegration.php index 5ecd64f0e4..9dfbe8b7c8 100644 --- a/includes/classes/Indexable/Term/QueryIntegration.php +++ b/includes/classes/Indexable/Term/QueryIntegration.php @@ -79,7 +79,7 @@ public function maybe_filter_query( $results, WP_Term_Query $query ) { return $results; } - if ( ! $this->is_indexable_taxonomies( $query ) ) { + if ( ! $this->is_searchable( $query ) ) { return $results; } @@ -338,16 +338,19 @@ protected function format_hits_as_names( $terms, $new_terms ) { } /** - * Determine if all taxonomies are indexable. + * Determine whether ES should be used for the query if all taxonomies are indexable. * * @param \WP_Term_Query $query The WP_Term_Query object. * @return boolean */ - protected function is_indexable_taxonomies( $query ) { + protected function is_searchable( $query ) { - $taxonomies = $query->query_vars['taxonomy']; - $indexable_taxonomies = Indexables::factory()->get( 'term' )->get_indexable_taxonomies(); + $taxonomies = $query->query_vars['taxonomy']; + if ( ! $taxonomies ) { + return true; + } + $indexable_taxonomies = Indexables::factory()->get( 'term' )->get_indexable_taxonomies(); return empty( array_diff( $taxonomies, $indexable_taxonomies ) ); } From 9cf8bd9c7ac7f21242fb05dea2c166a909dc7bbf Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 6 Sep 2022 17:45:23 +0500 Subject: [PATCH 41/73] Add Comments --- tests/cypress/integration/features/search/search.spec.js | 4 ++++ tests/cypress/integration/features/terms.spec.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/tests/cypress/integration/features/search/search.spec.js b/tests/cypress/integration/features/search/search.spec.js index acdcb3c80b..52ecb03da1 100644 --- a/tests/cypress/integration/features/search/search.spec.js +++ b/tests/cypress/integration/features/search/search.spec.js @@ -135,6 +135,10 @@ describe('Post Search Feature', () => { }, }).then(() => { cy.wpCli('elasticpress index --setup --yes').then(() => { + /** + * Give Elasticsearch some time. Apparently, if the visit happens right after the index, it won't find anything. + * + */ // eslint-disable-next-line cypress/no-unnecessary-waiting cy.wait(2000); cy.visit('/?s=awesome-aluminum-shoes-variation-sku'); diff --git a/tests/cypress/integration/features/terms.spec.js b/tests/cypress/integration/features/terms.spec.js index 494a3002a5..6f8210e220 100644 --- a/tests/cypress/integration/features/terms.spec.js +++ b/tests/cypress/integration/features/terms.spec.js @@ -86,6 +86,12 @@ describe('Terms Feature', () => { .find('.row-actions .delete a') .click({ force: true }); + /** + * Give Elasticsearch some time. Apparently, if we search again it returns the outdated data. + * + * @see https://github.com/10up/ElasticPress/issues/2726 + * + */ // eslint-disable-next-line cypress/no-unnecessary-waiting cy.wait(2000); From b88c9b8652175c25ae946cc623e07d683756b330 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 6 Sep 2022 17:46:24 +0500 Subject: [PATCH 42/73] Minor change --- tests/cypress/integration/features/terms.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/cypress/integration/features/terms.spec.js b/tests/cypress/integration/features/terms.spec.js index 6f8210e220..b2fa73d400 100644 --- a/tests/cypress/integration/features/terms.spec.js +++ b/tests/cypress/integration/features/terms.spec.js @@ -90,7 +90,6 @@ describe('Terms Feature', () => { * Give Elasticsearch some time. Apparently, if we search again it returns the outdated data. * * @see https://github.com/10up/ElasticPress/issues/2726 - * */ // eslint-disable-next-line cypress/no-unnecessary-waiting cy.wait(2000); From 045c83704a88a8947372e4c7666a996784901a0e Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 6 Sep 2022 18:31:22 +0500 Subject: [PATCH 43/73] Add filter to remove unavailable terms from facet --- .../Feature/Facets/Types/Taxonomy/Renderer.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php b/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php index 1bd852ee4f..0c9fd264e7 100644 --- a/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php +++ b/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php @@ -121,6 +121,16 @@ public function render( $args, $instance ) { } } + /** + * Filter the facet terms. + * + * @hook ep_facet_search_terms + * @param {array} $terms Terms + * @param {string} $taxonomy Taxonomy name + * @return {array} New terms + */ + $terms_by_slug = apply_filters( 'ep_facet_search_terms', $terms_by_slug, $taxonomy ); + /** * Check to make sure all terms exist before proceeding */ @@ -266,7 +276,7 @@ public function render( $args, $instance ) { slug ] ) ) { continue; } From 1603e94544076679fba3dccfc5f14c452c94e212 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Wed, 7 Sep 2022 15:31:54 +0500 Subject: [PATCH 44/73] Adjust Feedback --- .../Feature/Facets/Types/Taxonomy/Renderer.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php b/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php index 0c9fd264e7..cf7a3add0f 100644 --- a/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php +++ b/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php @@ -122,14 +122,15 @@ public function render( $args, $instance ) { } /** - * Filter the facet terms. + * Filter the taxonomy facet terms. * - * @hook ep_facet_search_terms + * @since 4.4.0 + * @hook ep_facet_taxonomy_terms * @param {array} $terms Terms * @param {string} $taxonomy Taxonomy name * @return {array} New terms */ - $terms_by_slug = apply_filters( 'ep_facet_search_terms', $terms_by_slug, $taxonomy ); + $terms_by_slug = apply_filters( 'ep_facet_taxonomy_terms', $terms_by_slug, $taxonomy ); /** * Check to make sure all terms exist before proceeding @@ -148,7 +149,7 @@ public function render( $args, $instance ) { $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'count'; $order = isset( $instance['order'] ) ? $instance['order'] : 'count'; - $terms = Utils\get_term_tree( $terms, $orderby, $order, true ); + $terms = Utils\get_term_tree( $terms_by_slug, $orderby, $order, true ); $outputted_terms = array(); @@ -276,7 +277,7 @@ public function render( $args, $instance ) { slug ] ) ) { continue; } From e8672cb73dc22f53ba347e3c2433670f0043c30f Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Thu, 8 Sep 2022 16:25:05 +0500 Subject: [PATCH 45/73] Add tests --- tests/php/indexables/TestTerm.php | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/php/indexables/TestTerm.php b/tests/php/indexables/TestTerm.php index d74fde16a9..07636ab3a3 100644 --- a/tests/php/indexables/TestTerm.php +++ b/tests/php/indexables/TestTerm.php @@ -1628,4 +1628,46 @@ public function testMetaWithoutValue() { $this->assertEquals( 2, count( $terms ) ); } + /** + * Test term query for non-public taxonomies. + * + * @return void + */ + public function testQueryForNonPublicTaxonomies() { + register_taxonomy( + 'wptests_tax', + 'post', + array( + 'public' => false, + ) + ); + + Functions\create_and_sync_term( 'term-name-1', 'term name 1', '', 'wptests_tax' ); + Functions\create_and_sync_term( 'term-name-2', 'term name 2', '', 'wptests_tax' ); + ElasticPress\Elasticsearch::factory()->refresh_indices(); + + $term_query = new \WP_Term_Query( + [ + 'taxonomy' => 'wptests_tax', + 'ep_integrate' => true, + 'hide_empty' => false, + ] + ); + $this->assertObjectNotHasAttribute( 'elasticsearch_success', $term_query ); + $this->assertEquals( 2, count( $term_query->terms ) ); + + Functions\create_and_sync_term( 'tag-name-1', 'tag name 1', '', 'post_tag' ); + Functions\create_and_sync_term( 'tag-name-1', 'tag name 2', '', 'post_tag' ); + ElasticPress\Elasticsearch::factory()->refresh_indices(); + + $term_query = new \WP_Term_Query( + [ + 'taxonomy' => array( 'wptests_tax', 'post_tag' ), + 'ep_integrate' => true, + 'hide_empty' => false, + ] + ); + $this->assertObjectNotHasAttribute( 'elasticsearch_success', $term_query ); + $this->assertEquals( 4, count( $term_query->terms ) ); + } } From 27619fe4428cc4fd8b84c7ed872aa6b6681f79e0 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Thu, 8 Sep 2022 21:41:55 +0500 Subject: [PATCH 46/73] Merge tests --- tests/cypress/integration/features/comments.spec.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/cypress/integration/features/comments.spec.js b/tests/cypress/integration/features/comments.spec.js index 7c7fb7b285..c576a76ecb 100644 --- a/tests/cypress/integration/features/comments.spec.js +++ b/tests/cypress/integration/features/comments.spec.js @@ -36,7 +36,7 @@ describe('Comments Feature', () => { cy.wpCli('elasticpress list-features').its('stdout').should('contain', 'comments'); }); - it('Can not sync anonymous comments', () => { + it('Can not sync anonymous comments until it is approved manually', () => { cy.login(); cy.maybeEnableFeature('comments'); @@ -67,11 +67,6 @@ describe('Comments Feature', () => { timeout: Cypress.config('elasticPressIndexTimeout'), }) .should('contain.text', `Number of comments indexed: ${defaultApprovedComments}`); - }); - - it('Can sync comments if approved manually', () => { - cy.login(); - cy.maybeEnableFeature('comments'); cy.visitAdminPage('edit-comments.php'); From fdabe6dc3bae6c0ed0042a8219a823ba9279c004 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Thu, 8 Sep 2022 21:42:54 +0500 Subject: [PATCH 47/73] Minor change --- tests/cypress/integration/features/comments.spec.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/cypress/integration/features/comments.spec.js b/tests/cypress/integration/features/comments.spec.js index c576a76ecb..cc004e5788 100644 --- a/tests/cypress/integration/features/comments.spec.js +++ b/tests/cypress/integration/features/comments.spec.js @@ -68,8 +68,6 @@ describe('Comments Feature', () => { }) .should('contain.text', `Number of comments indexed: ${defaultApprovedComments}`); - cy.visitAdminPage('edit-comments.php'); - // approve the comment cy.visitAdminPage('edit-comments.php?comment_status=moderated'); cy.get('.approve a').first().click({ force: true }); From 2978a0c10b8409eb9bd7d77f8dc133881738d4f2 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Thu, 8 Sep 2022 22:04:24 +0500 Subject: [PATCH 48/73] Feedback addressed --- .../features/search/search.spec.js | 29 --------------- .../integration/features/woocommerce.spec.js | 36 ++++++++++++++++--- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/tests/cypress/integration/features/search/search.spec.js b/tests/cypress/integration/features/search/search.spec.js index 52ecb03da1..90db47c8e6 100644 --- a/tests/cypress/integration/features/search/search.spec.js +++ b/tests/cypress/integration/features/search/search.spec.js @@ -120,33 +120,4 @@ describe('Post Search Feature', () => { cy.get('.ep-highlight').should('be.visible'); }); - - it('Can Search Product by Variation SKU', () => { - cy.login(); - cy.activatePlugin('woocommerce', 'wpCli'); - cy.maybeEnableFeature('woocommerce'); - - cy.updateWeighting({ - product: { - 'meta._variations_skus.value': { - weight: 1, - enabled: true, - }, - }, - }).then(() => { - cy.wpCli('elasticpress index --setup --yes').then(() => { - /** - * Give Elasticsearch some time. Apparently, if the visit happens right after the index, it won't find anything. - * - */ - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(2000); - cy.visit('/?s=awesome-aluminum-shoes-variation-sku'); - cy.contains( - '.site-content article:nth-of-type(1) h2', - 'Awesome Aluminum Shoes', - ).should('exist'); - }); - }); - }); }); diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index 0a2abb174a..86943f30c1 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -165,10 +165,9 @@ describe('WooCommerce Feature', () => { cy.visit('my-account/orders'); cy.get('.woocommerce-orders-table tbody tr').should('have.length', 0); - cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug').should( - 'contain.text', - 'Query Response Code: HTTP 200', - ); + cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug') + .should('contain.text', 'shop_order') + .should('contain.text', 'Query Response Code: HTTP 200'); }); it('Can search orders from ElasticPress in WP Dashboard', () => { @@ -219,4 +218,33 @@ describe('WooCommerce Feature', () => { `${userData.firstName} ${userData.lastName}`, ); }); + + it('Can Search Product by Variation SKU', () => { + cy.login(); + cy.activatePlugin('woocommerce', 'wpCli'); + cy.maybeEnableFeature('woocommerce'); + + cy.updateWeighting({ + product: { + 'meta._variations_skus.value': { + weight: 1, + enabled: true, + }, + }, + }).then(() => { + cy.wpCli('elasticpress index --setup --yes').then(() => { + /** + * Give Elasticsearch some time. Apparently, if the visit happens right after the index, it won't find anything. + * + */ + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(2000); + cy.visit('/?s=awesome-aluminum-shoes-variation-sku'); + cy.contains( + '.site-content article:nth-of-type(1) h2', + 'Awesome Aluminum Shoes', + ).should('exist'); + }); + }); + }); }); From 9323013e0dd60b42610e0ebdb7cf6e8f73b2cd11 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Thu, 8 Sep 2022 22:13:07 +0500 Subject: [PATCH 49/73] Update test assertion --- tests/cypress/integration/features/woocommerce.spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index 86943f30c1..e58ffe4759 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -148,10 +148,9 @@ describe('WooCommerce Feature', () => { cy.get('.woocommerce-orders-table tbody tr').should('have.length', 1); // Test orderby parameter set to `date` in query. - cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug').should( - 'contain.text', - "'orderby' => 'date'", - ); + cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-query-debug') + .should('contain.text', 'shop_order') + .should('contain.text', "'orderby' => 'date'"); cy.logout(); From dabc3e3ed7145af7906581f81880278aa0d4f94b Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Fri, 9 Sep 2022 11:38:42 +0500 Subject: [PATCH 50/73] Minor change --- tests/cypress/integration/features/woocommerce.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index e58ffe4759..22713fcb0e 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -155,8 +155,8 @@ describe('WooCommerce Feature', () => { cy.logout(); cy.createUser({ - username: 'testuser2', - email: 'testuser2@example.com', + username: 'buyer', + email: 'buyer@example.com', login: true, }); From b9f93448cb78f74a367af0bc412cf88f23ea6f97 Mon Sep 17 00:00:00 2001 From: Jacob Peattie Date: Tue, 13 Sep 2022 18:46:21 +1000 Subject: [PATCH 51/73] Update documentation. --- assets/js/autosuggest/index.js | 1 + docs/theme-integration.md | 93 +++++++++++++++++++++------------- 2 files changed, 59 insertions(+), 35 deletions(-) diff --git a/assets/js/autosuggest/index.js b/assets/js/autosuggest/index.js index b70728c1ea..a4f42f11e6 100644 --- a/assets/js/autosuggest/index.js +++ b/assets/js/autosuggest/index.js @@ -208,6 +208,7 @@ async function esSearch(query, searchTerm) { * @since 4.4.0 * * @param {object} data Response data. + * @param {string} searchTerm Search term. * @returns {object} Response data. */ return applyFilters('ep.Autosuggest.data', data, searchTerm); diff --git a/docs/theme-integration.md b/docs/theme-integration.md index 4af6993da7..ae44742809 100644 --- a/docs/theme-integration.md +++ b/docs/theme-integration.md @@ -36,47 +36,57 @@ You could display the loading gif while suggestions are being fetched with this ### Customize Suggestion Markup -When ElasticPress Autosuggest renders the list of suggestions, each item is run through a `window.epAutosuggestItemHTMLFilter()` function (if this function is defined). Defining this function in your theme (or a plugin, if appropriate) enables you to customize the markup for suggestions and add or remove fields to be displayed in the suggestion. +The HTML for individual Autosuggest suggestions are filtered by the `ep.Autosuggest.itemHTML` [JavaScript hook](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-hooks/). You can add or remove fields on suggestions by adding a filter to this hook from your theme (or a plugin, if appropriate). -The `epAutosuggestItemHTMLFilter()` function must return the HTML for the suggestion as a string, and accept 4 parameters: +Filters for the `ep.Autosuggest.itemHTML` hook receive the original HTML as a string and 3 additional values related to the suggestion as parameters: -1. `itemHTML` _(string)_ The suggestion HTML as a string. -2. `option` _(object)_ The Elasticsearch record for the suggestion. -3. `i` _(int)_ The index of the suggestion in the results set. -4. `searchText` _(string)_ The search term. +| Name | Type | Description +| -------------|--------|------------------------------------------------ +| `itemHTML` | string | The suggestion HTML as a string. +| `option` | object | The Elasticsearch record for the suggestion. +| `index` | number | The index of the suggestion in the results set. +| `searchText` | string | The search term. -This example uses the function to add the post date to the suggestion: +Filters must return HTML for the suggestion as a string. + +This example uses the hook to add the post date to the suggestion: ``` -window.epAutosuggestItemHTMLFilter = (itemHTML, option, i, searchText) => { +const autosuggestItemHTML = (itemHTML, option, index, searchText) => { const text = option._source.post_title; const url = option._source.permalink; const postDate = new Date(option._source.post_date).toLocaleString('en', { dateStyle: 'medium' }) - return `
  • + return `
  • ${text} (${postDate})
  • `; -} +}; + +wp.hooks.addFilter('ep.Autosuggest.itemHTML', 'myTheme/autosuggestItemHTML', autosuggestItemHTML); ``` Note that the `class`, `id`, `role`, `aria-selected`, `data-url`, and `tabindex` attributes in the returned markup must match the default values for those attributes, as they do in the example, to ensure that Autosuggest functions as normal. ### Customize Suggestions List Markup -ElasticPress Autosuggest enables customization of the entire suggestions list using the `window.epAutosuggestListItemsHTMLFilter()` function, (if this function is defined). By defining this function in your theme (or a plugin, if appropriate), you can append or prepend items to the suggestions list, or otherwise make edits to the entire list (rather than individual suggestions). +The HTML for the entire list of suggestions is filtered by the `ep.Autosuggest.listHTML` [JavaScript hook](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-hooks/). You can append or prepend items to the suggestions list, or otherwise make edits to the entire list (rather than individual suggestions), by adding a filter to this hook from your theme (or a plugin, if appropriate). + +Filters for the `ep.Autosuggest.listHTML` hook receive the original HTML as a string and 2 additional values related to the suggestion as parameters: -The `epAutosuggestListItemsHTMLFilter()` function must return the HTML for the suggestions list as a string, and accept 3 parameters: +| Name | Type | Description +| -------------|---------|----------------------------------------------- +| `listHTML` | string | The list HTML as a string. +| `options` | array | The Elasticsearch records for the suggestions. +| `input` | Element | The input element that triggered Autosuggest. -1. `listItemsHTML` _(string)_ The list items HTML as a string. -2. `options` _(array)_ The Elasticsearch records for all of the suggestions being listed. -3. `input` _(Element)_ The DOM element of the input that triggered Autosuggest. +Filters must return HTML for the suggestion list as a string. -This example uses the function to add a "View All Results" link to the bottom of the suggestions list. +This example uses the hook to add a "View All Results" link to the bottom of the suggestions list. ``` -window.epAutosuggestListItemsHTMLFilter = (listItemsHTML, options, input) => { +const autosuggestListHTMLFilter = (listHTML, options, input) => { const allUrl = new URL(input.form.action); const formData = new FormData(input.form); const urlParams = new URLSearchParams(formData); @@ -85,31 +95,37 @@ window.epAutosuggestListItemsHTMLFilter = (listItemsHTML, options, input) => { const url = allUrl.toString(); - listItemsHTML += `
  • + listHTML += `
  • View All Results
  • `; - return listItemsHTML; -} + return listHTML; +}; + +wp.hooks.addFilter('ep.Autosuggest.listHTML', 'myTheme/autosuggestListHTMLFilter', autosuggestListHTMLFilter); ``` Note that the `class`, `role`, `aria-selected`, and `tabindex` attributes in any new items must match the default values for those attributes, as they do in the example, to ensure that Autosuggest functions as normal. Items must also contain a link with the `href` and `data-url` attributes set to the URL that the item should link to. ### Customize the Suggestions Container -Before ElasticPress inserts the markup for Autosuggest into the search form the element to be added is run through a `window.epAutosuggestElementFilter()` function (if this function is defined). This function enables you to modify the markup of the Autosuggest container by defining this function in your theme (or a plugin, if appropriate). +When ElasticPress inserts the markup for Autosuggest into the search form the element to be added is filtered by the `ep.Autosuggest.element` [JavaScript hook](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-hooks/). You can modify the markup of the Autosuggest container by adding a filter to this hook from your theme (or a plugin, if appropriate). + +Filters for the `ep.Autosuggest.element` hook receive the DOM element that will be inserted and the element it will be inserted after as parameters: -The `epAutosuggestElementFilter()` function must return a DOM element, and accept 2 parameters: +| Name | Type | Description +| -----------------------|---------|----------------------------------------------- +| `element` | Element | The autosuggest container element. +| `inpreviousElementput` | Element | The element the container will be inserted after. -1. `element` _(Element)_ The DOM element being inserted. -2. `input` _(Element)_ The DOM element Autosuggest is being inserted after. +Filters must return a DOM element for the Autosuggest container. -This example uses the function to add a "Powered by ElasticPress" message to the Autosuggest dropdown. +This example uses the hook to add a "Powered by ElasticPress" message to the Autosuggest dropdown. ``` -window.epAutosuggestElementFilter = (element, input) => { +const autosuggestElementFilter = (element, previousElementput) => { const poweredBy = document.createElement('div'); poweredBy.textContent = 'Powered by ElasticPress'; @@ -117,23 +133,29 @@ window.epAutosuggestElementFilter = (element, input) => { element.appendChild(poweredBy); return element; -} +}; + +wp.hooks.addFilter('ep.Autosuggest.element', 'myTheme/autosuggestElementFilter', autosuggestElementFilter); ``` ### Customize the Autosuggest Query -To get suggestions for Autosuggest, ElasticPress sends an AJAX request containing an Elasticsearch query to your Autosuggest endpoint. This request can be modified prior to sending via the `window.epAutosuggestQueryFilter()` function (if this function is defined) in order to customize or enhance the request with additional client-side data. +To get suggestions for Autosuggest, ElasticPress sends an AJAX request containing an Elasticsearch query to your Autosuggest endpoint. Before this request is sent the Elasticsearch query is filtered by the `ep.Autosuggest.query` [JavaScript hook](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-hooks/). You can modify the query by adding a filter to this hook from your theme (or a plugin, if appropriate). + +Filters for the `ep.Autosuggest.query` hook receive the query as a JavaScript object and 2 additional values related to the request as parameters: -The `epAutosuggestQueryFilter()` function must return a JavaScript object representing the query, and accept 3 parameters: +| Name | Type | Description +| -------------|---------|------------------------------------------------ +| `query` | object | The Elasticsearch query as a JavaScript object. +| `searchText` | string | The search term. +| `input` | Element | The input element that triggered Autosuggest. -1. `query` _(Object)_ The Elasticsearch query as a JavaScript object. -2. `searchText` _(string)_ The search term. -2. `input` _(Element)_ The DOM element of the input that triggered Autosuggest. +Filters must return an Elasticsearch query as an object. This example uses the function to add the value of a `wp_dropdown_categories()` field as a filter to the search query: ``` -window.epAutosuggestQueryFilter = (query, searchText, input) => { +const autosuggestQueryFilter = (query, searchText, input) => { const formData = new FormData(input.form); const category = formData.get('cat'); @@ -146,9 +168,10 @@ window.epAutosuggestQueryFilter = (query, searchText, input) => { } return query; -} -``` +}; +wp.hooks.addFilter('ep.Autosuggest.query', 'myTheme/autosuggestQueryFilter', autosuggestQueryFilter); +``` ## Instant Results From b2e25ea72f3e00b94ec6039e6a243b2995a07a61 Mon Sep 17 00:00:00 2001 From: Jacob Peattie Date: Wed, 14 Sep 2022 00:55:53 +1000 Subject: [PATCH 52/73] Make related post block edit component functional. --- assets/js/blocks/related-posts/Edit.js | 152 ++++++++++++------------- 1 file changed, 73 insertions(+), 79 deletions(-) diff --git a/assets/js/blocks/related-posts/Edit.js b/assets/js/blocks/related-posts/Edit.js index 491102f966..0fec1dd86c 100644 --- a/assets/js/blocks/related-posts/Edit.js +++ b/assets/js/blocks/related-posts/Edit.js @@ -1,109 +1,103 @@ /** * WordPress dependencies. */ +import apiFetch from '@wordpress/api-fetch'; import { AlignmentToolbar, BlockControls, InspectorControls } from '@wordpress/block-editor'; import { PanelBody, Placeholder, Spinner, QueryControls } from '@wordpress/components'; -import { Fragment, Component, RawHTML } from '@wordpress/element'; +import { Fragment, RawHTML, useEffect, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { addQueryArgs } from '@wordpress/url'; /** - * Edit component + * Related Posts block edit component. + * + * @param {object} props Component props. + * @param {object} props.attributes Block attributes. + * @param {string} props.className Additional CSS class(es). + * @param {object} props.context Block context, + * @param {Function} props.setAttributes Attribute setter. + * @returns {Function} Component element. */ -class Edit extends Component { +export default ({ attributes, className, context, setAttributes }) => { + const { alignment, number } = attributes; + const [posts, setPosts] = useState(false); + /** - * Setup class - * - * @param {object} props Component properties + * Related posts, limited by the selected number. */ - constructor(props) { - super(props); - - this.state = { - posts: false, - }; - } + const displayPosts = posts.length > number ? posts.slice(0, number) : posts; /** - * Load preview data + * Initialize block. */ - componentDidMount() { + const handleInit = () => { const urlArgs = { number: 100, }; - // Use 0 if in the Widgets Screen - const { context: { postId = 0 } = {} } = this.props; + const { postId = 0 } = context; - wp.apiFetch({ + apiFetch({ path: addQueryArgs(`/wp/v2/posts/${postId}/related`, urlArgs), }) .then((posts) => { - this.setState({ posts }); + setPosts(posts); }) .catch(() => { - this.setState({ posts: false }); + setPosts(false); }); - } - - render() { - const { - attributes: { alignment, number }, - setAttributes, - className, - } = this.props; - const { posts } = this.state; + }; - const displayPosts = posts.length > number ? posts.slice(0, number) : posts; + /** + * Effects. + */ + useEffect(handleInit, [context]); - return ( - - - setAttributes({ alignment: newValue })} + return ( + + + setAttributes({ alignment: newValue })} + /> + + + + setAttributes({ number: value })} /> - - - - setAttributes({ number: value })} - /> - - - -
    - {displayPosts === false || displayPosts.length === 0 ? ( - - {posts === false ? ( - - ) : ( - __('No related posts yet.', 'elasticpress') - )} - - ) : ( - - )} -
    -
    - ); - } -} + + -export default Edit; +
    + {displayPosts === false || displayPosts.length === 0 ? ( + + {posts === false ? ( + + ) : ( + __('No related posts yet.', 'elasticpress') + )} + + ) : ( + + )} +
    + + ); +}; From e05433f419c5eee5f629a5d72f9c75e694251d82 Mon Sep 17 00:00:00 2001 From: Jacob Peattie Date: Wed, 14 Sep 2022 01:03:44 +1000 Subject: [PATCH 53/73] Prevent clicking Related Post links in the editor. --- assets/js/blocks/related-posts/Edit.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/assets/js/blocks/related-posts/Edit.js b/assets/js/blocks/related-posts/Edit.js index 0fec1dd86c..4be078c5cb 100644 --- a/assets/js/blocks/related-posts/Edit.js +++ b/assets/js/blocks/related-posts/Edit.js @@ -4,8 +4,11 @@ import apiFetch from '@wordpress/api-fetch'; import { AlignmentToolbar, BlockControls, InspectorControls } from '@wordpress/block-editor'; import { PanelBody, Placeholder, Spinner, QueryControls } from '@wordpress/components'; +import { useInstanceId } from '@wordpress/compose'; +import { useDispatch } from '@wordpress/data'; import { Fragment, RawHTML, useEffect, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; +import { store as noticeStore } from '@wordpress/notices'; import { addQueryArgs } from '@wordpress/url'; /** @@ -18,8 +21,10 @@ import { addQueryArgs } from '@wordpress/url'; * @param {Function} props.setAttributes Attribute setter. * @returns {Function} Component element. */ -export default ({ attributes, className, context, setAttributes }) => { +const RelatedPostsEdit = ({ attributes, className, context, setAttributes }) => { const { alignment, number } = attributes; + const { createWarningNotice } = useDispatch(noticeStore); + const instanceId = useInstanceId(RelatedPostsEdit); const [posts, setPosts] = useState(false); /** @@ -48,6 +53,21 @@ export default ({ attributes, className, context, setAttributes }) => { }); }; + /** + * Show a notice when redirect is prevented. + * + * @param {Event} event Click event. + * @returns {void} + */ + const showRedirectionPreventedNotice = (event) => { + event.preventDefault(); + + createWarningNotice(__('Links are disabled in the editor.'), { + id: `elasticpress/related-posts/redirection-prevented/${instanceId}`, + type: 'snackbar', + }); + }; + /** * Effects. */ @@ -85,7 +105,7 @@ export default ({ attributes, className, context, setAttributes }) => { const titleTrimmed = post.title.rendered.trim(); return (
  • - + {titleTrimmed ? ( {titleTrimmed} ) : ( @@ -101,3 +121,5 @@ export default ({ attributes, className, context, setAttributes }) => { ); }; + +export default RelatedPostsEdit; From 57b23796ca5a04010fd169540f59f026d1dde25d Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Thu, 15 Sep 2022 15:48:06 -0300 Subject: [PATCH 54/73] Move to 4.3.1 and add example --- .../Facets/Types/Taxonomy/Renderer.php | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php b/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php index cf7a3add0f..66944e60a9 100644 --- a/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php +++ b/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php @@ -124,11 +124,32 @@ public function render( $args, $instance ) { /** * Filter the taxonomy facet terms. * - * @since 4.4.0 + * Example of usage, to hide unavailable category terms: + * ``` + * add_filter( + * 'ep_facet_taxonomy_terms', + * function ( $terms, $taxonomy ) { + * if ( 'category' !== $taxonomy ) { + * return $terms; + * } + * + * return array_filter( + * $terms, + * function ( $term ) { + * return $term->count > 0; + * } + * ); + * }, + * 10, + * 2 + * ); + * ``` + * + * @since 4.3.1 * @hook ep_facet_taxonomy_terms - * @param {array} $terms Terms - * @param {string} $taxonomy Taxonomy name - * @return {array} New terms + * @param {array} $terms Terms + * @param {string} $taxonomy Taxonomy name + * @return {array} New terms */ $terms_by_slug = apply_filters( 'ep_facet_taxonomy_terms', $terms_by_slug, $taxonomy ); From 718a0c5c51104fafe271c2d8c559b39fde0f9f51 Mon Sep 17 00:00:00 2001 From: Jacob Peattie Date: Sat, 17 Sep 2022 00:57:09 +1000 Subject: [PATCH 55/73] Revert to simpler link blocking. --- assets/js/blocks/related-posts/Edit.js | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/assets/js/blocks/related-posts/Edit.js b/assets/js/blocks/related-posts/Edit.js index 4be078c5cb..17816f01dc 100644 --- a/assets/js/blocks/related-posts/Edit.js +++ b/assets/js/blocks/related-posts/Edit.js @@ -4,11 +4,8 @@ import apiFetch from '@wordpress/api-fetch'; import { AlignmentToolbar, BlockControls, InspectorControls } from '@wordpress/block-editor'; import { PanelBody, Placeholder, Spinner, QueryControls } from '@wordpress/components'; -import { useInstanceId } from '@wordpress/compose'; -import { useDispatch } from '@wordpress/data'; import { Fragment, RawHTML, useEffect, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; -import { store as noticeStore } from '@wordpress/notices'; import { addQueryArgs } from '@wordpress/url'; /** @@ -23,8 +20,6 @@ import { addQueryArgs } from '@wordpress/url'; */ const RelatedPostsEdit = ({ attributes, className, context, setAttributes }) => { const { alignment, number } = attributes; - const { createWarningNotice } = useDispatch(noticeStore); - const instanceId = useInstanceId(RelatedPostsEdit); const [posts, setPosts] = useState(false); /** @@ -53,21 +48,6 @@ const RelatedPostsEdit = ({ attributes, className, context, setAttributes }) => }); }; - /** - * Show a notice when redirect is prevented. - * - * @param {Event} event Click event. - * @returns {void} - */ - const showRedirectionPreventedNotice = (event) => { - event.preventDefault(); - - createWarningNotice(__('Links are disabled in the editor.'), { - id: `elasticpress/related-posts/redirection-prevented/${instanceId}`, - type: 'snackbar', - }); - }; - /** * Effects. */ @@ -105,7 +85,7 @@ const RelatedPostsEdit = ({ attributes, className, context, setAttributes }) => const titleTrimmed = post.title.rendered.trim(); return (
  • - + e.preventDefault()}> {titleTrimmed ? ( {titleTrimmed} ) : ( From 587e9c96f174fdbce59e77f53377f88030ed116e Mon Sep 17 00:00:00 2001 From: Jacob Peattie Date: Sat, 17 Sep 2022 00:57:37 +1000 Subject: [PATCH 56/73] Test that links aren't clickable. --- tests/cypress/integration/features/related-posts.spec.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/cypress/integration/features/related-posts.spec.js b/tests/cypress/integration/features/related-posts.spec.js index b94c7e1e53..c7cd0183a6 100644 --- a/tests/cypress/integration/features/related-posts.spec.js +++ b/tests/cypress/integration/features/related-posts.spec.js @@ -70,6 +70,12 @@ describe('Related Posts Feature', () => { .should('contain', 'Test related posts block #') .should('have.length', 2); + /** + * Clicking a related rost link in the editor shouldn't change the URL. + */ + cy.get('@block').find('a').first().click(); + cy.url().should('include', 'wp-admin/post.php'); + /** * Update the post and visit the front end. */ From a1f7a274da002b2341bac187a6b2c6d4a85b7e8c Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 16 Sep 2022 12:22:48 -0300 Subject: [PATCH 57/73] Instant Results e2e tests refactor --- .../features/instant-results.spec.js | 127 ++++++++---------- tests/cypress/support/global-hooks.js | 5 + 2 files changed, 61 insertions(+), 71 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 82f6a7dca0..bcbd1a29e5 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -1,33 +1,30 @@ +/* global isEpIo */ + describe('Instant Results Feature', () => { /** * Create a Search widget. + * + * As tests for facets will remove all widgets, we recreate it here. */ function createSearchWidget() { cy.openWidgetsPage(); - - cy.get('.edit-widgets-header-toolbar__inserter-toggle').click(); - cy.get('.block-editor-inserter__panel-content [class*="search/default"]').click({ - force: true, - }); - - cy.get('.edit-widgets-header__actions .components-button.is-primary').click(); - cy.get('body').should('contain.text', 'Widgets saved.'); + cy.openBlockInserter(); + cy.getBlocksList().should('contain.text', 'Search'); // Checking if it exists give JS time to process the full list. + cy.insertBlock('Search'); + cy.intercept('/wp-json/wp/v2/sidebars/*').as('sidebarsRest'); + cy.get('.edit-widgets-header__actions button').contains('Update').click(); + cy.wait('@sidebarsRest'); } - /** - * Check if it's Elasticpress.io. - */ - function isEpIo() { - cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { - // Nothing needs to be done if EP.io. - cy.wrap(epHost.stdout.match(/elasticpress\.io/)); - }); + function maybeEnableProxy() { + if (!isEpIo) { + cy.activatePlugin('elasticpress-proxy'); + } } before(() => { - if (!isEpIo()) { - cy.activatePlugin('elasticpress-proxy', 'dashboard'); - } + createSearchWidget(); + // Create a sample post and index cy.publishPost({ title: 'Blog post', @@ -38,23 +35,21 @@ describe('Instant Results Feature', () => { content: 'This is a sample test post.', }); cy.wpCli('elasticpress index --setup --yes'); - // Add search widget that will be used for the tests. - createSearchWidget(); }); after(() => { - cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); + cy.deactivatePlugin('elasticpress-proxy'); }); /** - * Test that the feature cannot be activted when not in ElasticPress.io nor using a custom PHP proxy. - * Also, it can show a warning when using a custom PHP proxy + * Test that the feature cannot be activated when not in ElasticPress.io nor using a custom PHP proxy. */ - it("Can't activate the feature If not in ElasticPress.io nor using a custom PHP proxy and can see a warning if using cusotom proxy", () => { - cy.login(); - if (isEpIo()) { + it("Can't activate the feature if not in ElasticPress.io nor using a custom PHP proxy", () => { + if (isEpIo) { return; } + + cy.login(); cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); @@ -63,25 +58,26 @@ describe('Instant Results Feature', () => { 'To use this feature you need to be an ElasticPress.io customer or implement a custom proxy', ); cy.get('.ep-feature-instant-results .input-wrap').should('have.class', 'disabled'); - // Can see the warning if using custom proxy - cy.activatePlugin('elasticpress-proxy', 'dashboard'); - cy.visitAdminPage('admin.php?page=elasticpress'); - cy.get('.ep-feature-instant-results .settings-button').click(); - cy.get('.requirements-status-notice').should( - 'contain.text', - 'You are using a custom proxy. Make sure you implement all security measures needed', - ); - cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); }); /** - * Test that the feature can be activted and it can sync automatically. + * Test that the feature can be activated and it can sync automatically. + * Also, it can show a warning when using a custom PHP proxy */ it('Can activate the feature and sync automatically', () => { cy.login(); + // Can see the warning if using custom proxy + maybeEnableProxy(); cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); + + cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); + cy.get('.requirements-status-notice').should( + isEpIo ? 'not.contain.text' : 'contain.text', + 'You are using a custom proxy. Make sure you implement all security measures needed', + ); + cy.get('.ep-feature-instant-results [name="settings[active]"][value="1"]').click(); cy.get('.ep-feature-instant-results .button-primary').click(); cy.on('window:confirm', () => { @@ -101,56 +97,45 @@ describe('Instant Results Feature', () => { * It can show the modal in the same state after a reload * Can change the URL when search term is changed */ - it('Can see instant results list, number of results, modal in the same state after reload, and updated result after changing the search term', () => { + it('Can see instant results elements, URL changes, reload, and update after changing search term', () => { cy.login(); cy.maybeEnableFeature('instant-results'); + maybeEnableProxy(); + + cy.intercept('*search=blog*').as('apiRequest'); cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button') + + cy.get('.wp-block-search').last().as('searchBlock'); + + cy.get('@searchBlock').find('.wp-block-search__input').type('blog'); + cy.get('@searchBlock').find('.wp-block-search__button').click(); + cy.get('.ep-search-modal').as('searchModal').should('be.visible'); // Should be visible immediatly + cy.url().should('include', 'search=blog'); + + cy.wait('@apiRequest'); + cy.get('@searchModal').should('contain.text', 'blog'); + // Show the number of results + cy.get('@searchModal').find('.ep-search-results__title').contains(/\d+/); + + cy.get('.ep-search-sidebar #ep-search-post-type-post') .click() .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); - // Show the number of results - cy.get('.ep-search-results__title').contains(/\d+/); + cy.url().should('include', 'ep-post_type=post'); }); + // Show the modal in the same state after a reload cy.reload(); + cy.wait('@apiRequest'); cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + // Update the results when search term is changed cy.get('#ep-instant-results .ep-search-input') .clearThenType('test') .then(() => { cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); + cy.url().should('include', 'search=test'); }); - }); - - it('Can update the URL after changing the filters', () => { - cy.login(); - cy.maybeEnableFeature('instant-results'); - - cy.visit('/'); - cy.get('.wp-block-search__input').type('test'); - cy.get('.wp-block-search__button') - .click() - .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); - }); - cy.get('.ep-search-sidebar #ep-search-post-type-post') - .click() - .then(() => { - cy.url().should('include', 'ep-post_type=post'); - }); - }); - - it('Can click outside when instant results are shown', () => { - cy.login(); - cy.maybeEnableFeature('instant-results'); - - cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button').click(); - cy.get('.ep-search-modal').should('be.visible'); cy.get('#wpadminbar li#wp-admin-bar-debug-bar').click(); cy.get('#querylist').should('be.visible'); diff --git a/tests/cypress/support/global-hooks.js b/tests/cypress/support/global-hooks.js index f52f467b95..905594380e 100644 --- a/tests/cypress/support/global-hooks.js +++ b/tests/cypress/support/global-hooks.js @@ -1,4 +1,5 @@ window.indexNames = null; +window.isEpIo = false; before(() => { cy.wpCliEval( @@ -24,6 +25,10 @@ before(() => { ).then((wpCliResponse) => { window.indexNames = JSON.parse(wpCliResponse.stdout); }); + + cy.wpCli('eval "echo (int) \\ElasticPress\\Utils\\is_epio();"').then((response) => { + window.isEpIo = response.stdout === 1; + }); }); afterEach(() => { From 8096c33000824ff66cbcc3963cac39af57c991ee Mon Sep 17 00:00:00 2001 From: Jacob Peattie Date: Sat, 17 Sep 2022 01:34:51 +1000 Subject: [PATCH 58/73] Update hook docs. --- .eslintrc.js | 6 ++++++ assets/js/autosuggest/index.js | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ceca853366..48c662675e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,4 +2,10 @@ const defaultEslintrc = require('10up-toolkit/config/.eslintrc'); module.exports = { ...defaultEslintrc, + 'jsdoc/check-tag-names': [ + 'error', + { + definedTags: ['filter', 'action'], + }, + ], }; diff --git a/assets/js/autosuggest/index.js b/assets/js/autosuggest/index.js index a4f42f11e6..154d71b85d 100644 --- a/assets/js/autosuggest/index.js +++ b/assets/js/autosuggest/index.js @@ -1,4 +1,4 @@ -/* eslint-disable camelcase, no-underscore-dangle, no-use-before-define, jsdoc/check-tag-names */ +/* eslint-disable camelcase, no-underscore-dangle, no-use-before-define */ /** * WordPress dependencies. @@ -204,8 +204,8 @@ async function esSearch(query, searchTerm) { /** * Filter the Elasticsearch response data used for Autosuggest. * - * @hook ep.Autosuggest.data - * @since 4.4.0 + * @filter ep.Autosuggest.data + * @since 4.3.1 * * @param {object} data Response data. * @param {string} searchTerm Search term. @@ -281,8 +281,8 @@ function updateAutosuggestBox(options, input) { /** * Filter the HTML for an Autosuggest suggestion. * - * @hook ep.Autosuggest.itemHTML - * @since 4.4.0 + * @filter ep.Autosuggest.itemHTML + * @since 4.3.1 * * @param {string} itemHTML Item HTML. * @param {object} option Elasticsearch record for suggestion. @@ -298,8 +298,8 @@ function updateAutosuggestBox(options, input) { /** * Filter the HTML for the list of Autosuggest suggestions. * - * @hook ep.Autosuggest.listHTML - * @since 4.4.0 + * @filter ep.Autosuggest.listHTML + * @since 4.3.1 * * @param {string} listHTML List HTML. * @param {object[]} options Elasticsearch records for suggestions. @@ -596,8 +596,8 @@ function init() { /** * Filter the Elasticsearch query used for Autosuggest. * - * @hook ep.Autosuggest.query - * @since 4.4.0 + * @filter ep.Autosuggest.query + * @since 4.3.1 * * @param {object} query Elasticsearch query. * @param {string} searchText Search term. @@ -698,8 +698,8 @@ function init() { /** * Filter the Autosuggest container element before it is inserted. * - * @hook ep.Autosuggest.element - * @since 4.4.0 + * @filter ep.Autosuggest.element + * @since 4.3.1 * * @param {Element} element Autosuggest container element. * @param {Element} previousElement Element the container will be inserted after. From 30e7ae60c4975e41d83d7252dceca787dd69b949 Mon Sep 17 00:00:00 2001 From: Jacob Peattie Date: Sat, 17 Sep 2022 01:46:56 +1000 Subject: [PATCH 59/73] Add capability check to API endpoints. --- .../Feature/SearchOrdering/SearchOrdering.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/includes/classes/Feature/SearchOrdering/SearchOrdering.php b/includes/classes/Feature/SearchOrdering/SearchOrdering.php index 14f79de4cd..55f412ea32 100644 --- a/includes/classes/Feature/SearchOrdering/SearchOrdering.php +++ b/includes/classes/Feature/SearchOrdering/SearchOrdering.php @@ -35,6 +35,11 @@ class SearchOrdering extends Feature { */ const TAXONOMY_NAME = 'ep_custom_result'; + /** + * Capability required to manage. + */ + const CAPABILITY = 'manage_options'; + /** * Initialize feature setting it's config * @@ -210,7 +215,7 @@ public function admin_menu() { 'elasticpress', esc_html__( 'Custom Results', 'elasticpress' ), esc_html__( 'Custom Results', 'elasticpress' ), - 'manage_options', + CAPABILITY, 'edit.php?post_type=' . self::POST_TYPE_NAME ); } @@ -689,7 +694,9 @@ public function rest_api_init() { [ 'methods' => 'GET', 'callback' => [ $this, 'handle_pointer_search' ], - 'permission_callback' => '__return_true', + 'permission_callback' => function() { + return current_user_can( CAPABILITY ); + }, 'args' => [ 's' => [ 'validate_callback' => function ( $param ) { @@ -707,7 +714,9 @@ public function rest_api_init() { [ 'methods' => 'GET', 'callback' => [ $this, 'handle_pointer_preview' ], - 'permission_callback' => '__return_true', + 'permission_callback' => function() { + return current_user_can( CAPABILITY ); + }, 'args' => [ 's' => [ 'validate_callback' => function ( $param ) { From 35874a0333d388aebed7f77f68e82732774c5b42 Mon Sep 17 00:00:00 2001 From: Jacob Peattie Date: Sat, 17 Sep 2022 01:54:51 +1000 Subject: [PATCH 60/73] Correct const syntax. --- includes/classes/Feature/SearchOrdering/SearchOrdering.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/classes/Feature/SearchOrdering/SearchOrdering.php b/includes/classes/Feature/SearchOrdering/SearchOrdering.php index 55f412ea32..78ed5ce75b 100644 --- a/includes/classes/Feature/SearchOrdering/SearchOrdering.php +++ b/includes/classes/Feature/SearchOrdering/SearchOrdering.php @@ -215,7 +215,7 @@ public function admin_menu() { 'elasticpress', esc_html__( 'Custom Results', 'elasticpress' ), esc_html__( 'Custom Results', 'elasticpress' ), - CAPABILITY, + self::CAPABILITY, 'edit.php?post_type=' . self::POST_TYPE_NAME ); } @@ -695,7 +695,7 @@ public function rest_api_init() { 'methods' => 'GET', 'callback' => [ $this, 'handle_pointer_search' ], 'permission_callback' => function() { - return current_user_can( CAPABILITY ); + return current_user_can( self::CAPABILITY ); }, 'args' => [ 's' => [ @@ -715,7 +715,7 @@ public function rest_api_init() { 'methods' => 'GET', 'callback' => [ $this, 'handle_pointer_preview' ], 'permission_callback' => function() { - return current_user_can( CAPABILITY ); + return current_user_can( self::CAPABILITY ); }, 'args' => [ 's' => [ From fbd4760548708fc5429aa668cbaa25cbb581b126 Mon Sep 17 00:00:00 2001 From: Jacob Peattie Date: Sat, 17 Sep 2022 02:15:06 +1000 Subject: [PATCH 61/73] Fix ESLint config. --- .eslintrc.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 48c662675e..f7ab578a0f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,10 +2,13 @@ const defaultEslintrc = require('10up-toolkit/config/.eslintrc'); module.exports = { ...defaultEslintrc, - 'jsdoc/check-tag-names': [ - 'error', - { - definedTags: ['filter', 'action'], - }, - ], + rules: { + ...defaultEslintrc.rules, + 'jsdoc/check-tag-names': [ + 'error', + { + definedTags: ['filter', 'action'], + }, + ], + }, }; From 7a5cb9c6658e7e48c09faea2ec9faec17be09245 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 16 Sep 2022 13:40:35 -0300 Subject: [PATCH 62/73] Fix type comparison --- tests/cypress/support/global-hooks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/support/global-hooks.js b/tests/cypress/support/global-hooks.js index 905594380e..33ba9426f9 100644 --- a/tests/cypress/support/global-hooks.js +++ b/tests/cypress/support/global-hooks.js @@ -27,7 +27,7 @@ before(() => { }); cy.wpCli('eval "echo (int) \\ElasticPress\\Utils\\is_epio();"').then((response) => { - window.isEpIo = response.stdout === 1; + window.isEpIo = response.stdout === '1'; }); }); From 85cacdbbe764b2c45f5a88493f69d596d1a96959 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 16 Sep 2022 14:44:25 -0300 Subject: [PATCH 63/73] Prevent autosuggest from running on Instant Results search --- assets/js/autosuggest.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/assets/js/autosuggest.js b/assets/js/autosuggest.js index 463fcef3b1..067a6486c5 100644 --- a/assets/js/autosuggest.js +++ b/assets/js/autosuggest.js @@ -676,9 +676,10 @@ function init() { */ const prepareInputForAutosuggest = (input) => { /** - * Skip facet widget search fields. + * Skip facet widget search fields and instant results. */ - if (input.classList.contains('facet-search')) { + const ignoredClasses = ['facet-search', 'ep-search-input']; + if (ignoredClasses.some((className) => input.classList.contains(className))) { return; } From 487796e893bd43a60d2d83efa0d6b9fc8a602c3c Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 16 Sep 2022 14:44:51 -0300 Subject: [PATCH 64/73] Deactivate elasticpress-proxy by default + stop dbdump generation --- bin/setup-cypress-env.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bin/setup-cypress-env.sh b/bin/setup-cypress-env.sh index 600426cc60..7d056655ab 100755 --- a/bin/setup-cypress-env.sh +++ b/bin/setup-cypress-env.sh @@ -75,7 +75,7 @@ fi ./bin/wp-env-cli tests-wordpress "wp --allow-root import /var/www/html/wp-content/uploads/content-example.xml --authors=create" -./bin/wp-env-cli tests-wordpress "wp --allow-root plugin deactivate woocommerce" +./bin/wp-env-cli tests-wordpress "wp --allow-root plugin deactivate woocommerce elasticpress-proxy" ./bin/wp-env-cli tests-wordpress "wp --allow-root plugin activate debug-bar debug-bar-elasticpress wordpress-importer --network" @@ -87,7 +87,5 @@ fi ./bin/wp-env-cli tests-wordpress "wp --allow-root user meta update admin edit_post_per_page 5" # Generate a SQL file that can be imported later to make things faster -SQL_FILENAME=./bin/$(date +'%F-%H-%M').sql -./bin/wp-env-cli tests-wordpress "wp --allow-root db export -" > $SQL_FILENAME - -exit 0 +# SQL_FILENAME=./bin/$(date +'%F-%H-%M').sql +# npm --silent run env run tests-cli "wp db export -" > $SQL_FILENAME From a2c09069e4faa8a4a7fcd203f536103f9506511a Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 16 Sep 2022 14:45:35 -0300 Subject: [PATCH 65/73] Wait for request --- .../integration/features/instant-results.spec.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index bcbd1a29e5..841e9b64c0 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -25,7 +25,7 @@ describe('Instant Results Feature', () => { before(() => { createSearchWidget(); - // Create a sample post and index + // Create some sample posts cy.publishPost({ title: 'Blog post', content: 'This is a sample Blog post.', @@ -34,7 +34,6 @@ describe('Instant Results Feature', () => { title: 'Test Post', content: 'This is a sample test post.', }); - cy.wpCli('elasticpress index --setup --yes'); }); after(() => { @@ -50,7 +49,7 @@ describe('Instant Results Feature', () => { } cy.login(); - cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); + cy.deactivatePlugin('elasticpress-proxy'); cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); cy.get('.requirements-status-notice').should( @@ -127,13 +126,15 @@ describe('Instant Results Feature', () => { // Show the modal in the same state after a reload cy.reload(); cy.wait('@apiRequest'); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('@searchModal').should('be.visible').should('contain.text', 'blog'); // Update the results when search term is changed - cy.get('#ep-instant-results .ep-search-input') + cy.get('@searchModal') + .find('.ep-search-input') .clearThenType('test') .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); + cy.wait('@apiRequest'); + cy.get('@searchModal').should('be.visible').should('contain.text', 'test'); cy.url().should('include', 'search=test'); }); From efbb8016a5164ef46d0141ceeb48c965434c90c2 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Wed, 21 Sep 2022 12:12:23 +0500 Subject: [PATCH 66/73] Fix: Taxonomy Facet tree issue --- includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php b/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php index 66944e60a9..be2af8b075 100644 --- a/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php +++ b/includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php @@ -240,8 +240,8 @@ public function render( $args, $instance ) { * Get top of tree */ while ( true && $i < 10 ) { - if ( ! empty( $term->parent_slug ) ) { - $top_of_tree = $terms_by_slug[ $term->parent_slug ]; + if ( ! empty( $term->parent_term->slug ) ) { + $top_of_tree = $terms_by_slug[ $term->parent_term->slug ]; } else { break; } From 673369a26db9a8c972c7d3f499926df79f48168c Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Thu, 22 Sep 2022 09:22:32 -0300 Subject: [PATCH 67/73] Fix typo --- tests/cypress/integration/features/related-posts.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/related-posts.spec.js b/tests/cypress/integration/features/related-posts.spec.js index c7cd0183a6..aabadcf51c 100644 --- a/tests/cypress/integration/features/related-posts.spec.js +++ b/tests/cypress/integration/features/related-posts.spec.js @@ -71,7 +71,7 @@ describe('Related Posts Feature', () => { .should('have.length', 2); /** - * Clicking a related rost link in the editor shouldn't change the URL. + * Clicking a related post link in the editor shouldn't change the URL. */ cy.get('@block').find('a').first().click(); cy.url().should('include', 'wp-admin/post.php'); From e9227b9c90d64bf4093840240b8948e725cfddfa Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Thu, 22 Sep 2022 09:59:35 -0300 Subject: [PATCH 68/73] Aligns visually elements in the settings page Co-authored-by: Mohammed Razzaq --- assets/css/dashboard.css | 18 +++++- includes/partials/settings-page.php | 86 +++++++++++++++-------------- 2 files changed, 61 insertions(+), 43 deletions(-) diff --git a/assets/css/dashboard.css b/assets/css/dashboard.css index 95597b6b5a..d8581f333f 100644 --- a/assets/css/dashboard.css +++ b/assets/css/dashboard.css @@ -995,6 +995,14 @@ h2 .nav-tab.ep-credentials-tab { border-top: 1px solid #ccc; } +.ep-settings .ep-credentials-general { + padding: 0 1rem; +} + +.ep-settings .button-primary { + margin: 0 1rem; +} + .ep-settings .description { font-size: 0.75rem; font-style: italic; @@ -1010,9 +1018,17 @@ h2 .nav-tab.ep-credentials-tab { width: auto; } - .ep-credentials .form-table td { + .ep-credentials .form-table td, + .ep-credentials-general .form-table td { padding-left: 0; } + + .ep-credentials .form-table td input, + .ep-credentials .form-table td select, + .ep-credentials-general .form-table td input, + .ep-credentials-general .form-table td select { + width: 250px; + } } .ep-flex-container { diff --git a/includes/partials/settings-page.php b/includes/partials/settings-page.php index 4230d4142e..21dec101a0 100644 --- a/includes/partials/settings-page.php +++ b/includes/partials/settings-page.php @@ -182,54 +182,56 @@ - - - - - - - - - - - +
    +
    - - - 'ep_language', - 'name' => 'ep_language', - 'selected' => $ep_language, - ] - ); - ?> -

    -
    - - - - - - - - — - - -
    + - - -
    - + - + 'ep_language', + 'name' => 'ep_language', + 'selected' => $ep_language, + ] + ); + ?> +

    + + + + + + + + + + + — + + + + + + + + + + + + + + + + + Date: Thu, 22 Sep 2022 14:14:35 -0300 Subject: [PATCH 69/73] Bump version number --- elasticpress.php | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- readme.txt | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/elasticpress.php b/elasticpress.php index 12916d15ef..aa3e137002 100644 --- a/elasticpress.php +++ b/elasticpress.php @@ -3,7 +3,7 @@ * Plugin Name: ElasticPress * Plugin URI: https://github.com/10up/ElasticPress * Description: A fast and flexible search and query engine for WordPress. - * Version: 4.3.0 + * Version: 4.3.1 * Requires at least: 5.6 * Requires PHP: 7.0 * Author: 10up @@ -32,7 +32,7 @@ define( 'EP_URL', plugin_dir_url( __FILE__ ) ); define( 'EP_PATH', plugin_dir_path( __FILE__ ) ); define( 'EP_FILE', plugin_basename( __FILE__ ) ); -define( 'EP_VERSION', '4.3.0' ); +define( 'EP_VERSION', '4.3.1' ); /** * PSR-4-ish autoloading diff --git a/package-lock.json b/package-lock.json index be9e7ddc2c..fe67b2f0db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "elasticpress", - "version": "4.3.0", + "version": "4.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "elasticpress", - "version": "4.3.0", + "version": "4.3.1", "license": "GPL-2.0-or-later", "dependencies": { "@10up/component-tooltip": "^2.0.0", diff --git a/package.json b/package.json index 8d9d27a3f7..c282ef001d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "elasticpress", - "version": "4.3.0", + "version": "4.3.1", "license": "GPL-2.0-or-later", "description": "A fast and flexible search and query engine for WordPress.", "devDependencies": { diff --git a/readme.txt b/readme.txt index 0e0f5702c1..a8d3c60312 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: 10up, tlovett1, vhauri, tott, oscarssanchez, cmmarslender Tags: performance, slow, search, elasticsearch, fuzzy, facet, aggregation, searching, autosuggest, suggest, elastic, advanced search, woocommerce, related posts, woocommerce Tested up to: 6.0 -Stable tag: 4.3.0 +Stable tag: 4.3.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html From 4616f0d0c7fec61ab67efbf5b63b87bab79ed71e Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Thu, 22 Sep 2022 14:36:23 -0300 Subject: [PATCH 70/73] Initial version of the changelog --- CHANGELOG.md | 24 ++++++++++++++++++++++++ CREDITS.md | 3 +++ 2 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a237d77cc0..aa3d5b4f10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file, per [the Ke ## [Unreleased] +## [4.3.1] - 2022-09-XX +This release fixes some bugs and also adds some new actions and filters. + +### Added +- New `ep_facet_taxonomy_terms` filter to filter the Facet terms. Props [@burhandodhy](https://github.com/burhandodhy) and [@felipeelia](https://github.com/felipeelia) via [#2989](https://github.com/10up/ElasticPress/pull/2989). +- Added `ep.Autosuggest.itemHTML`, `ep.Autosuggest.listHTML`, `ep.Autosuggest.query`, and `ep.Autosuggest.element` JavaScript hooks to Autosuggest and migrated filter functions to hook callbacks for backwards compatibility Props [@JakePT](https://github.com/JakePT) via [#2983](https://github.com/10up/ElasticPress/pull/2983). +- E2E tests for the Comments Feature. Props [@burhandodhy](https://github.com/burhandodhy) via [#2955](https://github.com/10up/ElasticPress/pull/2955). +- E2E tests for the Instant Results feature. Props [@MARQAS](https://github.com/MARQAS) and [@felipeelia](https://github.com/felipeelia) via [#2851](https://github.com/10up/ElasticPress/pull/2851). +- More E2E tests for the WooCommerce Feature. Props [@burhandodhy](https://github.com/burhandodhy) via [#2923](https://github.com/10up/ElasticPress/pull/2923). + +### Changed +- REST API endpoints used for managing custom results are no longer publicly accessible. Props [@JakePT](https://github.com/JakePT) and [@PypWalters](https://github.com/PypWalters) via [#3004](https://github.com/10up/ElasticPress/pull/3004). + +### Fixed +- WooCommerce data privacy eraser query deleting all orders if EP is enabled for admin and Ajax requests. Props [@sun](https://github.com/sun) and [@bogdanarizancu](https://github.com/bogdanarizancu) via [#2975](https://github.com/10up/ElasticPress/pull/2975). +- Facets removing WooCommerce sorting. Props [@burhandodhy](https://github.com/burhandodhy) and [@felipeelia](https://github.com/felipeelia) via [#2982](https://github.com/10up/ElasticPress/pull/2982). +- Facets triggering the ElasticPress integration in feed pages. Props [@felipeelia](https://github.com/felipeelia) and [@rafaucau](https://github.com/rafaucau) via [#2980](https://github.com/10up/ElasticPress/pull/2980). +- Taxonomy Facet tree issue when child category is selected. Props [@burhandodhy](https://github.com/burhandodhy) via [#3015](https://github.com/10up/ElasticPress/pull/3015). +- Term search in the admin panel for non-public taxonomies returning nothing. Props [@burhandodhy](https://github.com/burhandodhy) via [#2988](https://github.com/10up/ElasticPress/pull/2988). +- Clicking a Related Posts link while in the editor no longer follows the link. Props [@JakePT](https://github.com/JakePT) via [#2998](https://github.com/10up/ElasticPress/pull/2998). +- Visually alignment of elements in the Settings page. Props [@MARQAS](https://github.com/MARQAS) and [@felipeelia](https://github.com/felipeelia) via [#3018](https://github.com/10up/ElasticPress/pull/3018). +- Intermittent tests failures. Props [@burhandodhy](https://github.com/burhandodhy) via [#2984](https://github.com/10up/ElasticPress/pull/2984). + ## [4.3.0] - 2022-08-31 ElasticPress 4.3.0 fixes some bugs and introduces some new and exciting changes. @@ -1514,6 +1537,7 @@ This is a bug fix release with some filter additions. - Initial plugin release [Unreleased]: https://github.com/10up/ElasticPress/compare/trunk...develop +[4.3.1]: https://github.com/10up/ElasticPress/compare/4.3.0...4.3.1 [4.3.0]: https://github.com/10up/ElasticPress/compare/4.2.2...4.3.0 [4.2.2]: https://github.com/10up/ElasticPress/compare/4.2.1...4.2.2 [4.2.1]: https://github.com/10up/ElasticPress/compare/4.2.0...4.2.1 diff --git a/CREDITS.md b/CREDITS.md index 9dcbafdcd1..e47f2d4053 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -193,6 +193,9 @@ Thank you to all the people who have already contributed to this repository via [Oras Al-Kubaisi (@orasik)](https://github.com/orasik), [@nickchomey](https://github.com/nickchomey), [@alaa-alshamy](https://github.com/alaa-alshamy), +[Bogdan Arizancu (@bogdanarizancu)](https://github.com/bogdanarizancu), +[Stephanie Walters (@PypWalters)](https://github.com/PypWalters), +[Rafał Całka (@rafaucau)](https://github.com/rafaucau), and [@qazaqstan2025](https://github.com/qazaqstan2025). From 9ff4db95b4929376c1a1283524c381f3b950d069 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Tue, 27 Sep 2022 13:51:44 -0300 Subject: [PATCH 71/73] Release date + WP.org changelog --- CHANGELOG.md | 6 +++--- readme.txt | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa3d5b4f10..3b6cd92ba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ All notable changes to this project will be documented in this file, per [the Ke ## [Unreleased] -## [4.3.1] - 2022-09-XX -This release fixes some bugs and also adds some new actions and filters. +## [4.3.1] - 2022-09-27 +This release fixes some bugs and also adds some new filters. ### Added - New `ep_facet_taxonomy_terms` filter to filter the Facet terms. Props [@burhandodhy](https://github.com/burhandodhy) and [@felipeelia](https://github.com/felipeelia) via [#2989](https://github.com/10up/ElasticPress/pull/2989). @@ -24,7 +24,7 @@ This release fixes some bugs and also adds some new actions and filters. - Taxonomy Facet tree issue when child category is selected. Props [@burhandodhy](https://github.com/burhandodhy) via [#3015](https://github.com/10up/ElasticPress/pull/3015). - Term search in the admin panel for non-public taxonomies returning nothing. Props [@burhandodhy](https://github.com/burhandodhy) via [#2988](https://github.com/10up/ElasticPress/pull/2988). - Clicking a Related Posts link while in the editor no longer follows the link. Props [@JakePT](https://github.com/JakePT) via [#2998](https://github.com/10up/ElasticPress/pull/2998). -- Visually alignment of elements in the Settings page. Props [@MARQAS](https://github.com/MARQAS) and [@felipeelia](https://github.com/felipeelia) via [#3018](https://github.com/10up/ElasticPress/pull/3018). +- Visual alignment of elements in the Settings page. Props [@MARQAS](https://github.com/MARQAS) and [@felipeelia](https://github.com/felipeelia) via [#3018](https://github.com/10up/ElasticPress/pull/3018). - Intermittent tests failures. Props [@burhandodhy](https://github.com/burhandodhy) via [#2984](https://github.com/10up/ElasticPress/pull/2984). ## [4.3.0] - 2022-08-31 diff --git a/readme.txt b/readme.txt index a8d3c60312..31fbed3a32 100644 --- a/readme.txt +++ b/readme.txt @@ -77,6 +77,33 @@ For sure! Feel free to submit ideas or feedback in general to our [GitHub repo]( == Changelog == += 4.3.1 - 2022-09-27 = + +This release fixes some bugs and also adds some new filters. + +__Added:__ + +* New `ep_facet_taxonomy_terms` filter to filter the Facet terms. Props [@burhandodhy](https://github.com/burhandodhy) and [@felipeelia](https://github.com/felipeelia). +* Added `ep.Autosuggest.itemHTML`, `ep.Autosuggest.listHTML`, `ep.Autosuggest.query`, and `ep.Autosuggest.element` JavaScript hooks to Autosuggest and migrated filter functions to hook callbacks for backwards compatibility Props [@JakePT](https://github.com/JakePT). +* E2E tests for the Comments Feature. Props [@burhandodhy](https://github.com/burhandodhy). +* E2E tests for the Instant Results feature. Props [@MARQAS](https://github.com/MARQAS) and [@felipeelia](https://github.com/felipeelia). +* More E2E tests for the WooCommerce Feature. Props [@burhandodhy](https://github.com/burhandodhy). + +__Changed:__ + +* REST API endpoints used for managing custom results are no longer publicly accessible. Props [@JakePT](https://github.com/JakePT) and [@PypWalters](https://github.com/PypWalters). + +__Fixed:__ + +* WooCommerce data privacy eraser query deleting all orders if EP is enabled for admin and Ajax requests. Props [@sun](https://github.com/sun) and [@bogdanarizancu](https://github.com/bogdanarizancu). +* Facets removing WooCommerce sorting. Props [@burhandodhy](https://github.com/burhandodhy) and [@felipeelia](https://github.com/felipeelia). +* Facets triggering the ElasticPress integration in feed pages. Props [@felipeelia](https://github.com/felipeelia) and [@rafaucau](https://github.com/rafaucau). +* Taxonomy Facet tree issue when child category is selected. Props [@burhandodhy](https://github.com/burhandodhy). +* Term search in the admin panel for non-public taxonomies returning nothing. Props [@burhandodhy](https://github.com/burhandodhy). +* Clicking a Related Posts link while in the editor no longer follows the link. Props [@JakePT](https://github.com/JakePT). +* Visual alignment of elements in the Settings page. Props [@MARQAS](https://github.com/MARQAS) and [@felipeelia](https://github.com/felipeelia). +* Intermittent tests failures. Props [@burhandodhy](https://github.com/burhandodhy). + = 4.3.0 - 2022-08-31 = ElasticPress 4.3.0 fixes some bugs and introduces some new and exciting changes. From 82a2aa28c6f200e0195941e8574c6da06f2e0790 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Tue, 27 Sep 2022 13:54:25 -0300 Subject: [PATCH 72/73] MIssing `.` --- CHANGELOG.md | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b6cd92ba4..b9eded9568 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ This release fixes some bugs and also adds some new filters. ### Added - New `ep_facet_taxonomy_terms` filter to filter the Facet terms. Props [@burhandodhy](https://github.com/burhandodhy) and [@felipeelia](https://github.com/felipeelia) via [#2989](https://github.com/10up/ElasticPress/pull/2989). -- Added `ep.Autosuggest.itemHTML`, `ep.Autosuggest.listHTML`, `ep.Autosuggest.query`, and `ep.Autosuggest.element` JavaScript hooks to Autosuggest and migrated filter functions to hook callbacks for backwards compatibility Props [@JakePT](https://github.com/JakePT) via [#2983](https://github.com/10up/ElasticPress/pull/2983). +- Added `ep.Autosuggest.itemHTML`, `ep.Autosuggest.listHTML`, `ep.Autosuggest.query`, and `ep.Autosuggest.element` JavaScript hooks to Autosuggest and migrated filter functions to hook callbacks for backwards compatibility. Props [@JakePT](https://github.com/JakePT) via [#2983](https://github.com/10up/ElasticPress/pull/2983). - E2E tests for the Comments Feature. Props [@burhandodhy](https://github.com/burhandodhy) via [#2955](https://github.com/10up/ElasticPress/pull/2955). - E2E tests for the Instant Results feature. Props [@MARQAS](https://github.com/MARQAS) and [@felipeelia](https://github.com/felipeelia) via [#2851](https://github.com/10up/ElasticPress/pull/2851). - More E2E tests for the WooCommerce Feature. Props [@burhandodhy](https://github.com/burhandodhy) via [#2923](https://github.com/10up/ElasticPress/pull/2923). diff --git a/readme.txt b/readme.txt index 31fbed3a32..47bb1ccf68 100644 --- a/readme.txt +++ b/readme.txt @@ -84,7 +84,7 @@ This release fixes some bugs and also adds some new filters. __Added:__ * New `ep_facet_taxonomy_terms` filter to filter the Facet terms. Props [@burhandodhy](https://github.com/burhandodhy) and [@felipeelia](https://github.com/felipeelia). -* Added `ep.Autosuggest.itemHTML`, `ep.Autosuggest.listHTML`, `ep.Autosuggest.query`, and `ep.Autosuggest.element` JavaScript hooks to Autosuggest and migrated filter functions to hook callbacks for backwards compatibility Props [@JakePT](https://github.com/JakePT). +* Added `ep.Autosuggest.itemHTML`, `ep.Autosuggest.listHTML`, `ep.Autosuggest.query`, and `ep.Autosuggest.element` JavaScript hooks to Autosuggest and migrated filter functions to hook callbacks for backwards compatibility. Props [@JakePT](https://github.com/JakePT). * E2E tests for the Comments Feature. Props [@burhandodhy](https://github.com/burhandodhy). * E2E tests for the Instant Results feature. Props [@MARQAS](https://github.com/MARQAS) and [@felipeelia](https://github.com/felipeelia). * More E2E tests for the WooCommerce Feature. Props [@burhandodhy](https://github.com/burhandodhy). From e52164f2bc1fc749c0d7755ef2992c7b2f65ed4d Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 27 Sep 2022 17:03:44 +0000 Subject: [PATCH 73/73] Release 4.3.1 --- dist/css/autosuggest-styles.min.asset.php | 1 + dist/css/autosuggest-styles.min.css | 1 + dist/css/comments-styles.min.asset.php | 1 + dist/css/comments-styles.min.css | 1 + dist/css/dashboard-styles.min.asset.php | 1 + dist/css/dashboard-styles.min.css | 1 + dist/css/facets-admin-styles.min.asset.php | 1 + dist/css/facets-admin-styles.min.css | 1 + dist/css/facets-styles.min.asset.php | 1 + dist/css/facets-styles.min.css | 1 + dist/css/highlighting-styles.min.asset.php | 1 + dist/css/highlighting-styles.min.css | 1 + dist/css/instant-results-styles.min.asset.php | 1 + dist/css/instant-results-styles.min.css | 1 + dist/css/ordering-styles.min.asset.php | 1 + dist/css/ordering-styles.min.css | 1 + dist/css/related-posts-block-styles.min.asset.php | 1 + dist/css/related-posts-block-styles.min.css | 1 + dist/css/sync-styles.min.asset.php | 1 + dist/css/sync-styles.min.css | 1 + dist/css/synonyms-styles.min.asset.php | 1 + dist/css/synonyms-styles.min.css | 1 + dist/js/admin-script.min.asset.php | 1 + dist/js/admin-script.min.js | 1 + dist/js/autosuggest-script.min.asset.php | 1 + dist/js/autosuggest-script.min.js | 1 + dist/js/comments-script.min.asset.php | 1 + dist/js/comments-script.min.js | 1 + dist/js/dashboard-script.min.asset.php | 1 + dist/js/dashboard-script.min.js | 1 + dist/js/facets-block-script.min.asset.php | 1 + dist/js/facets-block-script.min.js | 1 + dist/js/facets-meta-block-script.min.asset.php | 1 + dist/js/facets-meta-block-script.min.js | 1 + dist/js/facets-script.min.asset.php | 1 + dist/js/facets-script.min.js | 1 + dist/js/instant-results-admin-script.min.asset.php | 1 + dist/js/instant-results-admin-script.min.js | 1 + dist/js/instant-results-script.min.asset.php | 1 + dist/js/instant-results-script.min.js | 1 + dist/js/notice-script.min.asset.php | 1 + dist/js/notice-script.min.js | 1 + dist/js/ordering-script.min.asset.php | 1 + dist/js/ordering-script.min.js | 1 + dist/js/related-posts-block-script.min.asset.php | 1 + dist/js/related-posts-block-script.min.js | 1 + dist/js/settings-script.min.asset.php | 1 + dist/js/settings-script.min.js | 1 + dist/js/sites-admin-script.min.asset.php | 1 + dist/js/sites-admin-script.min.js | 1 + dist/js/stats-script.min.asset.php | 1 + dist/js/stats-script.min.js | 1 + dist/js/sync-script.min.asset.php | 1 + dist/js/sync-script.min.js | 1 + dist/js/synonyms-script.min.asset.php | 1 + dist/js/synonyms-script.min.js | 1 + dist/js/weighting-script.min.asset.php | 1 + dist/js/weighting-script.min.js | 1 + 58 files changed, 58 insertions(+) create mode 100644 dist/css/autosuggest-styles.min.asset.php create mode 100644 dist/css/autosuggest-styles.min.css create mode 100644 dist/css/comments-styles.min.asset.php create mode 100644 dist/css/comments-styles.min.css create mode 100644 dist/css/dashboard-styles.min.asset.php create mode 100644 dist/css/dashboard-styles.min.css create mode 100644 dist/css/facets-admin-styles.min.asset.php create mode 100644 dist/css/facets-admin-styles.min.css create mode 100644 dist/css/facets-styles.min.asset.php create mode 100644 dist/css/facets-styles.min.css create mode 100644 dist/css/highlighting-styles.min.asset.php create mode 100644 dist/css/highlighting-styles.min.css create mode 100644 dist/css/instant-results-styles.min.asset.php create mode 100644 dist/css/instant-results-styles.min.css create mode 100644 dist/css/ordering-styles.min.asset.php create mode 100644 dist/css/ordering-styles.min.css create mode 100644 dist/css/related-posts-block-styles.min.asset.php create mode 100644 dist/css/related-posts-block-styles.min.css create mode 100644 dist/css/sync-styles.min.asset.php create mode 100644 dist/css/sync-styles.min.css create mode 100644 dist/css/synonyms-styles.min.asset.php create mode 100644 dist/css/synonyms-styles.min.css create mode 100644 dist/js/admin-script.min.asset.php create mode 100644 dist/js/admin-script.min.js create mode 100644 dist/js/autosuggest-script.min.asset.php create mode 100644 dist/js/autosuggest-script.min.js create mode 100644 dist/js/comments-script.min.asset.php create mode 100644 dist/js/comments-script.min.js create mode 100644 dist/js/dashboard-script.min.asset.php create mode 100644 dist/js/dashboard-script.min.js create mode 100644 dist/js/facets-block-script.min.asset.php create mode 100644 dist/js/facets-block-script.min.js create mode 100644 dist/js/facets-meta-block-script.min.asset.php create mode 100644 dist/js/facets-meta-block-script.min.js create mode 100644 dist/js/facets-script.min.asset.php create mode 100644 dist/js/facets-script.min.js create mode 100644 dist/js/instant-results-admin-script.min.asset.php create mode 100644 dist/js/instant-results-admin-script.min.js create mode 100644 dist/js/instant-results-script.min.asset.php create mode 100644 dist/js/instant-results-script.min.js create mode 100644 dist/js/notice-script.min.asset.php create mode 100644 dist/js/notice-script.min.js create mode 100644 dist/js/ordering-script.min.asset.php create mode 100644 dist/js/ordering-script.min.js create mode 100644 dist/js/related-posts-block-script.min.asset.php create mode 100644 dist/js/related-posts-block-script.min.js create mode 100644 dist/js/settings-script.min.asset.php create mode 100644 dist/js/settings-script.min.js create mode 100644 dist/js/sites-admin-script.min.asset.php create mode 100644 dist/js/sites-admin-script.min.js create mode 100644 dist/js/stats-script.min.asset.php create mode 100644 dist/js/stats-script.min.js create mode 100644 dist/js/sync-script.min.asset.php create mode 100644 dist/js/sync-script.min.js create mode 100644 dist/js/synonyms-script.min.asset.php create mode 100644 dist/js/synonyms-script.min.js create mode 100644 dist/js/weighting-script.min.asset.php create mode 100644 dist/js/weighting-script.min.js diff --git a/dist/css/autosuggest-styles.min.asset.php b/dist/css/autosuggest-styles.min.asset.php new file mode 100644 index 0000000000..5b605d3174 --- /dev/null +++ b/dist/css/autosuggest-styles.min.asset.php @@ -0,0 +1 @@ + array(), 'version' => '920b9281fd9c2a2111d551b519f66ec7'); \ No newline at end of file diff --git a/dist/css/autosuggest-styles.min.css b/dist/css/autosuggest-styles.min.css new file mode 100644 index 0000000000..4453af2f30 --- /dev/null +++ b/dist/css/autosuggest-styles.min.css @@ -0,0 +1 @@ +.ep-autosuggest-container{position:relative}.ep-autosuggest-container .ep-autosuggest{background:#fff;border:1px solid #ccc;-webkit-box-shadow:0 2px 4px rgba(0,0,0,.2);box-shadow:0 2px 4px rgba(0,0,0,.2);display:none;position:absolute;width:100%;z-index:200}.ep-autosuggest-container .ep-autosuggest>ul{list-style:none;margin:0!important}.ep-autosuggest-container .ep-autosuggest>ul>li{font-family:sans-serif}.ep-autosuggest-container .ep-autosuggest>ul>li>a.autosuggest-link{color:#000;cursor:pointer;display:block;padding:2px 10px}.ep-autosuggest-container .ep-autosuggest>ul>li>a.autosuggest-link:active,.ep-autosuggest-container .ep-autosuggest>ul>li>a.autosuggest-link:hover{background-color:#eee;text-decoration:none}.ep-autosuggest-container .selected{background-color:#eee;text-decoration:none} diff --git a/dist/css/comments-styles.min.asset.php b/dist/css/comments-styles.min.asset.php new file mode 100644 index 0000000000..662c3aeb75 --- /dev/null +++ b/dist/css/comments-styles.min.asset.php @@ -0,0 +1 @@ + array(), 'version' => '874c92e040d755e8db8c6badfca0cded'); \ No newline at end of file diff --git a/dist/css/comments-styles.min.css b/dist/css/comments-styles.min.css new file mode 100644 index 0000000000..421ce00372 --- /dev/null +++ b/dist/css/comments-styles.min.css @@ -0,0 +1 @@ +.ep-widget-search-comments-results{list-style-type:none;margin-left:0}.ep-widget-search-comments-result-item,.ep-widget-search-comments-result-item-not-found{margin-left:0}.ep-widget-search-comments-result-item.selected a{border:2px dotted #171923} diff --git a/dist/css/dashboard-styles.min.asset.php b/dist/css/dashboard-styles.min.asset.php new file mode 100644 index 0000000000..0becd9aa30 --- /dev/null +++ b/dist/css/dashboard-styles.min.asset.php @@ -0,0 +1 @@ + array(), 'version' => '20c661d88d9fb4a905e1ae26fb231775'); \ No newline at end of file diff --git a/dist/css/dashboard-styles.min.css b/dist/css/dashboard-styles.min.css new file mode 100644 index 0000000000..740971c233 --- /dev/null +++ b/dist/css/dashboard-styles.min.css @@ -0,0 +1 @@ +.a11y-tip{display:inline-block;position:relative}.a11y-tip__trigger[tabindex]{border-bottom:1px dotted #666}.a11y-tip__trigger[aria-describedby]:hover+.a11y-tip__help,.a11y-tip__trigger[aria-describedby]:hover+.a11y-tip__help:after,.a11y-tip__trigger[aria-describedby]:not(.a11y-tip__trigger--toggle):focus+.a11y-tip__help,.a11y-tip__trigger[aria-describedby]:not(.a11y-tip__trigger--toggle):focus+.a11y-tip__help:after,.a11y-tip__trigger[aria-describedby][aria-expanded=true] .a11y-tip__help,.a11y-tip__trigger[aria-describedby][aria-expanded=true] .a11y-tip__help:after{opacity:1;pointer-events:auto;-webkit-transform:translate(-50%);transform:translate(-50%);visibility:visible}@media screen and (min-width:40.625em){.a11y-tip__trigger[aria-describedby]:hover+.a11y-tip__help--left,.a11y-tip__trigger[aria-describedby]:hover+.a11y-tip__help--left:after,.a11y-tip__trigger[aria-describedby]:hover+.a11y-tip__help--right,.a11y-tip__trigger[aria-describedby]:hover+.a11y-tip__help--right:after,.a11y-tip__trigger[aria-describedby]:not(.a11y-tip__trigger--toggle):focus+.a11y-tip__help--left,.a11y-tip__trigger[aria-describedby]:not(.a11y-tip__trigger--toggle):focus+.a11y-tip__help--left:after,.a11y-tip__trigger[aria-describedby]:not(.a11y-tip__trigger--toggle):focus+.a11y-tip__help--right,.a11y-tip__trigger[aria-describedby]:not(.a11y-tip__trigger--toggle):focus+.a11y-tip__help--right:after,.a11y-tip__trigger[aria-describedby][aria-expanded=true] .a11y-tip__help--left,.a11y-tip__trigger[aria-describedby][aria-expanded=true] .a11y-tip__help--left:after,.a11y-tip__trigger[aria-describedby][aria-expanded=true] .a11y-tip__help--right,.a11y-tip__trigger[aria-describedby][aria-expanded=true] .a11y-tip__help--right:after{-webkit-transform:translateY(-50%);transform:translateY(-50%)}}.a11y-tip__trigger[aria-describedby].a11y-tip__trigger--toggle:hover+.a11y-tip__help,.a11y-tip__trigger[aria-describedby].a11y-tip__trigger--toggle:hover+.a11y-tip__help:after{opacity:0;pointer-events:none;visibility:hidden}.a11y-tip__trigger[aria-expanded=true].a11y-tip__trigger--toggle:hover+.a11y-tip__help,.a11y-tip__trigger[aria-expanded=true].a11y-tip__trigger--toggle:hover+.a11y-tip__help:after{opacity:1!important;pointer-events:auto!important;-webkit-transition:opacity .18s ease-in-out,-webkit-transform .18s ease-in-out;transition:opacity .18s ease-in-out,-webkit-transform .18s ease-in-out;transition:opacity .18s ease-in-out,transform .18s ease-in-out;transition:opacity .18s ease-in-out,transform .18s ease-in-out,-webkit-transform .18s ease-in-out;visibility:visible!important}.a11y-tip--no-delay .a11y-tip__help,.a11y-tip--no-delay .a11y-tip__help:after{-webkit-transition:opacity .18s ease-in-out,-webkit-transform .18s ease-in-out;transition:opacity .18s ease-in-out,-webkit-transform .18s ease-in-out;transition:opacity .18s ease-in-out,transform .18s ease-in-out;transition:opacity .18s ease-in-out,transform .18s ease-in-out,-webkit-transform .18s ease-in-out}[role=tooltip].a11y-tip__help{background:rgba(0,0,0,.9);border-radius:4px;color:#fff;font-size:14px;margin-top:9pt;max-width:25pc;min-width:220px;padding:.5em 1em;text-align:left;top:100%;width:100%}[role=tooltip].a11y-tip__help,[role=tooltip].a11y-tip__help:after{left:50%;opacity:0;pointer-events:none;position:absolute;-webkit-transform:translate(-50%,10px);transform:translate(-50%,10px);-webkit-transform-style:preserve-3d;transform-style:preserve-3d;-webkit-transition:opacity .2s ease-in-out 1s;transition:opacity .2s ease-in-out 1s;visibility:hidden;z-index:10}[role=tooltip].a11y-tip__help:after{speak:none;border:6px inset transparent;border-bottom:6px solid rgba(0,0,0,.9);bottom:100%;content:"";display:inline-block;height:0;margin-top:6px;width:0}[role=tooltip].a11y-tip__help--top{bottom:100%;left:50%;margin-bottom:9pt;margin-top:0;top:auto;-webkit-transform:translate(-50%,10px);transform:translate(-50%,10px);-webkit-transform-origin:center top;transform-origin:center top}[role=tooltip].a11y-tip__help--top:after{speak:none;border:6px inset transparent;border-top:6px solid rgba(0,0,0,.9);content:"";display:inline-block;height:0;left:50%;margin-bottom:6px;margin-top:0;top:100%;-webkit-transform:translate(-50%,-10px);transform:translate(-50%,-10px);-webkit-transform-origin:center top;transform-origin:center top;width:0}@media screen and (min-width:40.625em){[role=tooltip].a11y-tip__help--left{left:auto;margin-right:11px;margin-top:0;right:100%;top:50%;-webkit-transform:translate(10px,-50%);transform:translate(10px,-50%)}[role=tooltip].a11y-tip__help--left:after{speak:none;border:6px inset transparent;border-left:6px solid rgba(0,0,0,.9);content:"";display:inline-block;height:0;left:100%;margin-right:5px;margin-top:0;top:50%;-webkit-transform:translate(-10px,-50%);transform:translate(-10px,-50%);width:0}[role=tooltip].a11y-tip__help--right{left:100%;margin-left:11px;margin-top:0;top:50%;-webkit-transform:translate(10px,-50%);transform:translate(10px,-50%)}[role=tooltip].a11y-tip__help--right:after{speak:none;border:6px inset transparent;border-right:6px solid rgba(0,0,0,.9);bottom:auto;content:"";display:inline-block;height:0;left:auto;margin-left:5px;margin-top:0;right:100%;top:50%;-webkit-transform:translate(10px,-50%);transform:translate(10px,-50%);width:0}}.a11y-tip--hide~.a11y-tip__help{display:none}.no-js .a11y-tip__help:not([role]){font-size:.85em}.no-js .a11y-tip__help:not([role]):before{content:"("}.no-js .a11y-tip__help:not([role]):after{content:")"}:root{--statusOk:#6aa000;--statusWarning:#e3e600;--statusError:red}html.wp-toolbar{background:transparent}.wrap .notice,.wrap>h2{position:relative;z-index:2}.wrap h1{font-size:23px;font-weight:400;line-height:29px;margin:0;padding:9px 0 4px}.wrap h2{color:#888;line-height:1.75;margin:.5em 0 .75em}h2.ep-list-features{display:none}#wpbody #update-nag,#wpbody .update-nag{display:block;margin:5px 15px 2px}.ep-header-menu{background-color:#fff;border-bottom:2px solid #ddd;margin-left:-20px;padding-bottom:5px;padding-left:20px;padding-right:20px;padding-top:5px;position:relative;z-index:2}.ep-header-menu:after{clear:both;content:" ";display:block}.ep-header-menu img{float:left}.ep-header-menu .icons{display:inline-block;float:right;height:30px;line-height:34px;padding-right:3px}.ep-header-menu .icons a{color:inherit;cursor:pointer;font-size:27px;margin-left:8px;position:relative;top:-3px;vertical-align:middle}.ep-header-menu .icons .dashicons-admin-generic,.ep-header-menu .icons .dashicons-controls-pause,.ep-header-menu .icons .dashicons-controls-play,.ep-header-menu .icons .dashicons-no,.ep-header-menu .icons .dashicons-update{font-size:30px;top:1px}.ep-header-menu .cancel-sync,.ep-header-menu .pause-sync,.ep-header-menu .resume-sync{display:none}.ep-header-menu .sync-status{bottom:-1px;color:#666;display:none;font-style:italic;margin-right:8px;position:relative;vertical-align:middle}.ep-header-menu .progress-bar{background-color:#d84440;bottom:0;height:5px;left:0;margin-bottom:-5px;position:absolute}.ep-header-menu .icons .dashicons-admin-generic,.ep-header-menu .icons .dashicons-update{display:inline}.ep-header-menu .icons .dashicons-update{top:2px}.ep-features{overflow:auto}.error-overlay.cant-connect,.error-overlay.syncing{background-color:#fff;bottom:0;content:" ";display:block;left:0;opacity:.6;position:fixed;right:0;top:46px;z-index:1}@media (min-width:880px){.error-overlay,.error-overlay.cant-connect,.error-overlay.syncing{left:10pc;top:2pc}}.ep-feature .postbox{margin-bottom:0}.ep-feature .postbox .hndle{cursor:inherit}.ep-feature .postbox .hndle .settings-button{background-color:#efefef;border:none;border-radius:4px;color:inherit;cursor:pointer;display:inline-block;float:right;font-size:13px;font-weight:400;line-height:inherit;margin-top:-4px;padding:4px 7px;padding-left:23px;position:relative}.ep-feature .settings-button:before{color:#72777c;content:"\f140";display:inline-block;font:400 19px/1 dashicons;left:1px;padding:0 5px 0 0;position:absolute;top:4px;vertical-align:middle}.ep-feature .settings-button:after{border-radius:50%;content:" ";display:inline-block;height:8px;margin-left:10px;margin-top:-2px;vertical-align:middle;width:8px}.feature-requirements-status-2.ep-feature .postbox .hndle .settings-button:after{background-color:transparent;border:1px solid red;border:1px solid var(--statusError)}.feature-requirements-status-2.ep-feature .settings .requirements-status-notice{border-color:red;border-color:var(--statusError)}.feature-requirements-status-1.ep-feature .postbox .hndle .settings-button:after{background-color:transparent;border:1px solid #e3e600;border:1px solid var(--statusWarning)}.feature-requirements-status-1.ep-feature.feature-active .postbox .hndle .settings-button:after{background-color:#e3e600;background-color:var(--statusWarning)}.feature-requirements-status-1.ep-feature .settings .requirements-status-notice{border-color:#e3e600;border-color:var(--statusWarning)}.feature-requirements-status-0.ep-feature .postbox .hndle .settings-button:after{background-color:transparent;border:1px solid #6aa000;border:1px solid var(--statusOk)}.feature-requirements-status-0.ep-feature.feature-active .postbox .hndle .settings-button:after{background-color:#6aa000;background-color:var(--statusOk)}.feature-requirements-status-0.ep-feature .settings .requirements-status-notice{border-color:#6aa000;border-color:var(--statusOk)}.ep-feature{margin-bottom:20px;position:relative;vertical-align:top}.ep-feature.saving .action-wrap:before{-webkit-animation:load8 1.1s linear infinite;animation:load8 1.1s linear infinite;border-bottom:5px solid #ccc;border-left:5px solid #999;border-radius:50%;border-right:5px solid #ccc;border-top:5px solid #ccc;content:" ";display:inline-block;font-size:7px;height:8px;margin-right:1.4em;position:relative;text-indent:-9999em;top:4px;-webkit-transform:translateZ(0);transform:translateZ(0);vertical-align:middle;width:8px}.ep-feature .description,.ep-feature .settings{margin-bottom:0;text-align:left}.ep-feature .settings{display:none;overflow:auto}.ep-feature .settings h3{font-size:inherit;font-weight:700;margin-top:0}.ep-feature.show-settings .settings{display:block}.ep-feature.show-settings .description{display:none}.ep-feature.show-settings .settings-button:before{content:"\f142"}.ep-feature .settings .requirements-status-notice{background-color:#efefef;border-left:4px solid #6aa000;border-left:4px solid var(--statusOk);margin-bottom:10px;padding:8px 9pt}.ep-feature .settings .requirements-status-notice.requirements-status-notice--reindex{border-color:#e3e600;border-color:var(--statusWarning);display:none}.ep-feature .settings .requirements-status-notice.requirements-status-notice--syncing{border-color:red;border-color:var(--statusError);display:none}.ep-feature .settings .action-wrap{clear:both;padding-top:15px;text-align:right;vertical-align:middle}.ep-feature .settings .action-wrap a{cursor:pointer;display:inline-block}.ep-feature .settings .action-wrap .no-dash-sync{color:#aaa;display:none;line-height:27px;padding-right:8px}.ep-feature .settings .action-wrap a.disabled{cursor:default}.ep-feature .settings .action-wrap .cancel{margin-right:6px;margin-top:4px}.ep-feature.dash-sync-disabled .settings .action-wrap .no-dash-sync{display:inline}.ep-feature .settings .field{clear:both;overflow:visible;overflow:initial;padding-top:15px}.ep-feature .settings .field:first-child{padding-top:0}.ep-feature .settings .field label{display:inline-block;margin:.25em 0 .5em}.ep-feature .settings .field div{padding-top:5px}.ep-feature .settings .field .field-name,.ep-feature .settings .field>label{-webkit-box-sizing:border-box;box-sizing:border-box;display:block;float:left;padding-right:1.5em;width:25%}.ep-feature .settings .field .input-wrap{display:block;float:right;width:75%}.ep-feature .settings .field .field-description{color:#666;font-style:italic;margin-bottom:0;margin-top:4px}.ep-feature .settings .field .disabled{color:#bbb}.ep-feature .settings .field .disabled input{cursor:default}.ep-feature .settings .field .components-form-token-field{padding-top:0}.ep-feature .settings .field .components-form-token-field__label{margin-top:0}.ep-feature .settings .field .components-form-token-field__input-container{padding:2px 4px}.ep-feature .long{display:none}.ep-feature .long p:last-child{margin-bottom:0}.ep-feature.show-full .long{display:block}.ep-feature.show-full .learn-more{display:none}.ep-feature .learn-more:after{content:"\f140";font-family:dashicons;font-size:1.5em;line-height:1;position:relative;top:-.07em;vertical-align:middle}.ep-feature .collapse:after{content:"\f142";font-family:dashicons;font-size:1.5em;line-height:1;position:relative;top:-.07em;vertical-align:middle}.intro h2{line-height:1.2;padding:9px 0 4px 0}.intro h1{color:#626262;font-weight:600;margin:.5em 0 2em;text-align:center}.intro-container{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-box-pack:center;-ms-flex-pack:center;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;justify-content:center;position:relative;text-align:center}@media (min-width:880px){.intro-container{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}}@media (min-width:1270px){.intro-container{margin-left:10%;margin-right:10%}}.intro-container h2{color:#626262;height:8%}.intro-container p{margin-left:auto;margin-right:auto;max-width:300px}.ep-feature-list{display:inline-block;margin:0;text-align:left;vertical-align:top}.ep-feature-list li{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;margin:4px 3px}.ep-feature-list .a11y-tip__help--top[role=tooltip]{font-size:inherit}.ep-feature-info{text-decoration:none}.ep-feature-info .dashicons{font-size:14px;position:relative;top:2px}.intro-box{-webkit-box-flex:2;-ms-flex-positive:2;flex-grow:2;margin-bottom:2em}.intro-container-success{-webkit-box-pack:center;-ms-flex-pack:center;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;justify-content:center;text-align:center}.intro-container-success p{margin-top:23px;padding:0 35% 0 35%}@media (max-width:880px){.intro-container-success p{margin-top:23px;padding:0 26%}}.ep-config-success span{font-size:6em;padding-right:75px}.setup-complete{font-size:2em;margin-top:0;padding-top:0;width:100%}.setup-complete h2{margin-top:0;padding-top:0}@media (min-width:880px){.ep-copy-text{padding:0 9% 0 9%}}.ep-copy-text a{font-weight:700}.ep-circle{background:#fff;border-radius:50%;color:#626262;display:inline-block;font-size:1pc;font-weight:400;height:6em;line-height:2.8em;margin:0 1em;text-align:center;width:6em}.ep-circle p{border:0;font-size:50px;font-weight:700;line-height:.5em;margin:0}@media (min-width:880px){.ep-circle--first:after{background:#d4d4d4;content:"";height:.2em;left:50%;position:absolute;top:2.9em;-webkit-transform:translateX(-50%);transform:translateX(-50%);width:75%;z-index:-1}}.ep-circle--active{background-color:#d73c38;color:#fff}@media (min-width:880px){.wrap h1{line-height:1.75}}.wrap.intro{margin-bottom:30px;margin-top:30px;overflow:auto}.wrap.intro .error,.wrap.intro .is-dismissible,.wrap.intro .notice,.wrap.intro .updated{display:none!important}.features-screenshot{display:none}.setup-message{clear:both;text-align:center}.setup-button{-webkit-appearance:none;background-color:#e63e3b;border:none;border-radius:10px;-webkit-box-shadow:1px 1px 3px 1px rgba(0,0,0,.25);box-shadow:1px 1px 3px 1px rgba(0,0,0,.25);color:#fff;display:inline-block;margin:0 .75em;padding:1em 1.5em;text-decoration:none}.setup-button:hover{background-color:#b93431;color:#ffe8ed}.setup-message .setup-button-primary{background-color:#fff;color:#d84440}.weighting-settings .postbox{-webkit-box-sizing:border-box;box-sizing:border-box;max-width:650px}.weighting-settings .postbox *{-webkit-box-sizing:border-box;box-sizing:border-box}.weighting-settings .postbox h2.hndle{color:#444;cursor:inherit}.weighting-settings fieldset{padding:10px}.weighting-settings fieldset legend{float:left;position:relative;top:5px;width:75pt}.weighting-settings fieldset p{display:inline-block;float:left;margin:0}.weighting-settings .field-group{margin:10px 0 0}.weighting-settings .field-group h3{font-size:1em;margin:10px}.weighting-settings .fields>fieldset:nth-of-type(odd){background:#f9f9f9}.weighting-settings .searchable{display:inline-block;width:90pt}.weighting-settings .weighting{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex}.weighting-settings .weighting label{margin-right:10px;min-width:5pc}.weighting-settings input[type=range]{-webkit-appearance:none;background:transparent;display:inline-block;height:1em;margin:0;vertical-align:middle;width:200px}.weighting-settings input[type=range]:focus{outline:none}.weighting-settings input[type=range]:disabled{opacity:.5;pointer-events:none}.weighting-settings input[type=range]::-webkit-slider-runnable-track{background:#ddd;border:0 solid #000;border-radius:1px;-webkit-box-shadow:0 0 0 #000;box-shadow:0 0 0 #000;cursor:pointer;height:3px;width:100%}.weighting-settings input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;background:#1e8cbe;border:1px solid #1e8cbe;border-radius:25px;-webkit-box-shadow:0 0 0 #000;box-shadow:0 0 0 #000;cursor:pointer;height:14px;margin-top:-6px;width:14px}.weighting-settings input[type=range]:focus::-webkit-slider-runnable-track{background:#ddd}.weighting-settings input[type=range]:focus::-webkit-slider-thumb{background:#fff!important}.weighting-settings input[type=range]::-moz-range-track{background:#1e8cbe;border:0 solid #000;border-radius:1px;box-shadow:0 0 0 #000;cursor:pointer;height:3px;width:100%}.weighting-settings input[type=range]::-moz-range-thumb{background:#1e8cbe;border:1px solid #1e8cbe;border-radius:25px;box-shadow:0 0 0 #000;cursor:pointer;height:14px;width:14px}.weighting-settings input[type=range]::-ms-track{background:transparent;border-color:transparent;color:transparent;cursor:pointer;height:3px;width:100%}.weighting-settings input[type=range]::-ms-fill-lower{background:#1e8cbe;border:0 solid #000;border-radius:2px;box-shadow:0 0 0 #000}.weighting-settings input[type=range]::-ms-fill-upper{background:#1e8cbe;border:0 solid #000;border-radius:2px;box-shadow:0 0 0 #000}.weighting-settings input[type=range]::-ms-thumb{background:#a1d0ff;border:1px solid #1e8cbe;border-radius:25px;box-shadow:0 0 0 #000;cursor:pointer;height:14px;margin-top:1px;width:14px}.weighting-settings input[type=range]:focus::-ms-fill-lower{background:#1e8cbe}.weighting-settings input[type=range]:focus::-ms-fill-upper{background:#1e8cbe}.ep-feature-search .wp-color-result.button{margin-bottom:10px}.ep-feature.ep-feature-search .settings .wp-picker-input-wrap>label{margin-right:10px;margin-top:0}.ep-feature.ep-feature-search .settings.wp-picker-input-wrap label{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex}.ep-feature.ep-feature-search .settings .wp-picker-open+.wp-picker-input-wrap{display:-webkit-box;display:-ms-flexbox;display:flex}@-webkit-keyframes load8{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes load8{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@media (min-width:880px){.intro .left{float:left;width:30%}.features-screenshot{display:block;float:right;height:auto;margin:0 auto;max-width:750pt;width:70%}.ep-features .left{-webkit-box-sizing:border-box;box-sizing:border-box;display:block;float:left;padding-right:10px;width:50%}.ep-features .right{-webkit-box-sizing:border-box;box-sizing:border-box;display:block;float:right;padding-left:10px;width:50%}.ep-feature .feature-message{display:inline-block;float:left;padding:0;padding-top:.5em;vertical-align:middle}}.wrap h2.nav-tab-wrapper.ep-credentials-tabs{border-bottom:1px solid #ccc}.ep-credentials input[type=text]{min-width:250px}h2 .nav-tab.ep-credentials-tab{cursor:pointer;margin-bottom:-1px}.ep-credentials-tab.nav-tab-active{border-bottom-color:#f1f1f1}.ep-credentials-tab img,.ep-credentials-tab span{display:inline-block;vertical-align:middle}.ep-credentials fieldset{border-bottom:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;margin:0;padding:0 1rem}.ep-credentials fieldset.predefined{border-top:1px solid #ccc}.ep-settings .ep-credentials-general{padding:0 1rem}.ep-settings .button-primary{margin:0 1rem}.ep-settings .description{font-size:.75rem;font-style:italic}@media (min-width:880px){.ep-credentials{display:inline-block}.ep-credentials .form-table{width:auto}.ep-credentials .form-table td,.ep-credentials-general .form-table td{padding-left:0}.ep-credentials .form-table td input,.ep-credentials .form-table td select,.ep-credentials-general .form-table td input,.ep-credentials-general .form-table td select{width:250px}}.ep-flex-container{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;width:100%}.ep-flex-container-nowrap{display:-webkit-box;display:-ms-flexbox;display:flex;width:100%}.stats-list{margin-right:0;width:100%}@media (min-width:1270px){.stats-list{background-color:#fff;margin-right:28px;width:37%}}.stats-queries{background-color:#fff;width:100%}@media (min-width:1270px){.stats-queries{width:60%}}.stats-list-th span:last-of-type{border-radius:4px;color:inherit;cursor:pointer;display:inline-block;float:right;font-size:13px;margin-top:-4px;padding:4px 7px;padding-left:23px;position:relative}.status-circle{float:right;text-transform:capitalize}.status-circle:after{border-radius:50%;content:" ";display:inline-block;height:8px;margin-left:10px;margin-top:-2px;vertical-align:middle;width:8px}.green-status{color:#6aa000;color:var(--statusOk)}.yellow-status{color:#e3e600;color:var(--statusWarning)}.red-status{color:red;color:var(--statusError)}.green-status:after{background-color:#6aa000;background-color:var(--statusOk)}.yellow-status:after{background-color:#e3e600;background-color:var(--statusWarning)}.red-status:after{background-color:red;background-color:var(--statusError)}.doc-chart{margin-right:0;width:100%}@media (min-width:880px){.doc-chart{margin-right:24px;width:48%}}@media (min-width:1270px){.doc-chart{margin-right:28px;width:50%}}.ep-qchart-container{margin:0 auto;width:90%}@media (min-width:880px){.ep-qchart-container{width:48%}}@media (min-width:1270px){.ep-qchart-container{margin:0 auto;width:50%}}.inside-totals{padding:0 9pt 9pt}.ep-totals{-webkit-box-orient:vertical;-webkit-box-direction:normal;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;width:100%}@media (min-width:880px){.ep-totals{width:48%}}@media (min-width:1270px){.ep-totals{width:47%}}.ep-totals .ep-flex-container{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-box-pack:center;-ms-flex-pack:center;-ms-flex-direction:column;flex-direction:column;justify-content:center;margin-bottom:auto;margin-top:auto}@media (min-width:1270px){.ep-totals .ep-flex-container{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}}.ep-totals-column{-webkit-box-sizing:border-box;box-sizing:border-box;text-align:center;width:100%}@media (min-width:1270px){.ep-totals-column{width:50%}}p.ep-totals-title{font-weight:bolder;margin-top:28px}p.ep-totals-data{font-size:3em;margin-top:22px} diff --git a/dist/css/facets-admin-styles.min.asset.php b/dist/css/facets-admin-styles.min.asset.php new file mode 100644 index 0000000000..db996d6179 --- /dev/null +++ b/dist/css/facets-admin-styles.min.asset.php @@ -0,0 +1 @@ + array(), 'version' => '7c04ced215e799e33fee4b43c532da44'); \ No newline at end of file diff --git a/dist/css/facets-admin-styles.min.css b/dist/css/facets-admin-styles.min.css new file mode 100644 index 0000000000..c816d52d69 --- /dev/null +++ b/dist/css/facets-admin-styles.min.css @@ -0,0 +1 @@ +.widget-ep-facet label{margin-right:5px} diff --git a/dist/css/facets-styles.min.asset.php b/dist/css/facets-styles.min.asset.php new file mode 100644 index 0000000000..51e4e189d2 --- /dev/null +++ b/dist/css/facets-styles.min.asset.php @@ -0,0 +1 @@ + array(), 'version' => '7ecbaa6f4c896493c07d51a0116c219e'); \ No newline at end of file diff --git a/dist/css/facets-styles.min.css b/dist/css/facets-styles.min.css new file mode 100644 index 0000000000..82c8c85413 --- /dev/null +++ b/dist/css/facets-styles.min.css @@ -0,0 +1 @@ +.widget_ep-facet input[type=search],.wp-block-elasticpress-facet input[type=search]{margin-bottom:1rem}.widget_ep-facet .searchable .inner,.wp-block-elasticpress-facet .searchable .inner{max-height:20em;overflow:scroll}.widget_ep-facet .term.hide,.wp-block-elasticpress-facet .term.hide{display:none}.widget_ep-facet .empty-term,.wp-block-elasticpress-facet .empty-term{opacity:.5;position:relative}.widget_ep-facet .empty-term:after,.wp-block-elasticpress-facet .empty-term:after{bottom:0;content:" ";display:block;left:0;position:absolute;right:0;top:0;width:100%;z-index:2}.widget_ep-facet .level-1,.wp-block-elasticpress-facet .level-1{padding-left:20px}.widget_ep-facet .level-2,.wp-block-elasticpress-facet .level-2{padding-left:40px}.widget_ep-facet .level-3,.wp-block-elasticpress-facet .level-3{padding-left:60px}.widget_ep-facet .level-4,.wp-block-elasticpress-facet .level-4{padding-left:5pc}.widget_ep-facet .level-5,.wp-block-elasticpress-facet .level-5{padding-left:75pt}.widget_ep-facet input[disabled],.wp-block-elasticpress-facet input[disabled]{cursor:pointer;opacity:1}.widget_ep-facet .term a,.wp-block-elasticpress-facet .term a{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;position:relative}.widget_ep-facet .term a:hover .ep-checkbox,.wp-block-elasticpress-facet .term a:hover .ep-checkbox{background-color:#ccc}.ep-checkbox{-webkit-box-align:center;-ms-flex-align:center;-ms-flex-negative:0;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;background-color:#eee;display:-webkit-box;display:-ms-flexbox;display:flex;flex-shrink:0;height:1em;justify-content:center;margin-right:.25em;width:1em}.ep-checkbox:after{border:solid #fff;border-width:0 .125em .125em 0;content:"";display:none;height:.5em;-webkit-transform:rotate(45deg);transform:rotate(45deg);width:.25em}.ep-checkbox.checked{background-color:#5e5e5e}.ep-checkbox.checked:after{display:block} diff --git a/dist/css/highlighting-styles.min.asset.php b/dist/css/highlighting-styles.min.asset.php new file mode 100644 index 0000000000..561d33dc2f --- /dev/null +++ b/dist/css/highlighting-styles.min.asset.php @@ -0,0 +1 @@ + array(), 'version' => '390c918d67491df2c179d78284f576b3'); \ No newline at end of file diff --git a/dist/css/highlighting-styles.min.css b/dist/css/highlighting-styles.min.css new file mode 100644 index 0000000000..9a18e84516 --- /dev/null +++ b/dist/css/highlighting-styles.min.css @@ -0,0 +1 @@ +.ep-highlight{background-color:transparent;font-style:italic;font-weight:700} diff --git a/dist/css/instant-results-styles.min.asset.php b/dist/css/instant-results-styles.min.asset.php new file mode 100644 index 0000000000..13e5d4affe --- /dev/null +++ b/dist/css/instant-results-styles.min.asset.php @@ -0,0 +1 @@ + array(), 'version' => '598dfeaa3dace394f94a35ec2b53e4e1'); \ No newline at end of file diff --git a/dist/css/instant-results-styles.min.css b/dist/css/instant-results-styles.min.css new file mode 100644 index 0000000000..59c0df1be6 --- /dev/null +++ b/dist/css/instant-results-styles.min.css @@ -0,0 +1 @@ +.ep-search-reset-button{font:inherit!important;height:auto!important;letter-spacing:inherit!important;line-height:1!important;margin:0!important;padding:0!important;text-align:inherit!important;text-transform:inherit!important;width:auto!important}.ep-search-reset-button,.ep-search-reset-button:focus,.ep-search-reset-button:hover{background:transparent!important;border:none!important;-webkit-box-shadow:none!important;box-shadow:none!important;color:inherit!important;cursor:default!important}.ep-search-reset-button:focus{outline:medium auto Highlight!important;outline:medium auto -webkit-focus-ring-color!important;outline-offset:0!important}.ep-search-small-button{font-size:.875em!important;height:auto!important;line-height:1!important;padding:.5em!important}.ep-search-icon-button{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:justify;-ms-flex-pack:justify;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;justify-content:space-between}.ep-search-icon-button svg{fill:currentColor;-ms-flex-negative:0;flex-shrink:0;height:1em;width:1em}.ep-search-checkbox__count:before{content:"("}.ep-search-checkbox__count:after{content:")"}.ep-search-input{font-size:1.25em;margin:0!important;width:100%}.has-ep-search-modal{overflow:hidden}.ep-search-modal{--ep-search-modal-focus-within:0;background-color:rgba(43,46,56,.9);bottom:0;display:-webkit-box;display:-ms-flexbox;display:flex;left:0;position:fixed;right:0;top:0;z-index:9999}.rtl .ep-search-modal{direction:rtl;text-align:right}.admin-bar .ep-search-modal{top:2pc}@media (max-width:782px){.admin-bar .ep-search-modal{top:46px}}.ep-search-modal[aria-hidden=true]{display:none}.ep-search-modal[focus-within]{--ep-search-modal-focus-within:1}.ep-search-modal:focus-within{--ep-search-modal-focus-within:1}.ep-search-modal__content{-webkit-box-orient:vertical;-webkit-box-direction:normal;background-color:#fff;background-color:var(--ep-search-background-color);bottom:0;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:0;position:absolute;right:0;top:0}@media (min-width:768px){.ep-search-modal__content{bottom:1em;margin:0 auto;max-width:calc(100% - 2em);top:1em;width:80em}}.ep-search-modal__close{-ms-flex-item-align:end;align-self:flex-end;padding:1em!important}.ep-search-options-list{list-style:none;margin:0;padding:0}.ep-search-options-list__item{margin:.5em 0}.ep-search-options-list__item:before{content:none}.ep-search-options-list__sub-menu{padding-left:1em}.ep-search-page{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-box-flex:2;-ms-flex-positive:2;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;flex-grow:2;margin:0;overflow-y:auto;-webkit-transition:opacity .3s ease-out;transition:opacity .3s ease-out;width:100%}@media (min-width:768px){.ep-search-page{overflow:hidden}}.ep-search-page *,.ep-search-page :after,.ep-search-page :before{-webkit-box-sizing:border-box;box-sizing:border-box}.ep-search-page.is-loading{opacity:.5}.ep-search-page__body,.ep-search-page__header,.ep-search-page__tools{padding:0 1em}@media (min-width:768px){.ep-search-page__body{-webkit-box-align:start;-ms-flex-align:start;-webkit-box-flex:2;-ms-flex-positive:2;align-items:flex-start;display:-webkit-box;display:-ms-flexbox;display:flex;flex-grow:2;overflow:hidden}}.ep-search-panel{border:1px solid #dfdfdf;border:1px solid var(--ep-search-border-color);margin:0;padding:0}.ep-search-panel+.ep-search-panel{border-top-width:0}.ep-search-panel__heading{font-size:inherit;margin:0}.ep-search-panel__button{padding:1em!important;width:100%!important}.ep-search-panel__content{padding:0 1em 1em 1em}.ep-search-panel__content[aria-hidden=true]{display:none}.ep-search-pagination{-webkit-box-align:center;-ms-flex-align:center;-ms-grid-columns:1fr 1fr 1fr;align-items:center;display:-ms-grid;display:grid;grid-template-columns:1fr 1fr 1fr;margin-top:auto;text-align:center}.rtl .ep-search-pagination{direction:rtl}.ep-search-pagination__next{-ms-grid-column-align:end;justify-self:end}.ep-search-pagination__previous{-ms-grid-column-align:start;justify-self:start}.ep-search-range-slider{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;margin:.5em 0;min-height:1.625em;min-height:var(--ep-search-range-thumb-size)}.ep-search-range-slider__track{background:#efefef;background:var(--ep-search-alternate-background-color);border-radius:.375em;border-radius:calc(var(--ep-search-range-track-size)/2);height:.75em;height:var(--ep-search-range-track-size)}.ep-search-range-slider__track-1{background-color:currentColor}.ep-search-range-slider__thumb{background-color:currentColor;border-radius:.8125em;border-radius:calc(var(--ep-search-range-thumb-size)/2);-webkit-box-shadow:inset 0 0 0 .1625em currentColor,inset 0 0 0 .4375em #fff;box-shadow:inset 0 0 0 .1625em currentColor,inset 0 0 0 .4375em #fff;-webkit-box-shadow:inset 0 0 0 calc(var(--ep-search-range-thumb-size)/10) currentColor,inset 0 0 0 calc((var(--ep-search-range-thumb-size) - var(--ep-search-range-track-size))/2) var(--ep-search-background-color);box-shadow:inset 0 0 0 calc(var(--ep-search-range-thumb-size)/10) currentColor,inset 0 0 0 calc((var(--ep-search-range-thumb-size) - var(--ep-search-range-track-size))/2) var(--ep-search-background-color);height:1.625em;height:var(--ep-search-range-thumb-size);width:1.625em;width:var(--ep-search-range-thumb-size)}.ep-search-result{-webkit-box-align:start;-ms-flex-align:start;grid-gap:.5em;-ms-grid-rows:auto .5em 1fr;align-items:flex-start;display:-ms-grid;display:grid;grid-template-areas:"header" "footer";grid-template-rows:auto 1fr}@media (min-width:768px){.ep-search-result{grid-gap:1em;-ms-grid-rows:auto 1em auto 1em 1fr;grid-template-areas:"header" "description" "footer";grid-template-rows:auto auto 1fr}}.ep-search-result--has-thumbnail{-ms-grid-columns:min(300px,34%) auto;grid-template-areas:"thumbnail header" "thumbnail footer";grid-template-columns:min(300px,34%) auto}@media (min-width:768px){.ep-search-result--has-thumbnail{grid-template-areas:"thumbnail header" "thumbnail description" "thumbnail footer"}}.ep-search-result__thumbnail{-ms-grid-row-span:2;display:block;grid-area:thumbnail;-ms-grid-column:1;-ms-grid-row:1}.ep-search-result__thumbnail img{display:block;margin:0;width:100%}.ep-search-result__header{grid-gap:.5em;-ms-grid-columns:auto;display:-ms-grid;display:grid;grid-area:header;-ms-grid-column:1;-ms-grid-row:1;grid-template-columns:auto;justify-items:start}.ep-search-result--has-thumbnail>.ep-search-result__header{-ms-grid-column:2;-ms-grid-row:1}.ep-search-result__title{font-size:1em;margin:0}@media (min-width:768px){.ep-search-result__title{font-size:1.25em}}.ep-search-result__type{background-color:#efefef;background-color:var(--ep-search-alternate-background-color);border-radius:.25em;display:inline-block;font-size:.875em;line-height:1.5;padding:0 .25em;vertical-align:text-bottom}.ep-search-result__description{display:none;font-size:.875em;grid-area:description;margin:0}@media (min-width:768px){.ep-search-result__description{display:block;font-size:1em}}.ep-search-result__footer{grid-gap:.5em;display:-ms-grid;display:grid;grid-area:footer;-ms-grid-column:1;-ms-grid-row:3;justify-items:start}.ep-search-result--has-thumbnail>.ep-search-result__footer{-ms-grid-column:2;-ms-grid-row:2}@media (min-width:768px){.ep-search-result__thumbnail{-ms-grid-row-span:3;-ms-grid-column:1;-ms-grid-row:1}.ep-search-result__header{-ms-grid-column:1;-ms-grid-row:1}.ep-search-result--has-thumbnail>.ep-search-result__header{-ms-grid-column:2;-ms-grid-row:1}.ep-search-result__description{-ms-grid-column:1;-ms-grid-row:3}.ep-search-result__description{-ms-grid-column:2;-ms-grid-row:2}.ep-search-result__footer{-ms-grid-column:1;-ms-grid-row:5}.ep-search-result--has-thumbnail>.ep-search-result__footer{-ms-grid-column:2;-ms-grid-row:3}}.ep-search-results{grid-gap:2em;-ms-grid-columns:100%;-ms-grid-rows:-webkit-max-content;-ms-grid-rows:max-content;display:-ms-grid;display:grid;grid-template-columns:100%;grid-template-rows:-webkit-max-content;grid-template-rows:max-content;padding:0 0 1em 0;width:100%}@media (min-width:768px){.ep-search-results{height:100%;overflow-y:auto;padding:0 1em 1em 1em}}.ep-search-results__header{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:justify;-ms-flex-pack:justify;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;gap:1em;justify-content:space-between}.ep-search-results__title{font-size:1.25em;margin:0!important}@media (min-width:768px){.ep-search-results__title{font-size:1.5em}}.ep-search-sidebar{display:none;margin-bottom:2em}.ep-search-sidebar.is-open{display:block}@media (min-width:768px){.ep-search-sidebar{display:block;max-height:calc(100% - 1em);min-width:25%;overflow-y:auto}}.ep-search-sidebar-toggle{width:100%}@media (min-width:768px){.ep-search-sidebar-toggle{display:none}}.ep-search-sort{-ms-flex-negative:0;flex-shrink:0;gap:.5em;margin:0}.ep-search-results .ep-search-sort{display:none}@media (min-width:768px){.ep-search-results .ep-search-sort{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex}}.ep-search-sidebar .ep-search-sort{-webkit-box-orient:vertical;-webkit-box-direction:normal;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;margin-bottom:1em}@media (min-width:768px){.ep-search-sidebar .ep-search-sort{display:none}}.ep-search-toolbar .ep-search-tokens{display:contents}.ep-search-toolbar{-webkit-box-align:start;-ms-flex-align:start;align-items:start;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;gap:.25em;margin:1em 0}@media (min-width:768px){.ep-search-toolbar{-webkit-box-align:center;-ms-flex-align:center;align-items:center}}:root{--ep-search-background-color:#fff;--ep-search-alternate-background-color:#efefef;--ep-search-border-color:#dfdfdf;--ep-search-range-thumb-size:1.625em;--ep-search-range-track-size:0.75em}@media (min-width:768px){:root{--ep-search-range-thumb-size:1.25em;--ep-search-range-track-size:0.5em}} diff --git a/dist/css/ordering-styles.min.asset.php b/dist/css/ordering-styles.min.asset.php new file mode 100644 index 0000000000..52da86537c --- /dev/null +++ b/dist/css/ordering-styles.min.asset.php @@ -0,0 +1 @@ + array(), 'version' => '01d814020cc480b3998d208dc131f6f0'); \ No newline at end of file diff --git a/dist/css/ordering-styles.min.css b/dist/css/ordering-styles.min.css new file mode 100644 index 0000000000..fa5543f4f0 --- /dev/null +++ b/dist/css/ordering-styles.min.css @@ -0,0 +1 @@ +#ep-ordering{border-left-width:0;border-right-width:0}#ep-ordering .inside{background-color:#f1f1f1;margin:0;padding:0}#ep-ordering .loading,#ep-ordering .pointer-search,#ep-ordering .pointers{background-color:#fff;border-left:1px solid #eee;border-right:1px solid #eee}#ep-ordering .new-post{background:#fff;padding:0 1em}#ep-ordering .loading{padding:1em}#ep-ordering .loading .spinner{float:left;margin-left:0;margin-top:0}#ep-ordering .pointer-type{border:2px solid #0073aa;border-radius:2px;color:#0073aa;display:inline-block;font-size:.75em;font-weight:700;margin-right:8px;padding:1px 2px}#ep-ordering .pointers .pointer,#ep-ordering .pointers .post{padding:1em}#ep-ordering .pointers .pointer:nth-child(odd),#ep-ordering .pointers .post:nth-child(odd){background-color:#f9f9f9}#ep-ordering .pointers .title{color:#0073aa}#ep-ordering .pointers .pointer-actions{float:right}#ep-ordering .pointers .pointer-actions .handle{cursor:move}#ep-ordering .pointers .pointer-actions .delete-pointer{margin-left:10px}#ep-ordering .pointers .next-page-notice{background-color:#fdeeca;padding:1em 0;text-align:center}#ep-ordering .legend{background:#fff;border-bottom:1px solid #eee;padding:1em 0;text-align:center}#ep-ordering .legend-item{display:inline-block;font-size:.875em;font-style:italic;margin:0 .5em}#ep-ordering .pointer-search{margin-top:2em}#ep-ordering .pointer-search .no-results{padding:1em}#ep-ordering .pointer-search .section-title{border-bottom:1px solid #eee;border-top:1px solid #eee;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.04);box-shadow:0 1px 1px rgba(0,0,0,.04);font-weight:700}#ep-ordering .pointer-search .search-wrapper{padding:1em 0}#ep-ordering .pointer-search .input-wrap{padding:0 1em}#ep-ordering .pointer-search .search-pointers{font-size:18px;height:1.7em;line-height:100%;padding:3px 8px}#ep-ordering .pointer-search .pointer-results{padding:1em 0 0}#ep-ordering .pointer-search .pointer-result{padding:10px 2em}#ep-ordering .pointer-search .pointer-result .dashicons{float:right}#ep-ordering .pointer-search .pointer-result:hover{background-color:#f9f9f9}#ep-ordering .add-pointer,#ep-ordering .delete-pointer{cursor:pointer} diff --git a/dist/css/related-posts-block-styles.min.asset.php b/dist/css/related-posts-block-styles.min.asset.php new file mode 100644 index 0000000000..4b759e4af6 --- /dev/null +++ b/dist/css/related-posts-block-styles.min.asset.php @@ -0,0 +1 @@ + array(), 'version' => 'efc2056570d8dace97fac086da0cad4a'); \ No newline at end of file diff --git a/dist/css/related-posts-block-styles.min.css b/dist/css/related-posts-block-styles.min.css new file mode 100644 index 0000000000..7addbc46ae --- /dev/null +++ b/dist/css/related-posts-block-styles.min.css @@ -0,0 +1 @@ +.editor-styles-wrapper .wp-block-elasticpress-related-posts ul,.wp-block-elasticpress-related-posts ul{list-style-type:none;padding:0}.editor-styles-wrapper .wp-block-elasticpress-related-posts ul li a>div{display:inline} diff --git a/dist/css/sync-styles.min.asset.php b/dist/css/sync-styles.min.asset.php new file mode 100644 index 0000000000..4e6f2e37fb --- /dev/null +++ b/dist/css/sync-styles.min.asset.php @@ -0,0 +1 @@ + array(), 'version' => '2ce25d34635e95d5480d907ae6a8e96a'); \ No newline at end of file diff --git a/dist/css/sync-styles.min.css b/dist/css/sync-styles.min.css new file mode 100644 index 0000000000..2f889e31c2 --- /dev/null +++ b/dist/css/sync-styles.min.css @@ -0,0 +1 @@ +.ep-sync-button.components-button.has-icon.has-text{-webkit-box-pack:center;-ms-flex-pack:center;height:4rem;justify-content:center;width:100%}.ep-sync-button.components-button.has-icon.has-text svg{height:2em;margin:0;width:2em}.ep-sync-button--sync{font-size:1.5em;font-weight:700}.ep-sync-button--pause,.ep-sync-button--resume,.ep-sync-button--stop{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.ep-sync-controls{grid-gap:1em;-ms-grid-columns:1fr 1fr;display:-ms-grid;display:grid;grid-template-columns:1fr 1fr;margin:0 auto;max-width:16rem}.ep-sync-controls__sync{grid-column:1/-1}.ep-sync-controls__learn-more{grid-column:1/-1;text-align:center}.wrap .ep-sync-heading{font-weight:400;margin:.5rem 0 .75rem;padding:0}.wrap h2.ep-sync-heading{color:inherit}.ep-sync-messages{-ms-flex-line-pack:start;-ms-grid-columns:-webkit-min-content auto;-ms-grid-columns:min-content auto;align-content:start;background:#1a1e24;background:var(--ep-sync-color-black);color:#fff;color:var(--ep-sync-color-white);display:-ms-grid;display:grid;font-family:monospace;grid-auto-flow:column;grid-template-columns:-webkit-min-content auto;grid-template-columns:min-content auto;height:21em;line-height:2;overflow-y:auto;white-space:pre-wrap}.ep-sync-messages__message{-ms-grid-column:2;grid-column:2}.ep-sync-messages__line-number{-webkit-box-sizing:content-box;box-sizing:content-box;min-width:3ch;opacity:.5;padding:0 .5em;text-align:right}.ep-sync-panel{margin-bottom:2rem;max-width:75pc}.ep-sync-panel__body{grid-column-gap:2rem;grid-row-gap:1rem;-ms-grid-columns:auto 16rem;display:-ms-grid;display:grid;grid-template-columns:auto 16rem}.ep-sync-panel__body.is-opened{padding:2rem 2rem 1rem 2rem}.ep-sync-panel__body .components-tab-panel__tab-content,.ep-sync-panel__body .components-toggle-control,.ep-sync-panel__body p{margin-bottom:1rem;margin-top:0}@media (max-width:960px){.ep-sync-panel__body{-ms-grid-columns:100%;grid-template-columns:100%}}.ep-sync-panel__row{grid-column:1/-1}.ep-sync-panel__introduction{font-size:18px}@-webkit-keyframes epSyncRotation{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes epSyncRotation{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.ep-sync-progress{-webkit-box-align:center;-ms-flex-align:center;grid-row-gap:1rem;-ms-grid-columns:-webkit-min-content minmax(-webkit-max-content,1fr) 3fr;-ms-grid-columns:min-content minmax(max-content,1fr) 3fr;align-items:center;display:-ms-grid;display:grid;grid-template-columns:-webkit-min-content minmax(-webkit-max-content,1fr) 3fr;grid-template-columns:min-content minmax(max-content,1fr) 3fr;margin-bottom:1rem}@media (max-width:960px){.ep-sync-progress{-ms-grid-columns:-webkit-min-content auto;-ms-grid-columns:min-content auto;grid-template-columns:-webkit-min-content auto;grid-template-columns:min-content auto}}.ep-sync-progress svg{-webkit-animation:epSyncRotation 1.5s linear infinite;animation:epSyncRotation 1.5s linear infinite;-webkit-animation-play-state:paused;animation-play-state:paused;height:36px;margin-right:9pt;width:36px}.ep-sync-progress--syncing svg{-webkit-animation-play-state:running;animation-play-state:running}.ep-sync-progress__details strong{display:block;font-size:14px}@media (max-width:960px){.ep-sync-progress__progress-bar{grid-column:1/-1}}.ep-sync-progress-bar{background:#f0f0f0;background:var(--ep-sync-color-light-grey);display:-webkit-box;display:-ms-flexbox;display:flex;overflow:hidden;text-align:center}.ep-sync-progress-bar,.ep-sync-progress-bar__progress{border-radius:.875em}.ep-sync-progress-bar__progress{background:var(--wp-admin-theme-color);color:#fff;color:var(--ep-sync-color-white);padding:0 .875em;-webkit-transition:all .5s ease-in-out;transition:all .5s ease-in-out;white-space:nowrap}.ep-sync-progress-bar--complete .ep-sync-progress-bar__progress{background:#46b450;background:var(--ep-sync-color-success)}.ep-sync-progress-bar--paused .ep-sync-progress-bar__progress{opacity:.5}.ep-sync-status{-webkit-box-align:center;-ms-flex-align:center;grid-gap:.5rem;-ms-grid-columns:-webkit-min-content auto;-ms-grid-columns:min-content auto;align-items:center;display:-ms-grid;display:grid;grid-template-columns:-webkit-min-content auto;grid-template-columns:min-content auto}.ep-sync-status svg{fill:#b52727;fill:var(--ep-sync-color-error)}.ep-sync-status--success svg{fill:#46b450;fill:var(--ep-sync-color-success)}.ep-sync-status__time{background-color:#f0f0f0;background-color:var(--ep-sync-color-light-grey);border-radius:2px;padding:.25em .5em}.ep-sync-warning{grid-gap:.5rem;-ms-grid-columns:-webkit-min-content auto;-ms-grid-columns:min-content auto;display:-ms-grid;display:grid;grid-template-columns:-webkit-min-content auto;grid-template-columns:min-content auto}.ep-sync-warning svg{fill:#ffb359;fill:var(--ep-sync-color-warning);margin-top:-3px}:root{--ep-sync-color-black:#1a1e24;--ep-sync-color-error:#b52727;--ep-sync-color-light-grey:#f0f0f0;--ep-sync-color-success:#46b450;--ep-sync-color-warning:#ffb359;--ep-sync-color-white:#fff} diff --git a/dist/css/synonyms-styles.min.asset.php b/dist/css/synonyms-styles.min.asset.php new file mode 100644 index 0000000000..030b94aa74 --- /dev/null +++ b/dist/css/synonyms-styles.min.asset.php @@ -0,0 +1 @@ + array(), 'version' => '8d787160bf57ec3bab087de52b964079'); \ No newline at end of file diff --git a/dist/css/synonyms-styles.min.css b/dist/css/synonyms-styles.min.css new file mode 100644 index 0000000000..0ad97e83fe --- /dev/null +++ b/dist/css/synonyms-styles.min.css @@ -0,0 +1 @@ +:root{--ep-synonyms-input-border-color:#ccc;--ep-synonyms-color-black:#1a1e24;--ep-synonyms-color-error:#b52727}html.wp-toolbar{background:transparent}#synonym-root .page-title-action{margin-left:10px}#synonym-root .postbox .hndle{cursor:default}#synonym-root h2{color:#1a1e24;color:var(--ep-synonyms-color-black)}.synonym-editor .postbox{width:100%}.synonym-editor .postbox>.hndle{display:-webkit-box;display:-ms-flexbox;display:flex}.synonym-alternative-editor,.synonym-set-editor{-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start;display:-webkit-box;display:-ms-flexbox;display:flex}.synonym-alternative-editor .components-form-token-field,.synonym-set-editor .components-form-token-field{-webkit-box-flex:1;-ms-flex:1;flex:1;margin-bottom:.5em}.synonym-alternative-editor .components-form-token-field__label,.synonym-set-editor .components-form-token-field__label{display:none}.synonym-alternative-editor .components-form-token-field__input-container,.synonym-set-editor .components-form-token-field__input-container{border-color:#ccc;border-color:var(--ep-synonyms-input-border-color);-webkit-box-sizing:border-box;box-sizing:border-box}.synonym-alternative-editor .components-form-token-field__token-text,.synonym-set-editor .components-form-token-field__token-text{padding-bottom:1px;padding-top:1px}@media screen and (max-width:782px){.synonym-alternative-editor .components-form-token-field__token-text,.synonym-set-editor .components-form-token-field__token-text{padding-bottom:3px;padding-top:3px}}.synonym-alternative-editor input.components-form-token-field__input[type=text],.synonym-set-editor input.components-form-token-field__input[type=text]{margin-bottom:2px;margin-top:2px}@media screen and (max-width:782px){.synonym-alternative-editor input.components-form-token-field__input[type=text],.synonym-set-editor input.components-form-token-field__input[type=text]{min-height:30px}}.synonym-alternative-editor .components-form-token-field__help,.synonym-set-editor .components-form-token-field__help{margin-top:0}input[type=text].ep-synonyms__input{border:1px solid #ccc;border:1px solid var(--ep-synonyms-input-border-color);margin-bottom:.5em;margin-right:1em;min-height:36px;width:10em}@media screen and (max-width:782px){input[type=text].ep-synonyms__input{min-height:40px}}.synonym-alternatives__primary-heading{width:11em}.synonym-alternatives__input-heading{-webkit-box-flex:1;-ms-flex:1;flex:1}button.synonym__remove{background-color:transparent;border:none;color:#b52727;color:var(--ep-synonyms-color-error);cursor:pointer;margin:0 0 0 10px;min-height:36px;padding:0}@media screen and (max-width:782px){button.synonym__remove{min-height:40px}}button.synonym__remove .dashicons-dismiss{margin:-2px 2px 0 0}.synonym__validation:before{-ms-flex-preferred-size:100%;content:"";flex-basis:100%;height:0}.synonym-solr-editor__validation p,.synonym__validation{color:#b52727;color:var(--ep-synonyms-color-error);font-style:italic}.synonym__validation{margin:0 0 .625em .5em}.synonym-btn-group button.button{margin-right:.625em} diff --git a/dist/js/admin-script.min.asset.php b/dist/js/admin-script.min.asset.php new file mode 100644 index 0000000000..f64a0ac6ae --- /dev/null +++ b/dist/js/admin-script.min.asset.php @@ -0,0 +1 @@ + array('wp-dom-ready', 'wp-polyfill'), 'version' => 'c19779493128c9e8879f80e518dc1031'); \ No newline at end of file diff --git a/dist/js/admin-script.min.js b/dist/js/admin-script.min.js new file mode 100644 index 0000000000..25d99fa539 --- /dev/null +++ b/dist/js/admin-script.min.js @@ -0,0 +1 @@ +!function(){"use strict";var e={n:function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,{a:t}),t},d:function(n,t){for(var o in t)e.o(t,o)&&!e.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:t[o]})},o:function(e,n){return Object.prototype.hasOwnProperty.call(e,n)}},n=window.wp.domReady;e.n(n)()((()=>{const e=document.getElementById("ep-wp-header-end"),n=document.querySelectorAll("div.update-nag");for(const t of n)e.after(t)}))}(); \ No newline at end of file diff --git a/dist/js/autosuggest-script.min.asset.php b/dist/js/autosuggest-script.min.asset.php new file mode 100644 index 0000000000..8f58cd0900 --- /dev/null +++ b/dist/js/autosuggest-script.min.asset.php @@ -0,0 +1 @@ + array('wp-hooks', 'wp-polyfill'), 'version' => '7631a8067195d75c29644811b91cc701'); \ No newline at end of file diff --git a/dist/js/autosuggest-script.min.js b/dist/js/autosuggest-script.min.js new file mode 100644 index 0000000000..29fbec6f59 --- /dev/null +++ b/dist/js/autosuggest-script.min.js @@ -0,0 +1 @@ +!function(){"use strict";var e=window.wp.hooks;"undefined"!==typeof window.epDataFilter&&(0,e.addFilter)("ep.Autosuggest.data","ep/epDatafilter",window.epDatafilter),"undefined"!==typeof window.epAutosuggestItemHTMLFilter&&(0,e.addFilter)("ep.Autosuggest.itemHTML","ep/epAutosuggestItemHTMLFilter",window.epAutosuggestItemHTMLFilter),"undefined"!==typeof window.epAutosuggestListItemsHTMLFilter&&(0,e.addFilter)("ep.Autosuggest.listHTML","ep/epAutosuggestListItemsHTMLFilter",window.epAutosuggestListItemsHTMLFilter),"undefined"!==typeof window.epAutosuggestQueryFilter&&(0,e.addFilter)("ep.Autosuggest.query","ep/epAutosuggestQueryFilter",window.epAutosuggestQueryFilter),"undefined"!==typeof window.epAutosuggestElementFilter&&(0,e.addFilter)("ep.Autosuggest.element","ep/epAutosuggestElementFilter",window.epAutosuggestElementFilter);const t=(e,t)=>{let s=null;return function(...o){const n=this;window.clearTimeout(s),s=window.setTimeout((()=>{e.apply(n,o)}),t)}},s=(e,t)=>{for(;(e=e.parentElement)&&!e.classList.contains(t););return e},{epas:o}=window;function n(e,t){t.setAttribute("aria-activedescendant",e)}function r(e,t){!function(e){const t=new CustomEvent("ep-autosuggest-click",{detail:e});if(window.dispatchEvent(t),e.searchTerm&&1===parseInt(o.triggerAnalytics,10)&&"function"===typeof gtag){const t=`click - ${e.searchTerm}`;gtag("event",t,{event_category:"EP :: Autosuggest",event_label:e.url,transport_type:"beacon"})}}({searchTerm:e,url:t}),window.location.href=t}function i(e,t){return"navigate"===o.action?r(e.value,t.dataset.url):(function(e,t){e.value=t}(e,t.innerText),function(e){e.closest("form").submit()}(e))}function a(e,t,{query:s}){const o=(n=t,r=e,s.replace(new RegExp((e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))(n),"g"),r));var n,r;return o}async function u(t,s){const n={body:t,method:"POST",mode:"cors",headers:{"Content-Type":"application/json; charset=utf-8"}};o?.http_headers&&"object"===typeof o.http_headers&&Object.keys(o.http_headers).forEach((e=>{n.headers[e]=o.http_headers[e]})),o.addSearchTermHeader&&(n.headers["EP-Search-Term"]=encodeURI(s));try{const t=await fetch(o.endpointUrl,n);if(!t.ok)throw Error(t.statusText);const r=await t.json();return(0,e.applyFilters)("ep.Autosuggest.data",r,s)}catch(e){return console.error(e),e}}function l(t,n){let r="";const{value:a}=n,u=s(n,"ep-autosuggest-container").querySelector(".ep-autosuggest"),l=u.querySelector(".autosuggest-list");for(;l.firstChild;)l.removeChild(l.firstChild);t.length>0?u.style="display: block;":u.style="display: none;";const c=t.length;for(let s=0;c>s;++s){const n=t[s],i=n._source.post_title,u=n._source.permalink,l=i.replace(/\\([\s\S])|(")/g,"""),c=a.trim().split(" ");let d=l;if(o.highlightingEnabled){const e=new RegExp(`\\b(${c.join("|")})`,"gi");d=d.replace(e,(e=>`<${o.highlightingTag} class="${o.highlightingClass} ep-autosuggest-highlight">${e}`))}let g=`
  • \n\t\t\t\t\n\t\t\t\t\t${d}\n\t\t\t\t\n\t\t\t
  • `;g=(0,e.applyFilters)("ep.Autosuggest.itemHTML",g,n,s,a),r+=g}r=(0,e.applyFilters)("ep.Autosuggest.listHTML",r,t,n),l.innerHTML=r;const d=Array.from(document.querySelectorAll(".autosuggest-link"));return l.addEventListener("click",(e=>{e.preventDefault();const t=e.target.tagName===o.highlightingTag?.toUpperCase()?e.target.parentElement:e.target;d.includes(t)&&i(n,t)})),!0}function c(){const e=document.querySelectorAll(".autosuggest-list"),t=document.querySelectorAll(".ep-autosuggest");return e.forEach((e=>{for(;e.firstChild;)e.removeChild(e.firstChild)})),t.forEach((e=>{e.style="display: none;"})),!0}function d(e,t){const s=t.closest("form");e?s.classList.add("is-loading"):s.classList.remove("is-loading")}o.endpointUrl&&""!==o.endpointUrl&&(!function(){const r=[o.defaultSelectors,o.selector].filter(Boolean).join(",");if(!r)return;let g,p;const f=[38,40,13],h=e=>{if(!f.includes(e.keyCode))return;const t=e.target,o=s(t,"ep-autosuggest-container").querySelector(".autosuggest-list").children,r=()=>Array.from(o).findIndex((e=>e.classList.contains("selected"))),a=()=>{Array.from(o).forEach((e=>{e.classList.remove("selected"),e.setAttribute("aria-selected","false")}))},u=()=>{if(p>=0){const e=o[p];e.classList.add("selected"),e.setAttribute("aria-selected","true"),n(e.id,t)}};switch(e.keyCode){case 38:p=p-1>=0?p-1:0,a();break;case 40:if("undefined"===typeof p)p=0;else{const e=r();o[e+1]&&(p=e+1,a())}break;case 13:o[p]?.classList.contains("selected")&&i(t,o[p].querySelector(".autosuggest-link"))}o[p]&&o[p].classList.contains("autosuggest-item")?u():a(),38===e.keyCode&&e.preventDefault()};function m(e){const t=new FormData(e);return t.has("post_type")?t.getAll("post_type").slice(-1):t.has("post_type[]")?t.getAll("post_type[]"):[]}const y=t((async t=>{const s=function(){if("undefined"===typeof window.epas){const e="No epas object defined";return console.warn(e),{error:e}}return window.epas}();if(s.error)return;const o=t.value,n="ep_autosuggest_placeholder",r=m(t.form);if(o.length>=2){d(!0,t);let i=a(o,n,s);i=JSON.parse(i),r.length>0&&"undefined"!==typeof i.post_filter.bool.must&&i.post_filter.bool.must.push({terms:{"post_type.raw":r}}),i=(0,e.applyFilters)("ep.Autosuggest.query",i,o,t),i=JSON.stringify(i);const g=await u(i,o);if(g&&g._shards&&g._shards.successful>0){const e=function(e,t){const s={},o="ep_custom_result",n=t.toLowerCase(),r=e.filter((e=>{let t=!0;return void 0!==e._source.terms&&void 0!==e._source.terms[o]&&e._source.terms[o].forEach((o=>{o.name.toLowerCase()===n&&(s[o.term_order]=e,t=!1)})),t})),i={};Object.keys(s).sort().forEach((e=>{i[e]=s[e]})),Object.keys(i).length>0&&Object.keys(i).forEach((e=>{const t=i[e];r.splice(e-1,0,t)}));return r}(g.hits.hits,o);0===e.length?c():l(e,t)}else c();d(!1,t)}else 0===o.length&&c()}),200),w=e=>{e.preventDefault();const{target:t,key:s,keyCode:o}=e;if("Escape"===s||"Esc"===s||27===o)return c(),function(e,t){t.setAttribute("aria-expanded",e)}(!1,t),void n("",t);if(f.includes(o)&&""!==t.value)return void h(e);const r=e.target;y(r)},A=e=>{const t=document.createElement("div");t.classList.add("ep-autosuggest-container"),e.insertAdjacentElement("afterend",t),t.appendChild(e)},E=t=>{if(!g){g=document.createElement("div"),g.classList.add("ep-autosuggest");const e=document.createElement("ul");e.classList.add("autosuggest-list"),e.setAttribute("role","listbox"),g.appendChild(e)}let s=g.cloneNode(!0);s=(0,e.applyFilters)("ep.Autosuggest.element",s,t),t.insertAdjacentElement("afterend",s)},v=e=>{if(["facet-search","ep-search-input"].some((t=>e.classList.contains(t))))return;e.setAttribute("autocomplete","off"),e.classList.contains("wp-block-search__input")?(e.form.classList.add("ep-autosuggest-container"),E(e.parentElement)):(A(e),E(e));const t=new CustomEvent("elasticpress.input.moved");e.dispatchEvent(t),e.addEventListener("keyup",w),e.addEventListener("blur",(function(){window.setTimeout(c,200)}))},L=e=>{const t=e.querySelectorAll(r);t&&Array.from(t).forEach(v)},b=()=>{const e=document.body,t={subtree:!0,childList:!0};new MutationObserver(((s,o)=>{s.forEach((s=>{Array.from(s.addedNodes).forEach((s=>{s.nodeType===Node.ELEMENT_NODE&&(o.disconnect(),"INPUT"===s.tagName?s.matches(r)&&v(s):L(s),o.observe(e,t))}))}))})).observe(e,t)};L(document.body),_=b,"undefined"!==typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",_):_());var _}(),window.epasAPI={hideAutosuggestBox:c,updateAutosuggestBox:l,esSearch:u,buildSearchQuery:a})}(); \ No newline at end of file diff --git a/dist/js/comments-script.min.asset.php b/dist/js/comments-script.min.asset.php new file mode 100644 index 0000000000..796e1e8f15 --- /dev/null +++ b/dist/js/comments-script.min.asset.php @@ -0,0 +1 @@ + array('wp-polyfill'), 'version' => 'f75bb5e70aa706add691fd79d13275fc'); \ No newline at end of file diff --git a/dist/js/comments-script.min.js b/dist/js/comments-script.min.js new file mode 100644 index 0000000000..4383dfba11 --- /dev/null +++ b/dist/js/comments-script.min.js @@ -0,0 +1 @@ +!function(){"use strict";const e=(e,t)=>{for(;(e=e.parentElement)&&!e.classList.contains(t););return e},t=document.querySelectorAll(".ep-widget-search-comments");let n;t.forEach((e=>{const t=document.createElement("input");t.setAttribute("autocomplete","off"),t.setAttribute("type","search"),t.setAttribute("class","ep-widget-search-comments-input");const n=document.createElement("ul");n.setAttribute("class","ep-widget-search-comments-results"),e.appendChild(t),e.appendChild(n)}));const s=[38,40,13];function i(t){n=void 0;const s=e(t,"ep-widget-search-comments").querySelector(".ep-widget-search-comments-results");for(;s.firstChild;)s.removeChild(s.firstChild)}function o(e){const t=window.epc.minimumLengthToSearch||2;return e?.value?.trim().length>=t}function c(t,n){const s=e(n,"ep-widget-search-comments");t?s.classList.add("ep-widget-search-comments-is-loading"):s.classList.remove("ep-widget-search-comments-is-loading")}const r=((e,t)=>{let n=null;return function(...s){const i=this;window.clearTimeout(n),n=window.setTimeout((()=>{e.apply(i,s)}),t)}})((function(t){if(o(t)){const n=e(t,"ep-widget-search-comments").querySelector("#ep-widget-search-comments-post-type"),s=n?.value?`&post_type=${n.value.trim()}`:"";return c(!0,t),fetch(`${window.epc.restApiEndpoint}?s=${t.value.trim()}${s}`).then((e=>{if(!e.ok)throw e;return e.json()})).then((n=>{0===Object.keys(n).length?t.value.trim()?(t=>{const n=e(t,"ep-widget-search-comments").querySelector(".ep-widget-search-comments-results");let s=`
  • ${window.epc.noResultsFoundText}
  • `;"undefined"!==typeof window.epCommentWidgetItemNotFoundHTMLFilter&&(s=window.epCommentWidgetItemNotFoundHTMLFilter(s,window.epc.noResultsFoundText,t.value)),n.innerHTML=s})(t):i(t):((t,n)=>{let s="",i="";Object.keys(t).forEach(((e,o)=>{t[e]?.content&&t[e]?.link&&(i=`\n\t\t\t\t
  • \n\t\t\t\t\t\n\t\t\t\t\t\t${t[e].content}\n\t\t\t\t\t\n\t\t\t\t
  • \n\t\t\t`,"undefined"!==typeof window.epCommentWidgetItemHTMLFilter&&(i=window.epCommentWidgetItemHTMLFilter(i,t[e],o,n.value)),s+=i)}));const o=e(n,"ep-widget-search-comments").querySelector(".ep-widget-search-comments-results");"undefined"!==typeof window.epCommentWidgetItemsHTMLFilter&&(s=window.epCommentWidgetItemsHTMLFilter(s,n.value)),o.innerHTML=s})(n,t)})).catch((()=>{i(t)})).finally((()=>{c(!1,t)}))}return!1}),500),d=t=>{t.preventDefault();const{target:c,key:d,keyCode:l}=t;if("Escape"===d||"Esc"===d||27===l)return i(c),void c.setAttribute("aria-expanded",!1);s.includes(l)&&""!==c.value?(t=>{if(!s.includes(t.keyCode))return;const i=e(t.target,"ep-widget-search-comments").querySelector(".ep-widget-search-comments-results"),o=i.querySelectorAll(".ep-widget-search-comments-result-item").length,c=i.children,r=n;switch(t.keyCode){case 38:n=n-1<0||"undefined"===typeof n?o-1:n-1;break;case 40:"undefined"===typeof n||n+1>o-1?n=0:n+=1;break;case 13:if(c[n]?.classList.contains("selected")||1===o){const e=n||0;if(c[e]){const t=c[e].querySelector("a")?.getAttribute("href");window.location.href=t}}}"number"===typeof r&&(c[r].classList.remove("selected"),c[r].setAttribute("aria-selected","false")),c[n]?.classList.add("selected"),c[n]?.setAttribute("aria-selected","true")})(t):o(c)?r(c):i(c)};t.forEach((e=>{const t=e.querySelector(".ep-widget-search-comments-input");t.addEventListener("keyup",d),t.addEventListener("keydown",(e=>{38===e.keyCode&&e.preventDefault()})),t.addEventListener("blur",(function(){setTimeout((()=>i(t)),200)}))}))}(); \ No newline at end of file diff --git a/dist/js/dashboard-script.min.asset.php b/dist/js/dashboard-script.min.asset.php new file mode 100644 index 0000000000..78c62cbd1a --- /dev/null +++ b/dist/js/dashboard-script.min.asset.php @@ -0,0 +1 @@ + array('wp-i18n', 'wp-polyfill'), 'version' => '0db0a3bc92c83f453c9dd5e86d983e77'); \ No newline at end of file diff --git a/dist/js/dashboard-script.min.js b/dist/js/dashboard-script.min.js new file mode 100644 index 0000000000..2080f83d76 --- /dev/null +++ b/dist/js/dashboard-script.min.js @@ -0,0 +1 @@ +!function(){var t={3462:function(t,e,n){n(6699);var r=n(2649);t.exports=r("Array","includes")},9116:function(t,e,n){n(9601);var r=n(857);t.exports=r.Object.assign},9662:function(t,e,n){var r=n(7854),o=n(614),i=n(6330),s=r.TypeError;t.exports=function(t){if(o(t))return t;throw s(i(t)+" is not a function")}},6077:function(t,e,n){var r=n(7854),o=n(614),i=r.String,s=r.TypeError;t.exports=function(t){if("object"==typeof t||o(t))return t;throw s("Can't set "+i(t)+" as a prototype")}},1223:function(t,e,n){var r=n(5112),o=n(30),i=n(3070),s=r("unscopables"),c=Array.prototype;void 0==c[s]&&i.f(c,s,{configurable:!0,value:o(null)}),t.exports=function(t){c[s][t]=!0}},9670:function(t,e,n){var r=n(7854),o=n(111),i=r.String,s=r.TypeError;t.exports=function(t){if(o(t))return t;throw s(i(t)+" is not an object")}},8533:function(t,e,n){"use strict";var r=n(2092).forEach,o=n(9341)("forEach");t.exports=o?[].forEach:function(t){return r(this,t,arguments.length>1?arguments[1]:void 0)}},1318:function(t,e,n){var r=n(5656),o=n(1400),i=n(6244),s=function(t){return function(e,n,s){var c,a=r(e),u=i(a),f=o(s,u);if(t&&n!=n){for(;u>f;)if((c=a[f++])!=c)return!0}else for(;u>f;f++)if((t||f in a)&&a[f]===n)return t||f||0;return!t&&-1}};t.exports={includes:s(!0),indexOf:s(!1)}},2092:function(t,e,n){var r=n(9974),o=n(1702),i=n(8361),s=n(7908),c=n(6244),a=n(5417),u=o([].push),f=function(t){var e=1==t,n=2==t,o=3==t,f=4==t,l=6==t,p=7==t,v=5==t||l;return function(d,g,y,h){for(var b,m,x=s(d),O=i(x),w=r(g,y),S=c(O),L=0,j=h||a,E=e?j(d,S):n||p?j(d,0):void 0;S>L;L++)if((v||L in O)&&(m=w(b=O[L],L,x),t))if(e)E[L]=m;else if(m)switch(t){case 3:return!0;case 5:return b;case 6:return L;case 2:u(E,b)}else switch(t){case 4:return!1;case 7:u(E,b)}return l?-1:o||f?f:E}};t.exports={forEach:f(0),map:f(1),filter:f(2),some:f(3),every:f(4),find:f(5),findIndex:f(6),filterReject:f(7)}},9341:function(t,e,n){"use strict";var r=n(7293);t.exports=function(t,e){var n=[][t];return!!n&&r((function(){n.call(null,e||function(){return 1},1)}))}},7475:function(t,e,n){var r=n(7854),o=n(3157),i=n(4411),s=n(111),c=n(5112)("species"),a=r.Array;t.exports=function(t){var e;return o(t)&&(e=t.constructor,(i(e)&&(e===a||o(e.prototype))||s(e)&&null===(e=e[c]))&&(e=void 0)),void 0===e?a:e}},5417:function(t,e,n){var r=n(7475);t.exports=function(t,e){return new(r(t))(0===e?0:e)}},4326:function(t,e,n){var r=n(1702),o=r({}.toString),i=r("".slice);t.exports=function(t){return i(o(t),8,-1)}},648:function(t,e,n){var r=n(7854),o=n(1694),i=n(614),s=n(4326),c=n(5112)("toStringTag"),a=r.Object,u="Arguments"==s(function(){return arguments}());t.exports=o?s:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=a(t),c))?n:u?s(e):"Object"==(r=s(e))&&i(e.callee)?"Arguments":r}},9920:function(t,e,n){var r=n(2597),o=n(3887),i=n(1236),s=n(3070);t.exports=function(t,e,n){for(var c=o(e),a=s.f,u=i.f,f=0;f0&&r[0]<4?1:+(r[0]+r[1])),!o&&s&&(!(r=s.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=s.match(/Chrome\/(\d+)/))&&(o=+r[1]),t.exports=o},2649:function(t,e,n){var r=n(7854),o=n(1702);t.exports=function(t,e){return o(r[t].prototype[e])}},748:function(t){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2109:function(t,e,n){var r=n(7854),o=n(1236).f,i=n(8880),s=n(1320),c=n(3505),a=n(9920),u=n(4705);t.exports=function(t,e){var n,f,l,p,v,d=t.target,g=t.global,y=t.stat;if(n=g?r:y?r[d]||c(d,{}):(r[d]||{}).prototype)for(f in e){if(p=e[f],l=t.noTargetGet?(v=o(n,f))&&v.value:n[f],!u(g?f:d+(y?".":"#")+f,t.forced)&&void 0!==l){if(typeof p==typeof l)continue;a(p,l)}(t.sham||l&&l.sham)&&i(p,"sham",!0),s(n,f,p,t)}}},7293:function(t){t.exports=function(t){try{return!!t()}catch(t){return!0}}},9974:function(t,e,n){var r=n(1702),o=n(9662),i=n(4374),s=r(r.bind);t.exports=function(t,e){return o(t),void 0===e?t:i?s(t,e):function(){return t.apply(e,arguments)}}},4374:function(t,e,n){var r=n(7293);t.exports=!r((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},6916:function(t,e,n){var r=n(4374),o=Function.prototype.call;t.exports=r?o.bind(o):function(){return o.apply(o,arguments)}},6530:function(t,e,n){var r=n(9781),o=n(2597),i=Function.prototype,s=r&&Object.getOwnPropertyDescriptor,c=o(i,"name"),a=c&&"something"===function(){}.name,u=c&&(!r||r&&s(i,"name").configurable);t.exports={EXISTS:c,PROPER:a,CONFIGURABLE:u}},1702:function(t,e,n){var r=n(4374),o=Function.prototype,i=o.bind,s=o.call,c=r&&i.bind(s,s);t.exports=r?function(t){return t&&c(t)}:function(t){return t&&function(){return s.apply(t,arguments)}}},5005:function(t,e,n){var r=n(7854),o=n(614),i=function(t){return o(t)?t:void 0};t.exports=function(t,e){return arguments.length<2?i(r[t]):r[t]&&r[t][e]}},8173:function(t,e,n){var r=n(9662);t.exports=function(t,e){var n=t[e];return null==n?void 0:r(n)}},7854:function(t,e,n){var r=function(t){return t&&t.Math==Math&&t};t.exports=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof n.g&&n.g)||function(){return this}()||Function("return this")()},2597:function(t,e,n){var r=n(1702),o=n(7908),i=r({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,e){return i(o(t),e)}},3501:function(t){t.exports={}},490:function(t,e,n){var r=n(5005);t.exports=r("document","documentElement")},4664:function(t,e,n){var r=n(9781),o=n(7293),i=n(317);t.exports=!r&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},8361:function(t,e,n){var r=n(7854),o=n(1702),i=n(7293),s=n(4326),c=r.Object,a=o("".split);t.exports=i((function(){return!c("z").propertyIsEnumerable(0)}))?function(t){return"String"==s(t)?a(t,""):c(t)}:c},2788:function(t,e,n){var r=n(1702),o=n(614),i=n(5465),s=r(Function.toString);o(i.inspectSource)||(i.inspectSource=function(t){return s(t)}),t.exports=i.inspectSource},9909:function(t,e,n){var r,o,i,s=n(8536),c=n(7854),a=n(1702),u=n(111),f=n(8880),l=n(2597),p=n(5465),v=n(6200),d=n(3501),g="Object already initialized",y=c.TypeError,h=c.WeakMap;if(s||p.state){var b=p.state||(p.state=new h),m=a(b.get),x=a(b.has),O=a(b.set);r=function(t,e){if(x(b,t))throw new y(g);return e.facade=t,O(b,t,e),e},o=function(t){return m(b,t)||{}},i=function(t){return x(b,t)}}else{var w=v("state");d[w]=!0,r=function(t,e){if(l(t,w))throw new y(g);return e.facade=t,f(t,w,e),e},o=function(t){return l(t,w)?t[w]:{}},i=function(t){return l(t,w)}}t.exports={set:r,get:o,has:i,enforce:function(t){return i(t)?o(t):r(t,{})},getterFor:function(t){return function(e){var n;if(!u(e)||(n=o(e)).type!==t)throw y("Incompatible receiver, "+t+" required");return n}}}},3157:function(t,e,n){var r=n(4326);t.exports=Array.isArray||function(t){return"Array"==r(t)}},614:function(t){t.exports=function(t){return"function"==typeof t}},4411:function(t,e,n){var r=n(1702),o=n(7293),i=n(614),s=n(648),c=n(5005),a=n(2788),u=function(){},f=[],l=c("Reflect","construct"),p=/^\s*(?:class|function)\b/,v=r(p.exec),d=!p.exec(u),g=function(t){if(!i(t))return!1;try{return l(u,f,t),!0}catch(t){return!1}},y=function(t){if(!i(t))return!1;switch(s(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return d||!!v(p,a(t))}catch(t){return!0}};y.sham=!0,t.exports=!l||o((function(){var t;return g(g.call)||!g(Object)||!g((function(){t=!0}))||t}))?y:g},4705:function(t,e,n){var r=n(7293),o=n(614),i=/#|\.prototype\./,s=function(t,e){var n=a[c(t)];return n==f||n!=u&&(o(e)?r(e):!!e)},c=s.normalize=function(t){return String(t).replace(i,".").toLowerCase()},a=s.data={},u=s.NATIVE="N",f=s.POLYFILL="P";t.exports=s},111:function(t,e,n){var r=n(614);t.exports=function(t){return"object"==typeof t?null!==t:r(t)}},1913:function(t){t.exports=!1},2190:function(t,e,n){var r=n(7854),o=n(5005),i=n(614),s=n(7976),c=n(3307),a=r.Object;t.exports=c?function(t){return"symbol"==typeof t}:function(t){var e=o("Symbol");return i(e)&&s(e.prototype,a(t))}},3383:function(t,e,n){"use strict";var r,o,i,s=n(7293),c=n(614),a=n(30),u=n(9518),f=n(1320),l=n(5112),p=n(1913),v=l("iterator"),d=!1;[].keys&&("next"in(i=[].keys())?(o=u(u(i)))!==Object.prototype&&(r=o):d=!0),void 0==r||s((function(){var t={};return r[v].call(t)!==t}))?r={}:p&&(r=a(r)),c(r[v])||f(r,v,(function(){return this})),t.exports={IteratorPrototype:r,BUGGY_SAFARI_ITERATORS:d}},7497:function(t){t.exports={}},6244:function(t,e,n){var r=n(7466);t.exports=function(t){return r(t.length)}},133:function(t,e,n){var r=n(7392),o=n(7293);t.exports=!!Object.getOwnPropertySymbols&&!o((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&r&&r<41}))},8536:function(t,e,n){var r=n(7854),o=n(614),i=n(2788),s=r.WeakMap;t.exports=o(s)&&/native code/.test(i(s))},1574:function(t,e,n){"use strict";var r=n(9781),o=n(1702),i=n(6916),s=n(7293),c=n(1956),a=n(5181),u=n(5296),f=n(7908),l=n(8361),p=Object.assign,v=Object.defineProperty,d=o([].concat);t.exports=!p||s((function(){if(r&&1!==p({b:1},p(v({},"a",{enumerable:!0,get:function(){v(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},n=Symbol(),o="abcdefghijklmnopqrst";return t[n]=7,o.split("").forEach((function(t){e[t]=t})),7!=p({},t)[n]||c(p({},e)).join("")!=o}))?function(t,e){for(var n=f(t),o=arguments.length,s=1,p=a.f,v=u.f;o>s;)for(var g,y=l(arguments[s++]),h=p?d(c(y),p(y)):c(y),b=h.length,m=0;b>m;)g=h[m++],r&&!i(v,y,g)||(n[g]=y[g]);return n}:p},30:function(t,e,n){var r,o=n(9670),i=n(6048),s=n(748),c=n(3501),a=n(490),u=n(317),f=n(6200),l=f("IE_PROTO"),p=function(){},v=function(t){return"