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 this to your `functions.php` or (preferably) to a plugin: | |
function featured_products_orderby( $orderby, $query ) { | |
global $wpdb; | |
if ( 'featured_products' == $query->get( 'orderby' ) ) { | |
$featured_product_ids = (array) wc_get_featured_product_ids(); | |
if ( count( $featured_product_ids ) ) { | |
$string_of_ids = '(' . implode( ',', $featured_product_ids ) . ')'; | |
$orderby = "( {$wpdb->posts}.ID IN {$string_of_ids} ) " . $query->get( 'order' ); |
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: ElasticPress - Custom Query Boosting | |
* Description: Add Boosting query to ElasticPress | |
* Version: 1.0.0 | |
* Author: 10up | Felipe Elia | |
* Author URI: https://10up.com/ | |
* Text Domain: elasticpress-custom-query-boosting | |
* Domain Path: /languages | |
* |
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: ClassifAI and Polylang | |
* Description: Compatibility layer between the ClassifAI plugin and Polylang | |
* Version: 1.0.0 | |
* Author: Felipe Elia | |
* Author URI: https://felipeelia.dev/ | |
* Text Domain: felipeelia-classifai | |
* Domain Path: /languages | |
* |
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
let autosuggestTotal = 0; | |
const autosuggestDataFilter = (data) => { | |
autosuggestTotal = data?.hits?.total || 0; | |
return data; | |
} | |
wp.hooks.addFilter('ep.Autosuggest.data', 'myTheme/autosuggestDataFilter', autosuggestDataFilter); | |
const autosuggestListHTMLFilter = (listHTML, options, input) => { | |
const allUrl = new URL(input.form.action); |
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
/** | |
* This code should be added to functions.php of your theme | |
**/ | |
function my_woocommerce_catalog_orderby( $args ) { | |
$args['meta_key'] = '_stock_status'; | |
$args['orderby'] = array( 'meta_value' => 'ASC', 'date' => 'DESC' ); | |
return $args; | |
} | |
add_filter( 'woocommerce_get_catalog_ordering_args', 'my_woocommerce_catalog_orderby' ); |
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 | |
/** | |
* Sync and search for Media (attachment) posts in WordPress. | |
* It is NOT to be used with the ElasticPress's Documents feature | |
*/ | |
/** | |
* Add the attachment post type to be indexable and searchable | |
* | |
* @param array $post_types Post types |
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
Show hidden characters
{ | |
// Hit ctrl+P and select Snippets: Configure User Snippets | |
// New Global Snippets file | |
// Add `global-snippets` as the name and copy this file contents in it | |
// Go to the commit box, start typing `git_co_authored_by`, hit ctrl+space and select this snippet | |
"Git Co-authored-by": { | |
"prefix": "git_co_authored_by", | |
"body": [ | |
"", | |
"", |
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 | |
// Remove acentos e espaços dos arquivos no upload | |
function custom_sanitize_file_name ( $filename ) { | |
$filename = remove_accents( $filename ); | |
$filename = strtolower( $filename ); | |
$file_parts = pathinfo( $filename ); | |
$new_filename = sanitize_title( $file_parts['filename'] ); | |
if ( ! empty( $file_parts['extension'] ) ) { |
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 ); |
NewerOlder