Yes it is possible. When you use wp_dequeue_script() you have to use it after the script is enqueued. The earliest hook you can use to remove Caldera Forms scripts is “caldera_forms_render_form”
Thread Starter
fokus3
(@fokus3)
Hi Josh,
I tried this and my code looks like this now:
function deregister_select2_for_caldera( $items ) {
wp_dequeue_script( 'cfajax-baldrick' );
wp_dequeue_script( 'cfajax-core' );
wp_dequeue_script( 'cf-frontend-script-init' );
wp_dequeue_script( 'cf-frontend-fields' );
}
add_action( 'caldera_forms_render_form', 'deregister_select2_for_caldera', 11 );
So far so good – the JS files will be dequeued and not loaded anymore.
BUT – now I load these script manually inside of the footer. In the end the HTML code looks the same as when CF loads the scripts. But CF isn’t working anymore. It seems so, that the shortcode isn’t executed anymore now.
Did I made any mistakes. How can this be solved?
Thx for your assistance.
Thread Starter
fokus3
(@fokus3)
oops, found the mistake – it’s a filter and not an action. Code looks now like:
add_filter( 'caldera_forms_render_form', 'deregister_select2_for_caldera', 11, 2 );
function deregister_select2_for_caldera( $items, $form ) {
....
}
works like a charme now
Yes, it is a filter, so you must return, $items, or it’s going to break stuff. Confusing, as you’re using it the way we normally use an action. Then again, actions, are filters…
Thread Starter
fokus3
(@fokus3)
Thx for your help! Support is really great 🙂