Skip to content

Instantly share code, notes, and snippets.

<?php
/*
* Check if user has a valid subscription
*/
function wpzoo_edd_is_active_customer( $user_id = '' ) {
// Fail gracefully if EDD Software Licencing not active
if ( ! function_exists('edd_software_licensing') ) {
return;
}
$license_keys = edd_software_licensing()->get_license_keys_of_user( $user_id );
document.addEventListener('DOMContentLoaded', function(){
var tabs = {
tab1: document.getElementById('tab-link-1'),
tab2: document.getElementById('tab-link-2'),
tab3: document.getElementById('tab-link-3'),
tab4: document.getElementById('tab-link-4')
}
var content = {

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

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 July 1, 2016 16:47
Flowplayer speed buttons to switch video speed for https://wordpress.org/plugins/flowplayer5/ v1.11.1
<?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 May 19, 2022 06:08
WordCamp Köln Contributor Day Theme Review Info Links
@grappler
grappler / functions.php
Created February 11, 2015 18:50
Escaping for textarea values while leaving both double and single quotes unconverted.
<?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 December 7, 2014 21:49
EDD 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 January 21, 2017 08:06
// add ie conditional html5 shim to header
<?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 August 29, 2015 14:10
Extended mobile menu title for Responsive Mobile
<?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() ) {