For my WordPress site I really need to be able to have the functions that this library offers.
My question is would it be possible to convert that jQuery plugin into a working WordPress plugin? And if so, how?
Would this be the correct way to make the init.php file?
<?php
/*
Plugin Name: jQuery Windows
Plugin URI: http://fstoke.me/jquery/window
Description: Sexy jQuery Windows.
Version: 5.03
Author: PC - Prashant Chaudhary
Author URI: http://fstoke.me/jquery/window
License: Creative Commons Attribution-ShareAlike
*/
wp_enqueue_style(
'jquerywindowstyles',
WP_PLUGIN_URL.'/jQuery-windows/css/jquery.window.css',
false,
all);
// Add the scripts to the footer
function jquerywindowjs(){
// Identify our javascript files
wp_register_script(
'jquery.window',
WP_PLUGIN_URL.'/jquery-windows/jquery.window.js',
array( 'jquery' ),
"2.1.4",
1 );
wp_register_script(
'jquery.window.min',
WP_PLUGIN_URL.'/jquery-windows/jquery.window.min.js',
array( 'jquery', 'jquery.window' ),
"1.0",
1 );
// Then enqueue them
wp_enqueue_script( 'jquery.window' );
}
// Action our scripts
add_action( 'wp_enqueue_scripts', 'jquerywindowjs' );
?>
The direct answer is Yes, It is possible . and easily.
How to do that , is a different question and much more elaborated .
But , if you need it for a one-time-use in one site – you always have the option to just include the script using
wp_enqueue_script()
, and the styles withwp_enqueue_style()
in yourfunctions.php
and then use as is ..But , you already have a lot of wordpress plugins that have similar functionality ..
see :
http://wordpress.org/plugins/search.php?q=modal
or
http://wordpress.org/plugins/search.php?q=popup
It is not exluded that you can find the same script already as a plugin since there are literally hundreds of them..
Sure, all you do to make php/js code into a WordPress plugin is give it the plugin header, set up a place where your code is inserted into wordpress (actions), and optionally create a configuration page for the plugin in PHP for the wordpress admin.
Basically, that would mean repackaging the current jquery plugin as a wordpress plugin. It would function as a way to install this plugin into wordpress.
WP has pretty good documentation: http://codex.wordpress.org/Writing_a_Plugin
I found that starting with a simple plugin (one php file), reading it, and seeing how it worked gave me enough info to start turning my code into WP plugins.