Created
October 9, 2016 17:04
-
-
Save wpexplorer/cc4bb9757d44fa55a5d4dfe3de9c8552 to your computer and use it in GitHub Desktop.
Contact from 7 conditionally load scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Contat Form 7 Configuration Class | |
* | |
* @package Total WordPress Theme | |
* @subpackage 3rd Party | |
* @version 3.6.0 | |
*/ | |
if ( ! class_exists( 'WPEX_Contact_Form_7' ) ) { | |
class WPEX_Contact_Form_7 { | |
/** | |
* Start things up | |
* | |
* @version 3.6.0 | |
*/ | |
public function __construct() { | |
// Remove CSS Completely - theme adds styles | |
add_filter( 'wpcf7_load_css', '__return_false' ); | |
// Remove JS | |
add_filter( 'wpcf7_load_js', '__return_false' ); | |
// Conditionally load JS | |
add_action( 'wpcf7_contact_form', array( 'WPEX_Contact_Form_7', 'enqueue_js' ) ); | |
} | |
/** | |
* Load JS conditionally | |
* | |
* @version 3.6.0 | |
*/ | |
public static function enqueue_js() { | |
if ( function_exists( 'wpcf7_enqueue_scripts' ) ) { | |
wpcf7_enqueue_scripts(); | |
} | |
} | |
} | |
} | |
new WPEX_Contact_Form_7(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment