Topic: Getsimple 3.1 Script/ Style queuing
Hi All,
For the next release of GetSimple 3.1 we are introducing Script and Style queuing on the system to allow Theme and Plugin writers to include your own Javascript and styles easily with your plugin distributions.
This will also give us a standard way of loading standard script such as JQuery, JQuery-UI, fancybox etc... and ensure that only one copy of each is loaded.
GetSimple 3.1 comes preconfigured with the following scripts and styles preconfigured ready for queuing on your pages.
Scripts
jquery - CDN version of Jquery
jquery-ui - CDN version of JQuery UI
fancybox - Fancybox lighbox script
getsimple - GetSimple site Javascript
Styles
getsimple - Getsimple Site CSS
By default Jquery, Fancybox & Getsimple scripts and the Getsimpel Stylesheet are loaded on the back-end pages.
We recommend that if you are including your own scripts and styles that you store them in a seperate folder in your plugin folder, /my_plugin_folder/js for your javascript files /my_plugin_folder/css for your stylesheets
Scripts
To register your script with the system use the following in your plugin.
register_script($handle, $src, $ver, $in_footer=FALSE)Where
$handle = unique name for your script.
$src = src location of your script.
$ver = version of your script file
$in_footer = whether to load the script after the footer.
So for example to register a script from your plugin folder use:
register_script('myscript', $SITEURL.'plugins/myplugin/myscript.js', '0.1', FALSE);To load the script for use on the back-end pages you need to queue it.
queue_script('myscript', GSBACK);
// use GSFRONT to load a script with your theme, GSBOTH for theme and AdminIf your plugin requires say JQuery on the frontend just queue it
queue_script('myscript', GSFRONT); Styles
Styles are registered and queued in the same way as scripts.
register_style($handle, $src, $ver, $media)Where
$handle = unique name for your style.
$src = src location of your style.
$ver = version of your file
$media = Media type for CSS file
Then just queue your style for use with the system
queue_style('mystyle', GSBACK);
// use GSFRONT to load a script with your theme, GSBOTH for theme and AdminThemes
Theme writers should also register scripts/styles instead of hardcoding them into the theme as we can ensure that only one copy of the scripts are loaded.
Please let us know if you any suggestions or comments on the new system .
Mike...
Download


