Skip to content

Instantly share code, notes, and snippets.

View gthayer's full-sized avatar

Gary Thayer gthayer

View GitHub Profile
add_action( 'admin_init', 'auto_distribute_cron' );
add_action( 'mtm_auto_distribute_cron', 'mtm_push_nondistributed_posts' );
if ( class_exists( 'WP_CLI' ) ) {
\WP_CLI::add_command( 'mtm_sj', 'mtm_push_nondistributed_posts' );
}
/**
* Initialize the scheduled 'mtm_auto_distribute_cron' action.
*
* @return void
/**
* Automatically distribute posts using Distributor's external connections.
* Only applies to published posts.
*
* @param [int] $post_id The post's ID.
* @return void
*/
function auto_distribute( $post_id ) {
// Do not run this on unless a post is being updated.
@gthayer
gthayer / gist:08802c53f3a2ef757eb5ee06ac1a7157
Created February 7, 2018 16:42
A/B Test Helper Functions
// Get URL Parameter
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
add_filter( 'gform_confirmation_12', 'social_share', 10, 4 );
function social_share( $confirmation, $form, $entry, $is_ajax ) {
global $post;
$page = get_permalink();
$facebook_og = get_post_meta( $post->ID, '_yoast_wpseo_opengraph-description', true );
$twitter = get_post_meta( $post->ID, '_yoast_wpseo_twitter-description', true );
$confirmation .= '<div class="social-share">';
$confirmation .= '<a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=' . $page . '"><i class="fa fa-facebook" aria-hidden="true"></i></a>';
@gthayer
gthayer / gist:db72a76d9066c2f53d990b83a44dba83
Last active May 10, 2017 19:44
Remove product thumbnail IDs from galleries.
/*
* Removes the product's thumbnail from the gallery if it's set in both. Useful after the Woo 3.0 update as the system now automatically add the image to the gallery.
* Drop this snippet in functions.php, reload the page, then delete the function.
*/
add_action( 'init', 'remove_duplicate_gallery_images' );
function remove_duplicate_gallery_images() {
// Get the products.
add_filter( 'woocommerce_shipping_packages', 'free_shipping_wreaths' );
function free_shipping_wreaths( $packages ) {
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
foreach ( $packages as $i => $package ) {
$chosen_method = false;
if ( ! empty( $chosen_methods[ $i ] ) ) {
SELECT *
FROM `wp_stream`
LEFT JOIN `wp_usermeta`
ON wp_stream.user_id=wp_usermeta.user_id
WHERE wp_stream.action LIKE "login"
AND wp_usermeta.meta_key LIKE '%wp_capabilities%'
// TODO: look into basing this off order value.
//add_filter( 'woocommerce_email_enabled_new_renewal_order', 'unhook_those_pesky_emails', 20, 2 );
//add_filter( 'woocommerce_email_enabled_customer_renewal_invoice', 'unhook_those_pesky_emails', 20, 2 );
add_filter( 'woocommerce_email_enabled_customer_new_order', 'unhook_those_pesky_emails', 20, 2 );
function unhook_those_pesky_emails( $active, $order ) {
//var_dump($order);
//exit;
//add_action('wp_head', 'update_meta_values');
function update_meta_values() {
/*
* Takes a set of fields and resets them as part of a repeater
* To start, create a new repeater field and enter the slug in $new_repeater
* Find the fields you would like to move in wp_posts and set the post_parent to the new repeater's ID
*/
// Slug of the new repeater
/*
* Mailchimp API Calls
* V. 3.0
*/
//Push users to mailchimp on GF form completion
function mailchimp_newsletter_push_form_8($entry, $form) {
$list_id = '';
$email = $entry[3];