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 ( is_user_logged_in() && current_user_can( 'manage_options' ) ) {
define('DONOTCACHEPAGE', true);
}
?>
<?php
if (is_buddypress()){
define('DONOTCACHEPAGE', true);
}
<?php
function show_thumbnail_url ($url, $width=600, $height=300){
return 'http://s.wordpress.com/mshots/v1/'.urlencode($url).'?w='.$width.'&amp;h='.$height.';
}
<?php
add_filter( 'wp', '__rocket_lazyload_if_log' );
function __rocket_lazyload_if_log() {
if (is_user_logged_in ()){
add_filter( 'do_rocket_lazyload', '__return_false' );
}
}
@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');
<?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');
}
<?php
if ( wp_is_mobile() ) {
add_filter( 'do_rocket_lazyload', '__return_false' );
}
?>
<?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
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
function clear_rocket_woocommerce_thankyou( $order_id ) {
// clear Rocket cache
rocket_clean_domain();
};
add_action( 'woocommerce_thankyou', 'clear_rocket_woocommerce_thankyou', 10, 1 );