diff --git a/composer.json b/composer.json index 1d658327e7..adb140d6c1 100644 --- a/composer.json +++ b/composer.json @@ -26,12 +26,12 @@ } ], "require": { - "php": ">=5.6", - "phpunit/phpunit": "^7" + "php": ">=5.6" }, "require-dev": { "10up/phpcs-composer": "dev-master", - "wpackagist-plugin/woocommerce":"*" + "wpackagist-plugin/woocommerce":"*", + "phpunit/phpunit": "^7" }, "scripts": { "lint": "phpcs .", diff --git a/elasticpress.php b/elasticpress.php index 126dbd7660..45da677f81 100644 --- a/elasticpress.php +++ b/elasticpress.php @@ -2,7 +2,7 @@ /** * Plugin Name: ElasticPress * Description: A fast and flexible search and query engine for WordPress. - * Version: 3.1.3 + * Version: 3.1.4 * Author: 10up * Author URI: http://10up.com * License: GPLv2 or later @@ -27,7 +27,7 @@ define( 'EP_URL', plugin_dir_url( __FILE__ ) ); define( 'EP_PATH', plugin_dir_path( __FILE__ ) ); -define( 'EP_VERSION', '3.1.3' ); +define( 'EP_VERSION', '3.1.4' ); /** * PSR-4-ish autoloading diff --git a/includes/classes/Elasticsearch.php b/includes/classes/Elasticsearch.php index 5e040e7375..80b26ade76 100644 --- a/includes/classes/Elasticsearch.php +++ b/includes/classes/Elasticsearch.php @@ -211,8 +211,8 @@ public function query( $index, $type, $query, $query_args ) { ), ); - // If search, send the search term as a header to ES - if ( isset( $query_args['s'] ) && (bool) $query_args['s'] && ! is_admin() ) { + // If search, send the search term as a header to ES so the backend understands what a normal query looks like + if ( isset( $query_args['s'] ) && (bool) $query_args['s'] && ! is_admin() && ! isset( $_GET['post_type'] ) ) { $request_args['headers']['EP-Search-Term'] = $query_args['s']; } diff --git a/includes/classes/Feature/Facets/Facets.php b/includes/classes/Feature/Facets/Facets.php index a50d38da7d..9624d66f6a 100644 --- a/includes/classes/Feature/Facets/Facets.php +++ b/includes/classes/Feature/Facets/Facets.php @@ -262,9 +262,19 @@ public function facet_query( $query ) { $tax_query = $query->get( 'tax_query', [] ); + // Account for taxonomies that should be woocommerce attributes, if WC is enabled + $attribute_taxonomies = []; + if ( function_exists( 'wc_attribute_taxonomy_name' ) ) { + $all_attr_taxonomies = wc_get_attribute_taxonomies(); + + foreach ( $all_attr_taxonomies as $attr_taxonomy ) { + $attribute_taxonomies[ $attr_taxonomy->attribute_name ] = wc_attribute_taxonomy_name( $attr_taxonomy->attribute_name ); + } + } + foreach ( $selected_filters['taxonomies'] as $taxonomy => $filter ) { $tax_query[] = [ - 'taxonomy' => wc_attribute_taxonomy_name( $taxonomy ), + 'taxonomy' => isset( $attribute_taxonomies[ $taxonomy ] ) ? $attribute_taxonomies[ $taxonomy ] : $taxonomy, 'field' => 'slug', 'terms' => array_keys( $filter['terms'] ), 'operator' => ( 'any' === $settings['match_type'] ) ? 'or' : 'and', @@ -291,15 +301,17 @@ public function get_aggs( $response ) { if ( ! empty( $response['aggregations'] ) ) { $GLOBALS['ep_facet_aggs'] = []; - foreach ( $response['aggregations']['terms'] as $key => $agg ) { - if ( 'doc_count' === $key ) { - continue; - } + if ( isset( $response['aggregations']['terms'] ) && is_array( $response['aggregations']['terms'] ) ) { + foreach ( $response['aggregations']['terms'] as $key => $agg ) { + if ( 'doc_count' === $key ) { + continue; + } - $GLOBALS['ep_facet_aggs'][ $key ] = []; + $GLOBALS['ep_facet_aggs'][ $key ] = []; - foreach ( $agg['buckets'] as $bucket ) { - $GLOBALS['ep_facet_aggs'][ $key ][ $bucket['key'] ] = $bucket['doc_count']; + foreach ( $agg['buckets'] as $bucket ) { + $GLOBALS['ep_facet_aggs'][ $key ][ $bucket['key'] ] = $bucket['doc_count']; + } } } } diff --git a/includes/classes/Indexable/Post/Post.php b/includes/classes/Indexable/Post/Post.php index 5d150471f6..e975ce7aa8 100644 --- a/includes/classes/Indexable/Post/Post.php +++ b/includes/classes/Indexable/Post/Post.php @@ -688,9 +688,12 @@ public function format_args( $args ) { $use_filters = true; } elseif ( ! empty( $args['author_name'] ) ) { + // Since this was set to use the display name initially, there might be some code that used this feature. + // Let's ensure that any query vars coming in using author_name are in fact slugs. + $author_login = sanitize_user( $args['author_name'] ); $filter['bool']['must'][] = array( 'term' => array( - 'post_author.raw' => $args['author'], + 'post_author.login.raw' => $author_login, ), ); @@ -1333,7 +1336,7 @@ protected function parse_orderby( $orderbys, $default_order, $args ) { } elseif ( 'meta_value' === $orderby_clause ) { if ( ! empty( $args['meta_key'] ) ) { $sort[] = array( - 'meta.' . $args['meta_key'] . '.value' => array( + 'meta.' . $args['meta_key'] . '.raw' => array( 'order' => $order, ), ); diff --git a/includes/classes/Indexable/User/User.php b/includes/classes/Indexable/User/User.php index ebbb7bd21e..6f296d474a 100644 --- a/includes/classes/Indexable/User/User.php +++ b/includes/classes/Indexable/User/User.php @@ -571,7 +571,7 @@ public function parse_orderby( $orderby, $default_order, $query_vars ) { } elseif ( 'meta_value' === $orderby_clause ) { if ( ! empty( $query_vars['meta_key'] ) ) { $sort[] = array( - 'meta.' . $query_vars['meta_key'] . '.value' => array( + 'meta.' . $query_vars['meta_key'] . '.raw' => array( 'order' => $order, ), ); diff --git a/includes/dashboard.php b/includes/dashboard.php index d58c32ec9c..0f2108ff96 100644 --- a/includes/dashboard.php +++ b/includes/dashboard.php @@ -37,7 +37,7 @@ function setup() { add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\action_admin_enqueue_dashboard_scripts' ); add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\action_admin_enqueue_admin_scripts' ); add_action( 'admin_init', __NAMESPACE__ . '\action_admin_init' ); - add_action( 'plugins_loaded', __NAMESPACE__ . '\maybe_clear_es_info_cache' ); + add_action( 'admin_init', __NAMESPACE__ . '\maybe_clear_es_info_cache' ); add_action( 'wp_ajax_ep_index', __NAMESPACE__ . '\action_wp_ajax_ep_index' ); add_action( 'wp_ajax_ep_notice_dismiss', __NAMESPACE__ . '\action_wp_ajax_ep_notice_dismiss' ); add_action( 'wp_ajax_ep_cancel_index', __NAMESPACE__ . '\action_wp_ajax_ep_cancel_index' ); @@ -165,7 +165,7 @@ function maybe_clear_es_info_cache() { return; } - if ( empty( $_GET['ep-retry'] ) && ! in_array( Screen::factory()->get_current_screen(), [ 'dashboard', 'settings' ], true ) ) { // phpcs:ignore WordPress.Security.NonceVerification + if ( empty( $_GET['ep-retry'] ) && ! in_array( Screen::factory()->get_current_screen(), [ 'dashboard', 'settings', 'install' ], true ) ) { // phpcs:ignore WordPress.Security.NonceVerification return; } @@ -285,7 +285,10 @@ function maybe_notice( $force = false ) { foreach ( $notices as $notice_key => $notice ) { ?> -
diff --git a/package-lock.json b/package-lock.json index 71358033db..00d28d2c8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3434,10 +3434,13 @@ } }, "eslint-utils": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz", - "integrity": "sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q==", - "dev": true + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.2.tgz", + "integrity": "sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.0.0" + } }, "eslint-visitor-keys": { "version": "1.0.0", diff --git a/readme.txt b/readme.txt index 8c95baa1d0..a7d2ae0a77 100644 --- a/readme.txt +++ b/readme.txt @@ -43,6 +43,9 @@ Please refer to [Github](https://github.com/10up/ElasticPress) for detailed usag == Changelog == += 3.1.4 = +https://github.com/10up/ElasticPress/pulls?q=is%3Apr+milestone%3A3.1.4+is%3Aclosed + = 3.1.3 = This is a bug fix release.