Skip to content

Commit

Permalink
Merge pull request #3721 from 10up/feature/feature-settings-ui
Browse files Browse the repository at this point in the history
Opinionated changes to Features page copy and controls.
  • Loading branch information
felipeelia authored Oct 24, 2023
2 parents 24b619a + f134336 commit d621760
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 81 deletions.
4 changes: 4 additions & 0 deletions assets/js/features/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
.ep-dashboard-control {
margin-bottom: 24px;
margin-top: 24px;

& .components-base-control__help code {
font-size: inherit;
}
}

.ep-dashboard-heading {
Expand Down
13 changes: 7 additions & 6 deletions includes/classes/Feature/Autosuggest/Autosuggest.php
Original file line number Diff line number Diff line change
Expand Up @@ -882,16 +882,17 @@ protected function set_settings_schema() {
$this->settings_schema = [
[
'default' => '.ep-autosuggest',
'help' => __( 'Input additional selectors where you would like to include autosuggest separated by a comma. Example: .custom-selector, #custom-id, input[type="text"]', 'elasticpress' ),
'help' => __( 'Input additional selectors where you would like to include autosuggest, separated by a comma. Example: <code>.custom-selector, #custom-id, input[type="text"]</code>', 'elasticpress' ),
'key' => 'autosuggest_selector',
'label' => __( 'Autosuggest Selector', 'elasticpress' ),
'label' => __( 'Additional selectors', 'elasticpress' ),
'type' => 'text',
],
[
'key' => 'trigger_ga_event',
'help' => __( 'When enabled, a gtag tracking event is fired when an autosuggest result is clicked.', 'elasticpress' ),
'label' => __( 'Google Analytics Events', 'elasticpress' ),
'type' => 'checkbox',
'default' => '0',
'key' => 'trigger_ga_event',
'help' => __( 'Enable to fire a gtag tracking event when an autosuggest result is clicked.', 'elasticpress' ),
'label' => __( 'Trigger Google Analytics events', 'elasticpress' ),
'type' => 'checkbox',
],
];

Expand Down
7 changes: 3 additions & 4 deletions includes/classes/Feature/Facets/Facets.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,15 +670,14 @@ public function remove_facets_filter( $filters ) {
protected function set_settings_schema() {
$this->settings_schema[] = [
'key' => 'match_type',
'label' => __( 'Match Type', 'elasticpress' ),
'help' => __( '"All" will only show content that matches all filters. "Any" will show content that matches any filter.', 'elasticpress' ),
'label' => __( 'Filter matching', 'elasticpress' ),
'options' => [
[
'label' => __( 'Show any content tagged to <strong>all</strong> selected terms', 'elasticpress' ),
'label' => __( 'Show results that match <strong>all</strong> selected filters', 'elasticpress' ),
'value' => 'all',
],
[
'label' => __( 'Show all content tagged to <strong>any</strong> selected term', 'elasticpress' ),
'label' => __( 'Show results that match <strong>any</strong> selected filter', 'elasticpress' ),
'value' => 'any',
],
],
Expand Down
25 changes: 7 additions & 18 deletions includes/classes/Feature/InstantResults/InstantResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ protected function set_settings_schema() {
$this->settings_schema = [
[
'default' => 'mark',
'help' => __( 'Highlight search terms in results with the selected HTML tag.', 'elasticpress' ),
'help' => __( 'Select the HTML tag used to highlight search terms.', 'elasticpress' ),
'key' => 'highlight_tag',
'label' => __( 'Highlight tag', 'elasticpress' ),
'options' => [
Expand Down Expand Up @@ -1090,37 +1090,26 @@ protected function set_settings_schema() {
],
[
'default' => 'all',
'help' => __( '"All" will only show content that matches all filters. "Any" will show content that matches any filter.', 'elasticpress' ),
'key' => 'match_type',
'label' => __( 'Match Type', 'elasticpress' ),
'label' => __( 'Filter matching', 'elasticpress' ),
'options' => [
[
'label' => __( 'Show any content tagged to <strong>all</strong> selected terms', 'elasticpress' ),
'label' => __( 'Show results that match <strong>all</strong> selected filters', 'elasticpress' ),
'value' => 'all',
],
[
'label' => __( 'Show all content tagged to <strong>any</strong> selected term', 'elasticpress' ),
'label' => __( 'Show results that match <strong>any</strong> selected filter', 'elasticpress' ),
'value' => 'any',
],
],
'type' => 'radio',
],
[
'default' => '1',
'help' => __( 'When enabled, it will show the term count in the instant results widget.', 'elasticpress' ),
'help' => __( 'Enable to show the number of matching results next to filter options.', 'elasticpress' ),
'key' => 'term_count',
'label' => __( 'Term Count', 'elasticpress' ),
'options' => [
[
'label' => __( 'Enabled', 'elasticpress' ),
'value' => '1',
],
[
'label' => __( 'Disabled', 'elasticpress' ),
'value' => '0',
],
],
'type' => 'radio',
'label' => __( 'Show filter counts', 'elasticpress' ),
'type' => 'checkbox',
],
[
'default' => get_option( 'posts_per_page', 6 ),
Expand Down
51 changes: 16 additions & 35 deletions includes/classes/Feature/Search/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,38 +841,36 @@ protected function set_settings_schema() {
[
'default' => '1',
'key' => 'decaying_enabled',
'label' => __( 'Weight results by date', 'elasticpress' ),
'label' => __( 'Weighting by date', 'elasticpress' ),
'options' => [
[
'label' => __( 'Enabled', 'elasticpress' ),
'value' => '1',
'label' => __( 'Don\'t weight results by date', 'elasticpress' ),
'value' => '0',
],
[
'label' => __( 'Disabled', 'elasticpress' ),
'value' => '0',
'label' => __( 'Weight results by date', 'elasticpress' ),
'value' => '1',
],
],
'type' => 'radio',
],
[
'default' => '0',
'help' => __( 'Wrap search terms in HTML tags in results for custom styling. The wrapping HTML tag comes with the "ep-highlight" class for easy styling.' ),
'help' => __( 'Enable to wrap search terms in HTML tags in results for custom styling. The wrapping HTML tag comes with the <code>ep-highlight</code> class for easy styling.' ),
'key' => 'highlight_enabled',
'label' => __( 'Highlighting status', 'elasticpress' ),
'options' => [
[
'label' => __( 'Enabled', 'elasticpress' ),
'value' => '1',
],
[
'label' => __( 'Disabled', 'elasticpress' ),
'value' => '0',
],
],
'type' => 'radio',
'label' => __( 'Highlight search terms', 'elasticpress' ),
'type' => 'checkbox',
],
[
'default' => '0',
'help' => __( 'By default, WordPress strips HTML from content excerpts. Enable when using <code>the_excerpt()</code> to display search results.', 'elasticpress' ),
'key' => 'highlight_excerpt',
'label' => __( 'Highlight search terms in excerpts', 'elasticpress' ),
'type' => 'checkbox',
],
[
'default' => 'mark',
'help' => __( 'Select the HTML tag used to highlight search terms.', 'elasticpress' ),
'key' => 'highlight_tag',
'label' => __( 'Highlight tag', 'elasticpress' ),
'options' => [
Expand Down Expand Up @@ -903,23 +901,6 @@ protected function set_settings_schema() {
],
'type' => 'select',
],
[
'default' => '0',
'help' => __( 'By default, WordPress strips HTML from content excerpts. Enable when using the_excerpt() to display search results.', 'elasticpress' ),
'key' => 'highlight_excerpt',
'label' => __( 'Excerpt highlighting', 'elasticpress' ),
'options' => [
[
'label' => __( 'Enabled', 'elasticpress' ),
'value' => '1',
],
[
'label' => __( 'Disabled', 'elasticpress' ),
'value' => '0',
],
],
'type' => 'radio',
],
[
'default' => 'simple',
'key' => 'synonyms_editor_mode',
Expand Down
4 changes: 2 additions & 2 deletions includes/classes/Feature/WooCommerce/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -1067,11 +1067,11 @@ public function add_weight_settings_search_schema( $settings_schema, $feature_sl
$setting_schema['options'],
[
[
'label' => __( 'Disabled for product only queries', 'elasticpress' ),
'label' => __( 'Weight results by date, except for product-only queries', 'elasticpress' ),
'value' => 'disabled_only_products',
],
[
'label' => __( 'Disabled for any query that includes products', 'elasticpress' ),
'label' => __( 'Weight results by date, except for any query that includes products', 'elasticpress' ),
'value' => 'disabled_includes_products',
],
]
Expand Down
16 changes: 3 additions & 13 deletions includes/classes/Feature/WooCommerce/WooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ protected function set_settings_schema() {

$message = ( $available ) ?
/* translators: 1: <a> tag (ElasticPress.io); 2. </a>; 3: <a> tag (KB article); 4. </a>; */
__( 'You are directly connected to %1$sElasticPress.io%2$s! Enable Orders Autosuggest to enhance Dashboard results and quickly find WooCommerce Orders. %3$sLearn More%4$s.', 'elasticpress' ) :
__( 'You are directly connected to %1$sElasticPress.io%2$s! Enable autosuggest for Orders to enhance Dashboard results and quickly find WooCommerce Orders. %3$sLearn More%4$s.', 'elasticpress' ) :
/* translators: 1: <a> tag (ElasticPress.io); 2. </a>; 3: <a> tag (KB article); 4. </a>; */
__( 'Due to the sensitive nature of orders, this autosuggest feature is available only to %1$sElasticPress.io%2$s customers. %3$sLearn More%4$s.', 'elasticpress' );

Expand All @@ -356,19 +356,9 @@ protected function set_settings_schema() {
'disabled' => ! $available,
'help' => $message,
'key' => 'orders',
'label' => __( 'Orders Autosuggest', 'elasticpress' ),
'options' => [
[
'label' => __( 'Enabled', 'elasticpress' ),
'value' => '1',
],
[
'label' => __( 'Disabled', 'elasticpress' ),
'value' => '0',
],
],
'label' => __( 'Show suggestions when searching for Orders', 'elasticpress' ),
'requires_sync' => true,
'type' => 'radio',
'type' => 'checkbox',
],
];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/integration/features/facets.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ describe('Facets Feature', { tags: '@slow' }, () => {
cy.intercept('/wp-json/elasticpress/v1/features*').as('apiRequest');

cy.contains('button', 'Filters').click();
cy.contains('label', 'Show all content tagged to any selected term').click();
cy.contains('label', 'Show results that match any selected filter').click();
cy.contains('button', 'Save changes').click();

cy.wait('@apiRequest');
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/integration/features/search/search.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('Post Search Feature', { tags: '@slow' }, () => {
cy.intercept('/wp-json/elasticpress/v1/features*').as('apiRequest');

cy.contains('button', 'Post Search').click();
cy.get('.components-radio-control__input').eq(2).click();
cy.contains('label', 'Weight results by date').click();
cy.contains('button', 'Save changes').click();

cy.publishPost({
Expand Down
2 changes: 1 addition & 1 deletion tests/php/features/TestSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public function test_get_settings_schema() {

$settings_keys = wp_list_pluck( $settings_schema, 'key' );

$expected = [ 'active', 'decaying_enabled', 'highlight_enabled', 'highlight_tag', 'highlight_excerpt', 'synonyms_editor_mode' ];
$expected = [ 'active', 'decaying_enabled', 'highlight_enabled', 'highlight_excerpt', 'highlight_tag', 'synonyms_editor_mode' ];
if ( ! is_multisite() ) {
$expected[] = 'additional_links';
}
Expand Down

0 comments on commit d621760

Please sign in to comment.