Skip to content

Instantly share code, notes, and snippets.

View thomasgriffin's full-sized avatar
👋

Thomas Griffin thomasgriffin

👋
View GitHub Profile
@thomasgriffin
thomasgriffin / gist:9071378
Created February 18, 2014 13:52
Remove width and height attributes from images in Soliloquy sliders.
<?php
add_action( 'tgmsp_callback_start', 'tgm_soliloquy_remove_image_attr' );
function tgm_soliloquy_remove_image_attr( $id ) {
$script = 'var slides = $(slider).find(".soliloquy-slides > li img");';
$script .= '$(slides).each(function(i){';
$script .= '$(this).removeAttr("width height");';
$script .= '});';
echo $script;
@thomasgriffin
thomasgriffin / gist:9094912
Created February 19, 2014 15:56
Autoplay Vimeo videos AND always force them to replay when moving to them.
<?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 ) {
@thomasgriffin
thomasgriffin / gist:9219422
Created February 25, 2014 22:35
Add the image title as a caption below the image in the gallery display.
<?php
add_filter( 'envira_gallery_output_after_link', 'tgm_envira_gallery_caption', 10, 5 );
/**
* Adds a caption below each image in the gallery.
*
* @since 1.0.0
*
* @param string $output String of gallery output.
* @param mixed $id The ID of the gallery.
* @param array $item Array of data about the image.
@thomasgriffin
thomasgriffin / gist:9393337
Created March 6, 2014 16:21
Link Soliloquy captions (v1.x).
<?php
add_filter( 'tgmsp_caption_output', 'tgm_soliloquy_link_caption', 10, 3 );
function tgm_soliloquy_link_caption( $caption, $id, $image ) {
if ( empty( $image['link'] ) ) {
return $caption;
}
$linked_caption = '<a href="' . esc_url( $image['link'] ) . '" title="' . esc_attr( $image['title'] ) . '">' . $caption . '</a>';
return $linked_caption;
@thomasgriffin
thomasgriffin / gist:9416114
Created March 7, 2014 17:37
Removes all Soliloquy admin output signals.
<?php
add_action( 'after_setup_theme', 'tgm_soliloquy_remove_post_type' );
function tgm_soliloquy_remove_post_type() {
if ( ! class_exists( 'Soliloquy' ) ) {
return;
}
add_filter( 'soliloquy_post_type_args', '__return_empty_array' );
@thomasgriffin
thomasgriffin / gist:9606363
Created March 17, 2014 19:19
Remove Soliloquy boxes from everywhere except for the Soliloquy post type screen (v2).
<?php
add_action( 'add_meta_boxes', 'tgm_soliloquy_remove_metabox', 0 );
function tgm_soliloquy_remove_metabox() {
if ( ! class_exists( 'Soliloquy' ) ) {
return;
}
if ( empty( get_current_screen()->post_type ) || 'soliloquyv2' == get_current_screen()->post_type ) {
return;
jQuery(document).ready(function($){
$(document).on('click', '.manual-optin-trigger', function(e){
e.preventDefault();
var $this = $(this);
// Ensure that the OptinMonster function exists.
if ( typeof window['OptinMonster'] === 'function' ) {
// Load a different optin based on ID.
if ( 'your-id-here' == $this.attr('id') ) {
// Append our holder to the DOM if it does not already exist.
@thomasgriffin
thomasgriffin / gist:9832460
Created March 28, 2014 13:17
Turns on detailed OptinMonster reporting.
<?php
if ( ! defined( 'OPTINMONSTER_REPORTING' ) ) {
define( 'OPTINMONSTER_REPORTING', true );
}
<?php
add_filter( 'soliloquy_image_output_attr', 'tgm_soliloquy_prevent_pin' );
function tgm_soliloquy_prevent_pin( $attr ) {
return $attr . ' data-pin-no-hover="true"';
}
<?php
add_filter( 'tgmsp_image_output', 'tgm_soliloquy_prevent_pin', 10, 5 );
function tgm_soliloquy_prevent_pin( $html, $id, $image, $alt, $title ) {
return '<img class="soliloquy-item-image" src="' . esc_url( $image['src'] ) . '" alt="' . esc_attr( $alt ) . '" title="' . esc_attr( $title ) . '" data-pin-no-hover="true" />';
}