Available Filters

Filters allow you to change the way my plugin works without having to modify the plugin files directly. This means when updates come out, your changes will not get overwritten. For more information about filters and how they work, see this tutorial by Tom McFarlin. The basic usage involves you placing a new PHP function in your theme. The default placement is the functions.php file of your theme (some themes may have a specific file for them). Here is each available filter with an explanation and code snippit.

Filter Default Value
testimonial_rotator_scripts_in_footer false
testimonial_rotator_display_args Array of Arguments
testimonial_rotator_font_awesome_version latest
testimonial_rotator_base_transitions Array of Cycle2 Transitions
testimonial_rotator_testimonial_slug testimonials
testimonial_rotator_menu_position 26.6
testimonial_rotator_testimonial_supports Array(title,editor,excerpt,thumbnail,page-attributes,custom-fields)
testimonial_rotator_supports Array(title,custom-fields)
testimonial_rotator_pt_args Array of Arguments
testimonial_rotator_pt_rotator_args Array of Arguments
testimonial_rotator_auto_height calc
testimonial_rotator_div_selector > div.slide
testimonial_rotator_title_heading h2
testimonial_rotator_excerpt_length 20
testimonial_rotator_hover true
testimonial_rotator_star fa-star
testimonial_rotator_extra_wrap_class Empty
testimonial_rotator_fa_icon_prev fa-chevron-left
testimonial_rotator_fa_icon_next fa-chevron-right
testimonial_rotator_fa_icon_prev_vert fa-chevron-down
testimonial_rotator_fa_icon_next_vert fa-chevron-up
testimonial_rotator_swipe true
testimonial_rotator_themes Array of Themes
testimonial_rotator_pre_widget_instance Array of Settings
testimonial_rotator_single_page_theme default
testimonial_rotator_the_excerpt get_the_excerpt()
testimonial_rotator_order ASC

Default: false

Allows you to place the javascripts used in the footer

function hg_testimonial_rotator_scripts_in_footer()
  return true;

Default: Array of Arguments

Right before we query for testimonials, there is a filter to change any attributes passed to  query_posts.

