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-ie-conditional-comment-syntax-hack.php
Last active December 19, 2015 12:39
[WordPress] @2ndkauboy has a nice hack to conditionally generate an IE legacy stylesheet with SASS and load it conditionally (http://kau-boys.de/1747) (post in German). This solution tweaks WordPress’s syntax for conditional comments accordingly.
<?php
/**
* Read first, otherwise the following will make no sense at all:
* http://kau-boys.de/1747
*
*
* WordPress’s built-in conditional comment syntax allows
* for conditional comments like this:
*
* <!--[if gt IE 8]>
@glueckpress
glueckpress / single-select-form.html
Created July 14, 2013 14:24
Single select form with custom styles and arrow (incl. work-around for Mozilla select arrow bug). Form selector element could also be substituted by a wrapping span or div element for forms with multiple fields.
<form class="ordering" method="get">
<select name="name">
<option value="value">Option</option>
<option value="value">Option</option>
<option value="value">Option</option>
</select>
</form>
@glueckpress
glueckpress / wp-modify-text-strings.php
Last active December 21, 2015 00:19
[WordPress] Modify default (not translated) language strings of a plugin. Beware: Might result in performance issues when applied to many strings.
<?php
/**
* Translate text strings in WordPress programmatically.
*
* Assuming plugin intorduces "Foo_Plugin" class, has text domain "foo-plugin".
*
* @param mixed $translated
* @param mixed $original
* @param mixed $domain
* @return string
@glueckpress
glueckpress / css-only-off-canvas-menu.css
Created January 1, 2014 15:37
CSS-only off-canvas menu, no javascript at all. Requires browser support for :checked pseudo-class and adjacent sibling selector. Fiddle at http://jsfiddle.net/glueckpress/3psut/.
* {
margin: 0;
padding: 0;
}
html,
body,
#page {
height: 100%;
}
p, ul {
@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 / 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 / glckprss-reduce-tags.php
Last active December 14, 2015 21:38
[WordPress] Mini plugin to reduce the number of tags displayed in the Tag Cloud widget.
<?php
/**
* Plugin Name: GlückPress Reduce Tags
* Description: Reduce the number of tags displayed in the tag cloud widget.
* Version: 2014.01
* Author: Caspar Hübinger
* Author URI: http://glueckpress.com/
*
*/
@glueckpress
glueckpress / child-theme-functions.php
Last active December 14, 2015 21:39
[WordPress] Parent/child theme l10n logic.
<?php
/**
* child-theme/functions.php
*
* Loads first, before parent-theme/functions.php.
*/
function child_after_setup_theme() {
load_child_theme_textdomain( 'child-textdomain', get_stylesheet_directory() . '/languages' );
@glueckpress
glueckpress / content-product.php
Last active December 14, 2015 21:39
[WordPress] WooCommerce: Display product variation attributes on product category pages.
<?php
/*
* Regular content of content-product.php
* ...
* ...
*/
/**
* Display product variation attributes on product category pages.
*
@glueckpress
glueckpress / 1-style.scss
Last active February 21, 2016 17:29
SASS/Compass Typo Toolbox: Tackling vertical rhythm.
// A tidy house, a tidy mind.
@import "compass";
@import "numbers";
@import "vertical-rhythm";
@import "math";