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 | |
/** | |
* Plugin Name: REST API - Post list randomize | |
* Description: Randomize the content list in REST API passing `orderby=rand` as parameter. | |
* Version: 1.0.0 | |
* Author: Felipe Elia | Codeable | |
* Author URI: https://codeable.io/developers/felipe-elia?ref=qGTOJ | |
*/ | |
/** |
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; | |
} |
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 | |
/** | |
* Função para exibir paginação | |
* | |
* @param WP_Query $query Query que deverá ser paginada. | |
* @param integer $range Quantidade de páginas ao redor da página atual. | |
* @param string $get_param Nome do parâmetro em `$_GET` com o número da página atual. | |
* @return string HTML com a paginação | |
*/ | |
function starter_pagination( $query = null, $range = 2, $get_param = null ) { |
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 | |
/** | |
* Since ElasticPress 4.0, thumbnails are indexed in a separate field. | |
*/ | |
add_filter( | |
'ep_post_formatted_args', | |
function ( $formatted_args ) { | |
if ( empty( $_GET['has_image'] ) ) { | |
return $formatted_args; | |
} |
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 | |
/** | |
* This is a set of functions that can be used to debug | |
* the dynamic sync made by ElasticPress | |
* | |
* phpcs:disable WordPress.PHP.DevelopmentFunctions -- Reason: the whole purpose of the file is to use error_log(). | |
* | |
* @package ElasticPress_Custom | |
*/ |
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 the ngram analyzer if not added yet by autosuggest. | |
* | |
* @param array $mapping The mapping array. | |
* @return array | |
*/ | |
function ep_custom_add_edge_ngram_analyzer( $mapping ) { | |
if ( ! @isset( $mapping['settings']['analysis']['analyzer']['edge_ngram_analyzer'] ) ) { | |
$mapping['settings']['analysis']['analyzer']['edge_ngram_analyzer'] = array( |
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 compatibility between ElasticPress and WooCommerce Customer/Order/Coupon Export. | |
*/ | |
add_filter( | |
'ep_sync_taxonomies', | |
function ( $taxonomies ) { | |
if ( class_exists( '\SkyVerge\WooCommerce\CSV_Export\Taxonomies_Handler' ) ) { | |
$taxonomies[] = \SkyVerge\WooCommerce\CSV_Export\Taxonomies_Handler::TAXONOMY_NAME_ORDERS; |
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 | |
/* | |
* Part of this comment in the ElasticPress repository | |
* | |
* @see https://github.com/10up/ElasticPress/issues/2073#issuecomment-776155310 | |
*/ | |
add_filter( 'epwr_boost_mode', function() { return 'multiply'; } ); | |
add_filter( 'epwr_offset', function() { return '15d'; } ); | |
add_filter( 'epwr_scale', function() { return '30d'; } ); | |
add_filter( 'epwr_decay', function() { return 0.5; } ); |
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 | |
/** | |
* 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 |