Skip to content

Instantly share code, notes, and snippets.

View contemplate's full-sized avatar

Ted Barnett contemplate

View GitHub Profile
@contemplate
contemplate / profile_autofill_expiration.php
Last active May 1, 2016 06:14
PMPro - Custom JS to autofill the expiration date when a PMPro level is chosen on the edit user page by admin
/*---------------------------------
Autofill Expiration on Admin Level Change
-----------------------------------*/
function profile_autofill_expiration()
{
global $wpdb;
$sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levels ";
$sqlQuery .= "ORDER BY id ASC";
$levels = $wpdb->get_results($sqlQuery, OBJECT);
@contemplate
contemplate / functions.php
Created October 8, 2019 01:17
Bloom Email Opt-in Custom CSS Help Guide added in options panel
// 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 / footer.php
Created October 8, 2019 01:24
Bloom Email Optin move Below Post Opt-in into the post ( after 3rd paragraph )
@contemplate
contemplate / functions.php
Created October 23, 2019 03:52
WooCommerce Purchased Total Shortcode
//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 / shortcodes.php
Created April 17, 2020 21:51
Kleo K Elements kleo_search_form shortcode fix
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
Created November 13, 2020 06:18
PMPro show content before expiration shortcode [pmpro_before_expiration]
/*-- Show Content Before Expiration Shortcode -----------------*/
function pmpro_before_expiration_shortcode( $atts, $content=null, $code="" ) {
//make sure PMPro is active
if(!function_exists('pmpro_getMembershipLevelForUser'))
return;
//get attributes
$a = shortcode_atts( array(
'user' => '',
'days' => '15',
@contemplate
contemplate / functions.php
Created November 17, 2020 13:53
PMPro show member expiration date
/*-- Member Expiration Date Shortcode -----------------*/
//[pmpro_expiration_date]
function pmpro_expiration_date_shortcode( $atts ) {
//make sure PMPro is active
if(!function_exists('pmpro_getMembershipLevelForUser'))
return;
//get attributes
$a = shortcode_atts( array(
'user' => '',
@contemplate
contemplate / functions.php
Created December 2, 2020 20:57
Smart Coupons By URL Cartflows integration
/*-- Smart Coupons By URL Integration --*/
add_action( 'cartflows_checkout_after_configure_cart', 'cartflows_smart_coupons_apply_coupon_from_url', 10, 1 );
function cartflows_smart_coupons_apply_coupon_from_url( $checkout_id ) {
$cart = ( is_object( WC() ) && isset( WC()->cart ) ) ? WC()->cart : null;
parse_str( wp_unslash( $_SERVER['QUERY_STRING'] ), $coupon_args ); // phpcs:ignore
$coupon_args = wc_clean( $coupon_args );
// If Coupons are in URL
@contemplate
contemplate / functions.php
Last active March 3, 2021 03:24
WP Ultimate Post Grid filter to add secondary orderby date when custom meta key is selected as primary order
// ORDER GRID BY DATE SECOND IF META KEY ORDER IS ENABLED
//add_filter( 'wpupg_get_posts_args', 'wpupg_order_by_date_second', 10, 2);
add_filter( 'wpupg_query_post_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 / bp-custom.php
Created May 7, 2021 12:36
Buddypress: Expand autocomplete mentions list
//turn on @mentions for all users
define( 'BP_MESSAGES_AUTOCOMPLETE_ALL', true );
/*---- Expand Auto Complete -------*/
//https://github.com/buddypress/BuddyPress/blob/fe47890c1ab7e2cb24c005f1c35fb9c6c8c8ab7c/src/bp-core/classes/class-bp-members-suggestions.php#L85
function bp_filter_buddypress_auto_complete( $args ) {
$args['per_page'] = 100;
// $args['populate_extras'] = true;
//$args['search_terms'] = 'some term';
$args['search_wildcard'] = 'both';