Skip to content

Instantly share code, notes, and snippets.

Avatar

Marko Nikolic markonikolic985

View GitHub Profile
View webp-rewrite-nginx.conf
# 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 Nov 25, 2018 — forked from diorahman/client.html
Ajax, call jQuery POST to node.js expressjs
View client.html
<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');
View wp-rocket-disable-async-css.php
/* 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() ) {
View wp-rocket-browser-cache-removal.php
<?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
*/
View gist-23.php
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' );
View wp-rocket-deactivate-inline-css.php
function wp_rocket_deactivate_inline_css_minify( $html_options ) {
unset( $html_options['cssMinifier'] );
return $html_options;
}
View wp-rocket-activate-inline-js.php
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' );
View wprocket-exclude-cdn-logged-in.php
<?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 );
View lazyload-gravatars-only.php
<?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 );
View wprocket-exclude-cpt-from-cache.php
<?php
/**
* Plugin Name: WP Rocket | Disable Page Caching for Specific Custom Post Type
* Description: Disable WP Rocket’s page cache for Specific Custom Post Type.
* Author: your name here
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
defined( 'ABSPATH' ) or die( 'Cheatin&#8217; uh?' );
You can’t perform that action at this time.