Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I wish to change the default ajax loader for gravity forms. I have done this using the following code (link found here):

add_filter( 'gform_ajax_spinner_url', 'cwwp_custom_gforms_spinner' );

   /**
   * Changes the default Gravity Forms AJAX spinner.
   *
   * @since 1.0.0
   *
   * @param string $src The default spinner URL
   * @return string $src The new spinner URL
   */

    function cwwp_custom_gforms_spinner( $src ) {

    return get_stylesheet_directory_uri() . '/assets/img/css/newsletter-loader.gif';

}

This seems to work fine. What I would like todo is set another custom ajax spinner for a different form on a different page. The design of the page is different and I would like to set a different spinner. Any ideas how I do this?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Without testing, this should work (still use the add_filter bit):

function cwwp_custom_gforms_spinner( $src ) {
   global $post;
   if( $post->ID == $id ): // use whatever page identifier/conditional you like here: ID, template used, slug etc.
   // other identifiers would probably be better and won't rely on global $post
   // for example is_front_page(), is_archive(), etc
      return get_stylesheet_directory_uri() . 'path/to/spinner/1.gif';
   else:
      return get_stylesheet_directory_uri() . 'path/to/spinner/2.gif';
   endif;
}
share|improve this answer
    
Worked great! Thanks very much. –  Shane Griffiths Feb 20 '13 at 14:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.