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.
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.0.0
3.6.0
3.5.0
The Envato licensing terms and conditions prohibits you to include the plugin as a standalone item. This means that you cannot ask your users to treat it as a separate item for installation, you have to integrate it into your theme.
The preferred way it that you must hide the plugin within your theme and load it manually in your functions.php file. This requires some modifications, but it can be done quickly and easily. Below there is a step-by-step guide to do this.
First, you have to copy the plugin into your theme folder. This is located in your "/wp-content/themes/<your_theme>/" folder. In our sample we created a "plugins" folder in the theme root directory, this is the place where we copied LayerSlider WP. Later, you will need to edit some of the plugin files, so always keep in mind that we are referring to this location, but it can be different with your own file-structure.
You can include and activate LayerSlider WP in your functions.php
file. This file is located under your "/wp-content/themes/<your_theme>/"
folder.
Please note that this code assumes there is a "plugins" folder in your theme
root directory and LayerSlider WP is located in this folder. If you are using
a different file-structure, you need to change the file path on line 8.
Also, in this code, please replace the "<your_theme>" part with the name
of your theme.
<?php /**************************/ /* Include LayerSlider WP */ /**************************/ // Path for LayerSlider WP main PHP file $layerslider = get_stylesheet_directory() . '/plugins/LayerSlider/layerslider.php'; // Check if the file is available to prevent warnings if(file_exists($layerslider)) { // Include the file include $layerslider; // Activate the plugin if necessary if(get_option('<your_theme>_layerslider_activated', '0') == '0') { // Run activation script layerslider_activation_scripts(); // Save a flag that it is activated, so this won't run again update_option('<your_theme>_layerslider_activated', '1'); } } ?>
If you did it right, you can see that the LayerSlider WP menu item appeared in your WP admin area. It won't work just yet, we need some further changes, so don't scare if you run into some issues.
LayerSlider WP needs to load some plugin resources such as CSS and
Javascript files, so you have to specify the path of the plugin in the
layerslider.php file.
Remember, we created a "plugins" folder with the contents
of LayerSlider in our sample, but you may use a different file-structure, so you
may have to rewrite this path.
Also, our auto-update mechanism requires an item purchase code (which your
users won't have) and it isn't working with integrated plugins, so you should
disable it. It is your responsibility to release theme updates with the most
recent version of our plugin.
The highlighted lines indicates the changes.
/********************************************************/ /* Actions */ /********************************************************/ $GLOBALS['lsPluginVersion'] = '4.5.1'; $GLOBALS['lsPluginPath'] = get_stylesheet_directory_uri() . '/plugins/LayerSlider/'; $GLOBALS['lsAutoUpdateBox'] = false; $GLOBALS['lsRepoAPI'] = 'http://repo.kreatura.hu/'; $GLOBALS['lsPluginSlug'] = basename(dirname(__FILE__)); // Activation hook for creating the initial DB table register_activation_hook(__FILE__, 'layerslider_activation_scripts');
LayerSlider WP is now integrated into your theme and it is fully functional.
However, if you want to make your users 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. It is also can be wise that you offer an option to disable the plugin,
since WordPress won't recognize it as a normal plugin and your users won't be
able to deactivate it by default.
Unfortunately, this documentation doesn't include these techniques. We are assume
that you are a developer who understands how WordPress works, so you should
be able to archive these kind of features by yourself. We made this documentation
to make your life easier without the need to analyze our codebase.
Here is a final example to show how you can fetch the LayerSlider WP sliders. You can use it for the above mentioned feature. The rest is up to you.
<?php // Get WPDB Object global $wpdb; // Table name $table_name = $wpdb->prefix . "layerslider"; // Get sliders $sliders = $wpdb->get_results( "SELECT * FROM $table_name WHERE flag_hidden = '0' AND flag_deleted = '0' ORDER BY date_c ASC LIMIT 100" ); // Iterate over the sliders foreach($sliders as $key => $item) { echo '<option value="'.$item->id.'">'.$item->name.'</option>'; } } ?>