• the content of “init.php”

    <?php
    /*---------------------------------------------------------
    Plugin Name: Easy Logo Slider
    Plugin URI: https://jwthemes.com/easy_logo_slider/
    Description: Easy Logo Slider is plugin that helps users to upload the logos of clients,
                 partners, and affiliates along with title, short description and website URL.
                 For frontend display there is option to show or hide title and description and
                 also will be the features like linking images, opening in new window.
                 Embedd in any post/page using shortcode <code>[jw_easy_logo slider_name="Slider Name"]</code>
                 or you can add through widgets.
    Version: 1.1.0
    Author: JW Themes
    Author URI: https://jwthemes.com
    ------------------------------------------------------------*/
    register_activation_hook(__FILE__,'register_upon_activation_jw');
    function register_upon_activation_jw(){//create the uploads folder upon activation
    	define( 'YOURPLUGIN_PATH', plugin_dir_path(__FILE__) );
    	  $upload_dir = str_replace("\\","/","".plugin_dir_path(__FILE__).""."inc/images/");
      	if (!is_dir($upload_dir)) {
    		mkdir($upload_dir, 0777, true);
      	}
    	//creating table upon activation
      	global $wpdb;
      	$table_name = $wpdb->prefix . "jw_easy_logo_slider";
    	if($wpdb->get_var("show tables like '$table_name'") != $table_name){
      	 $sql = "CREATE TABLE $table_name (
         	id int NOT NULL AUTO_INCREMENT,
        	title varchar(50),
        	image varchar(50),
        	url VARCHAR(60),
        	description varchar(500),
        	slider_id int,
        	PRIMARY KEY id (id)
          );";
    	}
    	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
        dbDelta( $sql );
        //global $wpdb;
    	$table_name = $wpdb->prefix . "jw_easy_logo_slider_setting";
    	if($wpdb->get_var("show tables like '$table_name'") != $table_name){
      	 $sql = "CREATE TABLE $table_name (
        	id int NOT NULL AUTO_INCREMENT,
        	name varchar(50),
        	setting varchar(250),
        	PRIMARY KEY id (id)
          );";
    	}
       require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
       dbDelta( $sql );
    }
    
    //deactivation hoook
    register_deactivation_hook( __FILE__, 'jwplugin_deactivate' );
    function jwplugin_deactivate(){
    	global $wpdb;
        $jw_plugin_table_name_slider = $wpdb->prefix."jw_easy_logo_slider";
        $jw_plugin_table_name_setting = $wpdb->prefix."jw_easy_logo_slider_setting";
        $sql= "DROP TABLE IF EXISTS ".$jw_plugin_table_name_slider ;
        $wpdb->query($sql);
        $sql= "DROP TABLE IF EXISTS ".$jw_plugin_table_name_setting ;
        $wpdb->query($sql);
    }
    
    //admin_menu_setup
    add_action('admin_menu','jw_logo_slider');
    function jw_logo_slider() {
    	//this is the main item for the menu
    	add_menu_page('Diaporama des Logos', //page title
    	'Diapo des Logos', //menu title
    	'manage_options', //capabilities
    	'jw_easy_logo', //menu slug
    	'jw_easy_logo',
    	 plugin_dir_url( __FILE__ ) . 'images/easy-logo-slider-icon.png'
    	);
    
    	add_submenu_page('null', //parent slug
    	'Ajouter Nouvelle Image', //page title
    	'Ajouter Nouvelle Image', //menu title
    	'manage_options', //capability
    	'logo_slider_create', //menu slug
    	'logo_slider_create');
    
    	add_submenu_page('jw_easy_logo',
    	'Ajouter Diaporama',
    	'Ajouter Diaporama',
    	'manage_options',
    	'jw_easy_logo_slider_create',
    	'jw_easy_logo_slider_create'
    	);
    
    	//this submenu is HIDDEN, however, we need to add it anyways
    	add_submenu_page(null, //parent slug
    	'Mettre à jours les données', //page title
    	'Mettre à jour', //menu title
    	'manage_options', //capability
    	'logo_slider_update', //menu slug
    	'logo_slider_update'); //function
    
    	add_submenu_page(null, //parent slug
    	'Supprimer les données', //page title
    	'Supprimer', //menu title
    	'manage_options', //capability
    	'logo_slider_remove', //menu slug
    	'logo_slider_remove'); //function
    
    	add_submenu_page(null, //page title
    	'Voir les diapositives',
    	'Voir les diapositives', //menu title
    	'manage_options', //capabilities
    	'slider_content_detail', //menu slug
    	'slider_content_detail' //function
    	);
    
    	add_submenu_page(null, //page title
    	'Supprimer le nom d\'une diapositive',
    	'Supprimer diapositive', //menu title
    	'manage_options', //capabilities
    	'remove_jw_easy_slider_name', //menu slug
    	'remove_jw_easy_slider_name' //function
    	);
    }
    
    //function that generates a random string
    function randomStr($length = 6){
      $validCharacters = "0123456789abcdefghijklmnopqrstuxyvwzABCDEFGHIJKLMNOPQRSTUXYVWZ";
      $validCharNumber = strlen($validCharacters);
      $result = "";
      for ($i = 0; $i < $length; $i++) {
       $index = mt_rand(0, $validCharNumber - 1);
       $result .= $validCharacters[$index];
      }
      return $result;
    }
    
    /*start of shortcode*/
    add_shortcode('jw_easy_logo',function($atts){
      //add shortcode
      ob_start();
      $randomStr = randomStr();
      if(!isset($atts['slider_time_interval']) && intval(trim($atts['slider_time_interval'])) > 499) $slider_time_interval = intval(trim($atts['slider_time_interval']));
      else $slider_time_interval = 2500;
      if(!isset($atts['slider_notitle']) && in_array(trim($atts['slider_notitle']), array('1','0'))) $slider_notitle = trim($atts['slider_notitle']);
      else $slider_notitle = '0';
      if(!isset($atts['slider_nocontrols']) && in_array(trim($atts['slider_nocontrols']), array('1','0'))) $slider_nocontrols = trim($atts['slider_nocontrols']);
      else $slider_nocontrols = '0';
      if(!isset($atts['slider_nopagination']) && in_array(trim($atts['slider_nopagination']), array('1','0'))) $slider_nopagination = trim($atts['slider_nopagination']);
      else $slider_nopagination = '0';
    ?>
        <div class="wrapper">
            <?php if($slider_notitle == '1') { ?>
            <p class="jw_easy_slider_name"><?php if(isset($atts['slider_title'])) echo $atts['slider_title']; else echo $atts['slider_name'];?></p>
             <?php } ?>
            <div class="jcarousel-wrapper" id="<?php echo trim($select_no).$randomStr;?>">
                <div class="jcarousel">
                    <ul>
                    <?php
                    global $wpdb;
                    $rw = $wpdb->get_results("SELECT * from ".$wpdb->prefix."jw_easy_logo_slider INNER JOIN ".$wpdb->prefix."jw_easy_logo_slider_setting where ".$wpdb->prefix."jw_easy_logo_slider_setting.id = "."".$wpdb->prefix."jw_easy_logo_slider.slider_id"." AND ".$wpdb->prefix."jw_easy_logo_slider_setting.name='".$atts['slider_name']."'");
                    foreach ($rw as $setting){  $res=$setting->setting; $show=unserialize($res);}
                    $rows = $wpdb->get_results("SELECT * from ".$wpdb->prefix."jw_easy_logo_slider INNER JOIN ".$wpdb->prefix."jw_easy_logo_slider_setting where ".$wpdb->prefix."jw_easy_logo_slider_setting.id = "."".$wpdb->prefix."jw_easy_logo_slider.slider_id"." AND ".$wpdb->prefix."jw_easy_logo_slider_setting.name='".$atts['slider_name']."'");
                    foreach ($rows as $row ){?>
                        <li>
    						 <style>
                            	.easy-logo_image {height:<?php if($show['image_ht']!=''){echo $show['image_ht'];}else{ echo "150px";}?> !important}
                             </style>
                           <?php if($row->url!=''){?>
                             <a href="<?php echo $row->url;?>" target="<?php if($show['url_target']!=''){echo $show['url_target'];} else{ echo "_blank";} ?>" title="<?php echo stripcslashes($row->title);?>">
                              <img src="<?php echo plugins_url('inc/images/'.$row->image,__FILE__);?>" class="easy-logo_image" alt="" title="<?php echo stripcslashes($row->title);?>" />
                             </a>
                           <?php } else{?>
                             <img src="<?php echo plugins_url('inc/images/'.$row->image,__FILE__);?>" class="easy-logo_image" alt="" title="<?php echo stripcslashes($row->title);?>" />
                           <?php }?>
                           <?php if($row->url!=''){?>
                             <a href="<?php echo $row->url;?>" target="<?php if($show['url_target']!=''){echo $show['url_target'];} else{ echo "_blank";} ?>" title="<?php echo stripcslashes($row->title);?>">
                              <p><?php if($show['jw_easy_logo_slider_title_sh']!="hide" AND $show['jw_easy_logo_slider_title_sh']!=''){echo stripcslashes($row->title);}?></p>
                             </a>
                           <?php } else {?>
                             <p><?php if($show['jw_easy_logo_slider_title_sh']!="hide" AND $show['jw_easy_logo_slider_title_sh']!=''){echo stripcslashes($row->title);}?></p>
                           <?php }?>
                             <?php $str = substr($row->description, 0, $show['limit_description']);?>
                             <?php if($show['jw_easy_logo_slider_desc_sh']!="hide" AND $show['jw_easy_logo_slider_title_sh']!=''){echo '<p class="descp">'.stripcslashes($str).'</p>';}?>
                        </li>
                        <?php }?>
                    </ul>
                </div>
            <?php if($slider_nocontrols == '0') { ?>
                <a href="#" class="jcarousel-control-prev" title="Précédent">?</a>
                <a href="#" class="jcarousel-control-next" title="Suivant">?</a>
            <?php } ?>
            <?php if($slider_nopagination == '0') { ?>
                <p class="jcarousel-pagination"></p>
            <?php } ?>
            </div>
            <script type='text/javascript'>create_jcarousel('<?php echo trim($select_no).$randomStr;?>', <?php echo $slider_time_interval;?>, '<?php echo $slider_nocontrols;?>','<?php echo $slider_nopagination;?>');</script>
        </div>
      <?php return ob_get_clean();?>
    
    <?php });
    /*end of the shortcode*/
    
    /* start of the widgets*/
    class Jw_easy_logo_slider extends WP_Widget{
    	function __construct(){//function will call the description of the widget and it's name
    		$params=array(
    			'description'=>'Affiche les images du diaporama Easy Logo suivant le besoin',
    			'name'=>'Easy Logo Slider'
    		);
    	    parent::__construct('Jw_easy_logo_slider','',$params);
    	}
    	public function form($instance){//create the title form
    		extract($instance);
            $yesno_numbers = array('0' => 'Oui', '1' => 'Non');
        ?>
    		<p>
            	<label for="<?php echo $this->get_field_id('title');?>" title="Titre (laisser vide pour ne pas inclure)" style="cursor:pointer;">Titre (laisser vide pour ne pas inclure)</label>
                <input
                	class="widefat"
                    id="<?php echo $this->get_field_id('title');?>"
                    name="<?php echo $this->get_field_name('title');?>"
                    value="<?php if(isset($title)) echo esc_attr($title); ?>" />
    		</p>
    
    		<p>
            	<label for="<?php echo $this->get_field_id('htmltag');?>" title="Balise HTML du titre" style="cursor:pointer;">Balise HTML du titre</label>
                <input
                	class="widefat"
                    id="<?php echo $this->get_field_id('htmltag');?>"
                    name="<?php echo $this->get_field_name('htmltag');?>"
                    value="<?php if(isset($htmltag)) echo esc_attr($htmltag); else echo 'h3';?>" />
    		</p>
    
    		<p>
            	<label for="<?php echo $this->get_field_id('time_interval');?>" title="Intervalle de temps" style="cursor:pointer;">Intervalle de temps</label>
                <input
                	class="widefat"
                    id="<?php echo $this->get_field_id('time_interval');?>"
                    name="<?php echo $this->get_field_name('time_interval');?>"
                    value="<?php if(isset($time_interval)) echo esc_attr($time_interval); else echo '2500';?>" />
    		</p>
    
    		<p>
            	<label for="<?php echo $this->get_field_id('nocontrols');?>" title="Boutons de contr?le" style="cursor:pointer;">Boutons de contr?le</label>
                <select
                	class="widefat"
                    id="<?php echo $this->get_field_id('nocontrols');?>"
                    name="<?php echo $this->get_field_name('nocontrols');?>">
                    <option value="0"<?php if(isset($nocontrols) && esc_attr($nocontrols) == '0') echo ' selected="selected"'; ?>>
                     <?php echo $yesno_numbers['0'] ?>
                    </option>
                    <option value="1"<?php if(isset($nocontrols) && esc_attr($nocontrols) == '1') echo ' selected="selected"'; ?>>
                     <?php echo $yesno_numbers['1'] ?>
                    </option>
            	</select>
    
    		</p>
    
    		<p>
            	<label for="<?php echo $this->get_field_id('nopagination');?>" title="Pagination" style="cursor:pointer;">Pagination</label>
                <select
                	class="widefat"
                    id="<?php echo $this->get_field_id('nopagination');?>"
                    name="<?php echo $this->get_field_name('nopagination');?>">
                    <option value="0"<?php if(isset($nopagination) && esc_attr($nopagination) == '0') echo ' selected="selected"'; ?>>
                     <?php echo $yesno_numbers['0'] ?>
                    </option>
                    <option value="1"<?php if(isset($nopagination) && esc_attr($nopagination) == '1') echo ' selected="selected"'; ?>>
                     <?php echo $yesno_numbers['1'] ?>
                    </option>
            	</select>
    
    		</p>
    
            <p>
            	<label for="<?php echo $this->get_field_id('select_no');?>">Sélectionnez le Diaporama à afficher</label>
                <select
                	class="widefat"
                    id="<?php echo $this->get_field_id('select_no');?>"
                    name="<?php echo $this->get_field_name('select_no');?>"
                    value="<?php if(isset($select_no)) echo esc_attr($select_no); ?>">
                    <option value="<?php if(isset($select_no)) echo esc_attr($select_no); ?> " ><?php if(isset($select_no)) echo esc_attr($select_no); ?></option>
                    <?php global $wpdb; $rows = $wpdb->get_results("SELECT name from ".$wpdb->prefix."jw_easy_logo_slider_setting where name!='".$select_no."'");
    				foreach ($rows as $row ){?>
                    <option value="<?php echo $row->name;?>"><?php echo $row->name;?></option>
                    <?php }?>
            	</select>
    
            </p>
    
    	<?php }
    	public function widget($args,$instance){
    		extract($args);
    		extract($instance);
            $randomStr = randomStr();
    		echo $before_widget;
    ?>
            <div class="wrapper">
                <?php if(trim($title) != ''){ ?>
                 <<?php echo $htmltag;?>><?php echo $title;?></<?php echo $htmltag;?>>
                <?php } ?>
                <div class="jcarousel-wrapper" id="<?php echo trim($select_no).$randomStr;?>">
                    <div class="jcarousel">
                        <ul>
                         <?php
        					global $wpdb;
        				    $rw = $wpdb->get_results("SELECT *from ".$wpdb->prefix."jw_easy_logo_slider JOIN ".$wpdb->prefix."jw_easy_logo_slider_setting where
                                                     ".$wpdb->prefix."jw_easy_logo_slider_setting.name='".$select_no."'");
        				    foreach ($rw as $setting){  $res=$setting->setting; $show=unserialize($res);}
        					$rows = $wpdb->get_results("SELECT * from ".$wpdb->prefix."jw_easy_logo_slider JOIN ".$wpdb->prefix."jw_easy_logo_slider_setting where ".$wpdb->prefix."jw_easy_logo_slider_setting.id = "."".$wpdb->prefix."jw_easy_logo_slider.slider_id"." AND ".$wpdb->prefix."jw_easy_logo_slider_setting.name='".$select_no."'");
        					foreach ($rows as $row ){
                         ?>
                            <li>
    						 <style>
                            	.easy-logo_image {height:<?php if($show['image_ht']!=''){echo $show['image_ht'];}else{ echo "150px";}?> !important}
                             </style>
                           <?php if($row->url!=''){?>
                             <a href="<?php echo $row->url;?>" target="<?php if($show['url_target']!=''){echo $show['url_target'];} else{ echo "_blank";} ?>" title="<?php echo stripcslashes($row->title);?>">
                              <img src="<?php echo plugins_url('inc/images/'.$row->image,__FILE__);?>" class="easy-logo_image" alt="" />
                             </a>
                           <?php } else{?>
                             <img src="<?php echo plugins_url('inc/images/'.$row->image,__FILE__);?>" class="easy-logo_image"  alt="" title="<?php echo stripcslashes($row->title);?>" />
                           <?php }?>
                           <?php if($row->url!=''){?>
                             <a href="<?php echo $row->url;?>" target="<?php if($show['url_target']!=''){echo $show['url_target'];} else{ echo "_blank";} ?>" title="<?php echo stripcslashes($row->title);?>">
                              <p><?php if($show['jw_easy_logo_slider_title_sh']!="hide" AND $show['jw_easy_logo_slider_title_sh']!=''){echo stripcslashes($row->title);}?></p>
                             </a>
                           <?php } else {?>
                             <p><?php if($show['jw_easy_logo_slider_title_sh']!="hide" AND $show['jw_easy_logo_slider_title_sh']!=''){echo stripcslashes($row->title);}?></p>
                           <?php }?>
                           <?php $str = substr($row->description, 0, $show['limit_description']);?>
                            <?php if($show['jw_easy_logo_slider_desc_sh']!="hide"){echo '<p>'.stripcslashes($str).'</p>';}?>
                            </li>
                            <?php }?>
                        </ul>
                    </div>
                <?php if($nocontrols == '0') { ?>
                    <a href="#" class="jcarousel-control-prev" title="Précédent">?</a>
                    <a href="#" class="jcarousel-control-next" title="Suivant">?</a>
                <?php } ?>
                <?php if($nopagination == '0') { ?>
                    <p class="jcarousel-pagination"></p>
                <?php } ?>
                </div>
                <script type='text/javascript'>create_jcarousel('<?php echo trim($select_no).$randomStr;?>', <?php echo $time_interval;?>, '<?php echo $nocontrols;?>','<?php echo $nopagination;?>');</script>
            </div>
    		<?php echo $after_widget;
    	}
    }
    
    //widgets function
    add_action('widgets_init','jw_register_easy_logo_slider');
    function jw_register_easy_logo_slider(){
    	register_widget('Jw_easy_logo_slider');
    }
    
    //widgets
    /*end of the widgets*/
    define('ROOTDIR', plugin_dir_path(__FILE__));
    require_once(ROOTDIR . 'inc/logo_slider_list.php');
    require_once(ROOTDIR . 'inc/jw_easy_logo.php');
    require_once(ROOTDIR . 'inc/jw_easy_logo_slider_create.php');
    require_once(ROOTDIR . 'inc/logo_slider_create.php');
    require_once(ROOTDIR . 'inc/logo_slider_update.php');
    require_once(ROOTDIR . 'inc/logo_slider_remove.php');
    require_once(ROOTDIR . 'inc/remove_jw_easy_slider_name.php');
    
    function mytheme_enqueue_scripts(){
    	wp_register_script( 'jquery.jcarousel.min', plugins_url( '/js/jquery.jcarousel.min.js', __FILE__ ), array( 'jquery' ) );
    	wp_register_script( 'jcarousel.responsive', plugins_url( '/js/jcarousel.responsive.js', __FILE__ ), array( 'jquery' ) );
        if (!is_admin()):
         wp_enqueue_script('jquery.jcarousel.min');
     	 wp_enqueue_script('jcarousel.responsive');
        endif; //!is_admin
    }
    
    add_action( 'wp_print_scripts', 'mytheme_enqueue_scripts' );
    add_action( 'wp_print_scripts', 'register_plugin_styles' );
    function register_plugin_styles() {
    	wp_register_style( 'jcarouselresponsive', plugins_url( 'css/jcarouselresponsive.css',__FILE__ ) );
    	if (!is_admin()):
    	 wp_enqueue_style( 'jcarouselresponsive' );
    	endif;
    }

    The Content of “jcarousel.responsive.js”

    function create_jcarousel(id, interval, noControls, noPagination){
     var ID = '#'+id;
     var time_interval = interval * 1;
     if(time_interval < 500) time_interval = 2500;
     jQuery.noConflict();
     jQuery(document).ready(function($) {
        $(function() {
            var jcarousel = $(ID + ' .jcarousel');
            jcarousel
                .on('jcarousel:reload jcarousel:create', function () {
                    var width = jcarousel.innerWidth();
                    if (width >= 1100) {
                        width = width / 8;
                    } else if (width >= 992) {
                        width = width / 6;
                    } else if (width >= 768) {
                        width = width / 5;
                    } else if (width >= 600) {
                        width = width / 4;
                    } else if (width >= 480) {
                        width = width / 3;
                    }else if (width >= 320) {
                        width = width / 2;
                    }else if (width < 320) {
                        width = width / 1;
                    }
                    jcarousel.jcarousel('items').css('width', width + 'px');
                })
                .jcarousel({
                    wrap: 'circular'
                });
            if(noControls == '0'){
             $(ID + ' .jcarousel-control-prev')
                 .jcarouselControl({
                     target: '-=1'
                 });
    
             $(ID + ' .jcarousel-control-next')
                 .jcarouselControl({
                     target: '+=1'
                 });
            }
            if(noPagination == '0'){
             $(ID + ' .jcarousel-pagination')
                 .on('jcarouselpagination:active', 'a', function() {
                     $(this).addClass('active');
                 })
                 .on('jcarouselpagination:inactive', 'a', function() {
                     $(this).removeClass('active');
                 })
                 .on('click', function(e) {
                     e.preventDefault();
                 })
                 .jcarouselPagination({
                    perPage: 1,
                    item: function(page) {
                        return '<a href="#' + page + '">' + page + '</a>';
                    }
                });
            }
    		$(ID + ' .jcarousel').jcarouselAutoscroll({
       			interval: time_interval,
    			create: $(ID + ' .jcarousel').hover(function(){
    				$(this).jcarouselAutoscroll('stop');
    			},
    			function(){
    				$(this).jcarouselAutoscroll('start');
    			})
    		});
        });
     });
    }

    For the integration as a shortcode :
    1) slider_time_interval: need to be an integer, it is the time interval in milliseconds for each slide. Example: [jw_easy_logo slider_name="sponsors" slider_time_interval=3000]

    2) slider_nocontrols: need to be ‘1’ or ‘0’, it indicates that the jcarousel should or not uses Controls, if yes we put ‘0’ if no we put ‘1’. Example: [jw_easy_logo slider_name="sponsors" slider_nocontrols=1]

    3) slider_nopagination: need to be ‘1’ or ‘0’, it indicates that the jcarousel should or not uses Pagination, if yes we put ‘0’ if no we put ‘1’. Example: [jw_easy_logo slider_name="sponsors" slider_nopagination=1]

    4) slider_notitle: need to be ‘1’ or ‘0’, it indicates that the jcarousel should or not includes Title (a the top), if yes we put ‘0’ if no we put ‘1’. Example: [jw_easy_logo slider_name="sponsors" slider_notitle=1]

    Of course you can use a combination of all these switches.

    For the Widget version, the option can be set directly within de Widget panel.

    Enjoy it !

Viewing 7 replies - 1 through 7 (of 7 total)
  • That’s remarkable great
    It will certainly boost us
    Thank you

    Is it possible to add easing to the motion?

    can i use some sort of code or short code to change number of images scrolled after pushing “next” “pev” buttons?
    I want to scroll 4 logos at a time.

    ok. i get it.
    i have changed code in jcarousel.responsive.js file. Simply change 1 for any desire number

    $(ID + ' .jcarousel-control-prev')
    
                .jcarouselControl({
    
                    target: '-=1'
    
                });
    
            $(ID + ' .jcarousel-control-next')
    
                .jcarouselControl({
    
                    target: '+=1'
    
                });

    dezmont

    (@dezmont)

    Hey, What do I do to make the animation smooth? I do not like when the animation stops after each pass.

    Al Adam

    (@abc_plumb)

    How do I get the each logos to be in the centre of the box?
    at the moment there is bigger gap below the logos.

    Hi

    How can I disable or hide the “next” “pev” buttons also I need to hide the name of the slide that shows up at the left top corner.

    If I can use custome CSS will be grate

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘More Options’ is closed to new replies.