Skip to content

Instantly share code, notes, and snippets.

View glueckpress's full-sized avatar

Caspar Hübinger glueckpress

View GitHub Profile
@glueckpress
glueckpress / wp-rocket-custom-cron-script.php
Last active January 14, 2020 07:12
[WordPress][WP Rocket] Blue print for a custom cron job script. Clears WP Rocket’s cache and calls its preload bot.
<?php
/**
* Clears the global cache and calls WP Rocket’s preload bot.
* Place this file in your WordPress root directory (where wp-config.php and wp-load.php are located).
*/
require( 'wp-load.php' );
if( ! function_exists( 'rocket_clean_home' ) || ! function_exists( 'run_rocket_bot' ) || ! function_exists( 'get_rocket_option' ) )
return;
@glueckpress
glueckpress / .htaccess
Last active April 28, 2019 12:15 — forked from Zodiac1978/.htaccess
[WordPress] Security-related sort of stuff. **REVIEW AND EDIT BEFORE COPY-PASTING!**
# Don’t show errors which contain full path diclosure (FPD)
# Use that line only if PHP is installed as a module and not per CGI
# try using a php.ini in that case.
# CHANGE mod_php5.c TO mod_php7.c IF YOU RUN PHP7.
<IfModule mod_php5.c>
php_flag display_errors Off
</IfModule>
# Protect XMLRPC (needed for apps, offline blogging tools, pingback, etc.)
# If you use that, these tools will not work anymore
@glueckpress
glueckpress / wp-rocket-unlazyload-essential-grid.php
Created August 11, 2016 09:13
[WordPress][WP Rocket] Programmatically disables WP Rocket’s LazyLoad feature on pages with Essential Grid.
<?php
/**
* Plugin Name: WP Rocket | UnLazyLoad Essential Grid
* Description: Disables WP Rocket’s LazyLoad feature on pages with <a href="https://www.themepunch.com/portfolio/essential-grid-wordpress-plugin/">Essential Grid</a>.
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* Plugin URI: http://docs.wp-rocket.me/article/139-disable-lazyload-on-mobile#inactive
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
@glueckpress
glueckpress / wp-rocket-tve-compatibility.php
Created August 10, 2016 18:17
[WordPress][WP Rocket] Compatibility fix for WP Rocket and Thrive Visual Editor. Requires a to-be-implemented filter named “tve_dash_is_crawler” in TVE.
<?php
defined( 'ABSPATH' ) or die( 'No direct access here.' );
/**
* Plugin Name: WP Rocket | Thrive Visual Editor Compatibility
* Description: Fixes compatibility between WP Rocket and Thrive Visual Editor as of version ________ and higher.
* Author: WP Rocket Support Team (Caspar)
* 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
*/
@glueckpress
glueckpress / wp-rocket-example-deactivate-for-amp.php
Last active March 5, 2019 21:15
[WordPress][WP Rocket]Disable all WP Rocket functions on AMP pages created by the Automattic AMP plugin.
<?php
/**
* UNTESTED EXAMPLE!
* Please don’t use in production without having tested it before!
* @link http://wordpress.stackexchange.com/a/12165
* @return void
*/
function example__disable_rocket_cache_for_amp_pages() {
if ( ! defined( 'AMP_QUERY_VAR' ) )
return;
@glueckpress
glueckpress / wp-rocket-cpt-clean-posts-cache-example.php
Last active April 8, 2022 19:49
[WordPress][WP Rocket]Clear the cache only for certain pages when a new post of a certain custom post type is published, deleted or changed
<?php
/**
* UNTESTED EXAMPLE!
* Please don’t use in production without having tested it before!
* @param integer $post_id Current post ID
* @return integer Current post ID
*/
function example__cpt_clean_posts_cache( $post_id ) {
$post = get_post( $post_id );
@glueckpress
glueckpress / apple-macbook-wlan-passwort-nicht-gespeichert.md
Created July 25, 2016 06:49
[Mac] Problem: Nach der Migration auf einen neuen Mac merkt sich das System keine WLAN-Passwörter mehr. Lösung: System-Schlüsselbund im Recovery-Mode wieder beschreibbar machen.

Problem: Schlüsselbund „System“ blockiert

Nach der Migration der Benutzerdaten auf ein neues MacBook werden WLAN-Passwörter nicht mehr gespeichert.

Irgendwas scheint mit den Rechten des Schlüsselbunds System nicht zu stimmen. Die neuen WLAN-Passwörter werden dort nicht gespeichert, und auch das manuelle Hinzufügen eines Objekts klappt nicht, obwohl das Passwort zur Administration korrekt eingegeben wurde.

Lösung

1: https://discussions.apple.com/message/29960505#29960505
2: http://www.hillenius.com/blog/2016/02/fixing-the-el-capitan-keychain-error-100001/index.html

@glueckpress
glueckpress / wp-rocket-events-calendar-minify-fix.php
Last active October 6, 2017 13:41
[WordPress][WP Rocket] Compatibility for Modern Tribe’s Events Calendar plugin. Programmatically deactivates minification for events posts, events archives, events taxonomy pages, and posts/pages containing events shortcodes.
<?php
defined( 'ABSPATH' ) or die( 'You know better.' );
/**
* Plugin Name: WP Rocket | Events Calendar Minification Fix
* Description: Compatibility for <a href="https://wordpress.org/plugins/the-events-calendar/">Events Calendar</a>. Programmatically deactivates minification for events posts, events archives, events taxonomy pages, and posts/pages containing events shortcodes.
* Author: WP Rocket Support Team (Caspar)
* Author URI: http://wp-rocket.me/
* Plugin URI: https://gist.github.com/glueckpress/7cd7dc442c90b75aeb84f09f9af1a2db
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
@glueckpress
glueckpress / wp-rocket-dequeue-retina-js.php
Created June 14, 2016 12:19
[WordPress][WP Rocket] Dequeues retina.js from being loaded in order to prevent 404 errors for transparent GIFs used by WP Rocket’s LazyLoad feature. Requires correct script handle; default: retina.
<?php
/**
* Plugin Name: WP Rocket | Dequeue Retina.js
* Description: Dequeues retina.js from being loaded in order to prevent 404 errors for transparent GIFs used by WP Rocket’s LazyLoad feature. Requires correct script handle; default: <code>retina</code>.
* Version: 0.1
* Author: Caspar Hübinger
* Author URI: https://profiles.wordpress.org/glueckpress
* Plugin URI: https://gist.github.com/glueckpress/fbff2f3af0b0fafed2f41bacbe25ecb0
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
@glueckpress
glueckpress / wp-rocket-instapage.php
Created June 9, 2016 10:03
[WordPress][WP Rocket] Adds support of WP Rocket’s clear cache functionality for Instapage post.
<?php
/**
* Plugin Name: WP Rocket | Instapage
* Description: Adds support of WP Rocket’s clear cache functionality for <a href="https://wordpress.org/plugins/instapage/">Instapge posts</a>.
* Version: 0.1
* Author: WP Rocket Support Team (Caspar)
* Author URI: http://wp-rocket.me/
* Plugin URI: https://gist.github.com/glueckpress/5064440253c3e57a0dcbf7b5c5da7c3c
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html