Skip to content

Instantly share code, notes, and snippets.

Avatar

Caspar Hübinger glueckpress

View GitHub Profile
@glueckpress
glueckpress / wp-rocket-disable-inline-css-minify.php
Created Dec 21, 2017
[WordPress][WP Rocket] Disable minification of inline CSS when Minify HTML is enabled.
View wp-rocket-disable-inline-css-minify.php
<?php
/**
* Disables Minify for inline CSS.
* https://github.com/wp-media/wp-rocket/blob/v2.11.3/inc/front/minify.php#L72
*/
add_filter( 'rocket_minify_html_options', function ( $html_options ) {
$html_options = array();
return $html_options;
@glueckpress
glueckpress / wp-rocket-critical-css-params.php
Created Dec 15, 2017
[WordPress][WP Rocket] As of 2.11, WP Rocket generates critical CSS automatically. Here’s how to adjust parameters for maximum viewport width and height.
View wp-rocket-critical-css-params.php
<?php
/**
* Customise parameters for critical CSS generator.
*/
add_filter( 'rocket_cpcss_job_request', function ( $item ) {
return array(
'url' => $item['url'],
'mobile' => 0, // 1 = Emulate a mobile device
'viewport_width' => 1300 // px maximum width of the viewport
'viewport_height' => 900 // px maximum height of the viewport
@glueckpress
glueckpress / wp-rocket-remove-cache-options-meta-box.php
Last active Jun 14, 2020
[WordPress][WP Rocket] Remove Cache Options meta box from Edit screens.
View wp-rocket-remove-cache-options-meta-box.php
<?php
/**
* PLEASE SEE COMMENT BELOW:
* https://gist.github.com/glueckpress/0fcd12a8ada43e37e400facd987016a1#gistcomment-3009533
*/
defined( 'ABSPATH' ) or die();
/**
* Plugin Name: WP Rocket | Remove Cache Options Meta Boxx
* Description: Removes the Cache Options meta box from Edit screens.
* Author: Caspar Hübinger
@glueckpress
glueckpress / exclude
Last active Oct 29, 2020
[git] Exclude .gitignore and all of WordPress, except specified directories
View exclude
# Sample of .git/info/exclude
# Documentation: https://git-scm.com/docs/gitignore
# Exclude .gitignore file.
# If an initial .gitignore file has been added to the repo,
# you might have to delete it first and sync the change.
# Then create a new one which will be excluded according to this rule.
.gitignore
# Exclude all of WordPress, but keep these directories synced:
@glueckpress
glueckpress / wp-rocket-debug-minify-options.php
Created Nov 29, 2017
[WordPress][WP Rocket] Print values of minify options as HTML comments to wp_footer().
View wp-rocket-debug-minify-options.php
<?php
/**
* Quick and dirty addition to:
* https://github.com/wp-media/wp-rocket-helpers/tree/master/wp-rocket-debug-helper
*/
add_action( 'wp_footer', function () {
if ( ! function_exists( 'get_rocket_option' ) ) {
return;
}
@glueckpress
glueckpress / wp_rocket__wp_get_attachment_image__lazyload.php
Last active Jan 6, 2020
[WordPress][WP Rocket] [deprecated] Wrapper function: Applies WP Rocket’s LazyLoad to wp_get_attachment_image()
View wp_rocket__wp_get_attachment_image__lazyload.php
<?php
/**
* Wrapper function: Applies WP Rocket’s LazyLoad to wp_get_attachment_image()
*
* @link https://developer.wordpress.org/reference/functions/wp_get_attachment_image/
* @link https://github.com/wp-media/wp-rocket/blob/v2.10.9/inc/front/lazyload.php#L24-L47
*
* @param int $attachment_id (Required) Image attachment ID.
* @param string|array $size (Optional) Image size. Accepts any
* valid image size, or an array of width
@glueckpress
glueckpress / shoo.php
Created Jul 24, 2017
[WordPress] Plugin or MU plugin: Sends an HTTP status of 403 when a login has failed. Idea previously published by Sergej Müller.
View shoo.php
<?php
defined( 'ABSPATH' ) && function_exists( 'add_action' ) or exit;
/**
* Plugin Name: Shoo
* Plugin URI: https://gist.github.com/glueckpress/3a15c8a070f9451c18e10f6d6e76c56d
* Description: Sends an HTTP status of 403 when a login has failed. Idea previously <a href="https://plus.google.com/u/0/110569673423509816572/posts/T1gnqbiYjZZ">published by Sergej Müller</a>.
* Version: 0.0.2
* Author: Caspar Hübinger
* Author URI: https://profiles.wordpress.org/glueckpress
* License: GNU General Public License v3
@glueckpress
glueckpress / simple-map-defer.php
Last active Apr 28, 2019
[WordPress][Simple Map] Load Google Maps API script from Simple Map deferred.
View simple-map-defer.php
<?php
defined( 'ABSPATH' ) or die( 'No direct access here.' );
/**
* Plugin Name: Simple Map | Defer
* Description: Makes sure Google Maps API script from <a href="https://wordpress.org/plugins/simple-map/">Simple Map</a> gets loaded deferred.
* Author: Caspar Hübinger
* Author URI: https://profiles.wordpress.org/glueckpress
* Plugin URI: https://gist.github.com/glueckpress/56c88900aad391b95b5d44f4e752a1a4
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
@glueckpress
glueckpress / wp-rocket-is-preload.php
Created Apr 27, 2017
[WordPress][WP Rocket] Check if a visitor is WP Rocket’s preload user agent.
View wp-rocket-is-preload.php
<?php
/**
* More about WP Rocket’s preload options in this document:
* @link http://docs.wp-rocket.me/article/8-how-the-cache-is-preloaded
*/
/**
* Check if a visitor is WP Rocket’s preload user agent (bot or sitemap).
* This will trigger only on a document that has not been cached yet.
*
@glueckpress
glueckpress / ama-42.php
Created Feb 8, 2017
[WordPress] Ask me anything on post #42. Auto-approves comments and replies automatically on post ID 42 until a given date. CUSTOM EDITS REQUIRED!
View ama-42.php
<?php
/**
* Plugin Name: AMA 42
* Description: Ask me anything on post 42.
* Version: 2017-02-08
* Author: Caspar Hübinger
* Author URI: https://profiles.wordpress.org/glueckpress
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
You can’t perform that action at this time.