This documentation covers all the things you need to know to integrate LayerSlider WP into your WordPress theme. Please note that this documentation is made for developers, and it doesn't deal with the plugin itself. For information about installing and using the plugin, please read the other documentation.
Thank you for purchasing LayerSlider WP. If you have any questions beyond the
scope of this documentation, please do not hesitate to contact us.
We are excited that you chose LayerSlider WP for your theme, if you want to share
your work with us, we would love to see it.
As of 9th September, 2013, Envato requires authors to load bundled WordPress plugins in themes with the TGM Plugin Activation class. This helps authors to include 3rd party components easily and handle their dependencies and updates automatically.
Download the latest version of TGM Plugin Activation class from their website. The DL package has an example configuration, you just need to copy those into your theme's directory and include the the example.php in your functions.php file. In our example we put them into a folder called "plugins", so our code looks like this:
<?php require_once dirname( __FILE__ ) . '/plugins/example.php'; ?>
You can put those file anywhere in your theme you want with a name of your own choosing, but make sure you are referencing to the current path. The example PHP file will include the TGM Activation class, and you can use it all of the other plugins you want to include in your theme.
Copy the of the "installable" ZIP of LayerSlider into the same directory you have set up for the TGM Activation class next to the example plugin ZIP.
The example.php file already contains a sample configuration and you only need to add LayerSlider as a new array item.
Below you can see a sample array item to configure TGM for plugin installation. Make sure you are referencing for the correct source path. We are require you to set the force_deactivation option to true. To follow convention, you should only set the plugin as required if it is absolutely necessary for your theme to work properly, TGM will offer it to install anyway.
When you include an updated plugin, you need to update the version number, so TGM can recognize it and offer the update for your users.
// LayerSlider config array( 'name' => 'LayerSlider WP', 'slug' => 'LayerSlider', 'source' => get_stylesheet_directory() . '/plugins/layerslider.zip', 'required' => false, 'version' => '4.6.5', 'force_activation' => true, 'force_deactivation' => true )
We have an action hook with you can override the plugin's defaults externally from your theme. Since Envato now requires TGM, you need to update your code you may used previously. Our auto-update feature require an Item Purchase Code that your users won't have, and you should disable auto-updates and hide its settings from the LayerSlider admin page.
<?php // Register your custom function to override some LayerSlider data add_action('layerslider_ready', 'my_layerslider_overrides'); function my_layerslider_overrides() { // Disable auto-updates $GLOBALS['lsAutoUpdateBox'] = false; } ?>
LayerSlider WP is now properly integrated into your theme and ready to use by your customers. However, if you want to make them really happy, there are some other things you should consider. For example, it is always a good idea to offer
an option in the WP page editor where your users can choose a slider to
display.
Unfortunately, this documentation doesn't include techniques like this. We are assume that you are a developer who understands how WordPress works and should
be able to archive these kind of features on your own.
In future versions we will add a full and stable API for developers to change any settings the plugin have (including sliders), load your own skins, and to run custom filters before the slider is being displayed. Our goal is to offer the necessary tools for theme authors to control the plugin externally without modifying a single line in the original version.
mixed lsSliderById( mixed $id )
With this function, you can get a slider by its database ID. The $id parameter is required. Returns an associative array with the slider details (see below) on success, or false on failure.
array lsSliders( [mixed $limit = 50 [, bool $desc = true [, bool $withData = false ]]] )
This function returns the most recent sliders. Every parameter is optional. The $limit argument defaults to 50 entry. Without specifying the $desc parameter, the function returns the slider in descending order of creation. This function does not return the $data object for sliders by default, you need to set the third parameter to "true" for that. Returns an empty array on failure or if no sliders were found.
Type | Key | Purpose |
---|---|---|
int | $id | The database ID of the slider |
string | $name | The user defined name of the slider if any |
array | $data | The slider data object that contains all the settings |
int | $date_c | UNIX timestamp of the creation |
int | $date_m | UNIX timestamp of last modification |
Important: Please note that this changelog doesn't deal with the plugin itself, it is made for developers and it only lists the changes that affects them, and may requires modifications in their work.
4.6.3
4.6.1
4.6.0
4.0.0
3.6.0
3.5.0