I'm creating a basic plugin that allows me to add columns, accordions, and tabs. Everything is working fine but my tabs and accordions require http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js
How do I add this jquery library to my plugin? My code is below.
<?php
/*
Plugin Name: Everypraise Plugin
Plugin URI: http://breonwilliams.com
Description: adds a button to your editor to allow you to add basic shortcodes like buttons and columns
Version: 1.2
Author: Breon Williams
Author URI: http://breonwilliams.com
License: GPL2
*/
/* Variables */
$everypraise_shortcodes_path = dirname(__FILE__);
$everypraise_shortcodes_main_file = dirname(__FILE__).'/everypraiseplugin.php';
$everypraise_shortcodes_directory = plugin_dir_url($everypraise_shortcodes_main_file);
$everypraise_shortcodes_name = "Everypraise Plugin";
/* Add shortcodes scripts file */
function everypraise_shortcodes_add_scripts() {
global $everypraise_shortcodes_directory, $everypraise_shortcodes_path;
if(!is_admin()) {
/* Includes */
include($everypraise_shortcodes_path.'/assets/functions.php');
wp_enqueue_style('everypraise_shortcodes', $everypraise_shortcodes_directory.'/assets/css/shortcodes.css');
wp_enqueue_script('jquery');
wp_register_script('footerjs', $everypraise_shortcodes_directory.'assets/js/my-footer-scripts.js', 'jquery','1.0',true);
wp_register_script('easing', $everypraise_shortcodes_directory.'assets/js/jquery.easing.min.js', 'jquery','1.0',true);
wp_enqueue_script('footerjs');
wp_enqueue_script('easing');
} else {
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );
}
/* Font Awesome */
wp_enqueue_style('everypraise_shortcodes_fontawesome', $everypraise_shortcodes_directory.'/fonts/fontawesome/css/font-awesome.min.css');
wp_enqueue_style('everypraise_shortcodes_fontello', $everypraise_shortcodes_directory.'/fonts/fontello/css/fontello.css');
}
add_filter('init', 'everypraise_shortcodes_add_scripts');
// Add Formats Dropdown Menu To MCE
if ( ! function_exists( 'wpex_style_select' ) ) {
function wpex_style_select( $buttons ) {
array_push( $buttons, 'styleselect' );
return $buttons;
}
}
add_filter( 'mce_buttons', 'wpex_style_select' );
// Hooks your functions into the correct filters
function my_add_mce_button() {
// check user permissions
if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {
return;
}
// check if WYSIWYG is enabled
if ( 'true' == get_user_option( 'rich_editing' ) ) {
add_filter( 'mce_external_plugins', 'my_add_tinymce_plugin' );
add_filter( 'mce_buttons', 'my_register_mce_button' );
}
}
add_action('admin_head', 'my_add_mce_button');
// Declare script for new button
function my_add_tinymce_plugin( $plugin_array ) {
$plugin_array['my_mce_button'] = plugins_url( '/assets/js/mce-button.js', __FILE__ );
return $plugin_array;
}
// Register new button in the editor
function my_register_mce_button( $buttons ) {
array_push( $buttons, 'my_mce_button' );
return $buttons;
}
wp_deregister_script( 'jquery' ); //disable the stock jQuery
wp_register_script( 'google_jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js', array(), null, true ); //register the new version
wp_enqueue_script( 'google_jquery' ); //load the new version
If you will be using other scripts that use jQuery as a dependency, you should specify it.
wp_enqueue_script( 'some_other_script', 'path/to/script', array( 'google_jquery' ), null, true );