Skip to content

Instantly share code, notes, and snippets.

View glueckpress's full-sized avatar

Caspar Hübinger glueckpress

View GitHub Profile

Find me at @casparhubinger

I retired my @glueckpress GitHub account. My active account is @casparhubinger.

@glueckpress
glueckpress / press-this-custom-terms.php
Last active September 14, 2019 05:44
[WordPress][Press This] Sets a custom default post format and category for post drafts saved via PressThis.
<?php
/**
* Plugin Name: Press This | Default Terms
* Description: Sets a custom default post format and category for post drafts saved via Press This.
* Version: 0.0.2
* Author: Caspar Hübinger
* Author URI: http://glueckpress.com/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
@glueckpress
glueckpress / block-map.php
Last active September 17, 2019 15:29
[WordPress][Block Lab] Static Google Map block
<?php
/**
* Block: Map
* Description: Generates a static map image via Google Static Maps API.
*
* @see https://staticmapmaker.com/google/
* @see https://github.com/getblocklab/block-lab
* ----------------------------------------
* Block config:
* ----------------------------------------
@glueckpress
glueckpress / wordpress-indieweb-custom.php
Created May 5, 2019 14:03
[WordPress][IndieWeb] Customise relme list of the IndieWeb plugin.
<?php
/**
* Plugin Name: IndieWeb | Customisations
* Description: Customises relme list of the IndieWeb plugin.
* Version: 2019.01
* Author: Caspar Hübinger
* Author URI: http://glueckpress.com/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
@glueckpress
glueckpress / site-wide-top-banner.php
Created August 27, 2018 10:02
[WordPress][plugin] Adds an optional site-wide top banner to the website, editable via Posts screen. Requires a custom hook in a (child) theme template.
<?php
/**
* Plugin Name: Site-wide Top Banner
* Description: Adds an optional site-wide top banner to the website, editable via Posts screen. Requires a custom hook in your theme’s header.php: <code>&lt;?php do_action( 'site_wide_top_banner' ); ?&gt;</code>
* Version: 0.1.0
* Author: Caspar Hübinger
* Author URI: https://profiles.wordpress.org/glueckpress/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
@glueckpress
glueckpress / imagify-hide-admin-menu.php
Created August 16, 2018 09:36
[WordPress][Imagify] Quick and dirty solution to programmatically hides Imagify’s admin bar menu.
<?php
/**
* Quick and dirty solution to programmtically hides Imagify’s admin bar menu. (Sorry, Grégory!)
* Caveats: Visual option on settings page gets overriden; some visual indicator should make this clear for users!
*/
add_action( 'imagify_loaded', function () {
if ( 0 !== get_imagify_option( 'admin_bar_menu' ) ) {
update_imagify_option( 'admin_bar_menu', 0 );
}
<?php
/**
* Plugin Name: Comment without IP
* Plugin URI: https://gist.github.com/glueckpress/74710e5954f12f4da164f810b7976529
* Description: Removes a commenter’s IP address from new comments.
* Version: 0.0.1
* Author: Caspar Hübinger
* Author URI: https://profiles.wordpress.org/glueckpress
* License: GNU General Public License v3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
@glueckpress
glueckpress / wp-rocket-no-browser-caching-pdf.php
Created April 5, 2018 08:51
[WordPress][WP Rocket] Add browser caching rule to .htaccess; example: zero browser caching for PDF files
<?php
/**
* Zero browser caching for PDF files.
*/
add_filter( 'rocket_htaccess_mod_expires', function ( $rules ) {
$rules .= '# Expires headers for PDF' . PHP_EOL;
$rules .= '<IfModule mod_expires.c>' . PHP_EOL;
$rules .= 'ExpiresByType application/pdf "access plus 0 seconds"' . PHP_EOL;
$rules .= '</IfModule>' . PHP_EOL . PHP_EOL;
@glueckpress
glueckpress / wp-rocket-exclude-from-defer-only.php
Last active October 19, 2022 07:51
[WordPress][WP Rocket] Barely tested hack to exclude a file from defer JS only, without having to exclude it from minification.
<?php
/**
* WP Rocket:
* 1. Customise order of minification and defer operations.
* 2. Exclude file from defer JS only (still minified).
*
* Tested rudimentary with WP Rocket 2.11.7 and 3.0.x.
* Test before using this in production!
*/
add_action( 'wp_rocket_loaded', function () {
@glueckpress
glueckpress / wp-maybe-has-more-link.php
Created March 2, 2018 10:52
[WordPress] Function to check if a post (ID) has a more link.