Coder Social home page Coder Social logo

jjmix / rt-slider Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rohitink/rt-slider

0.0 1.0 0.0 37 KB

A Plugin to Help Theme Developers Integrate a Slider in their themes.

Home Page: https://wordpress.org/plugins/rt-slider/

License: GNU General Public License v3.0

PHP 100.00%

rt-slider's Introduction

RT Slider

RT Slider plugin helps theme developers by Creating a Slider Section in WordPress Customizer. That's all it does. The Developer Can use it with any Slider he wants like Nivo Slider, BX-Slider, etc.

The CSS, JS, etc are still in the hands of theme Developer and to be added via theme.

This plugin only creates Data for the slider, so that users do not loose their slider everytime they switch from one theme to another.

This Plugin is Available on WordPress.org here. So, you can recommened it to your theme users via TGM.

Benefits of integrating RT Slider in your Theme

  • No need to Write any Code to Creat Slider Sections, Options, etc in Customizer
  • Fully Sanitized Code
  • No loss of Slider Data while switching between themes that support RT Slider.
  • Very Easy to Use and Set up.
  • Works with Any Slider you want to use in your theme.
  • CSS is fully in your hands. Plugin doesn't render any styles at all.

How to Use RT Slider with your Theme?

First, Declare Support in your theme's functions.php file inside a function, which will be called at after_setup_theme hook. This the place, where you declare support for other stuff like custom-logo or title-tag.

  	/*
	 * Enable support for RT Slider Plugin.
	 */
	 add_theme_support('rt-slider', array( 10 , 'pages', 'front-page-only', 
		 'config' => array(
			 'options' => array('speed', 'duration','random', 'autoplay','pager'),
			 'effects' => array('fade','sliceUp'),
		 )
	 ));
Explanation of the Values in the Array
  • 10 -> This is the Maximum no. of slides you want the user to have. THIS MUST BE THE FIRST TERM IN THE ARRAY
  • 'pages' -> If you want user to be able to Choose upto 2 Individual Pages, on which He should Enable the slider. (Optional)
  • 'front-page-only' -> If you want user to have the option to Enable the slider on Front Page only. By default, user will have the option to choose from blog, static front page, all posts & all pages. (Optional)
  • 'config' -> Add this only if you want user to have control over the slider. (Optional)
    • 'options -> The list of options you want to choose from. You can choose from the Following 5 only.
      • 'speed' -> Transition Speed of the slider. (Returns value in ms) (Default = 500)
      • 'duration' -> Duration of Each Slide. (Returns value in ms) (Default = 5000)
      • 'random' -> Start Slider from Random Position. (Boolean) (Default = false)
      • 'autoplay' -> Autoplay the Slider. (Boolean) (Default = true)
      • 'pager' -> Enable the Pager. The navigation generally present below the slider. (Boolean) (Default = true)
    • 'effects' -> Add the names of all the effects your slider supports. Values in this array depend on the slider you are using. Some sliders support either fade or slide, and some sliders support over 20 effects. (Optional)
Most Common Usage Example.

If you want to just Enable a basic slider in your theme. Just add the following code.

	 add_theme_support('rt-slider', array( 5 , 'pages' )); //Max Slides = 5, Options to Choose pages = enabled.

Place your Slider in your theme.

For example, your slider code is a file called slider-nivo.php Then add this code, wherever you want the slider to show up. Generally, somewhere in header.php or front-page.php

if( class_exists('rt_slider') ) {
	rt_slider::render('slider', 'nivo' ); 
}

RT Slider Functions

The list of Functions available for the Theme Developer by this plugin. There is just one function, which has 2 forms.

Function 1:
rt_slider::fetch( $param )

e.g. $no_of_slides = rt_slider::fetch('count');

Possible Values of $param

  • count -> The No. of sliders set by user.
  • speed
  • duration
  • random
  • autoplay
  • pager

The Last 5 options above, are available if you have added support for 'config' and 'options'


Function 2
rt_slider::fetch( $param, $slide_number )

This is the function you would use inside your for or foreach loop, used to render each individual slide. The $slider_number is the loop index. Min Value should be 1. So start your For Loop from 1, rather than 0.

Possible Values for $param

  • img -> the slide image
  • url -> url to which the slider should link to
  • cta_button -> a call to action button in the slider
  • title -> Slide title
  • desc -> Slide description

Usage Example

$count = $no_of_slides = rt_slider::fetch('count');

for ( $i = 1; $i <= $no_of_slides; $i++ ) :
    
    $img   = rt_slider::fetch('img', $i);
    $url   = rt_slider::fetch('url', $i);
    $title = rt_slider::fetch('title', $i);
    $desc  = rt_slider::fetch('desc', $i);
    
    echo "<div class='slide'>;
      echo "<a href='".$url."' target='_blank'>";
      echo "<img src='".$img."'>";
      echo "<div class='caption'>
              <div class='slide-title'>".$title ."</div>
              <div class='slide-desc'>".$desc."</div>
            </div>"; //.caption
        echo "</a>"; //.slide   
      echo "</div>"; //.slide      
              
endfor;

If you need any help regarding this. [Contact me here] (http://rohitink.com/contact-me) or create an issue at Github.

Themes Already Implementing RT Slider

rt-slider's People

Contributors

rohitink avatar lippoliv avatar jjmix avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.