Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View curtismchale's full-sized avatar

Curtis McHale curtismchale

View GitHub Profile
<?php
/**
* Overrides the default message for subscription type 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
* @return string Your custom message
*/
function change_subscription_message( $message, $product_id ) {
return 'Our custom message';
<?php
/**
* Allows you to change the default message for variable 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_variable_product_message( $message, $product_id ) {
return 'Our custom message';
<?php
/**
* Allows you to change the default message for grouped 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_grouped_product_message( $message, $product_id ) {
return 'Our custom 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';
@curtismchale
curtismchale / ajax-handle.php
Created August 20, 2014 20:59
Basic AJAX request set up
<?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(){
@curtismchale
curtismchale / remove-from-account.php
Created January 30, 2015 04:37
Removes the restricted content display from the user My Account page
<?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' ) );
}
<?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
curtismchale / wecr_allowed_meta_post_types.php
Created April 10, 2015 18:58
Lets you change the allowed CPT's that show the 'Remove from Menu' or 'Remove from My Account' checkboxes.
/**
* 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;
}
@curtismchale
curtismchale / show-post-relations-relations-post-type
Created August 25, 2011 23:24
Shows the related content on a WordPress site using Relations post type
function tan_show_related_content( $postid, $post_type ) {
global $wp_query, $post;
// Related IDs for this view ?
$ids = rpt_get_object_relation( $postid, $post_type );
if( $ids == false || empty($ids) )
return false;
$items_query = new WP_Query( array(
'post__in' => $ids,
@curtismchale
curtismchale / populate-dropdown.php
Created August 31, 2011 05:06
Populates GF dropdown
/*
* Load any taxonomy terms
*/
function load_cpt_choices($post_type, $type, $first_choice = '', $term) {
$choices = array();
if ($type === 'select') {
$posts = get_posts('post_type='.$post_type.'&numberposts=-1&school_type='.$term);
}