Skip to content

Commit

Permalink
Merge branch 'develop' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeelia committed Jul 5, 2023
2 parents 49382f5 + 2ab656b commit 4dc189c
Show file tree
Hide file tree
Showing 19 changed files with 267 additions and 43 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ All notable changes to this project will be documented in this file, per [the Ke
### Security
-->

## [4.6.1] - 2023-07-05

**Note that starting from the ElasticPress 5.0.0 release the `Users` feature will be moved to the [ElasticPress Labs](https://github.com/10up/ElasticPressLabs) plugin. The `Terms` and `Comments` features will remain in ElasticPress but will be available only if enabled via code. Check [our blog post](https://www.elasticpress.io/blog/2023/03/enabling-comments-and-terms-in-elasticpress-5-0) for more info.**

### Added
* Add doc url for "Did You Mean" feature. Props [@burhandodhy](https://github.com/burhandodhy) via [#3529](https://github.com/10up/ElasticPress/pull/3529).

### Changed
* Use `wp_cache_supports` over `wp_cache_supports_group_flush`. Props [@spacedmonkey](https://github.com/spacedmonkey) via [#3501](https://github.com/10up/ElasticPress/pull/3501).
* Update the `ep_exclude_from_search` post meta only if it is set or has some value. Props [@MARQAS](https://github.com/MARQAS) and [@columbian-chris](https://github.com/columbian-chris) via [#3521](https://github.com/10up/ElasticPress/pull/3521).

### Fixed
* Deprecation notice in `ElasticPress\Feature\WooCommerce\Orders`. Props [@mwidmann](https://github.com/mwidmann) via [#3507](https://github.com/10up/ElasticPress/pull/3507).
* Don't apply a facet filter to the query if the filter value is empty. Props [@burhandodhy](https://github.com/burhandodhy) via [#3524](https://github.com/10up/ElasticPress/pull/3524).
* Syncing a post with empty post meta key. Props [@MARQAS](https://github.com/MARQAS) and [@oscarssanchez](https://github.com/oscarssanchez) via [#3516](https://github.com/10up/ElasticPress/pull/3516).
* Order by clauses with Elasticsearch field formats are not changed anymore. Props [@felipeelia](https://github.com/felipeelia) and [@tlovett1](https://github.com/tlovett1) via [#3512](https://github.com/10up/ElasticPress/pull/3512).
* Failed Query logs are automatically cleared on refreshing the "Status Report" page. Props [@burhandodhy](https://github.com/burhandodhy) via [#3533](https://github.com/10up/ElasticPress/pull/3533).
* Warning message on Health page when Last Sync information is not available. Props [@burhandodhy](https://github.com/burhandodhy) via [#3530](https://github.com/10up/ElasticPress/pull/3530).
* Deprecation notice: json_encode(): Passing null to parameter #2. Props [@burhandodhy](https://github.com/burhandodhy) via [#3532](https://github.com/10up/ElasticPress/pull/3532).
* Documentation of the `ep_facet_search_get_terms_args` filter. Props [@burhandodhy](https://github.com/burhandodhy) via [#3525](https://github.com/10up/ElasticPress/pull/3525).

## [4.6.0] - 2023-06-13

**Note that starting from the ElasticPress 5.0.0 release the `Users` feature will be moved to the [ElasticPress Labs](https://github.com/10up/ElasticPressLabs) plugin. The `Terms` and `Comments` features will remain in ElasticPress but will be available only if enabled via code. Check [our blog post](https://www.elasticpress.io/blog/2023/03/enabling-comments-and-terms-in-elasticpress-5-0) for more info.**
Expand Down Expand Up @@ -1831,6 +1852,7 @@ This is a bug fix release with some filter additions.
- Initial plugin release

[Unreleased]: https://github.com/10up/ElasticPress/compare/trunk...develop
[4.6.1]: https://github.com/10up/ElasticPress/compare/4.6.0...4.6.1
[4.6.0]: https://github.com/10up/ElasticPress/compare/4.5.2...4.6.0
[4.5.2]: https://github.com/10up/ElasticPress/compare/4.5.1...4.5.2
[4.5.1]: https://github.com/10up/ElasticPress/compare/4.5.0...4.5.1
Expand Down
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ Thank you to all the people who have already contributed to this repository via
[Alexander Z (@TorlockC)](https://github.com/TorlockC),
[Nabi (@navidabdi)](https://github.com/navidabdi)
[Dmitry Seleznyov (@selim13)](https://github.com/selim13)
[Martin Widmann (@mwidmann)](https://github.com/mwidmann)
and
[@qazaqstan2025](https://github.com/qazaqstan2025).

Expand Down
4 changes: 2 additions & 2 deletions elasticpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: ElasticPress
* Plugin URI: https://github.com/10up/ElasticPress
* Description: A fast and flexible search and query engine for WordPress.
* Version: 4.6.0
* Version: 4.6.1
* Requires at least: 5.6
* Requires PHP: 7.0
* Author: 10up
Expand Down Expand Up @@ -32,7 +32,7 @@
define( 'EP_URL', plugin_dir_url( __FILE__ ) );
define( 'EP_PATH', plugin_dir_path( __FILE__ ) );
define( 'EP_FILE', plugin_basename( __FILE__ ) );
define( 'EP_VERSION', '4.6.0' );
define( 'EP_VERSION', '4.6.1' );

/**
* PSR-4-ish autoloading
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ protected function print_json_response( $response, $pretty ) {
* @param boolean $pretty_print_flag Whether it should or not be formatted.
*/
protected function pretty_json_encode( $json_obj, $pretty_print_flag ) {
$flag = $pretty_print_flag ? JSON_PRETTY_PRINT : null;
$flag = $pretty_print_flag ? JSON_PRETTY_PRINT : 0;
WP_CLI::line( wp_json_encode( $json_obj, $flag ) );
}

Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Feature/Autosuggest/Autosuggest.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ public function intercept_search_request( $response, $query = [], $args = [], $f
public function delete_cached_query() {
global $wp_object_cache;
if ( wp_using_ext_object_cache() ) {
if ( function_exists( 'wp_cache_supports_group_flush' ) && wp_cache_supports_group_flush() ) {
if ( function_exists( 'wp_cache_supports' ) && wp_cache_supports( 'flush_group' ) ) {
wp_cache_flush_group( 'ep_autosuggest' );
} else {
// Try to delete the entire group.
Expand Down
2 changes: 2 additions & 0 deletions includes/classes/Feature/DidYouMean/DidYouMean.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public function __construct() {

$this->summary = __( 'Recommend alternative search terms for misspelled queries or terms with no results.', 'elasticpress' );

$this->docs_url = __( 'https://elasticpress.zendesk.com/hc/en-us/articles/16673223107085-Did-You-Mean', 'elasticpress' );

$this->requires_install_reindex = true;

$this->available_during_installation = true;
Expand Down
3 changes: 3 additions & 0 deletions includes/classes/Feature/Facets/Facets.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ public function get_selected() {

foreach ( $filter_names as $filter_name => $type_obj ) {
if ( 0 === strpos( $key, $filter_name ) ) {
if ( empty( $value ) ) {
continue;
}
$facet = str_replace( $filter_name, '', $key );

$filters = $type_obj->format_selected( $facet, $value, $filters );
Expand Down
8 changes: 4 additions & 4 deletions includes/classes/Feature/Facets/Types/Taxonomy/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ public function render( $args, $instance ) {
*
* @since 3.5.0
* @hook ep_facet_search_get_terms_args
* @param {array} $query Weighting query
* @param {string} $post_type Post type
* @param {array} $args WP Query arguments
* @return {array} New query
* @param {array} $terms_args Array of arguments passed to get_terms()
* @param {array} $args Widget args
* @param {array} $instance Instance settings
* @return {array} New terms args
*/
apply_filters(
'ep_facet_search_get_terms_args',
Expand Down
7 changes: 5 additions & 2 deletions includes/classes/Feature/Search/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,12 @@ public function save_exclude_from_search_meta( $post_id, $post ) {
return;
}

$exclude_from_search = isset( $_POST['ep_exclude_from_search'] ) ? true : false;
if ( isset( $_POST['ep_exclude_from_search'] ) ) {
update_post_meta( $post_id, 'ep_exclude_from_search', true );
} else {
delete_post_meta( $post_id, 'ep_exclude_from_search' );
}

update_post_meta( $post_id, 'ep_exclude_from_search', $exclude_from_search );
}

/**
Expand Down
7 changes: 7 additions & 0 deletions includes/classes/Feature/WooCommerce/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
* WooCommerce Orders Feature
*/
class Orders {
/**
* The name of the index;
*
* @var string
*/
protected $index;

/**
* Initialize feature.
*
Expand Down
61 changes: 46 additions & 15 deletions includes/classes/Indexable/Post/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,9 @@ public function prepare_meta( $post ) {
$prepared_meta = [];

foreach ( $filtered_metas as $key => $value ) {
$prepared_meta[ $key ] = maybe_unserialize( $value );
if ( ! empty( $key ) ) {
$prepared_meta[ $key ] = maybe_unserialize( $value );
}
}

/**
Expand Down Expand Up @@ -1290,6 +1292,12 @@ protected function parse_orderby_meta_fields( $orderby_clause, $args ) {
'unsigned' => 'long',
];

// Code is targeting Elasticsearch directly
if ( preg_match( '/^meta\.(.*?)\.(.*)/', $orderby_clause, $match_meta ) ) {
return $orderby_clause;
}

// WordPress meta_value_* compatibility
if ( preg_match( '/^meta_value_?(.*)/', $orderby_clause, $match_type ) ) {
$meta_type = $from_to_metatypes[ strtolower( $match_type[1] ) ] ?? 'value.sortable';
}
Expand All @@ -1298,25 +1306,48 @@ protected function parse_orderby_meta_fields( $orderby_clause, $args ) {
$meta_field = $args['meta_key'];
}

if ( ( ! isset( $meta_type ) || ! isset( $meta_field ) ) && ! empty( $args['meta_query'] ) ) {
$meta_query = new \WP_Meta_Query( $args['meta_query'] );
// Calling get_sql() to populate the WP_Meta_Query->clauses attribute
$meta_query->get_sql( 'post', $wpdb->posts, 'ID' );
// Already have everything needed
if ( isset( $meta_type ) && isset( $meta_field ) ) {
return "meta.{$meta_field}.{$meta_type}";
}

// Don't have any other ways to guess
if ( empty( $args['meta_query'] ) ) {
return $orderby_clause;
}

$clauses = $meta_query->get_clauses();
$meta_query = new \WP_Meta_Query( $args['meta_query'] );
// Calling get_sql() to populate the WP_Meta_Query->clauses attribute
$meta_query->get_sql( 'post', $wpdb->posts, 'ID' );

if ( ! empty( $clauses[ $orderby_clause ] ) ) {
$meta_field = $clauses[ $orderby_clause ]['key'];
$clause_meta_type = strtolower( $clauses[ $orderby_clause ]['type'] ?? $clauses[ $orderby_clause ]['cast'] );
$clauses = $meta_query->get_clauses();

// If it refers to a named meta_query clause
if ( ! empty( $clauses[ $orderby_clause ] ) ) {
$meta_field = $clauses[ $orderby_clause ]['key'];
$clause_meta_type = strtolower( $clauses[ $orderby_clause ]['type'] ?? $clauses[ $orderby_clause ]['cast'] );
} else {
/**
* At this point we:
* 1. Try to find the meta key in any meta_query clause and use the type WP found
* 2. If ordering by `meta_value*`, use the first meta_query clause
* 3. Give up and use the orderby clause as is (code could be capturing it later on)
*/
$meta_keys_and_types = wp_list_pluck( $clauses, 'cast', 'key' );
if ( isset( $meta_keys_and_types[ $orderby_clause ] ) ) {
$meta_field = $orderby_clause;
$clause_meta_type = strtolower( $meta_keys_and_types[ $orderby_clause ] ?? $meta_keys_and_types[ $orderby_clause ] );
} elseif ( isset( $meta_type ) ) {
$primary_clause = reset( $clauses );
$meta_field = $primary_clause['key'];
} else {
$primary_clause = reset( $clauses );
$meta_field = $primary_clause['key'];
$clause_meta_type = strtolower( $primary_clause['type'] ?? $primary_clause['cast'] );
unset( $meta_type );
unset( $meta_field );
}
}

if ( ! isset( $meta_type ) ) {
$meta_type = $from_to_metatypes[ $clause_meta_type ] ?? 'value.sortable';
}
if ( ! isset( $meta_type ) && isset( $clause_meta_type ) ) {
$meta_type = $from_to_metatypes[ $clause_meta_type ] ?? 'value.sortable';
}

if ( isset( $meta_type ) && isset( $meta_field ) ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Screen/HealthInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function last_sync_health_info( $debug_info ) {

$debug_info['ep-last-sync'] = [
'label' => esc_html__( 'ElasticPress - Last Sync', 'elasticpress' ),
'fields' => $first_group['fields'],
'fields' => $first_group['fields'] ?? [],
];

return $debug_info;
Expand Down
9 changes: 9 additions & 0 deletions includes/classes/StatusReport/FailedQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ protected function maybe_clear_logs() {
}

$this->query_logger->clear_logs();

if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) {
$redirect_url = network_admin_url( 'admin.php?page=elasticpress-status-report' );
} else {
$redirect_url = admin_url( 'admin.php?page=elasticpress-status-report' );
}

wp_safe_redirect( $redirect_url );
exit();
}

/**
Expand Down
30 changes: 17 additions & 13 deletions lang/elasticpress.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the GPL v2 or later.
msgid ""
msgstr ""
"Project-Id-Version: ElasticPress 4.6.0\n"
"Project-Id-Version: ElasticPress 4.6.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/elasticpress\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2023-06-13T13:37:04+00:00\n"
"POT-Creation-Date: 2023-07-05T16:24:55+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.7.1\n"
"X-Domain: elasticpress\n"
Expand Down Expand Up @@ -585,46 +585,50 @@ msgstr ""
msgid "Recommend alternative search terms for misspelled queries or terms with no results."
msgstr ""

#: includes/classes/Feature/DidYouMean/DidYouMean.php:28
msgid "https://elasticpress.zendesk.com/hc/en-us/articles/16673223107085-Did-You-Mean"
msgstr ""

#. translators: Tutorial URL
#: includes/classes/Feature/DidYouMean/DidYouMean.php:64
#: includes/classes/Feature/DidYouMean/DidYouMean.php:66
msgid "\"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 <a href=\"%s\">this tutorial</a>."
msgstr ""

#: includes/classes/Feature/DidYouMean/DidYouMean.php:142
#: includes/classes/Feature/DidYouMean/DidYouMean.php:144
msgid "Did you mean"
msgstr ""

#: includes/classes/Feature/DidYouMean/DidYouMean.php:227
#: includes/classes/Feature/DidYouMean/DidYouMean.php:229
#: includes/classes/Feature/Search/Synonyms.php:89
#: includes/classes/Feature/SearchOrdering/SearchOrdering.php:186
msgid "This feature requires the \"Post Search\" feature to be enabled"
msgstr ""

#: includes/classes/Feature/DidYouMean/DidYouMean.php:242
#: includes/classes/Feature/DidYouMean/DidYouMean.php:244
msgid "Search behavior when no result is found"
msgstr ""

#: includes/classes/Feature/DidYouMean/DidYouMean.php:244
#: includes/classes/Feature/DidYouMean/DidYouMean.php:246
msgid "Display the top suggestion"
msgstr ""

#: includes/classes/Feature/DidYouMean/DidYouMean.php:245
#: includes/classes/Feature/DidYouMean/DidYouMean.php:247
msgid "Display all the suggestions"
msgstr ""

#: includes/classes/Feature/DidYouMean/DidYouMean.php:246
#: includes/classes/Feature/DidYouMean/DidYouMean.php:248
msgid "Automatically redirect the user to the top suggestion"
msgstr ""

#: includes/classes/Feature/DidYouMean/DidYouMean.php:284
#: includes/classes/Feature/DidYouMean/DidYouMean.php:286
msgid "Other suggestions:"
msgstr ""

#: includes/classes/Feature/DidYouMean/DidYouMean.php:384
#: includes/classes/Feature/DidYouMean/DidYouMean.php:386
msgid "Showing results for: "
msgstr ""

#: includes/classes/Feature/DidYouMean/DidYouMean.php:386
#: includes/classes/Feature/DidYouMean/DidYouMean.php:388
msgid "No results for: "
msgstr ""

Expand Down Expand Up @@ -699,7 +703,7 @@ msgid "\"All\" will only show content that matches all facets. \"Any\" will show
msgstr ""

#. translators: URL
#: includes/classes/Feature/Facets/Facets.php:502
#: includes/classes/Feature/Facets/Facets.php:505
msgid "Adds a <a href='%s'>Facet widget</a> 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."
msgstr ""

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elasticpress",
"version": "4.6.0",
"version": "4.6.1",
"license": "GPL-2.0-or-later",
"description": "A fast and flexible search and query engine for WordPress.",
"devDependencies": {
Expand Down
Loading

0 comments on commit 4dc189c

Please sign in to comment.