auto-patch 638-dev-dev01-2024-05-14T20_44_36
This commit is contained in:
@@ -443,6 +443,12 @@ function relevanssi_admin_search_debugging_info( $query ) {
|
||||
function relevanssi_update_counts() {
|
||||
global $wpdb, $relevanssi_variables;
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
die();
|
||||
}
|
||||
|
||||
check_admin_referer( 'update_counts', '_wpnonce' );
|
||||
|
||||
relevanssi_update_doc_count();
|
||||
|
||||
$terms_count = $wpdb->get_var( 'SELECT COUNT(*) FROM ' . $relevanssi_variables['relevanssi_table'] ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
|
||||
|
||||
@@ -77,6 +77,13 @@ function relevanssi_index_ninja_table( $table_id ) {
|
||||
)
|
||||
);
|
||||
foreach ( $rows as $row ) {
|
||||
if ( empty( $row->value ) ) {
|
||||
continue;
|
||||
}
|
||||
$json_decoded = json_decode( $row->value );
|
||||
if ( ! is_object( $json_decoded ) ) {
|
||||
continue;
|
||||
}
|
||||
$array_values = array_map(
|
||||
function ( $value ) {
|
||||
if ( is_object( $value ) ) {
|
||||
@@ -84,7 +91,7 @@ function relevanssi_index_ninja_table( $table_id ) {
|
||||
}
|
||||
return strval( $value );
|
||||
},
|
||||
array_values( get_object_vars( json_decode( $row->value ) ) )
|
||||
array_values( get_object_vars( $json_decoded ) )
|
||||
);
|
||||
|
||||
$table_contents .= ' ' . implode( ' ', $array_values );
|
||||
|
||||
@@ -10,25 +10,6 @@
|
||||
* @see https://www.relevanssi.com/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enables TablePress shortcodes for Relevanssi indexing.
|
||||
*
|
||||
* @return null|object The TablePress controller.
|
||||
*/
|
||||
function relevanssi_enable_tablepress_shortcodes() {
|
||||
$my_tablepress_controller = null;
|
||||
if ( defined( 'TABLEPRESS_ABSPATH' ) ) {
|
||||
if ( ! isset( TablePress::$model_options ) ) {
|
||||
include_once TABLEPRESS_ABSPATH . 'classes/class-model.php';
|
||||
include_once TABLEPRESS_ABSPATH . 'models/model-options.php';
|
||||
TablePress::$model_options = new TablePress_Options_Model();
|
||||
}
|
||||
$my_tablepress_controller = TablePress::load_controller( 'frontend' );
|
||||
$my_tablepress_controller->init_shortcodes();
|
||||
}
|
||||
return $my_tablepress_controller;
|
||||
}
|
||||
|
||||
add_filter( 'relevanssi_post_content', 'relevanssi_table_filter' );
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
add_filter( 'relevanssi_indexing_restriction', 'relevanssi_woocommerce_restriction' );
|
||||
add_filter( 'relevanssi_admin_search_blocked_post_types', 'relevanssi_woocommerce_admin_search_blocked_post_types' );
|
||||
add_filter( 'relevanssi_modify_wp_query', 'relevanssi_woocommerce_filters' );
|
||||
add_filter( 'relevanssi_post_ok', 'relevanssi_variation_post_ok', 10, 2 );
|
||||
|
||||
/**
|
||||
* This action solves the problems introduced by adjust_posts_count() in
|
||||
@@ -280,3 +281,20 @@ function relevanssi_filtered_term_product_counts_query( $query ) {
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the parent product status for product variations.
|
||||
*
|
||||
* @param bool $ok Whether the post is OK to return in search.
|
||||
* @param int $post_id The post ID.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function relevanssi_variation_post_ok( $ok, $post_id ) : bool {
|
||||
$post_type = relevanssi_get_post_type( $post_id );
|
||||
if ( 'product_variation' === $post_type ) {
|
||||
$parent = get_post_parent( $post_id );
|
||||
return apply_filters( 'relevanssi_post_ok', $ok, $parent->ID );
|
||||
}
|
||||
return $ok;
|
||||
}
|
||||
|
||||
@@ -337,6 +337,16 @@ function relevanssi_output_exported_log( string $filename, array $data, string $
|
||||
}
|
||||
fputcsv( $df, array_keys( reset( $data ) ) );
|
||||
foreach ( $data as $row ) {
|
||||
if (
|
||||
in_array(
|
||||
substr( $row['query'], 0, 1 ),
|
||||
array( '=', '-', '"', '@', '+' ),
|
||||
true
|
||||
)
|
||||
) {
|
||||
$row['query'] = ' ' . $row['query'];
|
||||
$row['query'] = str_replace( "\t", '', $row['query'] );
|
||||
}
|
||||
fputcsv( $df, $row );
|
||||
}
|
||||
fclose( $df ); // phpcs:ignore WordPress.WP.AlternativeFunctions
|
||||
|
||||
@@ -270,7 +270,7 @@ function relevanssi_search( $args ) {
|
||||
|
||||
$total_hits += count( $matches );
|
||||
|
||||
$idf = log( $doc_count + 1 / ( 1 + $df ) );
|
||||
$idf = log( ( $doc_count + 1 ) / ( 1 + $df ) );
|
||||
$idf = $idf * $idf; // Adjustment to increase the value of IDF.
|
||||
if ( $idf < 1 ) {
|
||||
$idf = 1;
|
||||
@@ -460,10 +460,10 @@ function relevanssi_search( $args ) {
|
||||
if ( ! is_wp_error( $post_object ) ) {
|
||||
$hits[ intval( $i ) ] = $post_object;
|
||||
$hits[ intval( $i ) ]->relevance_score = round( $weight, 2 );
|
||||
}
|
||||
|
||||
if ( isset( $missing_terms[ $doc ] ) ) {
|
||||
$hits[ intval( $i ) ]->missing_terms = $missing_terms[ $doc ];
|
||||
if ( isset( $missing_terms[ $doc ] ) ) {
|
||||
$hits[ intval( $i ) ]->missing_terms = $missing_terms[ $doc ];
|
||||
}
|
||||
}
|
||||
}
|
||||
++$i;
|
||||
|
||||
@@ -206,11 +206,6 @@ function relevanssi_debug_echo( string $notice ) {
|
||||
*/
|
||||
function relevanssi_do_shortcode( string $content ): string {
|
||||
if ( 'on' === get_option( 'relevanssi_expand_shortcodes' ) ) {
|
||||
// TablePress support.
|
||||
if ( function_exists( 'relevanssi_enable_tablepress_shortcodes' ) ) {
|
||||
$tablepress_controller = relevanssi_enable_tablepress_shortcodes();
|
||||
}
|
||||
|
||||
relevanssi_disable_shortcodes();
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user