Skip to content

Instantly share code, notes, and snippets.

Thomas Griffin thomasgriffin

Block or report user

Report or block thomasgriffin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:8710900
jQuery.getJSON('http://freegeoip.net/json/', function(location) {
var d = new Date(),
curr_date = d.getDate(),
curr_month = d.getMonth(),
curr_year = d.getFullYear(),
fulldate = curr_date + "-" + curr_month + "-" + curr_year;
$('<input id="date" type="hidden" name="custom_date" value="' + full_date + '" />').appendTo($('#your-form-id-here'));
$('<input id="ip" type="hidden" name="custom_ip" value="' + location.ip + '" />').appendTo($('#your-form-id-here'));
$('<input id="country" type="hidden" name="custom_country" value="' + location.country_name + '" />').appendTo($('#your-form-id-here'));
});
@thomasgriffin
thomasgriffin / gist:8787961
Created Feb 3, 2014
Remove YouTube controls from video.
View gist:8787961
<?php
add_filter( 'tgmsp_youtube_query_args', 'tgm_soliloquy_remove_youtube_controls' );
function tgm_soliloquy_remove_youtube_controls( $query_args ) {
$query_args['controls'] = '0';
return $query_args;
}
View gist:8826992
jQuery(document).ready(function($){
$(document).on('OptinMonsterOptinSuccess', function(event, data){
// An optin has been processed. You can send this information to GA for analytics.
console.log(data);
});
});
View gist:8826589
jQuery(document).ready(function($){
$(document).on('OptinMonsterInit', function(event, data){
// If video is playing (add your own logic here), remove the optin.
if ( data.optin ) {
$('#om-' + data.optin).remove();
}
});
});
View gist:8869578
<?php
add_filter( 'optin_monster_cap', 'tgm_om_editor_cap' );
function tgm_om_editor_cap( $cap ) {
// Replace with the relevant capability needed for your editors.
return 'edit_others_posts';
}
View gist:8869849
<?php
add_filter( 'optinmonster_output', 'tgm_om_hide_optins' );
function tgm_om_hide_optins( $optins ) {
// Return an empty array if no user is logged in. Change this to your logic for determining where customers come from.
if ( ! is_user_logged_in() ) {
return array();
}
// Return the potentially modified optins.
@thomasgriffin
thomasgriffin / gist:8862970
Created Feb 7, 2014
Allow variable "custom" pricing for upgrades using a specific input field name "envira-custom-price". Change to whatever suits your needs.
View gist:8862970
<?php
add_filter( 'edd_add_to_cart_item', 'tgm_cp_add_to_cart_item' );
add_filter( 'edd_ajax_pre_cart_item_template', 'tgm_cp_add_to_cart_item' );
function tgm_cp_add_to_cart_item( $cart_item ) {
if ( ! empty( $_POST['post_data'] ) ) {
$post_data = array();
wp_parse_str( $_POST['post_data'], $post_data );
if ( isset( $post_data['envira-custom-price'] ) ) {
$cart_item['options']['custom_price'] = edd_sanitize_amount( $post_data['envira-custom-price'] );
@thomasgriffin
thomasgriffin / gist:9058101
Created Feb 17, 2014
Autoplay YouTube videos on both load and transition.
View gist:9058101
<?php
add_action( 'soliloquy_api_on_load', 'tgm_soliloquy_autoplay_youtube_on_load' );
function tgm_soliloquy_autoplay_youtube_on_load( $data ) {
ob_start();
?>
var slide_video = soliloquy_<?php echo $data['id']; ?>.find('.soliloquy-item:not(.soliloquy-clone):eq(' + currentIndex + ') .soliloquy-video-icon');
if ( slide_video.length > 0 ) {
var video_type = slide_video.data('soliloquy-video-type');
if ( 'youtube' == video_type ) {
@thomasgriffin
thomasgriffin / gist:9058111
Created Feb 17, 2014
Autoplay Wistia videos on load and transition.
View gist:9058111
<?php
add_action( 'soliloquy_api_on_load', 'tgm_soliloquy_autoplay_wistia_on_load' );
function tgm_soliloquy_autoplay_wistia_on_load( $data ) {
ob_start();
?>
var slide_video = soliloquy_<?php echo $data['id']; ?>.find('.soliloquy-item:not(.soliloquy-clone):eq(' + currentIndex + ') .soliloquy-video-icon');
if ( slide_video.length > 0 ) {
var video_type = slide_video.data('soliloquy-video-type');
if ( 'wistia' == video_type ) {
@thomasgriffin
thomasgriffin / gist:9057466
Last active Aug 29, 2015
Autoplay Vimeo videos on both load and transition.
View gist:9057466
<?php
add_action( 'soliloquy_api_on_load', 'tgm_soliloquy_autoplay_vimeo_on_load' );
function tgm_soliloquy_autoplay_vimeo_on_load( $data ) {
ob_start();
?>
var slide_video = soliloquy_<?php echo $data['id']; ?>.find('.soliloquy-item:not(.soliloquy-clone):eq(' + currentIndex + ') .soliloquy-video-icon');
if ( slide_video.length > 0 ) {
var video_type = slide_video.data('soliloquy-video-type');
if ( 'vimeo' == video_type ) {
You can’t perform that action at this time.