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 Cute Slider 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 Cute Slider WP

You can include and activate Cute Slider 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 Cute Slider 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 Cute Slider WP */
/**************************/

// Path for Cute Slider WP main PHP file
$cuteslider = get_stylesheet_directory() . '/plugins/CuteSlider/cuteslider.php';

// Check if the file is available to prevent warnings
if(file_exists($cuteslider)) {

	// Include the file
	include $cuteslider;

	// Activate the plugin if necessary
	if(get_option('<your_theme>_cuteslider_activated', '0') == '0') {

		// Run activation script
		cuteslider_activation_scripts();

		// Save a flag that it is activated, so this won't run again
		update_option('<your_theme>_cuteslider_activated', '1');
	}
}

?>

If you did it right, you can see that the Cute Slider 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

Cute Slider 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 cuteslider.php file. Remember, we created a "plugins" folder with the contents of Cute Slider 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['csPluginVersion'] = '1.1.1';
	$GLOBALS['csPluginPath'] = get_stylesheet_directory_uri() . '/plugins/CuteSlider';

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

So what's next?

Cute Slider 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 Cute Slider 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 . "cuteslider";

	// 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.