Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tlovett1 committed Aug 29, 2019
2 parents eeae8b5 + 2ca0f9d commit b21dc46
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 25 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 .",
Expand Down
4 changes: 2 additions & 2 deletions elasticpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions includes/classes/Elasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}

Expand Down
28 changes: 20 additions & 8 deletions includes/classes/Feature/Facets/Facets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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'];
}
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions includes/classes/Indexable/Post/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
);

Expand Down Expand Up @@ -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,
),
);
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Indexable/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
);
Expand Down
9 changes: 6 additions & 3 deletions includes/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -285,7 +285,10 @@ function maybe_notice( $force = false ) {

foreach ( $notices as $notice_key => $notice ) {
?>
<div data-ep-notice="<?php echo esc_attr( $notice_key ); ?>" class="notice notice-<?php echo esc_attr( $notice['type'] ); ?> <?php if ( $notice['dismiss'] ) : ?>is-dismissible<?php endif; ?>">
<div data-ep-notice="<?php echo esc_attr( $notice_key ); ?>" class="notice notice-<?php echo esc_attr( $notice['type'] ); ?> <?php
if ( $notice['dismiss'] ) :
?>
is-dismissible<?php endif; ?>">
<p>
<?php echo wp_kses( $notice['html'], 'ep-html' ); ?>
</p>
Expand Down
11 changes: 7 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit b21dc46

Please sign in to comment.