Skip to content

Instantly share code, notes, and snippets.

View markonikolic985's full-sized avatar

Marko Nikolic markonikolic985

View GitHub Profile
<?php
/**
* Plugin Name: Imagify | Skip &lt;picture&gt; Tag Replacement
* Description: Excludes &lt;img&gt; tags from &lt;picture&gt; tag replacement for WebP display if they have either a data-skip-picture-replacement="yes" attribute or "skip-picture-replacement" class. Can be edited to target other classes for exclusion.
* Plugin URI: https://github.com/wp-media/imagify-helpers/tree/master/optimization/imagify-skip-picture-tag-replacement/
* Author: WP Media
* Author URI: https://wp-media.me/
* Licence: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
# http config block
map $http_accept $webp_ext {
default "";
"~*webp" ".webp";
}
# server config block
location ~* ^(/wp-content/.+)\.(png|jpg)$ {
add_header Vary Accept;
try_files $1$webp_ext $uri =404;
@markonikolic985
markonikolic985 / client.html
Created November 25, 2018 11:54 — forked from diorahman/client.html
Ajax, call jQuery POST to node.js expressjs
<html>
<head>
<title>jsonp test</title>
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
$(function(){
$('#select_link').click(function(e){
e.preventDefault();
console.log('select_link clicked');
/* Disable WP Rocket option 'async_css'. */
add_action( 'wp', function () {
// Stop here if WPR is not active.
if ( ! function_exists( 'get_rocket_option' ) ) {
return false;
}
// Only on front-end.
if ( ! is_admin() ) {
<?php
defined( 'ABSPATH' ) or die( 'Cheatin&#8217; uh?' );
/**
* Plugin Name: WP Rocket | Fix Error 500
* Description: Prevents the dreaded error 500 from appearing.
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
function wp_rocket_clear_user_cache_purchase() {
$user = wp_get_current_user();
rocket_clean_user( $user->ID );
}
add_action( 'woocommerce_payment_complete', 'wp_rocket_clear_user_cache_purchase' );
function wp_rocket_activate_inline_js_minify( $html_options ) {
$html_options['jsMinifier'] = 'rocket_minify_inline_js';
return $html_options;
}
add_filter( 'rocket_minify_html_options', 'wp_rocket_activate_inline_js_minify' );
function wp_rocket_deactivate_inline_css_minify( $html_options ) {
unset( $html_options['cssMinifier'] );
return $html_options;
}
<?php // Do NOT use opening tag!
add_action( 'init', '__deactivate_rocket_cdn_for_logged_in_users_2911' );
function __deactivate_rocket_cdn_for_logged_in_users_2911() {
if ( ! is_user_logged_in() ) {
return;
}
remove_filter( 'template_directory_uri' , 'rocket_cdn_file', PHP_INT_MAX );
remove_filter( 'wp_get_attachment_url' , 'rocket_cdn_file', PHP_INT_MAX );
<?php // Remove the opening tag
remove_filter( 'the_content', 'rocket_lazyload_images', PHP_INT_MAX );
remove_filter( 'widget_text', 'rocket_lazyload_images', PHP_INT_MAX );
remove_filter( 'get_image_tag', 'rocket_lazyload_images', PHP_INT_MAX );
remove_filter( 'post_thumbnail_html', 'rocket_lazyload_images', PHP_INT_MAX );