Skip to content

Instantly share code, notes, and snippets.

View gthayer's full-sized avatar

Gary Thayer gthayer

View GitHub Profile
@gthayer
gthayer / WooCommerce Popup Gallery - Magnific
Last active May 22, 2019 13:43
WooCommerce Popup Gallery - Magnific
@gthayer
gthayer / gist:b20f7d363cbc846bde68
Created March 3, 2015 19:44
Recursive Array Search
//By buddel - http://php.net/manual/en/function.array-search.php#usernotes
function recursive_array_search($needle,$haystack) {
foreach($haystack as $key=>$value) {
$current_key=$key;
if($needle===$value OR (is_array($value) && recursive_array_search($needle,$value) !== false)) {
return true;
}
}
return false;
@gthayer
gthayer / main_analytics.js
Last active February 12, 2018 02:41
Google Analytics Plugin Wrapper
//Load GA Plugin. If unable to load, wait 50 milliseconds and attempt load again.
function providePlugin(pluginName, pluginConstructor) {
if (window.ga && document.body ) {
ga('provide', pluginName, pluginConstructor);
}
else {
window.setTimeout(function() {
providePlugin('main_analytics', gaEventsLoader);
},
50);
function change_acf_meta_keys() {
global $wpdb;
$values = array(
"0" => array(
'old_value' => 'foo1',
'new_value' => 'bar1',
),
"1" => array(
@gthayer
gthayer / gist:70d7a78c6cffe9630d95
Created August 26, 2015 20:50
Check for content, then remove from index
add_action( 'init', 'check_for_content', 30 );
function check_for_content( $post_id ) {
$args = array(
'posts_per_page' => -1,
'offset' => 0,
'category' => '',
'category_name' => '',
'orderby' => 'date',
'order' => 'DESC',
function retrieve_the_content( $var1 ) {
global $post;
return strip_tags($post->post_content);
}
function yoast_custom_meta_variables() {
wpseo_register_var_replacement( '%%the_content%%', 'retrieve_the_content', 'basic', 'Replaced with The Content' );
}
add_action( 'wpseo_register_extra_replacements', 'yoast_custom_meta_variables' );
//Replace og:image with either the post featured image, or an image of the speaker
//Requires Yoast
add_action( 'wpseo_opengraph', 'replace_og_image', 30 );
function replace_og_image() {
global $post;
$featured_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
$speaker = get_field('speaker', $post->ID);
/*
* 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];
//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
// 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;