Skip to content

Instantly share code, notes, and snippets.

@ApoGouv
Forked from danielpataki/compatibility.js
Created August 4, 2017 11:29
Show Gist options
  • Save ApoGouv/b706047d57532059596dd73d5daca905 to your computer and use it in GitHub Desktop.
Save ApoGouv/b706047d57532059596dd73d5daca905 to your computer and use it in GitHub Desktop.
jQuery in WordPress
/* Regular jQuery */
$('.hideable').on('click', function() {
$(this).hide();
})
/* Compatibility Mode */
jQuery('.hideable').on('click', function() {
jQuery(this).hide();
})
function my_admin_scripts() {
wp_enqueue_script( 'my-great-script', plugin_dir_url( __FILE__ ) . '/js/my-great-script.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'admin_enqueue_scripts', 'my_admin_scripts' );
function my_theme_scripts() {
wp_enqueue_script( 'my-great-script', get_template_directory_uri() . '/js/my-great-script.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' );
jQuery(document).ready(function( $ ) {
$('.hideable').on('click', function() {
$(this).hide();
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment