Skip to content

Instantly share code, notes, and snippets.

View glueckpress's full-sized avatar

Caspar Hübinger glueckpress

View GitHub Profile
@glueckpress
glueckpress / hmn.md.is.tabs.align.js
Created January 5, 2015 09:57
Vertically align team member content to clicked ui tabs on Human Made’s team page (http://hmn.md/is/).
/**
* Vertically align team member content to clicked ui tabs.
*
* @link http://hmn.md/is/
*
*/
( function( $ ) {
$( '.ui-tabs-anchor', '.about-teamlist' ).on( 'click', function( e ) {
@glueckpress
glueckpress / mixed-ol.css
Last active August 29, 2015 14:18
Mixed, nested ordered HTML lists; support request from https://plus.google.com/+ClaudioBott/posts/SYcohmFXc7g
ol {
list-style-type: decimal;
}
ol ol {
list-style-type: lower-roman;
}
@glueckpress
glueckpress / single_post_widget.php
Last active November 20, 2015 22:51
Makes a custom WordPress widget to display any published post.
<?php
// Make sure we have a theme domain for localization
if( ! defined( 'THEME_DOMAIN' ) )
define( 'THEME_DOMAIN', get_stylesheet() ); // Any translation has to go in your stylesheet directory
/**
* Makes a custom widget to display any published post.
*
* @package WordPress
@glueckpress
glueckpress / woocommerce-check-formal-locale.php
Last active December 14, 2015 21:30
[WordPress] Check whether the active locale is formal and whether a formal WooCommerce translation has been downloaded.
<?php
/**
* Check whether formal language files exist for WooCommerce.
*
* - Admin locales are found in:
* - WP_LANG_DIR/woocommerce/woocommerce-admin-LOCALE.mo
* - WP_LANG_DIR/plugins/woocommerce-admin-LOCALE.mo
*
* - Front-end/global locales found in:
* - WP_LANG_DIR/woocommerce/woocommerce-LOCALE.mo
@glueckpress
glueckpress / dewp-project-contact.php
Last active December 14, 2015 21:30
[WordPress] Kontaktzeile für dewp-Projekte mit Link zum Slack-Channel des Projekts, sowie Link zur Registrierungsanleitung.
<?php
if ( ! function_exists( 'dewp_project_contact' ) ) :
/**
* Kontaktzeile für dewp-Projekte.
*
* @param array $channel Channel-Name und URL
* @return string Kontaktzeile
*/
function dewp_project_contact( $args = array() ) {
@glueckpress
glueckpress / moderate-long-comments.php
Last active December 14, 2015 21:31
[WordPress] Sends a comment to moderation queue if it contains more than 499 words. Props @Ipstenu! https://twitter.com/Ipstenu/status/627130377828564993 **UPDATE:** This has become a plugin with a setting. https://github.com/glueckpress/comment-moderation-by-word-count
<?php
/**
* Plugin Name: Moderate Long Comments
* Description: Sends a comment to moderation queue if it contains more than 499 words.
* Version: 0.1
* Author: Caspar Hübinger
* Plugin URI: https://gist.github.com/glueckpress/34ae7508d9566131a249
* 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 / wcl10n-example.php
Last active December 14, 2015 21:31
[WordPress] Exclude text domains from language files by wrapping them into custom functions instead of default l10n functions. (http://glck.be/6651/)
<?php
/* String from your theme/plugin */
_e( 'Margaritas!', 'your-textdomain' );
__( 'Margaritas!', 'your-textdomain' );
/* Original string from WooCommerce: */
_e( 'Product', 'woocommerce' );
__( 'Product', 'woocommerce' );
@glueckpress
glueckpress / wp-pending-posts.php
Last active December 14, 2015 21:32
[WordPress] Post query for post status “pending” (print titles)
<?php
// WP_Query arguments
$args = array (
'post_type' => 'post',
'post_status' => 'pending',
);
// The Query
$query = new WP_Query( $args );
@glueckpress
glueckpress / video-oembeds.php
Last active December 14, 2015 21:32
[WordPress] Add a wrapping <div> around video embeds.
/**
* Add a wrapping <div> around video embeds in WordPress.
*
* @param string $html
* @param string $url
* @param array $attr
* @param integer $post_ID
* @return void
*/
function glueckpress_wrap_oembedded_video( $html, $url, $attr, $post_ID ) {