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?
1 Answer
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;
}