Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Created June 17, 2025 10:57
Show Gist options
  • Save xlplugins/678f1f20eb126d3031b273636bfae617 to your computer and use it in GitHub Desktop.
Save xlplugins/678f1f20eb126d3031b273636bfae617 to your computer and use it in GitHub Desktop.
Dequeue_wp_forms_js_on_optin
/**
* Dequeues the `wpforms-smart-phone-field` script on optin pages.
*
* This function hooks into the `wp_enqueue_scripts` action and checks if the current page
* is an optin page using the `WFFN_Optin_Pages` class. If the page is an optin page, it
* removes the `wpforms-smart-phone-field` script from the queue.
*
* @hook wp_enqueue_scripts
* @priority 20
*/
add_action( 'wp_enqueue_scripts', function() {
// Check if the current page is an optin page.
if ( class_exists( 'WFFN_Optin_Pages' ) && WFFN_Optin_Pages::get_instance()->is_wfop_page() ) {
// Dequeue the wpforms-smart-phone-field script.
wp_dequeue_script( 'wpforms-smart-phone-field' );
}
}, 9999999 ); // Priority set to 20 to ensure it runs after scripts are enqueued.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment