Skip to content

Instantly share code, notes, and snippets.

Avatar

Caspar Hübinger glueckpress

View GitHub Profile
View ciao.md

Find me at @casparhubinger

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

@glueckpress
glueckpress / press-this-custom-terms.php
Last active Sep 14, 2019
[WordPress][Press This] Sets a custom default post format and category for post drafts saved via PressThis.
View press-this-custom-terms.php
<?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 Sep 17, 2019
[WordPress][Block Lab] Static Google Map block
View block-map.php
<?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
[WordPress][IndieWeb] Customise relme list of the IndieWeb plugin.
View wordpress-indieweb-custom.php
<?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 Aug 27, 2018
[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.
View site-wide-top-banner.php
<?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 Aug 16, 2018
[WordPress][Imagify] Quick and dirty solution to programmatically hides Imagify’s admin bar menu.
View imagify-hide-admin-menu.php
<?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 );
}
View comment-without-ip.php
<?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 Apr 5, 2018
[WordPress][WP Rocket] Add browser caching rule to .htaccess; example: zero browser caching for PDF files
View wp-rocket-no-browser-caching-pdf.php
<?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 Mar 5, 2019
[WordPress][WP Rocket] Barely tested hack to exclude a file from defer JS only, without having to exclude it from minification.
View wp-rocket-exclude-from-defer-only.php
<?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 Mar 2, 2018
[WordPress] Function to check if a post (ID) has a more link.
View wp-maybe-has-more-link.php
You can’t perform that action at this time.