Skip to content

Instantly share code, notes, and snippets.

View jbma's full-sized avatar

Jean-Baptiste Marchand-Arvier jbma

View GitHub Profile
<?php
if (isset($_GET['min_price']) or isset($_GET['max_price']) ){
define('DONOTCACHEPAGE', true);
}
<?php
add_filter( 'rocket_minify_excluded_external_js', '__fix_wprocket_excluded_external_js' );
function __fix_wprocket_excluded_external_js( $external_js ) {
$external_js[] = 'ir-de.amazon-adsystem.com';
return $external_js;
}
<?php
if( current_user_can('administrator') ){
define('DONOTCACHEPAGE', true);
}
<?php
add_filter( 'rocket_minify_excluded_external_js', '__fix_wprocket_excluded_external_js' );
function __fix_wprocket_excluded_external_js( $external_js ) {
$external_js[] = 'google.com';
return $external_js;
}
<?php
function clear_rocket_woocommerce_thankyou( $order_id ) {
// clear Rocket cache
rocket_clean_domain();
};
add_action( 'woocommerce_thankyou', 'clear_rocket_woocommerce_thankyou', 10, 1 );
<?php
function clear_rocket_woocommerce_thankyou( $order_id ) {
// code to retrieve the products id from the $order_id
// should return an array of ids of the orders names $products_id
//empty in this exemple
$products_id = array();
<?php
remove_action( 'user_register', 'rocket_clean_domain' );
remove_action( 'profile_update', 'rocket_clean_domain' );
remove_action( 'deleted_user', 'rocket_clean_domain' );
remove_action( 'wp_update_nav_menu', 'rocket_clean_domain' );
remove_action( 'update_option_theme_mods_' . get_option( 'stylesheet' ), 'rocket_clean_domain' );
remove_action( 'update_option_sidebars_widgets', 'rocket_clean_domain' );
remove_action( 'update_option_category_base', 'rocket_clean_domain' );
remove_action( 'update_option_tag_base' , 'rocket_clean_domain' );
remove_action( 'permalink_structure_changed', 'rocket_clean_domain' );
<?php
if ( wp_is_mobile() ) {
add_filter( 'do_rocket_lazyload', '__return_false' );
}
?>
<?php
add_action( 'wp_enqueue_scripts', 'test_register_script' );
function test_register_script(){
wp_enqueue_script( 'test', get_template_directory_uri().'/js/test.js', false, '2.10.3');
}
@jbma
jbma / gist:19e6f8a8481b46fb75ee
Created January 3, 2016 09:34
disable-src-set-wp
add_filter('wp_get_attachment_image_attributes', function($attr) {
if (isset($attr['sizes'])) unset($attr['sizes']);
if (isset($attr['srcset'])) unset($attr['srcset']);
return $attr;
}, PHP_INT_MAX);
add_filter('wp_calculate_image_sizes', '__return_false', PHP_INT_MAX);
add_filter('wp_calculate_image_srcset', '__return_false', PHP_INT_MAX);
remove_filter('the_content', 'wp_make_content_images_responsive');