function hg_testimonial_rotator_display_args( $args, $rotator_id ) {
    $args['posts_per_page'] = 30;
    return $args;
add_filter( 'testimonial_rotator_display_args', 'hg_testimonial_rotator_display_args', 10, 2 );

Default: latest

Now that I found the latest version of font awesome this filter is a bit obsolete. I’ll leave it in place if someone needs it, but for now the ‘latest’ will also get the most recent version of the css.

function hg_testimonial_rotator_font_awesome_version()
  return "1.1.0";

Default: Array of Cycle2 Transitions

I include the basic transitions available with the Cycle 2 jQuery plugin. This is the plugin I use to handle the rotator of the rotator. Check out the documentation to create a custom transition.

function hg_testimonial_rotator_base_transitions( $transitions )
  $transitions[] = 'custom-transition';
  return $transitions;

Default: testimonials

The custom post type slug for the archive page is set here. You can change to whatever you need.

function hg_testimonial_rotator_testimonial_slug( ) 
  return "praise"; 
add_filter( 'testimonial_rotator_testimonial_slug', 'hg_testimonial_rotator_testimonial_slug' );

Default: 26.6

You can move the Testimonials Menu position in the admin. Changing this number will put it higher or lower in the navigation. See locations for the menu position.

function hg_testimonial_rotator_menu_position( ) 
  return "71"; 
add_filter( 'testimonial_rotator_menu_position', 'hg_testimonial_rotator_menu_position' );

Default: Array(title,editor,excerpt,thumbnail,page-attributes,custom-fields)

Simply change the custom post type support items for the testimonial custom post type. For instance if you want to add comments to testimonials, you can add the snippit below.

function hg_testimonial_rotator_testimonial_supports( $args ) 
  $args[] = 'comments';
  return $args ; 
add_filter( 'testimonial_rotator_testimonial_supports', 'hg_testimonial_rotator_testimonial_supports' );

Default: Array(title,custom-fields)

Simply change the custom post type support items for the testimonial rotator custom post type.

function hg_testimonial_rotator_supports( $args ) 
  $args[] = 'comments';
  return $args ; 
add_filter( 'testimonial_rotator_supports', 'hg_testimonial_rotator_supports' );

Default: Array of Arguments

Last chance to change arguments when creating the custom post type ‘testimonial’

function hg_testimonial_rotator_pt_args( $args )
  $args['has_archive'] = false;
  return $args;
add_filter( 'testimonial_rotator_pt_args', 'hg_testimonial_rotator_pt_args' );

Default: Array of Arguments

Last chance to change arguments when creating the custom post type ‘testimonial_rotator’

function hg_testimonial_rotator_pt_rotator_args( $args )
  $args['has_archive'] = true;
  return $args;
add_filter( 'testimonial_rotator_pt_rotator_args', 'hg_testimonial_rotator_pt_rotator_args' );

Default: calc

Allows to change how the rotator handles the height of the container. Testimonials will most likely be different sizes because of how much text is written. Learn more about the options available. For instance if you want the height to auto adjust add the following snippit.

function hg_testimonial_rotator_auto_height( $current, $rotator_id )
  return ( $id == 100 ) ? "container" : $current;
add_filter( 'testimonial_rotator_auto_height', 'hg_testimonial_rotator_auto_height', 10, 2 );

Default: > div.slide

You probably don’t want to change this unless you are building custom templates, but if you want to get wild with the Cycle 2 rotator you can change this to make whatever you wan.

function hg_testimonial_rotator_div_selector( $current, $rotator_id )
  return ( $id == 100 ) ? "> section.slide" : $current;
add_filter( 'testimonial_rotator_div_selector', 'hg_testimonial_rotator_div_selector', 10, 2 );

Default: h2

When using the default template there is a highlight spot. This is currently wrapped with an H2. You can change this in the rotator settings or using this filter.

function hg_testimonial_rotator_title_heading( $current, $template_name, $rotator_id )
  if( $template_name == "threepigs") return "h3";
  else if( $rotator_id == 100) return "span";
  return $current;
add_filter( 'testimonial_rotator_title_heading', 'hg_testimonial_rotator_title_heading', 10, 3 );

Default: 20

If you are using the excerpt of the testimonial for a widget you can specify the length of that widget with this filter. Starting in version 2.1 of the plugin and if PHP 5.3 is installed on your server you will be able to change this in a text box on your widget settings.

function hg_testimonial_rotator_excerpt_length( $current, $rotator_id )
  if( $rotator_id == 100) return 50;
  return $current;
add_filter( 'testimonial_rotator_excerpt_length', 'hg_testimonial_rotator_excerpt_length', 10,2 );

Default: true

If you pass in the attribute to the shortcode ‘no_pause_on_hover’ you can turn off this pause on hover functionality. This gives the reader a chance to stop the rotator by putting their mouse over the rotator.

function hg_testimonial_rotator_hover( $current, $rotator_id )
  if( $rotator_id == 100) return false;
  return $current;
add_filter( 'testimonial_rotator_hover', 'hg_testimonial_rotator_hover', 10,2 );

function hg_testimonial_rotator_hover()
  return false;
add_filter( 'testimonial_rotator_hover', 'hg_testimonial_rotator_hover' );

Default: fa-star

Beginning in version 2.0.5 you can now change the stars of the rotator to something else. Available icons are found here.

function hg_testimonial_rotator_star( $icon, $template_name, $rotator_id )
  if( $rotator_id == 100) return "fa-paw";
  return "fa-thumbs-up";
add_filter( 'testimonial_rotator_star' , 'hg_testimonial_rotator_star', 10, 3 );

Default: Empty

Add additional classes to your rotator. Create for creating custom testimonials and themes. The template_name is passed along with the rotator id so you can make custom changes to only certain rotators. Make sure to add a spaces at the beginning and end to avoid classes being strung together.

function hg_testimonial_rotator_extra_wrap_class( $current, $template_name, $rotator_id )
  if( $rotator_id == 100) return " cool-rotator-100 ";
  return $current;
add_filter( 'testimonial_rotator_extra_wrap_class' , 'hg_testimonial_rotator_extra_wrap_class', 10, 3 );

Default: fa-chevron-left

The Font Awesome icon used for the previous arrow. View directional icons

function hg_testimonial_rotator_fa_icon_prev( $current, $rotator_id )
  return 'fa-chevron-circle-left';
add_filter( 'testimonial_rotator_fa_icon_prev' , 'hg_testimonial_rotator_fa_icon_prev', 10, 2 );

Default: fa-chevron-right

The Font Awesome icon used for the next arrow. View directional icons

function hg_testimonial_rotator_fa_icon_next( $current, $rotator_id )
  return 'fa-chevron-circle-right';
add_filter( 'testimonial_rotator_fa_icon_next' , 'hg_testimonial_rotator_fa_icon_next', 10, 2 );

Default: fa-chevron-down

The Font Awesome icon used for the previous arrow when the transition scrollVert is used. View directional icons

function hg_testimonial_rotator_fa_icon_prev_vert( $current, $rotator_id )
  return 'fa-chevron-circle-down';
add_filter( 'testimonial_rotator_fa_icon_prev_vert' , 'hg_testimonial_rotator_fa_icon_prev_vert', 10, 2 );

Default: fa-chevron-up

The Font Awesome icon used for the next arrow when the transition scrollVert is used. View directional icons

function hg_testimonial_rotator_fa_icon_next_vert( $current, $rotator_id )
  return 'fa-chevron-circle-up';
add_filter( 'testimonial_rotator_fa_icon_next_vert' , 'hg_testimonial_rotator_fa_icon_next_vert', 10, 2 );

Default: true

Allows devices with touch screens to swipe through the testimonials.

function hg_testimonial_rotator_swipe( $current, $rotator_id )
  return 'false';
add_filter( 'testimonial_rotator_swipe' , 'hg_testimonial_rotator_swipe', 10, 2 );


The underlying plugin used to make my plugin work is the Cycle 2 jQuery plugin. It has a lot of data attribute that can be added to make your rotator even more custom. Note: instead of using data-cycle you need to use data-cycletwo.

function hg_testimonial_rotator_data_attributes( $current, $template_name, $rotator_id )
  return ' data-cycletwo-easing="linear" ';
add_filter( 'testimonial_rotator_data_attributes' , 'hg_testimonial_rotator_data_attributes', 10, 3 );

Default: Array of Themes

Themes started in version 2.1. This is where you can plugin to add custom themes for the user to select from. You need to add a properly formatted array item as the element.

function hg_testimonial_rotator_custom( $themes )
  $themes = (array) $themes;
  return array_merge( $themes, array( 
       'custom-slug' => array(
       'title' 	=> 'Custom Theme', 
       'icon' 	=> plugins_url( '/icon-custom.png', __FILE__) )
add_filter( 'testimonial_rotator_themes' , 'hg_testimonial_rotator_custom' );

Default: Array of Settings

You can hook into the object passed into the Widget. This allows you to change any variables that don’t have a user interface setting in the widget.

function hg_testimonial_rotator_pre_widget_instance( $obj, $rotator_id )
  $obj['shuffle'] = true;
  $obj['excerpt_length'] = 100;
  return $obj;
add_filter( 'testimonial_rotator_pre_widget_instance' , 'hg_testimonial_rotator_pre_widget_instance', 10, 2 );

Default: default

Each testimonial has a page all of its own just like a post or regular page. The template used is the default. You can use this filter to change which template is used.

function hg_testimonial_rotator_single_page_theme( $current, $testimonial_id )
  if( $testimonial_id == 100) return "longform";
  return $current;
add_filter( 'testimonial_rotator_single_page_theme' , 'hg_testimonial_rotator_single_page_theme', 10, 2 );

Default: get_the_excerpt()

This is a wrapper function starting in version 2.1.1 of my plugin. Instead of just calling get_the_excerpt you can now modify it’s output before being called easier.

function hg_testimonial_rotator_the_excerpt( $html, $limit )
	$more_text = '... <a class="read-more" href="'.get_permalink(get_the_ID()).'">Read Full...</a>';
	return wp_trim_words(get_the_excerpt(), $limit, $more_text);
add_filter('testimonial_rotator_the_excerpt', 'hg_testimonial_rotator_the_excerpt', 10, 2);

Default: ASC

Added in 2.2.7 to allow you to change the order of the testimonials in the rotator. Two parameters are available to filter based on template or testimonial ID.

function hg_testimonial_rotator_order($template_name, $testimonial_id)
  return 'DESC';
add_filter('testimonial_rotator_order', 'hg_testimonial_rotator_order', 10, 2);