This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* These functions can be used by ElasticPress 3.5.5+ users wanting to | |
* use the search algorithm introduced as default in EP 4.0 | |
*/ | |
/** | |
* Change the search algorithm to the one introduced in ElasticPress 4.0. | |
* | |
* @param array $query Current query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace TenUp_QueryLog; | |
function log_queries( $query ) { | |
if ( ! preg_match( '/^\s*(create|alter|truncate|drop|insert|delete|update|replace)\s/i', $query ) ) { | |
return $query; | |
} | |
// Not interested in any operations with transients |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add a cross_field type clause to the ES query, so it searches for terms | |
* in different fields. | |
* | |
* @param array $query Current query | |
* @param array $args Query variables | |
* @param string $search_text Search text | |
* @param array $search_fields Search fields |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Place this file in the wp-content/mu-plugins directory and run ngrok with | |
* `ngrok http http://<local_url> --host-header=<local_url>` | |
*/ | |
$ngrok_url = '<id>.ngrok.io'; | |
define( 'WP_HOME', 'http://' . $ngrok_url ); | |
define( 'WP_SITEURL', 'http://' . $ngrok_url ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Create a new field with product variation titles. | |
add_filter( | |
'ep_prepare_meta_data', | |
function( $post_meta, $post ) { | |
if ( 'product' !== get_post_type( $post ) ) { | |
return $post_meta; | |
} | |
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE | |
`wp_postmeta` pm | |
SET meta_value = 1924905600 | |
WHERE meta_key IN | |
( | |
SELECT * FROM | |
( | |
SELECT REPLACE(meta_key, '_oembed_', '_oembed_time_') | |
FROM `wp_postmeta` | |
WHERE meta_key LIKE '_oembed_%' AND ( meta_value LIKE '%id="fb-root"%' OR meta_value LIKE '%class="instagram-media"%' ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Exclude some terms form the ElasticPress Facets Widget Filter | |
add_action( | |
'pre_get_terms', | |
function ( $wp_term_query ) { | |
global $wp_query; | |
if ( ! $wp_query->get( 'ep_facet', false ) ) { | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( | |
'ep_weighting_configuration_for_search', | |
function( $weighting_config ) { | |
global $wpdb; | |
$post_meta = get_transient( 'custom_ep_distinct_post_meta' ); | |
if ( ! $post_meta ) { | |
$post_meta = $wpdb->get_col( | |
"SELECT DISTINCT meta_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( | |
'ep_prepare_meta_data', | |
function ( $prepared_meta ) { | |
foreach ( $prepared_meta as $key => $meta_val ) { | |
// Remove empty meta fields. | |
if ( empty( $key ) || empty( $meta_val ) || empty( $meta_val[0] ) ) { | |
unset( $prepared_meta[ $key ] ); | |
continue; | |
} |