Skip to content

Instantly share code, notes, and snippets.

View glueckpress's full-sized avatar

Caspar Hübinger glueckpress

View GitHub Profile
@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 / 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',
@glueckpress
glueckpress / wp-rocket-remove-cache-options-meta-box.php
Last active October 5, 2023 09:54
[WordPress][WP Rocket] Remove Cache Options meta box from Edit screens.
<?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 / GitHub-Desktop-Bitbucket.md
Last active June 20, 2023 08:16
[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-categories-from-ajacent-posts.php
Last active June 6, 2023 08:32
[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 / footnote.html
Last active March 23, 2023 19:48
HTML footnotes. Click on anchor #a(n): skips down to anchor #f(n) inside footnote. Click on anchor #f(n) inside footnote: skips back up to anchor #a(n).
<!-- Line-breaks suiting auto-p in WordPress: -->
Paragraph with a footnote<a id="a1" href="#f1"><sup>[1]</sup></a> and more text afterwards.
Another paragraph with another footnote<a id="a2" href="#f2"><sup>[2]</sup></a> and more text afterwards.
<!-- At the end of all paragraphs: -->
<footer class="footnotes">
<a id="f1" href="#a1">[1]</a> Footnote #1 here.
@glueckpress
glueckpress / exclude
Last active January 4, 2023 17:57
[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 / sample-admin-notice.php
Last active October 30, 2022 15:03
[WordPress] Sample Admin Notices
<?php
defined( 'ABSPATH' ) or die( 'Poop.' );
/**
* Plugin Name: _Sample Admin Notice
* Description: Displays a sample admin notice once for admins. (Requires PHP 5.3+.)
* Version: 0.1
* Author: Caspar Hübinger
* Plugin URI: https://gist.github.com/glueckpress/6befeb937da89025d4d8#file-sample-admin-notice-php
* Author URI: https://profiles.wordpress.org/glueckpress
* License: GNU General Public License v3
@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 / multisite-custom-my-sites-menu-titles.php
Last active September 1, 2022 20:50
[WordPress] Custom site titles for the My Sites network admin bar menu in a multisite network. Configure first function, then auto-activate by saving this file in wp-content/mu-plugins, or network activate as a regular plugin.
<?php
/**
* Plugin Name: Custom My Sites Menu Titles
* Description: Custom site titles for the My Sites network admin bar menu. Multisite only.
* Version: 2015.11
* 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
*/