Skip to content

Instantly share code, notes, and snippets.

Avatar

Ted Barnett contemplate

View GitHub Profile
@contemplate
contemplate / functions.php
Last active Jul 10, 2020
Shortcode for WooCommerce Subscriptions User Action Buttons
View functions.php
// Shortcode For User Subscription Actions
function cd_wcs_user_action_button( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'user' => '',
'status' => 'active',
'button' => 'id',
'title' => '',
@contemplate
contemplate / shortcodes.php
Created Apr 17, 2020
Kleo K Elements kleo_search_form shortcode fix
View shortcodes.php
add_shortcode( 'kleo_search_form', 'kleo_search_form_func' );
function kleo_search_form_func( $atts, $content = null ) {
$form_style = $type = $placeholder = $context = $el_class = '';
extract( shortcode_atts( array(
'form_style' => 'default',
'type' => 'both',
'context' => '',
'placeholder' => '',
'el_class' => ''
@contemplate
contemplate / functions.php
Last active Mar 13, 2020
AffiliateWP: Disable New Referral Email for Affiliates with Store Credit Disabled
View functions.php
/*-- Disable New Referral Email for PAID Affiliates -----------*/
function disable_new_refferal_email( $return, $referral ) {
// Check to see if AffiliateWP is active.
if ( ! function_exists( 'affiliate_wp' ) ) {
return;
}
$affiliate_id = $referral->affiliate_id;
@contemplate
contemplate / functions.php
Created Dec 15, 2019
MyBookTable: use book image as post thumbnail
View functions.php
/**
* MyBookTable: use book image as post thumbnail
*/
//Find Book Image ID
add_filter( 'get_post_metadata', 'mbt_use_book_image_as_thumbnail', 10, 4 );
function mbt_use_book_image_as_thumbnail( $null, $object_id, $meta_key, $single ) {
if ( '_thumbnail_id' !== $meta_key ) {
return $null;
}
@contemplate
contemplate / functions.php
Created Oct 23, 2019
WP Ultimate Post Grid filter to add secondary orderby date when custom meta key is selected as primary order
View functions.php
// ORDER GRID BY DATE SECOND IF META KEY ORDER IS ENABLED
add_filter( 'wpupg_get_posts_args', 'wpupg_order_by_date_second', 10, 2);
function wpupg_order_by_date_second( $args, $page ){
if( $args['orderby'] == 'meta_value_num' ){
$args['orderby'] = 'meta_value_num date';
}
return $args;
}
@contemplate
contemplate / functions.php
Created Oct 23, 2019
WooCommerce Purchased Total Shortcode
View functions.php
//WooCommerce Purchased Total Shortcode
add_shortcode( 'cd-purchased-total', 'cd_shortcode_purchased_totals' );
function cd_shortcode_purchased_totals( $atts ){
STATIC $cd_shortcode_count;
$cd_shortcode_count++;
$total_value = 0;
$_atts = shortcode_atts( array(
'product_ids' => '',
@contemplate
contemplate / MailChimp.php
Created Oct 16, 2019
Bloom better Mailchimp integration for groups and custom field updates
View MailChimp.php
<?php
/**
* Wrapper for MailChimp's API.
*
* @since 1.1.0
*
* @package ET\Core\API\Email
*/
class ET_Core_API_Email_MailChimp extends ET_Core_API_Email_Provider {
@contemplate
contemplate / footer.php
Created Oct 8, 2019
Bloom Email Optin move Below Post Opt-in into the post ( after 3rd paragraph )
View footer.php
@contemplate
contemplate / functions.php
Created Oct 8, 2019
Bloom Email Opt-in Custom CSS Help Guide added in options panel
View functions.php
// Bloom Custom CSS Help
add_action( 'et_bloom_after_main_options', 'add_bloom_custom_options', 10, 2 );
function add_bloom_custom_options( $option, $current_option_value ) {
if ( is_admin() && $option[name] == 'custom_css' ) {
$optin_id = $_POST['reset_optin_id'];
printf( '<li class="et_dashboard_auto_height">
<h3 style="margin-top: 15px">CSS HELP</h3>
<div style="margin-bottom:15px;"><strong>Target This Optin:</strong><br>.et_bloom_%1$s.et_bloom_optin { ... css code here ... }</div>
<div style="margin-bottom:15px;"><strong>HIDE ON DESKTOP:</strong><br>@media screen and (min-width:981px) { .et_bloom_%1$s.et_bloom_optin {display:none !important;} }</div>
<div style="margin-bottom:15px;"><strong>HIDE ON MOBILE:</strong><br>@media screen and (max-width:981px) { .et_bloom_%1$s.et_bloom_optin {display:none !important;} }</div>
@contemplate
contemplate / functions.php
Created Jul 14, 2018
WPBakery Page Builder ACF EXTRA Grid Item
View functions.php
/**************************************
* VC ACF GRID ITEM W/ RELATIONSHIP
***************************************/
add_filter( 'vc_grid_item_shortcodes', 'vc_grid_item_shortcode_acf_extra' );
function vc_grid_item_shortcode_acf_extra( $shortcodes ) {
$groups = function_exists( 'acf_get_field_groups' ) ? acf_get_field_groups() : apply_filters( 'acf/get_field_groups', array() );
$groups_param_values = $fields_params = array();
foreach ( $groups as $group ) {
$id = isset( $group['id'] ) ? 'id' : ( isset( $group['ID'] ) ? 'ID' : 'id' );
$groups_param_values[ $group['title'] ] = $group[ $id ];
You can’t perform that action at this time.