Skip to content

Instantly share code, notes, and snippets.

View Disambiguation.md

Adding context to strings

A word or phrase may be ambiguous to a translator who will likely only see the string in the interface of their translation tool and not necessarily on the front-end of your theme. Ambiguity can arise when a term is used in more than one context.

The functions _x() or _ex() are used to add the context to a string. They are similar to __() and _e(), but have a comment as an additional argument.

The function can be used in differnt ways

  • Explain the use for words with double meaings
  • Give extra information about the string
View git-sync.md

Clone repo

Run following code to clone from GitHub. git clone git@github.com:grappler/WPZOO.git

Install dependencies

Run composer to install the dependencies composer install

@grappler
grappler / fp5-speed-buttons.php
Last active Jul 1, 2016
Flowplayer speed buttons to switch video speed for https://wordpress.org/plugins/flowplayer5/ v1.11.1
View fp5-speed-buttons.php
<?php
/*
Plugin Name: Flowplayer speed buttons
Plugin URI: https://gist.github.com/grappler/02b9d43c0606d74869a1
Description: Add buttons to adjust the speed of the video. The styles are added in the child theme
Version: 0.1.0
Author: Ulrich Pogson
Author URI: https://ulrich.pogson.ch/
License: GPLv2
License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
@grappler
grappler / Theme-review-links
Last active Oct 12, 2015
WordCamp Köln Contributor Day Theme Review Info Links
View Theme-review-links
@grappler
grappler / functions.php
Created Feb 11, 2015
Escaping for textarea values while leaving both double and single quotes unconverted.
View functions.php
<?php
/**
* Escaping for textarea values while leaving both double and single quotes unconverted.
*
* @param string $text
* @return string
*/
function theme_slug_esc_text( $text ) {
return htmlspecialchars( $text, ENT_NOQUOTES, get_option( 'blog_charset' ) );
}
@grappler
grappler / wpml-config.xml
Created Dec 7, 2014
EDD wpml-config.xml
View wpml-config.xml
<wpml-config>
<custom-types>
<custom-type translate="1">download</custom-type>
<custom-type translate="0">edd_payment</custom-type>
</custom-types>
<custom-fields>
<custom-field action="ignore">_edd_download_earnings</custom-field>
<custom-field action="ignore">_edd_download_sales</custom-field>
<custom-field action="copy">edd_price</custom-field>
<custom-field action="copy">edd_variable_prices</custom-field>
@grappler
grappler / functions.php
Last active Jan 21, 2017
// add ie conditional html5 shim to header
View functions.php
<?php
// add ie conditional html5 shim to header
function _s_add_ie_html5_shim () {
echo '<!--[if lt IE 9]>';
echo '<script src="' . get_template_directory_uri() . '/js/html5.js"></script>';
echo '<![endif]-->';
}
add_action('wp_head', '_s_add_ie_html5_shim');
@grappler
grappler / functions.php
Last active Aug 29, 2015
Extended mobile menu title for Responsive Mobile
View functions.php
<?php
function responsive_extended_mobile_menu_title( $page_title ) {
if ( is_front_page() ) {
$page_title = __( 'Home', 'responsive-mobile' );
} elseif ( is_home() ) {
$page_title = __( 'Blog', 'responsive-mobile' );
} elseif ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) {
// @TODO Display porudct name on single product page
$page_title = woocommerce_page_title();
} elseif ( is_archive() ) {
View child-functions.php
<?php
/**
* Enqueue scripts and styles.
*/
function presentation_lite_parent_scripts() {
wp_enqueue_style( 'presentation-lite-parent-style', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'presentation_lite_parent_scripts', 9 );
View header.php
<?php
/**
* The header for our theme.
*
* Displays all of the <head> section and everything up till <div id="content">
*
* @package _s
*/
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>