Skip to content

Instantly share code, notes, and snippets.

View glueckpress's full-sized avatar
🚫
Discontinued

Caspar Hübinger glueckpress

🚫
Discontinued
View GitHub Profile
@glueckpress
glueckpress / exclude-categories-from-ajacent-posts.php
Last active July 13, 2026 17:49
[WordPress] Mini plugin to exclude any given categories from queries and widgets. The first file is not part of the plugin, but is included to demonstrate the differences in applying $query->set() instead its wrapper function set_query_var().
<?php
/**
* Exclude categories from prev/next post links.
*
* $exclude (array) - category slugs to retrieve IDs from
* $excluded (array) - category IDs to be excluded
*/
$exclude = array();
$excluded = array();
@glueckpress
glueckpress / remove-file-versions-from-scripts.php
Last active April 20, 2026 12:05
[WordPress] Removes version queries from script/stylesheet calls in WordPress, but keeps query of google font stylesheets.
<?php
/**
* Removes file version queries from script/stylesheet calls.
* http://wordpress.stackexchange.com/a/96325/23011
*
* Enhanced to keep query of google font stylesheets:
* Removes “?ver=3.5.1” from http://domain.tld/wp-content/themes/theme/stlye.css?ver=3.5.1
* Leaves http://fonts.googleapis.com/css?family=MyFont untouched.
*/
add_filter( 'script_loader_src', 'gp130419_remove_script_version', 15, 1 );
$colours:
"red" #FF0000,
"blue" #001EFF,
"green" #00FF00,
"yellow" #F6FF00;
@each $i in $colours{
.#{nth($i, 1)}-background {
background: nth($i, 2);
}
@glueckpress
glueckpress / wp-rocket-disable-preload.php
Last active August 15, 2025 20:25
[WordPress][WP Rocket] Prevents WP Rocket’s preload bot from visiting your site.
<?php
/**
* Plugin Name: WP Rocket | Disable Cache Preloading
* Description: Prevents WP Rocket’s preload bot from visiting your site.
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* Plugin URI: https://gist.github.com/glueckpress/a6c1f7a22a92e8e8bb10
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
@glueckpress
glueckpress / px-rem-cheat-sheet.css
Created May 26, 2013 16:17
Cheat sheet for rem-calculations based upon 14px and 16px.
/*! = $rembase: 14px
--------------------------------------------------------------
* hmtl { font-size: 87.5%; }
* body { font-size: 14px; font-size: 1rem; line-height: 1; }
* 4px 0.28571429rem
* 8px 0.571428571rem
* 12px 0.857142857rem
* 13px 0.928571429rem
* 14px 1rem
* 16px 1.142857143rem
@glueckpress
glueckpress / no-comment.php
Last active February 21, 2025 18:16
[WordPress] This plugin started as a Gist, but can now be found at https://github.com/glueckpress/no-comment.
<?php
/**
* Plugin Name: No Comment
* Description: A plugin to close, disable and remove comments from the WordPress admin UI.
* Version: 0.1
* 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 / GitHub-Desktop-Bitbucket.md
Last active February 6, 2025 13:18
[How-to] Use GitHub Desktop to clone and commit to a Bitbucket repository just as you would with any GitHub repository. (Mac)

⚠️ Note: this guide is from 2016 – a long time on the internet. Content may be outdated, check the comments for more recent info.


Clone Bitbucket Repository and Add it to GitHub Desktop App (Mac)

You can’t clone a Bitbucket repo using GithHub Desktop directly. Instead you would have to:

  1. Clone the Bitbucket repo locally via command line.
  2. Add the cloned repository to your GitHub Desktop app.
@glueckpress
glueckpress / exclude
Last active November 17, 2024 10:42
[git] Exclude .gitignore and all of WordPress, except specified directories
# 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 / jquery.indexlist.js
Created July 31, 2012 15:17
Create a clickable index list from all heading elements on a page.
/*
* Assuming your post/page content happens in .entry-content and you structured it semantically using h3 elements,
* these functions will create a clickable index list at the top of your content.
* Modify hard-coded selectors as you see fit; I used .indexlist for the ul element,
* .indexitem for each li item and h3 elements within .entry-content to create the list items from.
*/
$.fn.inlineScrolling = function(options) {
return this.each(function(event) {
@glueckpress
glueckpress / woocommerce-delete-customer-ip.php
Created January 9, 2014 15:29
Snippet to clear customer IP address when order is sent. #woocommerce #wordpress
<?php
/**
* Snippet for deleting the customer IP address from WooCommerce orders.
* Important for Trusted Shops® certificates in Germany.
*/
add_action( 'woocommerce_checkout_update_order_meta', 'mp1401091554', 1 );
function mp1401091554( $order_id ) {
update_post_meta(
$order_id,
'_customer_ip_address',