Skip to content

Instantly share code, notes, and snippets.

@yeriepiscesa
Created April 20, 2019 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yeriepiscesa/fc87da06142c6e7657c4612605055cdf to your computer and use it in GitHub Desktop.
Save yeriepiscesa/fc87da06142c6e7657c4612605055cdf to your computer and use it in GitHub Desktop.
<?php
$page_slug = 'cf7-administrative-data';
function wpcf7_enqueue_script() {
if( is_page( $page_slug ) ) {
wp_register_script( 'yp-administrative', plugin_dir_url( __FILE__ ) . 'chainedselect.js' );
}
}
add_action( 'wp_enqueue_scripts', 'wpcf7_enqueue_script' );
function wpcf7_load_javascript() {
if( is_page( $page_slug ) ) {
wp_localize_script( 'yp-administrative', 'chainedselect', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'security' => wp_create_nonce( 'ajax-get-administrative' ),
));
wp_enqueue_script( 'yp-administrative' );
}
}
add_action( 'wp_head', 'wpcf7_load_javascript', 999, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment