diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a823974afa..69ce9db24c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,4 +82,4 @@ jobs: run: composer install - name: PHPCS check - run: './vendor/bin/phpcs . -q --report=checkstyle --warning-severity=6 --runtime-set testVersion 7.4- | cs2pr' + run: './vendor/bin/phpcs . -q --report=checkstyle --runtime-set testVersion 7.4- | cs2pr' diff --git a/.stylelintrc b/.stylelintrc index f7007ae70b..3b8c4705a1 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -1,18 +1,17 @@ { - "extends": [ - "@10up/stylelint-config" - ], - "rules": { - "scale-unlimited/declaration-strict-value": [ - "/color/", - { - "ignoreValues": ["currentColor", "inherit", "initial", "transparent", "unset"], - "severity": "warning" - } - ], - "font-family-no-missing-generic-family-keyword": null, - "declaration-property-unit-allowed-list": null, - "at-rule-disallowed-list": null - } + "extends": [ + "@10up/stylelint-config" + ], + "rules": { + "scale-unlimited/declaration-strict-value": [ + "/color/", + { + "ignoreValues": ["currentcolor", "inherit", "initial", "transparent", "unset"], + "severity": "warning" + } + ], + "font-family-no-missing-generic-family-keyword": null, + "declaration-property-unit-allowed-list": null + } } diff --git a/assets/css/autosuggest.css b/assets/css/autosuggest.css index 636183860c..56d4a605f1 100644 --- a/assets/css/autosuggest.css +++ b/assets/css/autosuggest.css @@ -1,9 +1,11 @@ +@import "./global/colors.css"; + .ep-autosuggest-container { position: relative; & .ep-autosuggest { - background: #fff; - border: 1px solid #ccc; + background: var(--ep-c-white); + border: 1px solid var(--ep-c-white-gray); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); display: none; position: absolute; @@ -19,14 +21,14 @@ font-family: sans-serif; & > a.autosuggest-link { - color: #000; + color: var(--ep-c-black); cursor: pointer; display: block; padding: 2px 10px; &:hover, &:active { - background-color: #eee; + background-color: var(--ep-c-medium-white); text-decoration: none; } } @@ -35,7 +37,7 @@ } & .selected { - background-color: #eee; + background-color: var(--ep-c-medium-white); text-decoration: none; } } diff --git a/assets/css/dashboard.css b/assets/css/dashboard.css index 329f3a7c75..9ed56d97d7 100644 --- a/assets/css/dashboard.css +++ b/assets/css/dashboard.css @@ -1,10 +1,5 @@ @import "@10up/component-tooltip"; - -:root { - --ep-dashboard-status-ok: #6aa000; - --ep-dashboard-status-warning: #e3e600; - --ep-dashboard-status-error: #f00; -} +@import "./global/colors.css"; html.wp-toolbar { background: transparent; @@ -40,7 +35,7 @@ h2.ep-list-features { } .ep-header-menu { - background-color: #fff; + background-color: var(--ep-c-white); border-bottom: 2px solid #ddd; margin-left: -20px; padding-bottom: 5px; @@ -96,7 +91,7 @@ h2.ep-list-features { .ep-header-menu .sync-status { bottom: -1px; - color: #666; + color: var(--ep-c-medium-gray); display: none; font-style: italic; margin-right: 8px; @@ -105,7 +100,7 @@ h2.ep-list-features { } .ep-header-menu .progress-bar { - background-color: #d84440; + background-color: var(--ep-c-medium-red); bottom: 0; height: 5px; left: 0; @@ -132,7 +127,7 @@ h2.ep-list-features { .error-overlay.cant-connect, .error-overlay.syncing { - background-color: #fff; + background-color: var(--ep-c-white); bottom: 0; content: " "; display: block; @@ -163,7 +158,7 @@ h2.ep-list-features { } .ep-feature .postbox .hndle .settings-button { - background-color: #efefef; + background-color: var(--ep-c-medium-white); border: none; border-radius: 4px; color: inherit; @@ -180,7 +175,7 @@ h2.ep-list-features { } .ep-feature .settings-button::before { - color: #72777c; + color: var(--ep-c-medium-gray); content: "\f140"; display: inline-block; font: 400 19px/1 dashicons; @@ -206,11 +201,11 @@ h2.ep-list-features { & .postbox .hndle .settings-button::after { background-color: transparent; - border: 1px solid var(--ep-dashboard-status-error); + border: 1px solid var(--ep-status-error); } & .settings .requirements-status-notice { - border-color: var(--ep-dashboard-status-error); + border-color: var(--ep-status-error); } } @@ -218,15 +213,15 @@ h2.ep-list-features { & .postbox .hndle .settings-button::after { background-color: transparent; - border: 1px solid var(--ep-dashboard-status-warning); + border: 1px solid var(--ep-status-warning); } &.feature-active .postbox .hndle .settings-button::after { - background-color: var(--ep-dashboard-status-warning); + background-color: var(--ep-status-warning); } & .settings .requirements-status-notice { - border-color: var(--ep-dashboard-status-warning); + border-color: var(--ep-status-warning); } } @@ -234,15 +229,15 @@ h2.ep-list-features { & .postbox .hndle .settings-button::after { background-color: transparent; - border: 1px solid var(--ep-dashboard-status-ok); + border: 1px solid var(--ep-status-ok); } &.feature-active .postbox .hndle .settings-button::after { - background-color: var(--ep-dashboard-status-ok); + background-color: var(--ep-status-ok); } & .settings .requirements-status-notice { - border-color: var(--ep-dashboard-status-ok); + border-color: var(--ep-status-ok); } } @@ -254,11 +249,11 @@ h2.ep-list-features { .ep-feature.saving .action-wrap::before { animation: load8 1.1s infinite linear; - border-bottom: 5px solid #ccc; - border-left: 5px solid #999; + border-bottom: 5px solid var(--ep-c-white-gray); + border-left: 5px solid var(--ep-c-light-gray); border-radius: 50%; - border-right: 5px solid #ccc; - border-top: 5px solid #ccc; + border-right: 5px solid var(--ep-c-white-gray); + border-top: 5px solid var(--ep-c-white-gray); content: " "; display: inline-block; font-size: 7px; @@ -305,18 +300,18 @@ h2.ep-list-features { } .ep-feature .settings .requirements-status-notice { - background-color: #efefef; - border-left: 4px solid var(--ep-dashboard-status-ok); + background-color: var(--ep-c-medium-white); + border-left: 4px solid var(--ep-status-ok); margin-bottom: 10px; padding: 8px 12px; &.requirements-status-notice--reindex { - border-color: var(--ep-dashboard-status-warning); + border-color: var(--ep-status-warning); display: none; /* Controlled by JavaScript. */ } &.requirements-status-notice--syncing { - border-color: var(--ep-dashboard-status-error); + border-color: var(--ep-status-error); display: none; /* Controlled by JavaScript. */ } } @@ -333,7 +328,7 @@ h2.ep-list-features { } & .no-dash-sync { - color: #aaa; + color: var(--ep-c-light-gray); display: none; line-height: 27px; padding-right: 8px; @@ -387,14 +382,14 @@ h2.ep-list-features { } & .field-description { - color: #666; + color: var(--ep-c-medium-gray); font-style: italic; margin-bottom: 0; margin-top: 4px; } & .disabled { - color: #bbb; + color: var(--ep-c-light-gray); & input { cursor: default; @@ -410,7 +405,7 @@ h2.ep-list-features { } & .components-form-token-field__input-container { - border-color: #8c8f94; + border-color: var(--ep-c-light-gray); } } @@ -461,7 +456,7 @@ h2.ep-list-features { } .intro h1 { - color: #626262; + color: var(--ep-c-medium-gray); font-weight: 600; margin: 0.5em 0 2em; text-align: center; @@ -484,7 +479,7 @@ h2.ep-list-features { } & h2 { - color: #626262; + color: var(--ep-c-medium-gray); height: 8%; } @@ -576,9 +571,9 @@ h2.ep-list-features { } .ep-circle { - background: #fff; + background: var(--ep-c-white); border-radius: 50%; - color: #626262; + color: var(--ep-c-medium-gray); display: inline-block; font-size: 16px; font-weight: 400; @@ -616,8 +611,8 @@ h2.ep-list-features { } .ep-circle--active { - background-color: #d73c38; - color: #fff; + background-color: var(--ep-c-medium-red); + color: var(--ep-c-white); } .wrap.intro { @@ -644,11 +639,11 @@ h2.ep-list-features { .setup-button { -webkit-appearance: none; - background-color: #e63e3b; + background-color: var(--ep-c-medium-red); border: none; border-radius: 10px; box-shadow: 1px 1px 3px 1px rgba(0, 0, 0, 0.25); - color: #fff; + color: var(--ep-c-white); display: inline-block; margin: 0 0.75em; padding: 1em 1.5em; @@ -656,13 +651,13 @@ h2.ep-list-features { } .setup-button:hover { - background-color: #b93431; - color: #ffe8ed; + background-color: var(--ep-c-dark-red); + color: var(--ep-c-white-red); } .setup-message .setup-button-primary { - background-color: #fff; - color: #d84440; + background-color: var(--ep-c-white); + color: var(--ep-c-medium-red); } .ep-feature-search .wp-color-result.button { @@ -761,7 +756,7 @@ h2.ep-list-features { /* @media screen and (max-width: 600px) { */ .wrap h2.nav-tab-wrapper.ep-credentials-tabs { - border-bottom: 1px solid #ccc; + border-bottom: 1px solid var(--ep-c-white-gray); } /* } */ @@ -776,7 +771,7 @@ h2 .nav-tab.ep-credentials-tab { } .ep-credentials-tab.nav-tab-active { - border-bottom-color: #f1f1f1; + border-bottom-color: var(--ep-c-white); } .ep-credentials-tab img, @@ -786,15 +781,15 @@ h2 .nav-tab.ep-credentials-tab { } .ep-credentials fieldset { - border-bottom: 1px solid #ccc; - border-left: 1px solid #ccc; - border-right: 1px solid #ccc; + border-bottom: 1px solid var(--ep-c-white-gray); + border-left: 1px solid var(--ep-c-white-gray); + border-right: 1px solid var(--ep-c-white-gray); margin: 0; padding: 0 1rem; } .ep-credentials fieldset.predefined { - border-top: 1px solid #ccc; + border-top: 1px solid var(--ep-c-white-gray); } .ep-settings .ep-credentials-general { @@ -859,14 +854,14 @@ h2 .nav-tab.ep-credentials-tab { } */ @media (--wide-min) { - background-color: #fff; + background-color: var(--ep-c-white); margin-right: 28px; width: 37%; } } .stats-queries { - background-color: #fff; + background-color: var(--ep-c-white); width: 100%; /* @media( --tablet-min ) { @@ -908,27 +903,27 @@ h2 .nav-tab.ep-credentials-tab { } .green-status { - color: var(--ep-dashboard-status-ok); + color: var(--ep-status-ok); } .yellow-status { - color: var(--ep-dashboard-status-warning); + color: var(--ep-status-warning); } .red-status { - color: var(--ep-dashboard-status-error); + color: var(--ep-status-error); } .green-status::after { - background-color: var(--ep-dashboard-status-ok); + background-color: var(--ep-status-ok); } .yellow-status::after { - background-color: var(--ep-dashboard-status-warning); + background-color: var(--ep-status-warning); } .red-status::after { - background-color: var(--ep-dashboard-status-error); + background-color: var(--ep-status-error); } .doc-chart { diff --git a/assets/css/facets.css b/assets/css/facets.css index 22a9f6e8ca..4ca5a25004 100644 --- a/assets/css/facets.css +++ b/assets/css/facets.css @@ -1,6 +1,6 @@ +@import "./global/colors.css"; + :root { - --ep-range-slider-background-color: #fff; - --ep-range-slider-track-color: #eee; @media ( min-width: 768px ) { --ep-range-slider-thumb-size: 1.25em; @@ -73,13 +73,13 @@ } & .term a:hover .ep-checkbox { - background-color: #ccc; + background-color: var(--ep-c-white-gray); } } .ep-checkbox { align-items: center; - background-color: #eee; + background-color: var(--ep-c-medium-white); display: flex; flex-shrink: 0; height: 1em; @@ -99,7 +99,7 @@ } .ep-checkbox.checked { - background-color: #5e5e5e; + background-color: var(--ep-c-medium-gray); } .ep-checkbox.checked::after { @@ -128,21 +128,21 @@ } .ep-range-slider__track { - background: var(--ep-range-slider-track-color); + background: var(--ep-c-medium-white); border-radius: calc(var(--ep-range-slider-track-size) / 2); height: var(--ep-range-slider-track-size); } .ep-range-slider__track-1 { - background-color: currentcolor; /* stylelint-disable-line scale-unlimited/declaration-strict-value */ + background-color: currentcolor; } .ep-range-slider__thumb { - background-color: currentcolor; /* stylelint-disable-line scale-unlimited/declaration-strict-value */ + background-color: currentcolor; border-radius: calc(var(--ep-range-slider-thumb-size) / 2); box-shadow: inset 0 0 0 calc(var(--ep-range-slider-thumb-size) / 10) currentcolor, - inset 0 0 0 calc((var(--ep-range-slider-thumb-size) - var(--ep-range-slider-track-size)) / 2) var(--ep-range-slider-background-color); + inset 0 0 0 calc((var(--ep-range-slider-thumb-size) - var(--ep-range-slider-track-size)) / 2) var(--ep-c-white); height: var(--ep-range-slider-thumb-size); width: var(--ep-range-slider-thumb-size); } @@ -155,7 +155,7 @@ & .ep-radio { appearance: none; - border: 1px solid #eee; + border: 1px solid var(--ep-c-medium-white); border-radius: 50%; height: 1em; margin-right: 0.25em; @@ -165,7 +165,7 @@ &:checked { background-color: transparent; - border: 5px solid #5e5e5e; + border: 5px solid var(--ep-c-medium-gray); &::after { opacity: 0; diff --git a/assets/css/global/colors.css b/assets/css/global/colors.css new file mode 100644 index 0000000000..66569fe649 --- /dev/null +++ b/assets/css/global/colors.css @@ -0,0 +1,27 @@ +/* + * Colors + */ +:root { + + /** + * Brand colors + */ + --ep-c-white: #fff; + --ep-c-medium-white: #eee; + --ep-c-white-gray: #ccc; + --ep-c-white-red: #ffe8ed; + --ep-c-white-yellow: #fdeeca; + --ep-c-medium-gray: #626262; + --ep-c-light-gray: #999; + --ep-c-black: #000; + --ep-c-medium-red: #d73c38; + --ep-c-dark-red: #b93431; + --ep-c-medium-dark-blue: #0073aa; + + /** + * Status colors + */ + --ep-status-ok: #6aa000; + --ep-status-warning: #e3e600; + --ep-status-error: #f00; +} diff --git a/assets/css/instant-results.css b/assets/css/instant-results.css index 25a110f9d6..0bf5317945 100644 --- a/assets/css/instant-results.css +++ b/assets/css/instant-results.css @@ -1,3 +1,4 @@ +@import "./global/colors.css"; @import "instant-results/utilities.css"; @import "instant-results/checkbox.css"; @import "instant-results/input.css"; @@ -17,8 +18,6 @@ @import "instant-results/toolbar.css"; :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; diff --git a/assets/css/instant-results/modal.css b/assets/css/instant-results/modal.css index 081dfffc0a..f66631ae7d 100644 --- a/assets/css/instant-results/modal.css +++ b/assets/css/instant-results/modal.css @@ -13,19 +13,6 @@ top: 0; z-index: 9999; - @nest .rtl & { - direction: rtl; - text-align: right; - } - - @nest .admin-bar & { - top: 32px; - - @media ( max-width: 782px ) { - top: 46px; - } - } - &[aria-hidden="true"] { display: none; } @@ -35,8 +22,25 @@ } } +.rtl .ep-search-modal { + direction: rtl; + text-align: right; +} + +.admin-bar .ep-search-modal { + top: 32px; +} + +@media ( max-width: 782px ) { + + .admin-bar .ep-search-modal { + top: 46px; + } +} + + .ep-search-modal__content { - background-color: var(--ep-search-background-color); + background-color: var(--ep-c-white); bottom: 0; display: flex; flex-direction: column; diff --git a/assets/css/instant-results/pagination.css b/assets/css/instant-results/pagination.css index c0eb1b2bfa..3d69e61e13 100644 --- a/assets/css/instant-results/pagination.css +++ b/assets/css/instant-results/pagination.css @@ -4,10 +4,10 @@ grid-template-columns: 1fr 1fr 1fr; margin-top: auto; text-align: center; +} - @nest .rtl & { - direction: rtl; - } +.rtl .ep-search-pagination { + direction: rtl; } .ep-search-pagination__next { diff --git a/assets/css/instant-results/panel.css b/assets/css/instant-results/panel.css index cfa0620f19..32d5cfa82d 100644 --- a/assets/css/instant-results/panel.css +++ b/assets/css/instant-results/panel.css @@ -2,10 +2,10 @@ border: 1px solid var(--ep-search-border-color); margin: 0; padding: 0; +} - @nest .ep-search-panel + & { - border-top-width: 0; - } +.ep-search-panel + .ep-search-panel { + border-top-width: 0; } .ep-search-panel__heading { diff --git a/assets/css/instant-results/range-slider.css b/assets/css/instant-results/range-slider.css index 521fa79c96..cdc09d95c1 100644 --- a/assets/css/instant-results/range-slider.css +++ b/assets/css/instant-results/range-slider.css @@ -6,7 +6,7 @@ } .ep-search-range-slider__track { - background: var(--ep-search-alternate-background-color); + background: var(--ep-c-medium-white); border-radius: calc(var(--ep-search-range-track-size) / 2); height: var(--ep-search-range-track-size); } @@ -20,7 +20,7 @@ border-radius: calc(var(--ep-search-range-thumb-size) / 2); 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); + inset 0 0 0 calc((var(--ep-search-range-thumb-size) - var(--ep-search-range-track-size)) / 2) var(--ep-c-white); height: var(--ep-search-range-thumb-size); width: var(--ep-search-range-thumb-size); } diff --git a/assets/css/instant-results/result.css b/assets/css/instant-results/result.css index 333769be1a..d0081747a8 100644 --- a/assets/css/instant-results/result.css +++ b/assets/css/instant-results/result.css @@ -61,7 +61,7 @@ } .ep-search-result__type { - background-color: var(--ep-search-alternate-background-color); + background-color: var(--ep-c-medium-white); border-radius: 0.25em; display: inline-block; font-size: 0.875em; diff --git a/assets/css/instant-results/sort.css b/assets/css/instant-results/sort.css index be9e085b4c..264fd13385 100644 --- a/assets/css/instant-results/sort.css +++ b/assets/css/instant-results/sort.css @@ -2,23 +2,26 @@ flex-shrink: 0; gap: 0.5em; margin: 0; +} - @nest .ep-search-results & { - display: none; +.ep-search-sidebar .ep-search-sort { + display: flex; + flex-direction: column; + margin-bottom: 1em; +} - @media ( min-width: 768px ) { - align-items: center; - display: flex; - } - } +.ep-search-results .ep-search-sort { + display: none; +} + +@media ( min-width: 768px ) { - @nest .ep-search-sidebar & { + .ep-search-results .ep-search-sort { + align-items: center; display: flex; - flex-direction: column; - margin-bottom: 1em; + } - @media ( min-width: 768px ) { - display: none; - } + .ep-search-sidebar .ep-search-sort { + display: none; } } diff --git a/assets/css/instant-results/tokens.css b/assets/css/instant-results/tokens.css index a09d20f17a..8237f5b6b1 100644 --- a/assets/css/instant-results/tokens.css +++ b/assets/css/instant-results/tokens.css @@ -1,6 +1,3 @@ -.ep-search-tokens { - - @nest .ep-search-toolbar & { - display: contents; - } +.ep-search-toolbar .ep-search-tokens { + display: contents; } diff --git a/assets/css/ordering.css b/assets/css/ordering.css index db0814af3a..f6c3b7ccf5 100644 --- a/assets/css/ordering.css +++ b/assets/css/ordering.css @@ -1,9 +1,11 @@ +@import "./global/colors.css"; + #ep-ordering { border-left-width: 0; border-right-width: 0; & .inside { - background-color: #f1f1f1; + background-color: var(--ep-c-white); margin: 0; padding: 0; } @@ -11,13 +13,13 @@ & .pointers, & .pointer-search, & .loading { - background-color: #fff; - border-left: 1px solid #eee; - border-right: 1px solid #eee; + background-color: var(--ep-c-white); + border-left: 1px solid var(--ep-c-medium-white); + border-right: 1px solid var(--ep-c-medium-white); } & .new-post { - background: #fff; + background: var(--ep-c-white); padding: 0 1em; } @@ -32,9 +34,9 @@ } & .pointer-type { - border: 2px solid #0073aa; + border: 2px solid var(--ep-c-medium-dark-blue); border-radius: 2px; - color: #0073aa; + color: var(--ep-c-medium-dark-blue); display: inline-block; font-size: 0.75em; font-weight: 700; @@ -49,16 +51,16 @@ padding: 1em; &:nth-child(odd) { - background-color: #f9f9f9; + background-color: var(--ep-c-white); } } & .title { - color: #0073aa; + color: var(--ep-c-medium-dark-blue); } & .removed .title { - color: #999; + color: var(--ep-c-light-gray); } & .pointer-actions { @@ -74,15 +76,15 @@ } & .next-page-notice { - background-color: #fdeeca; + background-color: var(--ep-c-white-yellow); padding: 1em 0; text-align: center; } } & .legend { - background: #fff; - border-bottom: 1px solid #eee; + background: var(--ep-c-white); + border-bottom: 1px solid var(--ep-c-medium-white); padding: 1em 0; text-align: center; } @@ -102,8 +104,8 @@ } & .section-title { - border-bottom: 1px solid #eee; - border-top: 1px solid #eee; + border-bottom: 1px solid var(--ep-c-medium-white); + border-top: 1px solid var(--ep-c-medium-white); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04); font-weight: 700; } @@ -135,7 +137,7 @@ } &:hover { - background-color: #f9f9f9; + background-color: var(--ep-c-white); } } } diff --git a/assets/css/woocommerce/admin/components/combobox.css b/assets/css/woocommerce/admin/components/combobox.css index fc3cbdd639..39bd1d7f7e 100644 --- a/assets/css/woocommerce/admin/components/combobox.css +++ b/assets/css/woocommerce/admin/components/combobox.css @@ -1,7 +1,5 @@ :root { - --ep-combobox-list-background: #fff; --ep-combobox-list-background-selected: #f5f5f5; - --ep-combobox-list-border: #8c8f94; } .ep-combobox { @@ -9,8 +7,8 @@ } .ep-combobox__list { - background-color: var(--ep-combobox-list-background); - border: 1px solid var(--ep-combobox-list-border); + background-color: var(--ep-c-white); + border: 1px solid var(--ep-c-light-gray); border-radius: 4px; box-shadow: 0 2px 6px rgb(0 0 0 / 5%); box-sizing: border-box; @@ -23,9 +21,10 @@ width: 100%; z-index: 1; - @nest .ep-combobox__input[aria-expanded="true"] ~ & { - display: block; - } +} + +.ep-combobox__input[aria-expanded="true"] ~ .ep-combobox__list { + display: block; } .ep-combobox__option { diff --git a/assets/css/woocommerce/admin/components/suggestion.css b/assets/css/woocommerce/admin/components/suggestion.css index bcf2ed9fc8..4700ba4dcf 100644 --- a/assets/css/woocommerce/admin/components/suggestion.css +++ b/assets/css/woocommerce/admin/components/suggestion.css @@ -10,10 +10,10 @@ display: block; font-size: small; font-weight: 600; +} - @nest [aria-selected="true"] & { - color: var(--wp-admin-theme-color); - } +[aria-selected="true"] .ep-suggestion__title { + color: var(--wp-admin-theme-color); } .ep-suggestion__footer { diff --git a/assets/css/woocommerce/admin/orders.css b/assets/css/woocommerce/admin/orders.css index 7e96809cd2..0493062a4a 100644 --- a/assets/css/woocommerce/admin/orders.css +++ b/assets/css/woocommerce/admin/orders.css @@ -1,3 +1,4 @@ +@import "../../global/colors.css"; @import "components/combobox.css"; @import "components/suggestion.css"; diff --git a/assets/js/api-search/src/utilities.js b/assets/js/api-search/src/utilities.js index 60b315b994..587020e4ff 100644 --- a/assets/js/api-search/src/utilities.js +++ b/assets/js/api-search/src/utilities.js @@ -135,9 +135,9 @@ export const getUrlParamsFromArgs = (args, schema, prefix = '') => { * @property {any} [default] Default arg value. * @property {Array} [allowedValues] Array of allowed values. * - * @param {Object} argsSchema Schema to build args from. + * @param {{[key: string]: ArgSchema}} argsSchema Schema to build args from. * @param {string} [paramPrefix] Parameter prefix. - * @returns {Object} Query args. + * @returns {{[key: string]: any}} Query args. */ export const getArgsFromUrlParams = (argsSchema, paramPrefix = '') => { const urlParams = new URLSearchParams(window.location.search); @@ -159,8 +159,8 @@ export const getArgsFromUrlParams = (argsSchema, paramPrefix = '') => { /** * Build request args from defaults provided in a given schema. * - * @param {Object} argsSchema Schema to build args from. - * @returns {Object} Query args. + * @param {{[key: string]: ArgSchema}} argsSchema Schema to build args from. + * @returns {{[key: string]: any}} Query args. */ export const getDefaultArgsFromSchema = (argsSchema) => { return Object.entries(argsSchema).reduce((args, [arg, schema]) => { diff --git a/assets/js/sync-ui/css/advanced-control.css b/assets/js/sync-ui/css/advanced-control.css index 4757c3abf9..bb89b51438 100644 --- a/assets/js/sync-ui/css/advanced-control.css +++ b/assets/js/sync-ui/css/advanced-control.css @@ -1,10 +1,6 @@ .ep-sync-advanced-control { margin-bottom: 24px; - @nest fieldset& { - margin-bottom: 16px; - } - &.components-flex .components-flex-item { flex-grow: 2; } @@ -14,6 +10,10 @@ } } +fieldset.ep-sync-advanced-control { + margin-bottom: 16px; +} + .ep-sync-advanced-control__label { display: inline-block; font-size: 11px; diff --git a/assets/js/sync-ui/css/progress-bar.css b/assets/js/sync-ui/css/progress-bar.css index cd30f368ff..9e3431d1a9 100644 --- a/assets/js/sync-ui/css/progress-bar.css +++ b/assets/js/sync-ui/css/progress-bar.css @@ -17,16 +17,16 @@ padding: 0 8px; transition: all 500ms ease-in-out; white-space: nowrap; +} - @nest .ep-sync-progress-bar--complete & { - background: var(--ep-sync-color-success); - } +.ep-sync-progress-bar--complete .ep-sync-progress-bar__progress { + background: var(--ep-sync-color-success); +} - @nest .ep-sync-progress-bar--paused & { - opacity: 0.5; - } +.ep-sync-progress-bar--paused .ep-sync-progress-bar__progress { + opacity: 0.5; +} - @nest .ep-sync-progress-bar--failed & { - background: var(--ep-sync-color-error); - } +.ep-sync-progress-bar--failed .ep-sync-progress-bar__progress { + background: var(--ep-sync-color-error); } diff --git a/assets/js/synonyms/css/list-table.css b/assets/js/synonyms/css/list-table.css index e9af067b42..f5f344499d 100644 --- a/assets/js/synonyms/css/list-table.css +++ b/assets/js/synonyms/css/list-table.css @@ -46,10 +46,10 @@ .ep-synonyms-list-table__primary-column { width: 25%; +} - @nest .ep-synonyms-list-table--replacements & { - width: auto; - } +.ep-synonyms-list-table--replacements .ep-synonyms-list-table__primary-column { + width: auto; } .ep-synonyms-list-table__actions-column { diff --git a/includes/classes/AdminNotices.php b/includes/classes/AdminNotices.php index 352f0badaa..a735f539a8 100644 --- a/includes/classes/AdminNotices.php +++ b/includes/classes/AdminNotices.php @@ -831,7 +831,19 @@ public function get_notices() { * @param {array} $notices Admin notices * @return {array} New notices */ - return apply_filters( 'ep_admin_notices', $this->notices ); + $notices = apply_filters( 'ep_admin_notices', $this->notices ); + + // If the plugin is network-activated and not in the network admin, return the notices whose scope is site. + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK && ! is_network_admin() ) { + $notices = array_filter( + $notices, + function ( $notice ) { + return isset( $notice['scope'] ) && 'site' === $notice['scope']; + } + ); + } + + return $notices; } /** diff --git a/includes/classes/Command.php b/includes/classes/Command.php index 0ae7e9bcd8..873de8c194 100644 --- a/includes/classes/Command.php +++ b/includes/classes/Command.php @@ -1114,14 +1114,13 @@ private function maybe_change_host( $assoc_args ) { if ( isset( $assoc_args['ep-host'] ) ) { add_filter( 'ep_host', - function ( $host ) use ( $assoc_args ) { + function () use ( $assoc_args ) { return $assoc_args['ep-host']; } ); } } - /** * maybe change index prefix on the fly * @@ -1133,7 +1132,7 @@ private function maybe_change_index_prefix( $assoc_args ) { if ( isset( $assoc_args['ep-prefix'] ) ) { add_filter( 'ep_index_prefix', - function ( $prefix ) use ( $assoc_args ) { + function ( $prefix ) use ( $assoc_args ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found return $assoc_args['ep-prefix']; } ); diff --git a/includes/classes/Feature.php b/includes/classes/Feature.php index 43295b5b40..dfd2082918 100644 --- a/includes/classes/Feature.php +++ b/includes/classes/Feature.php @@ -622,4 +622,13 @@ protected function set_settings_schema() { ]; } } + + /** + * Sets the i18n strings for the feature. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + } } diff --git a/includes/classes/Feature/Autosuggest/Autosuggest.php b/includes/classes/Feature/Autosuggest/Autosuggest.php index b811965b12..85445c3d18 100644 --- a/includes/classes/Feature/Autosuggest/Autosuggest.php +++ b/includes/classes/Feature/Autosuggest/Autosuggest.php @@ -40,14 +40,6 @@ class Autosuggest extends Feature { public function __construct() { $this->slug = 'autosuggest'; - $this->title = esc_html__( 'Autosuggest', 'elasticpress' ); - - $this->short_title = esc_html__( 'Autosuggest', 'elasticpress' ); - - $this->summary = '

' . __( 'Input fields of type "search" or with the CSS class "search-field" or "ep-autosuggest" will be enhanced with autosuggest functionality. As text is entered into the search field, suggested content will appear below it, based on top search results for the text. Suggestions link directly to the content.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#autosuggest', 'elasticpress' ); - $this->requires_install_reindex = true; $this->default_settings = [ @@ -63,6 +55,22 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Autosuggest', 'elasticpress' ); + + $this->short_title = esc_html__( 'Autosuggest', 'elasticpress' ); + + $this->summary = '

' . __( 'Input fields of type "search" or with the CSS class "search-field" or "ep-autosuggest" will be enhanced with autosuggest functionality. As text is entered into the search field, suggested content will appear below it, based on top search results for the text. Suggestions link directly to the content.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#autosuggest', 'elasticpress' ); + } + /** * Output feature box long * diff --git a/includes/classes/Feature/Comments/Comments.php b/includes/classes/Feature/Comments/Comments.php index 302c24b489..c8e07cb7e8 100644 --- a/includes/classes/Feature/Comments/Comments.php +++ b/includes/classes/Feature/Comments/Comments.php @@ -36,12 +36,6 @@ class Comments extends Feature { public function __construct() { $this->slug = 'comments'; - $this->title = esc_html__( 'Comments', 'elasticpress' ); - - $this->summary = '

' . __( 'This feature will empower your website to overcome traditional WordPress comment search and query limitations that can present themselves at scale. This feature is only needed if you are using WP_Comment_Query directly.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#comments', 'elasticpress' ); - $this->requires_install_reindex = true; Indexables::factory()->register( new Indexable\Comment\Comment(), false ); @@ -49,6 +43,20 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Comments', 'elasticpress' ); + + $this->summary = '

' . __( 'This feature will empower your website to overcome traditional WordPress comment search and query limitations that can present themselves at scale. This feature is only needed if you are using WP_Comment_Query directly.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#comments', 'elasticpress' ); + } + /** * Setup search functionality * diff --git a/includes/classes/Feature/DidYouMean/DidYouMean.php b/includes/classes/Feature/DidYouMean/DidYouMean.php index 63e60d4e1a..8b28771b5c 100644 --- a/includes/classes/Feature/DidYouMean/DidYouMean.php +++ b/includes/classes/Feature/DidYouMean/DidYouMean.php @@ -21,12 +21,6 @@ class DidYouMean extends Feature { public function __construct() { $this->slug = 'did-you-mean'; - $this->title = esc_html__( 'Did You Mean', 'elasticpress' ); - - $this->summary = '

' . __( '"Did You Mean" search feature provides alternative suggestions for misspelled or ambiguous search queries, enhancing search accuracy and user experience. To display suggestions in your theme, please follow this tutorial.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/did-you-mean/', 'elasticpress' ); - $this->requires_install_reindex = true; $this->available_during_installation = true; @@ -40,6 +34,20 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Did You Mean', 'elasticpress' ); + + $this->summary = '

' . __( '"Did You Mean" search feature provides alternative suggestions for misspelled or ambiguous search queries, enhancing search accuracy and user experience. To display suggestions in your theme, please follow this tutorial.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/did-you-mean/', 'elasticpress' ); + } + /** * Setup search functionality. * diff --git a/includes/classes/Feature/Documents/Documents.php b/includes/classes/Feature/Documents/Documents.php index f70602125c..4785f9444c 100644 --- a/includes/classes/Feature/Documents/Documents.php +++ b/includes/classes/Feature/Documents/Documents.php @@ -25,15 +25,23 @@ class Documents extends Feature { public function __construct() { $this->slug = 'documents'; + $this->requires_install_reindex = false; + + parent::__construct(); + } + + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { $this->title = esc_html__( 'Documents', 'elasticpress' ); $this->summary = '

' . __( 'Website search results will include popular document file types, using file names as well as their content. Supported file types include: ppt, pptx, doc, docx, xls, xlsx, pdf, csv, txt.', 'elasticpress' ) . '

'; $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#documents', 'elasticpress' ); - - $this->requires_install_reindex = false; - - parent::__construct(); } /** diff --git a/includes/classes/Feature/Facets/Facets.php b/includes/classes/Feature/Facets/Facets.php index 72e0868cd5..76e636b485 100644 --- a/includes/classes/Feature/Facets/Facets.php +++ b/includes/classes/Feature/Facets/Facets.php @@ -38,24 +38,6 @@ class Facets extends Feature { public function __construct() { $this->slug = 'facets'; - $this->title = esc_html__( 'Filters', 'elasticpress' ); - - $this->summary = '

' . - ( wp_is_block_theme() - ? sprintf( - /* translators: Site Editor URL */ - __( 'Adds filter blocks that administrators can add to the website’s templates and template parts, so that visitors can filter applicable content and search results by one or more taxonomy terms, metafields, and date ranges.', 'elasticpress' ), - esc_url( admin_url( 'site-editor.php' ) ) - ) - : sprintf( - /* translators: Widgets Edit Screen URL */ - __( 'Adds filter widgets that administrators can add to the website’s sidebars (widgetized areas), so that visitors can filter applicable content and search results by one or more taxonomy terms, metafields, and date ranges.', 'elasticpress' ), - esc_url( admin_url( 'widgets.php' ) ) - ) - ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#filters', 'elasticpress' ); - $this->requires_install_reindex = false; $this->default_settings = [ @@ -103,6 +85,32 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Filters', 'elasticpress' ); + + $this->summary = '

' . + ( wp_is_block_theme() + ? sprintf( + /* translators: Site Editor URL */ + __( 'Adds filter blocks that administrators can add to the website’s templates and template parts, so that visitors can filter applicable content and search results by one or more taxonomy terms, metafields, and date ranges.', 'elasticpress' ), + esc_url( admin_url( 'site-editor.php' ) ) + ) + : sprintf( + /* translators: Widgets Edit Screen URL */ + __( 'Adds filter widgets that administrators can add to the website’s sidebars (widgetized areas), so that visitors can filter applicable content and search results by one or more taxonomy terms, metafields, and date ranges.', 'elasticpress' ), + esc_url( admin_url( 'widgets.php' ) ) + ) + ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#filters', 'elasticpress' ); + } + /** * Setup hooks and filters for feature * diff --git a/includes/classes/Feature/Facets/Renderer.php b/includes/classes/Feature/Facets/Renderer.php index 03fec4ba30..c31c253031 100644 --- a/includes/classes/Feature/Facets/Renderer.php +++ b/includes/classes/Feature/Facets/Renderer.php @@ -72,7 +72,8 @@ protected function order_values( array $values, string $orderby = 'count', $orde * @param string $url URL for the facet item. * @return string|null */ - public function get_facet_item_value_html( $item, string $url ) { + public function get_facet_item_value_html( $item, string $url ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable return null; } } diff --git a/includes/classes/Feature/InstantResults/InstantResults.php b/includes/classes/Feature/InstantResults/InstantResults.php index 4635089e14..de5fbc8bee 100644 --- a/includes/classes/Feature/InstantResults/InstantResults.php +++ b/includes/classes/Feature/InstantResults/InstantResults.php @@ -67,15 +67,6 @@ class InstantResults extends Feature { public function __construct() { $this->slug = 'instant-results'; - $this->title = esc_html__( 'Instant Results', 'elasticpress' ); - - $this->short_title = esc_html__( 'Instant Results', 'elasticpress' ); - - $this->summary = '

' . __( 'WordPress search forms will display results instantly. When the search query is submitted, a modal will open that populates results by querying ElasticPress directly, bypassing WordPress. As the user refines their search, results are refreshed.', 'elasticpress' ) . '

' . - '

' . __( 'Requires an ElasticPress.io plan or a custom proxy to function.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#instant-results', 'elasticpress' ); - $this->host = trailingslashit( Utils\get_host() ); $this->index = Indexables::factory()->get( 'post' )->get_index_name(); @@ -102,6 +93,23 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Instant Results', 'elasticpress' ); + + $this->short_title = esc_html__( 'Instant Results', 'elasticpress' ); + + $this->summary = '

' . __( 'WordPress search forms will display results instantly. When the search query is submitted, a modal will open that populates results by querying ElasticPress directly, bypassing WordPress. As the user refines their search, results are refreshed.', 'elasticpress' ) . '

' . + '

' . __( 'Requires an ElasticPress.io plan or a custom proxy to function.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#instant-results', 'elasticpress' ); + } + /** * Output detailed feature description. * diff --git a/includes/classes/Feature/ProtectedContent/ProtectedContent.php b/includes/classes/Feature/ProtectedContent/ProtectedContent.php index d8c197368a..96e47562fa 100644 --- a/includes/classes/Feature/ProtectedContent/ProtectedContent.php +++ b/includes/classes/Feature/ProtectedContent/ProtectedContent.php @@ -30,13 +30,6 @@ class ProtectedContent extends Feature { public function __construct() { $this->slug = 'protected_content'; - $this->title = esc_html__( 'Protected Content', 'elasticpress' ); - - $this->summary = '

' . __( 'Syncs unpublished content — including private, draft, and scheduled posts — improving load times in places like the administrative dashboard where WordPress needs to include protected content in a query.', 'elasticpress' ) . '

' . - '

' . __( 'We recommend using a secured Elasticsearch setup, such as ElasticPress.io, to prevent potential exposure of content not intended for the public.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#protected-content', 'elasticpress' ); - $this->requires_install_reindex = true; $this->available_during_installation = true; @@ -44,6 +37,21 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Protected Content', 'elasticpress' ); + + $this->summary = '

' . __( 'Syncs unpublished content — including private, draft, and scheduled posts — improving load times in places like the administrative dashboard where WordPress needs to include protected content in a query.', 'elasticpress' ) . '

' . + '

' . __( 'We recommend using a secured Elasticsearch setup, such as ElasticPress.io, to prevent potential exposure of content not intended for the public.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#protected-content', 'elasticpress' ); + } + /** * Setup all feature filters * diff --git a/includes/classes/Feature/RelatedPosts/RelatedPosts.php b/includes/classes/Feature/RelatedPosts/RelatedPosts.php index e3806d95cf..9ed6e8920f 100644 --- a/includes/classes/Feature/RelatedPosts/RelatedPosts.php +++ b/includes/classes/Feature/RelatedPosts/RelatedPosts.php @@ -26,15 +26,23 @@ class RelatedPosts extends Feature { public function __construct() { $this->slug = 'related_posts'; + $this->requires_install_reindex = false; + + parent::__construct(); + } + + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { $this->title = esc_html__( 'Related Posts', 'elasticpress' ); $this->summary = '

' . __( 'Instantly deliver engaging and precise related content with no impact on site performance. Output related content using our block or directly in your theme using our API functions.', 'elasticpress' ) . '

'; $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#related-posts', 'elasticpress' ); - - $this->requires_install_reindex = false; - - parent::__construct(); } /** @@ -114,14 +122,14 @@ public function formatted_args( $formatted_args, $args ) { * Search Elasticsearch for related content * * @param int $post_id Post ID - * @param int $return Return code + * @param int $post_return Number of posts to return * @since 4.1.0 * @return WP_Query */ - public function get_related_query( $post_id, $return = 5 ) { + public function get_related_query( $post_id, $post_return = 5 ) { $args = array( 'more_like' => $post_id, - 'posts_per_page' => $return, + 'posts_per_page' => $post_return, 'ep_integrate' => true, 'ignore_sticky_posts' => true, ); @@ -141,15 +149,15 @@ public function get_related_query( $post_id, $return = 5 ) { * Search Elasticsearch for related content * * @param int $post_id Post ID - * @param int $return Return code + * @param int $post_return Number of posts to return * * @since 2.1 * @uses get_related_query * * @return array|bool */ - public function find_related( $post_id, $return = 5 ) { - $query = $this->get_related_query( $post_id, $return ); + public function find_related( $post_id, $post_return = 5 ) { + $query = $this->get_related_query( $post_id, $post_return ); if ( ! $query->have_posts() ) { return false; diff --git a/includes/classes/Feature/Search/Search.php b/includes/classes/Feature/Search/Search.php index 9bdf44cd47..9bcc1711d9 100644 --- a/includes/classes/Feature/Search/Search.php +++ b/includes/classes/Feature/Search/Search.php @@ -52,13 +52,6 @@ class Search extends Feature { public function __construct() { $this->slug = 'search'; - $this->title = esc_html__( 'Post Search', 'elasticpress' ); - - $this->summary = '

' . __( 'Instantly find the content you’re looking for. The first time.', 'elasticpress' ) . '

' . - '

' . __( 'Overcome higher-end performance and functional limits posed by the traditional WordPress structured (SQL) database to deliver superior keyword search, instantly. ElasticPress indexes custom fields, tags, and other metadata to improve search results. Fuzzy matching accounts for misspellings and verb tenses.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#post-search', 'elasticpress' ); - $this->requires_install_reindex = false; $this->default_settings = [ @@ -74,6 +67,21 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Post Search', 'elasticpress' ); + + $this->summary = '

' . __( 'Instantly find the content you’re looking for. The first time.', 'elasticpress' ) . '

' . + '

' . __( 'Overcome higher-end performance and functional limits posed by the traditional WordPress structured (SQL) database to deliver superior keyword search, instantly. ElasticPress indexes custom fields, tags, and other metadata to improve search results. Fuzzy matching accounts for misspellings and verb tenses.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#post-search', 'elasticpress' ); + } + /** * We need to delay search setup up since it will fire after protected content and protected * content filters into the search setup @@ -81,6 +89,8 @@ public function __construct() { * @since 2.2 */ public function setup() { + Indexables::factory()->activate( 'post' ); + add_action( 'init', [ $this, 'search_setup' ] ); add_filter( 'ep_sanitize_feature_settings', [ $this, 'sanitize_highlighting_settings' ] ); diff --git a/includes/classes/Feature/Search/Weighting.php b/includes/classes/Feature/Search/Weighting.php index f7d582b9fc..2b34e62053 100644 --- a/includes/classes/Feature/Search/Weighting.php +++ b/includes/classes/Feature/Search/Weighting.php @@ -351,9 +351,10 @@ public function render_settings_page() { * @param string $post_type Current post type we're rendering * @param array $field Current field to render * @param array $current_values Current stored weighting values + * * @deprecated */ - public function render_settings_section( $post_type, $field, $current_values ) { + public function render_settings_section( $post_type, $field, $current_values ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed _doing_it_wrong( __METHOD__, esc_html( 'Weighting sections display are now handled via React components.' ), @@ -381,7 +382,7 @@ public function handle_save() { * @param string $redirect_url Redirect URL. * @deprecated */ - protected function redirect( $redirect_url ) { + protected function redirect( $redirect_url ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed,Generic.CodeAnalysis.UnusedFunctionParameter.Found _doing_it_wrong( __METHOD__, esc_html( 'Weighting settings are now updated using the REST API, and do not redirect server-side.' ), @@ -397,7 +398,7 @@ protected function redirect( $redirect_url ) { * @since 3.4.1 * @deprecated */ - public function save_weighting_configuration( $settings ) { + public function save_weighting_configuration( $settings ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed,Generic.CodeAnalysis.UnusedFunctionParameter.Found _doing_it_wrong( __METHOD__, esc_html( 'Weighting sections display are now handled via React components.' ), diff --git a/includes/classes/Feature/SearchOrdering/SearchOrdering.php b/includes/classes/Feature/SearchOrdering/SearchOrdering.php index 3dde596494..41d2b14007 100644 --- a/includes/classes/Feature/SearchOrdering/SearchOrdering.php +++ b/includes/classes/Feature/SearchOrdering/SearchOrdering.php @@ -52,12 +52,6 @@ class SearchOrdering extends Feature { public function __construct() { $this->slug = 'searchordering'; - $this->title = esc_html__( 'Custom Search Results', 'elasticpress' ); - - $this->summary = '

' . __( 'Selected posts will be inserted into search results in the specified position.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#custom-search-results', 'elasticpress' ); - $this->requires_install_reindex = false; $this->requires_feature = 'search'; @@ -65,6 +59,20 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Custom Search Results', 'elasticpress' ); + + $this->summary = '

' . __( 'Selected posts will be inserted into search results in the specified position.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#custom-search-results', 'elasticpress' ); + } + /** * Setup Feature Functionality */ diff --git a/includes/classes/Feature/Terms/Terms.php b/includes/classes/Feature/Terms/Terms.php index f81998885a..fde8661560 100644 --- a/includes/classes/Feature/Terms/Terms.php +++ b/includes/classes/Feature/Terms/Terms.php @@ -33,12 +33,6 @@ class Terms extends Feature { public function __construct() { $this->slug = 'terms'; - $this->title = esc_html__( 'Terms', 'elasticpress' ); - - $this->summary = '

' . __( 'This feature will empower your website to overcome traditional WordPress term search and query limitations that can present themselves at scale. This feature is only needed if you are using WP_Term_Query directly.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#terms', 'elasticpress' ); - $this->requires_install_reindex = true; Indexables::factory()->register( new Indexable\Term\Term(), false ); @@ -46,6 +40,20 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Terms', 'elasticpress' ); + + $this->summary = '

' . __( 'This feature will empower your website to overcome traditional WordPress term search and query limitations that can present themselves at scale. This feature is only needed if you are using WP_Term_Query directly.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#terms', 'elasticpress' ); + } + /** * Setup search functionality * diff --git a/includes/classes/Feature/WooCommerce/OrdersAutosuggest.php b/includes/classes/Feature/WooCommerce/OrdersAutosuggest.php index ef2c9036a4..f38ca3f9dc 100644 --- a/includes/classes/Feature/WooCommerce/OrdersAutosuggest.php +++ b/includes/classes/Feature/WooCommerce/OrdersAutosuggest.php @@ -312,7 +312,7 @@ public function get_search_template() { add_filter( 'ep_bypass_exclusion_from_search', '__return_true', 10 ); add_filter( 'ep_intercept_remote_request', '__return_true' ); - add_filter( 'ep_do_intercept_request', [ $this, 'intercept_search_request' ], 10, 4 ); + add_filter( 'ep_do_intercept_request', [ $this, 'intercept_search_request' ], 10, 3 ); add_filter( 'ep_is_integrated_request', [ $this, 'is_integrated_request' ], 10, 2 ); $query = new \WP_Query( @@ -363,10 +363,9 @@ public function is_integrated_request( $is_integrated, $context ) { * @param object $response Response * @param array $query Query * @param array $args WP_Query argument array - * @param int $failures Count of failures in request loop * @return object $response Response */ - public function intercept_search_request( $response, $query = [], $args = [], $failures = 0 ) { + public function intercept_search_request( $response, $query = [], $args = [] ) { $this->search_template = $query['args']['body']; return wp_remote_request( $query['url'], $args ); diff --git a/includes/classes/Feature/WooCommerce/WooCommerce.php b/includes/classes/Feature/WooCommerce/WooCommerce.php index 689840c61e..b87ed6663c 100644 --- a/includes/classes/Feature/WooCommerce/WooCommerce.php +++ b/includes/classes/Feature/WooCommerce/WooCommerce.php @@ -54,12 +54,6 @@ class WooCommerce extends Feature { public function __construct() { $this->slug = 'woocommerce'; - $this->title = esc_html__( 'WooCommerce', 'elasticpress' ); - - $this->summary = '

' . __( 'Most caching and performance tools can’t keep up with the nearly infinite ways your visitors might filter or navigate your products. No matter how many products, filters, or customers you have, ElasticPress will keep your online store performing quickly. If used in combination with the Protected Content feature, ElasticPress will also accelerate order searches and back end product management.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#woocommerce', 'elasticpress' ); - $this->requires_install_reindex = true; $this->setting_requires_install_reindex = 'orders'; @@ -77,6 +71,20 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'WooCommerce', 'elasticpress' ); + + $this->summary = '

' . __( 'Most caching and performance tools can’t keep up with the nearly infinite ways your visitors might filter or navigate your products. No matter how many products, filters, or customers you have, ElasticPress will keep your online store performing quickly. If used in combination with the Protected Content feature, ElasticPress will also accelerate order searches and back end product management.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#woocommerce', 'elasticpress' ); + } + /** * Setup all feature filters * diff --git a/includes/classes/Features.php b/includes/classes/Features.php index c0231bb603..103100719d 100644 --- a/includes/classes/Features.php +++ b/includes/classes/Features.php @@ -330,6 +330,8 @@ public function setup_features() { do_action( 'ep_setup_features' ); foreach ( $this->registered_features as $feature_slug => $feature ) { + $feature->set_i18n_strings(); + if ( $feature->is_active() ) { $feature->setup(); } diff --git a/includes/classes/IndexHelper.php b/includes/classes/IndexHelper.php index ffc761b582..143dee551e 100644 --- a/includes/classes/IndexHelper.php +++ b/includes/classes/IndexHelper.php @@ -1168,21 +1168,21 @@ public function get_last_sync(): array { * We used to have two different filters for this (one for the dashboard, another for CLI), * this method combines both. * - * @param {stdClass} $object Object to be checked + * @param {stdClass} $indexable_object Object to be checked * @param {Indexable} $indexable Indexable * @return boolean */ - protected function should_skip_object_index( $object, $indexable ) { + protected function should_skip_object_index( $indexable_object, $indexable ) { /** * Filter whether to not sync specific item in dashboard or not * * @since 2.1 * @hook ep_item_sync_kill * @param {boolean} $kill False means dont sync - * @param {array} $object Object to sync + * @param {array} $indexable_object Object to sync * @return {Indexable} Indexable that object belongs to */ - $ep_item_sync_kill = apply_filters( 'ep_item_sync_kill', false, $object, $indexable ); + $ep_item_sync_kill = apply_filters( 'ep_item_sync_kill', false, $indexable_object, $indexable ); /** * Conditionally kill indexing for a post @@ -1192,7 +1192,7 @@ protected function should_skip_object_index( $object, $indexable ) { * @param {int} $object_id Object ID * @return {bool} New value */ - $ep_indexable_sync_kill = apply_filters( 'ep_' . $indexable->slug . '_index_kill', false, $object->ID ); + $ep_indexable_sync_kill = apply_filters( 'ep_' . $indexable->slug . '_index_kill', false, $indexable_object->ID ); return $ep_item_sync_kill || $ep_indexable_sync_kill; } diff --git a/includes/classes/Indexable.php b/includes/classes/Indexable.php index 75b9f318c5..a76561c906 100644 --- a/includes/classes/Indexable.php +++ b/includes/classes/Indexable.php @@ -76,7 +76,10 @@ abstract class Indexable { * @since 4.5.0 * @var array */ - public $labels = []; + public $labels = [ + 'plural' => '', + 'singular' => '', + ]; /** * Get number of bulk items to index per page diff --git a/includes/classes/Indexable/Comment/Comment.php b/includes/classes/Indexable/Comment/Comment.php index 49ad4082ad..08082cd4f6 100644 --- a/includes/classes/Indexable/Comment/Comment.php +++ b/includes/classes/Indexable/Comment/Comment.php @@ -33,24 +33,17 @@ class Comment extends Indexable { public $slug = 'comment'; /** - * Create indexable and initialize dependencies + * Instantiate the indexable SyncManager and QueryIntegration, the main responsibles for the WP integration. * - * @since 3.6.0 + * @since 4.5.0 + * @return void */ - public function __construct() { + public function setup() { $this->labels = [ 'plural' => esc_html__( 'Comments', 'elasticpress' ), 'singular' => esc_html__( 'Comment', 'elasticpress' ), ]; - } - /** - * Instantiate the indexable SyncManager and QueryIntegration, the main responsibles for the WP integration. - * - * @since 4.5.0 - * @return void - */ - public function setup() { $this->sync_manager = new SyncManager( $this->slug ); $this->query_integration = new QueryIntegration(); } diff --git a/includes/classes/Indexable/Post/Post.php b/includes/classes/Indexable/Post/Post.php index f3ff530de4..c02201fd13 100644 --- a/includes/classes/Indexable/Post/Post.php +++ b/includes/classes/Indexable/Post/Post.php @@ -42,11 +42,12 @@ class Post extends Indexable { public $support_indexing_advanced_pagination = true; /** - * Create indexable and initialize dependencies + * Instantiate the indexable SyncManager and QueryIntegration * - * @since 3.0 + * @since 5.2.0 + * @return void */ - public function __construct() { + public function setup() { $this->labels = [ 'plural' => esc_html__( 'Posts', 'elasticpress' ), 'singular' => esc_html__( 'Post', 'elasticpress' ), diff --git a/includes/classes/Indexable/Post/QueryIntegration.php b/includes/classes/Indexable/Post/QueryIntegration.php index 06d78c9781..846bb8187e 100644 --- a/includes/classes/Indexable/Post/QueryIntegration.php +++ b/includes/classes/Indexable/Post/QueryIntegration.php @@ -64,7 +64,7 @@ public function __construct( $indexable_slug = 'post' ) { add_filter( 'posts_pre_query', array( $this, 'get_es_posts' ), 10, 2 ); // Properly restore blog if necessary - add_action( 'loop_end', array( $this, 'maybe_restore_blog' ), 10, 1 ); + add_action( 'loop_end', array( $this, 'maybe_restore_blog' ), 10 ); // Properly switch to blog if necessary add_action( 'the_post', array( $this, 'maybe_switch_to_blog' ), 10, 2 ); @@ -194,10 +194,11 @@ public function maybe_switch_to_blog( $post, $query = null ) { /** * Make sure the correct blog is restored * - * @param WP_Query $query WP_Query instance + * @param WP_Query $query WP_Query instance + * * @since 0.9 */ - public function maybe_restore_blog( $query ) { + public function maybe_restore_blog( $query ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found if ( ! is_multisite() ) { // @codeCoverageIgnoreStart return; diff --git a/includes/classes/Indexable/Post/SyncManager.php b/includes/classes/Indexable/Post/SyncManager.php index f5b1591f41..7ad9968581 100644 --- a/includes/classes/Indexable/Post/SyncManager.php +++ b/includes/classes/Indexable/Post/SyncManager.php @@ -421,6 +421,7 @@ public function maybe_display_notice_edit_single_term( $notices ) { ), 'type' => 'warning', 'dismiss' => true, + 'scope' => 'site', ]; break; } @@ -436,6 +437,7 @@ public function maybe_display_notice_edit_single_term( $notices ) { ), 'type' => 'warning', 'dismiss' => true, + 'scope' => 'site', ]; return $notices; @@ -470,6 +472,7 @@ public function maybe_display_notice_term_list_screen( $notices ) { ), 'type' => 'warning', 'dismiss' => true, + 'scope' => 'site', ]; return $notices; diff --git a/includes/classes/Indexable/Term/Term.php b/includes/classes/Indexable/Term/Term.php index 0f67fa0b1a..bb2d35545f 100644 --- a/includes/classes/Indexable/Term/Term.php +++ b/includes/classes/Indexable/Term/Term.php @@ -32,24 +32,17 @@ class Term extends Indexable { public $slug = 'term'; /** - * Create indexable and initialize dependencies + * Instantiate the indexable SyncManager and QueryIntegration, the main responsibles for the WP integration. * - * @since 3.1 + * @since 4.5.0 + * @return void */ - public function __construct() { + public function setup() { $this->labels = [ 'plural' => esc_html__( 'Terms', 'elasticpress' ), 'singular' => esc_html__( 'Term', 'elasticpress' ), ]; - } - /** - * Instantiate the indexable SyncManager and QueryIntegration, the main responsibles for the WP integration. - * - * @since 4.5.0 - * @return void - */ - public function setup() { $this->sync_manager = new SyncManager( $this->slug ); $this->query_integration = new QueryIntegration( $this->slug ); } diff --git a/includes/classes/Indexables.php b/includes/classes/Indexables.php index a2011c616a..c405f1edc3 100644 --- a/includes/classes/Indexables.php +++ b/includes/classes/Indexables.php @@ -118,24 +118,24 @@ public function is_active( string $slug ): bool { /** * Get all indexable instances * - * @param boolean $global If true or false, will only get Indexables with that global property. + * @param boolean $global_property If true or false, will only get Indexables with that global property. * @param boolean $slug_only True returns an array of only string slugs. * @param string $status Whether to return active indexables or all registered. * @since 3.0, 4.5.0 Added $status * @return array */ - public function get_all( $global = null, $slug_only = false, $status = 'active' ) { + public function get_all( $global_property = null, $slug_only = false, $status = 'active' ) { $indexables = []; $list = ( 'active' === $status ) ? $this->active_indexables : $this->registered_indexables; foreach ( $list as $slug => $indexable ) { - if ( null === $global ) { + if ( null === $global_property ) { if ( $slug_only ) { $indexables[] = $slug; } else { $indexables[] = $indexable; } - } elseif ( $global === $indexable->global ) { + } elseif ( $global_property === $indexable->global ) { if ( $slug_only ) { $indexables[] = $slug; } else { diff --git a/includes/classes/Installer.php b/includes/classes/Installer.php index c5a54bb4f5..c62235059d 100644 --- a/includes/classes/Installer.php +++ b/includes/classes/Installer.php @@ -33,18 +33,17 @@ class Installer { */ public function setup() { add_action( 'admin_init', [ $this, 'calculate_install_status' ], 9 ); - add_filter( 'admin_title', [ $this, 'filter_admin_title' ], 10, 2 ); + add_filter( 'admin_title', [ $this, 'filter_admin_title' ], 10 ); } /** * Filter admin title for install page * * @param string $admin_title Current title - * @param string $title Original title * @since 3.0 * @return string */ - public function filter_admin_title( $admin_title, $title ) { + public function filter_admin_title( $admin_title ) { if ( 'install' === Screen::factory()->get_current_screen() ) { // translators: Site Name return sprintf( esc_html__( 'ElasticPress Setup ‹ %s — WordPress', 'elasticpress' ), esc_html( get_bloginfo( 'name' ) ) ); diff --git a/includes/classes/REST/MetaKeys.php b/includes/classes/REST/MetaKeys.php index ae75cd595a..f7c8d56f40 100644 --- a/includes/classes/REST/MetaKeys.php +++ b/includes/classes/REST/MetaKeys.php @@ -50,10 +50,9 @@ public function check_permission() { /** * Get indexed meta keys. * - * @param \WP_REST_Request $request Full details about the request. * @return array */ - public function get_meta_keys( \WP_REST_Request $request ) { + public function get_meta_keys() { $post_indexable = Indexables::factory()->get( 'post' ); try { diff --git a/includes/classes/REST/Sync.php b/includes/classes/REST/Sync.php index 41280bdddc..7c16fe0fbe 100644 --- a/includes/classes/REST/Sync.php +++ b/includes/classes/REST/Sync.php @@ -177,10 +177,9 @@ public function output( array $message ) { /** * Get the status of a sync in progress. * - * @param \WP_REST_Request $request Full details about the request. * @return void */ - public function get_sync_status( \WP_REST_Request $request ) { + public function get_sync_status() { nocache_headers(); $index_meta = Utils\get_indexing_status(); @@ -211,10 +210,9 @@ public function get_sync_status( \WP_REST_Request $request ) { /** * Cancel a sync in progress. * - * @param \WP_REST_Request $request Full details about the request. * @return void */ - public function cancel_sync( \WP_REST_Request $request ) { + public function cancel_sync() { nocache_headers(); $index_meta = Utils\get_indexing_status(); diff --git a/includes/classes/REST/Taxonomies.php b/includes/classes/REST/Taxonomies.php index 582cccb333..92caf0af73 100644 --- a/includes/classes/REST/Taxonomies.php +++ b/includes/classes/REST/Taxonomies.php @@ -49,10 +49,9 @@ public function check_permission() { /** * Get filterable taxonomies. * - * @param \WP_REST_Request $request Full details about the request. * @return array */ - public function get_taxonomies( \WP_REST_Request $request ) { + public function get_taxonomies() { $filterable_taxonomies = Features::factory()->get_registered_feature( 'facets' )->types['taxonomy']->get_facetable_taxonomies(); $taxonomies = []; diff --git a/includes/classes/REST/Token.php b/includes/classes/REST/Token.php index a999de8de6..3afe88bf73 100644 --- a/includes/classes/REST/Token.php +++ b/includes/classes/REST/Token.php @@ -81,10 +81,9 @@ public function get_token( \WP_REST_Request $request ) { /** * Refresh the temporary token. * - * @param \WP_REST_Request $request Full details about the request. * @return string|false */ - public function refresh_token( \WP_REST_Request $request ) { + public function refresh_token() { $user_id = get_current_user_id(); $endpoint = $this->get_token_endpoint(); diff --git a/includes/compat.php b/includes/compat.php index 173db48b06..4fa0ce9437 100644 --- a/includes/compat.php +++ b/includes/compat.php @@ -51,16 +51,16 @@ public function __construct( $code, $message = null ) { * Search Elasticsearch for related content * * @param int $post_id Post ID - * @param int $return Number of posts to get + * @param int $post_return Number of posts to get * @since 2.1 * @return array|bool */ -function ep_find_related( $post_id, $return = 5 ) { +function ep_find_related( $post_id, $post_return = 5 ) { _deprecated_function( __FUNCTION__, '3.0', 'ElasticPress\Features::factory()->get_registered_feature' ); $feature = \ElasticPress\Features::factory()->get_registered_feature( 'related_posts' ); - return ( ! empty( $feature ) ) ? $feature->find_related( $post_id, $return ) : false; + return ( ! empty( $feature ) ) ? $feature->find_related( $post_id, $post_return ) : false; } /** diff --git a/includes/dashboard.php b/includes/dashboard.php index f43cf1f99f..47e659d513 100644 --- a/includes/dashboard.php +++ b/includes/dashboard.php @@ -298,13 +298,8 @@ function filter_plugin_action_links( $plugin_actions, $plugin_file ) { * @since 3.0 */ function maybe_notice( $force = false ) { - // Admins only. - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { - if ( ! is_super_admin() || ! is_network_admin() ) { - return false; - } - } elseif ( is_network_admin() || ! current_user_can( Utils\get_capability() ) ) { - return false; + if ( ! current_user_can( Utils\get_capability() ) ) { + return false; } /** diff --git a/tests/cypress/integration/features/woocommerce.cy.js b/tests/cypress/integration/features/woocommerce.cy.js index 184056684c..cf6f81fcd4 100644 --- a/tests/cypress/integration/features/woocommerce.cy.js +++ b/tests/cypress/integration/features/woocommerce.cy.js @@ -146,12 +146,17 @@ describe('WooCommerce Feature', { tags: '@slow' }, () => { // enable payment gateway. cy.visitAdminPage('admin.php?page=wc-settings&tab=checkout§ion=cod'); + // if the checkbox is already checked, uncheck it first to enable the save button. + cy.get('#woocommerce_cod_enabled').uncheck(); cy.get('#woocommerce_cod_enabled').check(); cy.get( `.button-primary.woocommerce-save-button, .components-button.is-primary.woocommerce-save-button`, ).click(); + // disable coming soon option. + cy.wpCli('option update woocommerce_coming_soon off'); + cy.logout(); // create new user. diff --git a/tests/php/TestAdminNotices.php b/tests/php/TestAdminNotices.php index 8d831a195e..654156f2e1 100644 --- a/tests/php/TestAdminNotices.php +++ b/tests/php/TestAdminNotices.php @@ -648,7 +648,6 @@ function ( $values ) { * Tests notice is show when number of posts linked with term is greater than number of items per cycle. */ public function testNumberOfPostsBiggerThanItemPerCycle() { - global $pagenow, $tax; // set global variables. @@ -673,6 +672,98 @@ public function testNumberOfPostsBiggerThanItemPerCycle() { $this->assertArrayHasKey( 'too_many_posts_on_term', $notices ); } + /** + * Tests that the admin notice with the scope 'site' appears only on the sub site when the plugin is network-activated. + * + * @group admin-notices + * @group skip-on-single-site + */ + public function test_notice_with_scope_site_shows_only_on_site() { + global $pagenow, $tax; + + // set global variables. + $pagenow = 'edit-tags.php'; + + set_current_screen( 'edit-tags' ); + $tax = get_taxonomy( 'category' ); + + $number_of_posts = ElasticPress\IndexHelper::factory()->get_index_default_per_page() + 10; + $term = $this->factory->term->create_and_get( array( 'taxonomy' => 'category' ) ); + $this->posts = $this->factory->post->create_many( + $number_of_posts, + [ + 'tax_input' => [ + 'category' => [ + $term->term_id, + ], + ], + ] + ); + + add_action( + 'ep_admin_notices', + function ( $notices ) { + $notices['test_notice'] = [ + 'type' => 'error', + 'dismiss' => true, + 'html' => 'Test notice', + ]; + + return $notices; + } + ); + + $notices = ElasticPress\AdminNotices::factory()->get_notices(); + $this->assertCount( 1, $notices ); + $this->assertArrayHasKey( 'too_many_posts_on_term', $notices ); + } + + /** + * Tests that the admin notice with the scope 'site' has no effect when WordPress is not on multisite mode. + * + * @group admin-notices + * @group skip-on-multi-site + */ + public function test_notice_with_scope_site_has_no_effect_on_non_multisite() { + global $pagenow, $tax; + + // set global variables. + $pagenow = 'edit-tags.php'; + + set_current_screen( 'edit-tags' ); + $tax = get_taxonomy( 'category' ); + + $number_of_posts = ElasticPress\IndexHelper::factory()->get_index_default_per_page() + 10; + $term = $this->factory->term->create_and_get( array( 'taxonomy' => 'category' ) ); + $this->posts = $this->factory->post->create_many( + $number_of_posts, + [ + 'tax_input' => [ + 'category' => [ + $term->term_id, + ], + ], + ] + ); + + add_action( + 'ep_admin_notices', + function ( $notices ) { + $notices['test_notice'] = [ + 'type' => 'error', + 'dismiss' => true, + 'html' => 'Test notice', + ]; + + return $notices; + } + ); + + $notices = ElasticPress\AdminNotices::factory()->get_notices(); + $this->assertArrayHasKey( 'too_many_posts_on_term', $notices ); + $this->assertArrayHasKey( 'test_notice', $notices ); + } + /** * Utilitary function to set `ep_post_mapping_version_determined` * as the wanted Mapping version. diff --git a/tests/php/features/TestAutosuggest.php b/tests/php/features/TestAutosuggest.php index 953da07c05..66775d0278 100644 --- a/tests/php/features/TestAutosuggest.php +++ b/tests/php/features/TestAutosuggest.php @@ -68,6 +68,7 @@ protected function get_feature() { */ public function testConstruct() { $instance = new ElasticPress\Feature\Autosuggest\Autosuggest(); + $instance->set_i18n_strings(); $this->assertEquals( 'autosuggest', $instance->slug ); $this->assertEquals( 'Autosuggest', $instance->title ); @@ -346,7 +347,7 @@ public function test_autosuggest_ngram_fields_for_ajax_request() { add_filter( 'ep_query_request_path', - function ( $path, $index, $type, $query, $query_args, $query_object ) { + function ( $path, $index, $type, $query ) { $fields = $query['query']['function_score']['query']['bool']['should'][0]['bool']['must'][0]['bool']['should'][1]['multi_match']['fields']; $this->assertContains( 'term_suggest^1', $fields ); @@ -354,7 +355,7 @@ function ( $path, $index, $type, $query, $query_args, $query_object ) { return $path; }, 10, - 6 + 4 ); $query = new \WP_Query( @@ -398,7 +399,7 @@ public function test_autosuggest_ngram_fields_for_ajax_request_negative() { add_filter( 'ep_query_request_path', - function ( $path, $index, $type, $query, $query_args, $query_object ) { + function ( $path, $index, $type, $query ) { $fields = $query['query']['function_score']['query']['bool']['should'][0]['bool']['must'][0]['bool']['should'][1]['multi_match']['fields']; $this->assertNotContains( 'term_suggest^1', $fields ); @@ -406,7 +407,7 @@ function ( $path, $index, $type, $query, $query_args, $query_object ) { return $path; }, 10, - 6 + 4 ); $query = new \WP_Query( @@ -448,12 +449,12 @@ public function test_fuziness_with_type_auto_set_for_ajax_call() { add_filter( 'ep_query_request_path', - function ( $path, $index, $type, $query, $query_args, $query_object ) { + function ( $path, $index, $type, $query ) { $this->assertEquals( 'auto', $query['query']['function_score']['query']['bool']['should'][2]['multi_match']['fuzziness'] ); return $path; }, 10, - 6 + 4 ); $query = new \WP_Query( @@ -499,12 +500,12 @@ public function test_fuziness_with_type_auto_set_for_ajax_call_negative() { add_filter( 'ep_query_request_path', - function ( $path, $index, $type, $query, $query_args, $query_object ) { + function ( $path, $index, $type, $query ) { $this->assertNotEquals( 'auto', $query['query']['function_score']['query']['bool']['should'][2]['multi_match']['fuzziness'] ); return $path; }, 10, - 6 + 4 ); $query = new \WP_Query( diff --git a/tests/php/features/TestComments.php b/tests/php/features/TestComments.php index f6e8309ca1..89cd70eaa9 100644 --- a/tests/php/features/TestComments.php +++ b/tests/php/features/TestComments.php @@ -73,6 +73,7 @@ protected function get_feature() { */ public function testConstruct() { $instance = new ElasticPress\Feature\Comments\Comments(); + $instance->set_i18n_strings(); $this->assertEquals( 'comments', $instance->slug ); $this->assertEquals( 'Comments', $instance->title ); diff --git a/tests/php/features/TestDidYouMean.php b/tests/php/features/TestDidYouMean.php index befbe8926b..d514f99082 100644 --- a/tests/php/features/TestDidYouMean.php +++ b/tests/php/features/TestDidYouMean.php @@ -43,6 +43,7 @@ public function set_up() { */ public function testConstruct() { $instance = new ElasticPress\Feature\DidYouMean\DidYouMean(); + $instance->set_i18n_strings(); $this->assertEquals( 'did-you-mean', $instance->slug ); $this->assertEquals( 'Did You Mean', $instance->title ); @@ -251,12 +252,12 @@ function () use ( $search_analyzer ) { add_filter( 'ep_query_request_args', - function ( $request_args, $path, $index, $type, $query, $query_args, $query_object ) use ( $search_analyzer ) { + function ( $request_args, $path, $index, $type, $query ) use ( $search_analyzer ) { $this->assertEquals( $search_analyzer, $query['suggest']['ep_suggestion'] ); return $request_args; }, 10, - 7 + 5 ); $query = new \WP_Query( diff --git a/tests/php/features/TestFacetTypeDate.php b/tests/php/features/TestFacetTypeDate.php index 637ff7c26b..d2a95c1d6a 100644 --- a/tests/php/features/TestFacetTypeDate.php +++ b/tests/php/features/TestFacetTypeDate.php @@ -254,7 +254,7 @@ public function testGetFacetOptions() { ], ]; - $change_filter_type = function ( $options ) use ( $modified_options ) { + $change_filter_type = function ( $options ) use ( $modified_options ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found return $modified_options; }; diff --git a/tests/php/features/TestFacetTypeMeta.php b/tests/php/features/TestFacetTypeMeta.php index a82ae8f644..93f2f25593 100644 --- a/tests/php/features/TestFacetTypeMeta.php +++ b/tests/php/features/TestFacetTypeMeta.php @@ -365,9 +365,9 @@ public function testGetSanitizeCallback() { $expected_result = sanitize_text_field( $test_meta ); $this->assertArrayHasKey( $expected_result, $selected['meta']['new_meta_key_1']['terms'] ); - $sanitize_function = function ( $function ) { + $sanitize_function = function ( $callback ) { - $this->assertSame( 'sanitize_text_field', $function ); + $this->assertSame( 'sanitize_text_field', $callback ); return 'sanitize_title'; }; diff --git a/tests/php/features/TestFacetTypeTaxonomy.php b/tests/php/features/TestFacetTypeTaxonomy.php index e7a626d901..4292d5fc5a 100644 --- a/tests/php/features/TestFacetTypeTaxonomy.php +++ b/tests/php/features/TestFacetTypeTaxonomy.php @@ -219,9 +219,9 @@ public function testGetSanitizeCallback() { $expected_result = sanitize_title( $test_taxonomy ); $this->assertArrayHasKey( $expected_result, $selected['taxonomies']['taxonomy']['terms'] ); - $sanitize_function = function ( $function ) { + $sanitize_function = function ( $callback ) { - $this->assertSame( 'sanitize_title', $function ); + $this->assertSame( 'sanitize_title', $callback ); return 'sanitize_text_field'; }; diff --git a/tests/php/features/TestSearchOrdering.php b/tests/php/features/TestSearchOrdering.php index 2f25546720..924f899603 100644 --- a/tests/php/features/TestSearchOrdering.php +++ b/tests/php/features/TestSearchOrdering.php @@ -73,6 +73,8 @@ public function get_feature() { */ public function testConstruct() { $instance = new \ElasticPress\Feature\SearchOrdering\SearchOrdering(); + $instance->set_i18n_strings(); + $this->assertSame( 'searchordering', $instance->slug ); $this->assertSame( 'Custom Search Results', $instance->title ); } diff --git a/tests/php/features/WooCommerce/TestWooCommerceProduct.php b/tests/php/features/WooCommerce/TestWooCommerceProduct.php index b2c9eb170f..ce991468bf 100644 --- a/tests/php/features/WooCommerce/TestWooCommerceProduct.php +++ b/tests/php/features/WooCommerce/TestWooCommerceProduct.php @@ -439,7 +439,7 @@ public function testProductListInAdminUseElasticSearch() { add_filter( 'ep_post_filters', - function ( $filters, $args, $query ) { + function ( $filters ) { $expected_result = array( 'terms' => array( 'post_type.raw' => array( @@ -452,7 +452,6 @@ function ( $filters, $args, $query ) { return $filters; }, 10, - 3 ); parse_str( 'post_type=product&s=product', $_GET ); @@ -487,7 +486,7 @@ public function testProductListSearchInAdminUseElasticSearch() { add_filter( 'ep_post_formatted_args', - function ( $formatted_args, $args, $wp_query ) { + function ( $formatted_args, ) { $this->assertEquals( 'findme', $formatted_args['query']['function_score']['query']['bool']['should'][0]['multi_match']['query'] ); $this->assertEquals( $args['search_fields'], @@ -504,8 +503,7 @@ function ( $formatted_args, $args, $wp_query ) { return $formatted_args; }, - 10, - 3 + 10 ); parse_str( 'post_type=product&s=findme', $_GET ); diff --git a/tests/php/includes/classes/mock/class-wp-cli.php b/tests/php/includes/classes/mock/class-wp-cli.php index b4e0c48a95..64a1c971d0 100644 --- a/tests/php/includes/classes/mock/class-wp-cli.php +++ b/tests/php/includes/classes/mock/class-wp-cli.php @@ -34,10 +34,9 @@ public static function success( $message ) { /** * Display debug message. * - * @param string $message Message to display to the end user. - * @param boolean $group Group + * @param string $message Message to display to the end user. */ - public static function debug( $message, $group = false ) { + public static function debug( $message ) { print $message; } @@ -54,13 +53,13 @@ public static function warning( $message ) { * Display error message. * * @param string $message Message to display to the end user. - * @param boolean $exit Whether exit or not. + * @param boolean $should_exit Whether exit or not. * @return void * @throws Exception Exception */ - public static function error( $message, $exit = true ) { + public static function error( $message, $should_exit = true ) { - if ( ! $exit ) { + if ( ! $should_exit ) { print $message; return; } diff --git a/tests/php/includes/wp-cli-utils.php b/tests/php/includes/wp-cli-utils.php index 40693f7008..02bfd05e0d 100644 --- a/tests/php/includes/wp-cli-utils.php +++ b/tests/php/includes/wp-cli-utils.php @@ -19,9 +19,9 @@ * * @param array $assoc_args Arguments array. * @param string $flag Flag to get the value. - * @param mixed $default Default value for the flag. Default: NULL + * @param mixed $default_value Default value for the flag. Default: NULL * @return mixed */ -function get_flag_value( $assoc_args, $flag, $default = null ) { - return isset( $assoc_args[ $flag ] ) ? $assoc_args[ $flag ] : $default; +function get_flag_value( $assoc_args, $flag, $default_value = null ) { + return isset( $assoc_args[ $flag ] ) ? $assoc_args[ $flag ] : $default_value; } diff --git a/tests/php/indexables/TestPost.php b/tests/php/indexables/TestPost.php index d48e8d46dc..ebfbda75b7 100644 --- a/tests/php/indexables/TestPost.php +++ b/tests/php/indexables/TestPost.php @@ -3827,11 +3827,11 @@ public function testAutoDraftPostStatus() { * * @param array|WP_Error $response HTTP response or WP_Error object. * @param string $type Context under which the hook is fired. - * @param string $class HTTP transport used. + * @param string $http_class HTTP transport used. * @param array $args HTTP request arguments. * @param string $url The request URL. */ - public function check404( $response, $type, $class, $args, $url ) { + public function check404( $response, $type, $http_class, $args, $url ) { $response_code = $response['response']['code']; if ( 404 === $response_code ) { $this->is_404 = true; @@ -6167,6 +6167,7 @@ function ( $args ) { public function testPostConstructor() { $post = new \ElasticPress\Indexable\Post\Post(); + $post->setup(); $this->assertSame( 'Posts', $post->labels['plural'] ); $this->assertSame( 'Post', $post->labels['singular'] ); @@ -8319,7 +8320,7 @@ public function testHighlightTagsWithCustomClass() { add_filter( 'ep_highlighting_class', - function ( $class ) { + function ( $highlight_class ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found return 'my-custom-class'; } ); @@ -8357,7 +8358,7 @@ public function testHighlightTagsOnlyForTitle() { add_filter( 'ep_highlighting_fields', - function ( $fields ) { + function ( $fields ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found return array( 'post_title' ); } ); @@ -8433,14 +8434,14 @@ public function testHighlightTagsNotSetWhenSearchIsEmpty() { add_action( 'pre_http_request', - function ( $preempt, $parsed_args, $url ) { + function ( $preempt, $parsed_args ) { $body = json_decode( $parsed_args['body'], true ); $this->assertArrayNotHasKey( 'highlight', $body ); return $preempt; }, 10, - 3 + 2 ); $args = array( diff --git a/tests/php/screen/TestStatusReport.php b/tests/php/screen/TestStatusReport.php index cebc284d67..4049a69eab 100644 --- a/tests/php/screen/TestStatusReport.php +++ b/tests/php/screen/TestStatusReport.php @@ -60,7 +60,7 @@ public function testGetReportsFilter() { public function testGetReportsSkipped() { $status_report = new StatusReport(); - parse_str( 'ep-skip-reports[]=wordpress&ep-skip-reports[]=indexable', $_GET ); // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled + parse_str( 'ep-skip-reports[]=wordpress&ep-skip-reports[]=indexable', $_GET ); // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledInText $reports = $status_report->get_reports(); $this->assertSame(