Skip to content

Instantly share code, notes, and snippets.


Curtis McHale curtismchale

View GitHub Profile
curtismchale / selects-same-as-billing.php
Last active May 1, 2017
preselects the same as billing checkbox for WP ecommerce
View selects-same-as-billing.php
* Defaults customer meta for shipping same as billing.
* Means that by default we say that billing and shipping match so just hide the stuff
* about shipping unless the user unselects the box.
* @author SFNdesign, Curtis McHale
* @link
* @param null $value A null flag.
curtismchale / select-us-default-country.php
Last active Mar 30, 2017
Improves the WP eCommerce checkout for stores.
View select-us-default-country.php
* Defaults customer meta for shipping country to the good ol' US of A.
* A function like this could be really useful in defaulting to the country that is most commonly purchased from.
* Or even to the base country of the store. Sky's the limit, folks.
* @param null $value A null flag.
* @param string $key The meta key being passed to the customer meta API.
* @param int $id The current user/customer/visitor ID.
curtismchale / only-top-term-filters.php
Created May 25, 2016
Only lets the top level term in the permalink structure
View only-top-term-filters.php
function wpse147453_remove_child_categories_from_permalinks( $permalink, $post, $leavename, $sample ) {
if ( in_array( $post->post_type, array( 'focus_courses' ) ) ) {
// Allow for slug to be editable
$slug = $leavename ? '%' . $post->post_type . '%' : $post->post_name;
// Generate premalink prefix based on post type
$prefix = 'courses';
// add parent term slug
$term_slug = focus_top_term( $post );
curtismchale / wecr_allowed_meta_post_types.php
Created Apr 10, 2015
Lets you change the allowed CPT's that show the 'Remove from Menu' or 'Remove from My Account' checkboxes.
View wecr_allowed_meta_post_types.php
* Changes the post types that show the 'remove from menu' and 'remove from my account' checkboxes in the WordPress admin
* @param array $types required The existing allowed CPTs
* @return array $types Our modified array of CPTs
function change_allowed( $types ){
$types[] = 'forum'; // change this to your registered custom post type name
return $types;
View wecr_bbp_topic_message_global.php
* Override topic feedback message
* @param string $translated_text_out the original feedback text
* @param string $translated_text_in The text that bbPress sent in to the function, or the 'default' text bbPres uses here
* @return string $translated_text_out the filtered feedback text
function custom_topic_feedback_messages( $translated_text_out, $translated_text_in ) {
curtismchale / remove-from-account.php
Created Jan 30, 2015
Removes the restricted content display from the user My Account page
View remove-from-account.php
* Removes the restricted content display from the account page
* Don't forget that you are now responsible to show the restricted content to your users somewhere else
function remove_from_account_page(){
remove_action( 'woocommerce_before_my_account', array( $GLOBALS['wecr_show_content'], 'show_content' ) );
View gist:a87772bf706bbd278ceb
curtismchale / ajax-handle.php
Created Aug 20, 2014
Basic AJAX request set up
View ajax-handle.php
class CT_Config_Ajax{
function __construct(){
add_action( 'wp_ajax_ct_get_sku', array( $this, 'get_sku' ) );
add_action( 'wp_ajax_nopriv_ct_get_sku', array( $this, 'get_sku' ) );
} // __construct
public function get_sku(){
View wecr_simple_product_message.php
* Allows you to change the default message for simple products.
* @param string $message stock Easy Content Restriction message
* @param int $product_id The post_id for the product the message would be tied to, may be a product variation id
* @return string Your custom message
function change_simple_product_message( $message, $product_id ) {
return 'Our custom message';