Create Your Own Plugins

Different websites do different tasks. For example, some websites sell products & services while others post blogs. And some websites use APIs and complex functions to carry out the tasks. Plugins are designed to achieve necessary tasks without slowing down your website.

Why are plugins important?

Plugins are really amazing and a good way to add/remove special tasks to/from your website. Here is something to know about RND plugins.

  • You can download plugins from our website or other sources to carry out difficult tasks on your website.
  • You can disable unused plugins to improve performance of your website.
  • You can develop your own plugins using RND Hooks & Constants.
  • Plugins do not depend on template functions. Directly linked with the RND Engine.
  • Plugins help us to import/export their functions to another website easily. You do not have to re-write codes to achieve the same task again and again.

SPECIAL: Many developers can create their own plugins and sell to RND customers to make extra money.

Steps to add a new plugin

After downloading a plugin from any source, just try the following steps to install it on your website.

  1. RND Framework stores plugins inside "rnd-content/plugins" path. Go there.
  2. Just put your plugin folder inside "plugins" folder.
  3. Optional: Follow instructions by the plugin developer.
  4. Wash your hands and grab a coffee *_* (Kidding! That's all).

Steps to disable a plugin

Let’s say you have a plugin named “my-stupid-plugin”. Disabling this is really easy as follows,

  1. Just go to "rnd-content/plugins" folder.
  2. Rename "my-stupid-plugin" plugin folder as "disabled-my-stupid-plugin".
  3. Now reload your website. Too easy right?

Removing unwanted plugins

If you have a plugin that is no longer needed, you can easily remove it by deleting the plugin folder. Our advice is to backup it before deleting. Let’s say you want to remove “my-stupid-plugin”,

  1. Just go to "rnd-content/plugins" folder.
  2. Backup "my-stupid-plugin" plugin for safety.
  3. Then delete "my-stupid-plugin" plugin folder.

Creating your first plugin

  1. Go to "rnd-content/plugins" path.
  2. Create a folder named "my-first-plugin".
  3. Inside "my-first-plugin" folder, create "my-first-plugin.php" file as shown below.

     * My First Plugin
     * @package           Your Package Name Here
     * @author            Your Name
     * @copyright         Your Copyright Details
     * @license           Your License Name
     * @rnd-plugin
     * Plugin Name:       My First Plugin
     * Plugin URI:
     * Description:       This is my first plugin to test RND Framework.
     * Version:           1.0.0
     * Requires at least: 1.0.0
     * Requires PHP:      5.2
     * Author:            Your Name
     * Author URI:
     * Text Domain:       your-website
     * License:           Your License Name
     * License URI:

    // Use php code here to write plugin functions.
    // You can use Constants & Hooks actions/filters also.

If you understand RND Constants & Hooks filters/actions, you can easily develop powerful plugins quickly. Below, we explain some PHP codes that are used by our popular plugins.

NOTE: Plugin folder and its PHP file must have the same name to work. You can add more files inside the plugin folder, but do not forget that the main PHP file works as the Core File of your plugin.

How to program your plugin?

The main PHP file which has plugin folder name is the core file that keeps all instructions & commands. You have to use our Hooks & Constants with PHP programming to build your plugin. Please read RND Hooks & Constants (Click Here) section before you start your plugin programming.

Adding a favicon to the website

This simple plugin shows how to add a favicon to your website. We use a filter to hook the icon into the page head area.

    function rnd_favicon_add_image($items) {

        $path   = APP_TMPL_URL . '/plugins/' . basename( dirname( __FILE__ ) ) . '/logos';

        $str = '<link rel="icon" type="image/png" href="'.$path.'/favicon.ico" sizes="16x16">'; 

        return $items.$str;
    add_filter('page_head', 'rnd_favicon_add_image'); 

APP_TMPL_URL . '/plugins/' . basename( dirname( __FILE__ ) ) . '/logos' will target logos folder that we store our favicon images.

Download complete plugin from GitHub here.

Lazy loading images

The following plugin will lazy-load images on the site to reduce bandwidth usage, and improve site speed. Just try to understand how it works.

    function rnd_lazy_loader_manipulate_content($items) {

        $pattern    = "/<img.*?src=[\'|\"](.*?)[\'|\"].*?[\/]?>/"; 
        $loader     = APP_TMPL_URL . '/plugins/' . basename( dirname( __FILE__ ) ) . '/images/loader2.png';

        return preg_replace_callback( $pattern, function($m) use($loader){

            $img    = $m[0];
            $img    = str_replace('src=', 'data-src=', $img);
            $img    = str_replace('<img', '<img src="' . $loader . '"', $img); 

            if( strpos($img,'class="') ){
               $img = preg_replace('#class="#is', 'class="lazy ', $img);
               $img = str_replace('<img', '<img class="lazy"', $img);

            return $img;

        }, $items);

    add_filter('page_content', 'rnd_lazy_loader_manipulate_content');

    function rnd_lazy_loader_put_scripts($items) {

        $js_path = APP_TMPL . '/plugins/' . basename( dirname( __FILE__ ) ) . '/script.js';

        $scripts = get_file_contents_from_a_file( $js_path );
        return $items.$scripts;
    add_filter('page_script', 'rnd_lazy_loader_put_scripts');  

Download complete plugin from GitHub here.

Where can I store my data?

That’s it! Now you understand everything about RND Framework, but it doesn’t have a database like other CMSs do. So confused right? Relax! We do have a Cloud Database that is connected by our API.

About Cloud Database