Skip to content

Instantly share code, notes, and snippets.

View om4james's full-sized avatar

James Collins om4james

View GitHub Profile
@om4james
om4james / 1_unsafe.php
Created May 5, 2012 00:02
WordPress String Translation Escaping Example
<?php
echo '<p>' . __('This is some text that needs to be translatable in my WordPress plugin', 'myplugin') . '</p>';
@om4james
om4james / mini-loops-2-recent-posts.html
Created October 5, 2011 08:44
Mini Loops Example: 2 recent posts displayed on home page
[miniloop number_posts=2]
<li>
<h2>{title}</h2>
{image from=thumb width=75 height=75 class=alignleft}{ml_excerpt wlength=35 up_to_more=1 after=More... space_between=1}</li>
[/miniloop]
@om4james
om4james / woocommerce-category-archives.php
Created May 1, 2015 04:45
WooCommerce wrap product category/subcategory images in the loop (shop/archive pages)
<?php
/**
* Archives: wrap the category/subcategory image/thumbnail in a div.
*
* The category image itself is hooked in at priority 10 using woocommerce_subcategory_thumbnail(),
* so priority 9 and 11 are used to open and close the div.
*/
add_action( 'woocommerce_before_subcategory_title', function(){
echo '<div class="imagewrapper">';
@om4james
om4james / functions.php
Created April 2, 2014 02:54
Allow the .4w7 file type to be uploaded to the WordPress media library
<?php
/**
* Allow the .4w7 file type to be uploaded to the WordPress media library.
*
* Ref: https://gist.github.com/om4james/9927208
*
* Put this snippet into a child theme's functions.php file
*/
function rasq_myme_types( $mime_types ){
$mime_types['4w7'] = 'application/octet-stream';
@om4james
om4james / functions.php
Last active August 29, 2015 13:57 — forked from simonlk/WooCommerce - Change Sort Code to BSB
WooCommerce - Change Sort Code to BSB
<?php
/**
* Rename WooCommmerce's "Sort Code" to "BSB". Useful for Australian stores
* Ref: https://gist.github.com/om4james/9885791
*/
function woocommerce_sort_code_rename_to_bsb($translation, $text, $domain) {
if ($domain == 'woocommerce') {
switch ($text) {
case 'Sort Code':
$translation = 'BSB';