Skip to content

Instantly share code, notes, and snippets.

View danielmcclure's full-sized avatar

Daniel McClure danielmcclure

View GitHub Profile
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@mikejolley
mikejolley / gist:1733834
Created February 3, 2012 23:53
WooCommerce - Make address fields wider
add_filter('woocommerce_billing_fields', 'custom_woocommerce_billing_fields');
function custom_woocommerce_billing_fields( $fields ) {
$fields['billing_address_1']['class'] = array( 'form-row-wide' );
$fields['billing_address_2']['class'] = array( 'form-row-wide' );
return $fields;
}
@BronsonQuick
BronsonQuick / gravity_forms_validation.php
Created April 12, 2012 09:51
Change the default validation message and add validation on default values in Gravity Forms
<?php
//This is a filter to change the default validation message that Gravity Forms generates
add_filter('gform_validation_message', 'change_validation_message', 10, 2);
function change_validation_message($message, $form)
{
return "<div class='validation_error'><strong>Oops!</strong> Looks like there’s something wrong. Please review the form above.</div>";
}
// Often forms in Gravity Forms to need to start with default values and we need to check the form in case the user hasn't entered new data and give them a validation message back
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@mikejolley
mikejolley / gist:3097073
Last active January 18, 2024 17:54
WooCommerce - Unhook/Disable emails
/**
* Code goes in functions.php or a custom plugin.
*/
add_action( 'woocommerce_email', 'unhook_those_pesky_emails' );
function unhook_those_pesky_emails( $email_class ) {
/**
* Hooks for sending emails during store events
**/
@clawfire
clawfire / functions.php
Created August 7, 2012 13:18
Don't display placeholder and image if there's no picture defined for a category
<?php
// unload the original one
remove_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail');
// load mine
add_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail_custom', 10);
if ( ! function_exists( 'woocommerce_subcategory_thumbnail_custom' ) ) {
function woocommerce_subcategory_thumbnail_custom( $category ) {
global $woocommerce;
@ChromeOrange
ChromeOrange / functions.php
Created August 20, 2012 10:21
Managing WooCommerce Product Tabs
<?php
/**
* Standard Tab Code from woocommerce-hooks.php
*/
/* Product page tabs */
add_action( 'woocommerce_product_tabs', 'woocommerce_product_description_tab', 10 );
add_action( 'woocommerce_product_tabs', 'woocommerce_product_attributes_tab', 20 );
add_action( 'woocommerce_product_tabs', 'woocommerce_product_reviews_tab', 30 );
add_action( 'woocommerce_product_tab_panels', 'woocommerce_product_description_panel', 10 );
@kasparsd
kasparsd / wordpress-plugin-svn-to-git.md
Last active April 17, 2024 12:35
Using Git with Subversion Mirroring for WordPress Plugin Development
@retlehs
retlehs / gist:4120053
Created November 20, 2012 18:45
Remove unnecessary markup from WooCommerce
<?php
/**
* Remove unnecessary markup from WooCommerce:
*
* 1. Remove <meta name="generator" content="WooCommerce (version)" />
* 2. Remove the addition of <body class="theme-themename">
*/
function woocommerce_head_cleanup() {
global $woocommerce;
@kloon
kloon / gist:4239771
Created December 8, 2012 10:48
WooCommerce Name Your Price, show minimum price on archive pages
add_filter( 'woocommerce_get_price_html', 'woocommerce_nyp_min_price', 11, 2 );
function woocommerce_nyp_min_price( $price, $product ) {
if ( !$product->nyp )
return $price;
if( is_shop() || is_product_category() || is_product_tag() ) {
$price = woocommerce_price( $product->minimum );
}
return $price;