Skip to content

Instantly share code, notes, and snippets.

@coenjacobs
coenjacobs / wc-remove-dutch-provinces.php
Created January 29, 2013 13:33
Removes the Dutch provinces from WooCommerce country dropdown boxes as they are not required for Dutch shops. Will become superfluous once WooCommerce 2.0 is released. Important: Make sure you select 'Netherlands' as country again in WooCommerce settings.
<?php
/*
Plugin Name: WC Remove Dutch Provinces
Description: Removes the Dutch provinces from the WooCommerce country dropdown boxes, no need to show these. Will become superfluous once WooCommerce 2.0 is released. Important: Make sure you select 'Netherlands' as country again in WooCommerce settings.
Author: Coen Jacobs
Author URI: http://coenjacobs.me/
*/
add_filter( 'woocommerce_states', 'cj_woocommerce_states' );
@coenjacobs
coenjacobs / gist:3714838
Created September 13, 2012 14:55
Make the phone number not required in WooCommerce checkout
<?php
add_filter( 'woocommerce_billing_fields', 'wc_npr_filter_phone', 10, 1 );
function wc_npr_filter_phone( $address_fields ) {
$address_fields['billing_phone']['required'] = false;
return $address_fields;
}
?>
@coenjacobs
coenjacobs / wc-attribute-links.php
Created May 4, 2012 14:05
Display WooCommerce product attribute archive links on product page, right below the add to cart button.
@coenjacobs
coenjacobs / wc-show-dimensions-on-archive.php
Created May 4, 2012 14:02
Display WooCommerce product dimensions on archive pages, right below the title of the product
<?php
/*
Plugin Name: WooCommerce Show Dimensions On Archive
Description: Display product dimensions on archive pages, right below the title of the product.
Version: 1.0
Author: Coen Jacobs
Author URI: http://coenjacobs.me
*/
@coenjacobs
coenjacobs / gist:2571441
Created May 1, 2012 21:12 — forked from boonebgorges/gist:2571318
Update Woo Framework for all WooThemes on an installation
<?php
/**
* Updates Woo Framework in all WooThemes on a WP installation
*
* To use:
*
* - Get the latest copy of the framework
* - Unzip to /wp-content/framework/
* - Visit wp-admin?cac_update_woo=1 as super admin
@coenjacobs
coenjacobs / gist:2510177
Created April 27, 2012 15:30
Allow HTML in term (category, tag) descriptions
foreach ( array( 'pre_term_description' ) as $filter ) {
remove_filter( $filter, 'wp_filter_kses' );
}
foreach ( array( 'term_description' ) as $filter ) {
remove_filter( $filter, 'wp_kses_data' );
}
@coenjacobs
coenjacobs / archive-recept.php
Created March 25, 2012 21:01
Demonstration plugin that registers a post type for 'recipes'. This code is not fully tested, is not 100% written according to the WordPress Coding Standards and could use function prefixing to minimize the risk of having duplicate function names.
<?php get_header(); ?>
<div id="container">
<div id="content" role="main">
<h1 class="page-title">Recepten</h1>
<?php get_template_part( 'loop', 'recept' ); ?>
</div>
@coenjacobs
coenjacobs / custom-login.js
Created January 25, 2012 10:21
Adding a link to wp-login.php via jQuery
jQuery( document ).ready(function( $ ) {
var href = $("#nav a").attr("href");
var html = '<a href="'+ href +'">First login?</a> - ';
$( "#nav" ).prepend( html );
} );
@coenjacobs
coenjacobs / gist:1389756
Created November 23, 2011 20:09 — forked from remkus/gist:1235165
Example of WordPress coding standards
<?php
add_filter( 'body_class' , 'ft_add_guest_body_class' );
/**
* Adds a body class for guests.
*
* @author Remkus de Vries
* @link http://remkusdevries.com/when-sharing-wordpress-related-code-snippets-i-can-haz-standards-please/
* @tested WordPress 3.2.1
* @param array $classes Existing body classes