# LayerSlider WP 3.6.0

## The WordPress Parallax Slider

### Documentation for Developers

- Overview
  - Thank you
  - Changelog
- About licensing terms
  - Restrictions in licensing terms
  - The prefered way
  - Benefits
  - Disadvantages
- Step-by-step guide
  - Copy the plugin into your theme folder
  - Including and activating LayerSlider WP
  - Setting the plugin's path
  - So what's next?
  - One final example

### Overview

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

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.

### Changelog

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.

3.6.0

- Localization ready You can find the .PO file if you want to translate the entire plugin (including the admin user interface) in the languages folder.
- Language support You can now create multilingual sliders with popular translation plugins like qTranslate.
- Multisite ready LayerSlider WP 3.6.0 is now supports network-wide activation and it automatically handles the database when a Super Admin adds a new site to the network.

3.5.0

- New data storage: LayerSlider WP doesn't use the WP options API anymore, it has a separate database table now. The data structure also changed, we are now using JSON serialization. If you are working with LayerSlider WP data for example to offer an option to your users to select a slider which will be shown on a page, you need to change your code for the new data storage. You can find an example at the end of this documentation.
  Please note that LayerSlider WP 3.5.0 is compatible with the old data storage, your users will be prompted to convert their data associated with the plugin with a banner on the top of the page.

# About licensing terms

### Restrictions in licensing terms

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 prefered way

The prefered 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 fast and easily. Below there is a step-by-step guide to do this.

### Benefits

- It complies for the Envato licensing terms,
- It is automatic, your users don't have to bother with plugin installation,
- The plugin will be activated automatically,
- There won't be any dependency, every feature will work by default,
- And you can achieve deeper integration with many features built upon the plugin

### Disadvantages

- You need to do some extra work to achieve these benefits, but it only takes a few minutes

# Step-by-step guide

### Copy the plugin into your theme folder

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 refering to this location, but it can be different with your own file-structure.

### Including and activating LayerSlider WP

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.

### Setting the plugin's path

LayerSlider WP needs to load some plugin resources such as CSS and Javascript files, so you have to specify the path of the plugin relative to the root of your theme 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. The higlighted line indicates the changes.

    /********************************************************/
    /*                        Actions                       */
    /********************************************************/

    	$GLOBALS['lsPluginPath'] = get_stylesheet_directory_uri() . '/plugins/LayerSlider/';

    	// Activation hook for creating the initial DB table
    	register_activation_hook(__FILE__, 'layerslider_activation_scripts');

    	// Run activation scripts when adding new sites to a multisite installation
    	add_action('wpmu_new_blog', 'layerslider_new_site');

### So what's next?

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 recognise 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 achive these kind of features by yourself. We made this documentation to make your life easier without the need to analyze our codebase.

### One final example

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>';
    	}
    }

    ?>

### Contact us!

## If you like our works.
If you need a help in using one of our CodeCanyon items.
If you have a great idea which we can work together.