Asked By
Jacobson
0 points
N/A
Posted on - 07/20/2011
As we know, jQuery is a cross browser JavaScript library designed to simplify the client side scripting of HTML. I am interested in creating a plug-in for WordPress.
In addition to using PHP according to my friends also have to use jQuery and $ programming language. Which do you think is better to create a word press plug-in?
Create a Plugin for WordPress using Jquery
Before you create any Ajax code you need to include the jQuery library, so that it is loaded as part of your WordPress webpages. You need to do three things:
1. Create your own JavaScript apply for your Ajax code.
2. Write a function which loads your own JavaScript file and also the jQuery library.
3. Add an action to phone the aforementioned perform.
So, inside your plugin listing, create a folder called “js”, and within which folder produce a file known as “myJavascript.js”. Now, in your main WordPress plugin PHP piece of software, create the following function:
functionmy_init() {
wp_enqueue_script( 'myJavascript',get_bloginfo('wpurl').'/wp-content/plugins/YourPluginName/js/myJavascript.js', array('jquery'));
}
Now we have the function, we have to tell the plugin in order to call which function once the page is loaded. We all do this by adding a new motion, so include the following for your main PHP script of your plugin:
add_action('init', 'my_init')
This action will now make sure jQuery and your JavaScript are known asin the <HEAD> a part of your pages. All you now have to does create your Ajax code in your recently created “myJavascript.js” and you’re done!
Answered By
Jacobson
0 points
N/A
#85660
Create a Plugin for WordPress using Jquery
My problem when coding with jQuery is always conflict with other functions thanks Shethkushal for this one. I actually wanted to post a note to be able to appreciate you Rizamelle.otic for those awesome strategies you are giving on your solutions.