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
// place the code in the child theme functions.php or a custom code snippets plugin, like FluentSnippets | |
// Define the coupon discount rate | |
define('COUPON_DISCOUNT_RATE', 10); // 10% discount | |
// Enqueue custom script for exit intent detection | |
function enqueue_exit_intent_script() { | |
if (is_cart() || is_checkout()) { | |
?> |
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
/* I'll put here different examples of dynamic query for Oxygen repeater : | |
* - Use one of the following repeater_dynamic_query definitions | |
* in code block just BEFORE the repeater | |
* - Set the repeater custom query settings : post type, number of posts, order... | |
* - Add the remove_action in a code block AFTER the repeater | |
*/ | |
/**************************************************************************************************** | |
* Display related posts for any CPT with taxonomy: |
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 App\Rules; | |
use Illuminate\Http\Request; | |
use Illuminate\Cache\RateLimiter; | |
use Illuminate\Contracts\Validation\Rule; | |
class Throttle implements Rule | |
{ |
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 | |
//Allows to skip multiple directories, as specified in array | |
add_filter( 'wp_smush_image', 'filter_by_directory', '', 2 ); | |
function filter_by_directory( $smush, $id ) { | |
$file_path = get_attached_file( $id ); | |
//List of directories to be ignored | |
$dirs = array( | |
'uploads/2016/11', | |
'uploads/2017/01' | |
); |
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
# SELECT any post_status | |
SELECT meta_value,COUNT(meta_value),GROUP_CONCAT(DISTINCT post_id ORDER BY post_id SEPARATOR ',') post_id | |
FROM wp_postmeta | |
WHERE meta_key = '_sku' | |
AND meta_value != '' | |
GROUP BY meta_value HAVING COUNT(meta_value) > 1 | |
# SELECT only from products that are already published or in draft | |
SELECT meta_value,COUNT(meta_value),GROUP_CONCAT(DISTINCT post_id ORDER BY post_id SEPARATOR ',') post_id | |
FROM wp_postmeta |
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 | |
require dirname(__FILE__).'/wp-blog-header.php'; | |
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')"); | |
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'"); | |
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)"); | |
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))"); | |
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))"); | |
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')"); |