Skip to content

Commit

Permalink
Merge branch 'develop' into feature/issue-3302
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeelia committed Jul 21, 2023
2 parents 239b4ea + c02aa45 commit 6674fcc
Show file tree
Hide file tree
Showing 44 changed files with 3,996 additions and 2,268 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
52 changes: 26 additions & 26 deletions includes/classes/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -1484,31 +1484,6 @@ public function settings_reset( $args, $assoc_args ) {
WP_CLI::line( esc_html__( 'Settings deleted.', 'elasticpress' ) );
}

/**
* Get an index settings
*
* ## OPTIONS
*
* <index_name>
* : Index name
*
* [--pretty]
* : Use this flag to render a pretty-printed version of the JSON response.
*
* @subcommand get-index-settings
*
* @since 4.7.0
*
* @param array $args Positional CLI args.
* @param array $assoc_args Associative CLI args.
*/
public function get_index_settings( $args, $assoc_args ) {
$response = Elasticsearch::factory()->remote_request( $args[0] );
$pretty = \WP_CLI\Utils\get_flag_value( $assoc_args, 'pretty' );

$this->print_json_response( $response, $pretty );
}

/**
* Print an HTTP response.
*
Expand Down Expand Up @@ -1540,7 +1515,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 Expand Up @@ -1589,4 +1564,29 @@ public function delete_search_template() {
$instant_results->epio_delete_search_template();
WP_CLI::success( esc_html__( 'Done.', 'elasticpress' ) );
}

/**
* Get an index settings
*
* ## OPTIONS
*
* <index_name>
* : Index name
*
* [--pretty]
* : Use this flag to render a pretty-printed version of the JSON response.
*
* @subcommand get-index-settings
*
* @since 4.7.0
*
* @param array $args Positional CLI args.
* @param array $assoc_args Associative CLI args.
*/
public function get_index_settings( $args, $assoc_args ) {
$response = Elasticsearch::factory()->get_index_settings( $args[0] );
$pretty = \WP_CLI\Utils\get_flag_value( $assoc_args, 'pretty' );

$this->pretty_json_encode( $response, $pretty );
}
}
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
27 changes: 18 additions & 9 deletions includes/classes/Feature/Search/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ public function search_setup() {
add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_block_editor_assets' ] );
add_filter( 'ep_post_filters', [ $this, 'exclude_posts_from_search' ], 10, 3 );
add_action( 'post_submitbox_misc_actions', [ $this, 'output_exclude_from_search_setting' ] );
add_action( 'edit_post', [ $this, 'save_exclude_from_search_meta' ], 10, 2 );
add_action( 'edit_post', [ $this, 'save_exclude_from_search_meta' ] );
add_filter( 'ep_skip_query_integration', [ $this, 'skip_query_integration' ], 10, 2 );

add_action( 'attachment_submitbox_misc_actions', [ $this, 'output_exclude_from_search_setting' ], 15 );
add_action( 'edit_attachment', [ $this, 'save_exclude_from_search_meta' ] );
}


Expand Down Expand Up @@ -775,7 +778,6 @@ public function exclude_posts_from_search( $filters, $args, $query ) {
* @param WP_POST $post Post object.
*/
public function output_exclude_from_search_setting( $post ) {

$searchable_post_types = $this->get_searchable_post_types();
if ( ! in_array( $post->post_type, $searchable_post_types, true ) ) {
return;
Expand All @@ -784,7 +786,13 @@ public function output_exclude_from_search_setting( $post ) {
<div class="misc-pub-section">
<input id="ep_exclude_from_search" name="ep_exclude_from_search" type="checkbox" value="1" <?php checked( get_post_meta( get_the_ID(), 'ep_exclude_from_search', true ) ); ?>>
<label for="ep_exclude_from_search"><?php esc_html_e( 'Exclude from search results', 'elasticpress' ); ?></label>
<p class="howto"><?php esc_html_e( 'Excludes this post from the results of your site\'s search form while ElasticPress is active.', 'elasticpress' ); ?></p>
<p class="howto">
<?php if ( 'attachment' === $post->post_type ) : ?>
<?php esc_html_e( 'Excludes this media from the results of your site\'s search form while ElasticPress is active.', 'elasticpress' ); ?>
<?php else : ?>
<?php esc_html_e( 'Excludes this post from the results of your site\'s search form while ElasticPress is active.', 'elasticpress' ); ?>
<?php endif; ?>
</p>
<?php wp_nonce_field( 'save-exclude-from-search', 'ep-exclude-from-search-nonce' ); ?>
</div>
<?php
Expand All @@ -793,11 +801,9 @@ public function output_exclude_from_search_setting( $post ) {
/**
* Saves exclude from search meta.
*
* @param int $post_id The post ID.
* @param WP_Post $post Post object.
* @param int $post_id The post ID.
*/
public function save_exclude_from_search_meta( $post_id, $post ) {

public function save_exclude_from_search_meta( $post_id ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
Expand All @@ -810,9 +816,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
Loading

0 comments on commit 6674fcc

Please sign in to comment.