Support » Plugin: Easy Logo Slider » Good one but …

  • First good job done.
    Second many issues when used many times as widget on the same page, that means “many instances”, the first work, the others NO.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author JW Themes

    (@jwthemes)

    We will try our best to solve those issues, thanks for the information.

    Thread Starter phpcore

    (@phpcore)

    Within “init.php” add this function :

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

    For the normal shortcode the action should be:

    /*start of shortcode*/
    add_shortcode('jw_easy_logo',function($atts){
      //add shortcode
      ob_start();
      $randomStr = randomStr();
    ?>
        <div class="wrapper">
            <?php if(!isset($atts['slider_notitle'])) { ?>
            <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>
                <a href="#" class="jcarousel-control-prev" title="Précédent">&lsaquo;</a>
    
                <a href="#" class="jcarousel-control-next" title="Suivant">&rsaquo;</a>
    
                <p class="jcarousel-pagination"></p>
    
            </div>
            <script type='text/javascript'>create_jcarousel('<?php echo trim($select_no).$randomStr;?>');</script>
        </div>
      <?php return ob_get_clean();?>
    
    <?php });

    The part of code for Widget should be:

    <?php
    	public function widget($args,$instance){
    
    		extract($args);
    
    		extract($instance);
    
            $randomStr = randomStr();
    
    		echo $before_widget;
    ?>
    
            <div class="wrapper">
    
                <<?php echo $htmltag;?>><?php echo $title;?></<?php echo $htmltag;?>>
    
                <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>
    
                    <a href="#" class="jcarousel-control-prev" title="Précédent">&lsaquo;</a>
    
                    <a href="#" class="jcarousel-control-next" title="Suivant">&rsaquo;</a>
    
                    <p class="jcarousel-pagination"></p>
                </div>
                <script type='text/javascript'>create_jcarousel('<?php echo trim($select_no).$randomStr;?>');</script>
            </div>
    
    		<?php echo $after_widget;
    	}
    ?>

    The Javascript function “create_jcarousel(id)” :

    function create_jcarousel(id){
     var ID = '#'+id;
     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'
    
                });
    
            $(ID + ' .jcarousel-control-prev')
    
                .jcarouselControl({
    
                    target: '-=1'
    
                });
    
            $(ID + ' .jcarousel-control-next')
    
                .jcarouselControl({
    
                    target: '+=1'
    
                });
            /*
            //if more than 10 logos, the links break into many rows :(
    
            $(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: 2500,
    
    			create: $(ID + ' .jcarousel').hover(function(){
    				$(this).jcarouselAutoscroll('stop');
    			},
    			function(){
    				$(this).jcarouselAutoscroll('start');
    			})
    		});
    
        });
    
     });
    }

    Hello phpcore,

    Thank You So Much for the great suggestion.This works perfectly.
    Thank You…

    Thread Starter phpcore

    (@phpcore)

    @kamal Karki, you’re welcome 🙂

    Plugin Author JW Themes

    (@jwthemes)

    Thanks for your contribution, we really appreciate it.

    Thread Starter phpcore

    (@phpcore)

    @jw Themes, you’re welcome 🙂

    Thread Starter phpcore

    (@phpcore)

    Just one thing for users, we can use the tag (exists in the new release) :

    slider_notitle<
    within the shortcode directly to remove the title from the carousel (the title is the same as the name, sometimes we don’t need to include it)

    example :

    [jw_easy_logo slider_name="sponsors" slider_notitle=1]

    Developers should add the condition to the Widget part, the condition is :

    <?php if(!isset($atts['slider_notitle'])) { ?>
      <p class="jw_easy_slider_name">
    <?php if(isset($atts['slider_title']))
            echo $atts['slider_title'];
           else
            echo $atts['slider_name'];?>
       </p>
    <?php } ?>

    😉

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Good one but …’ is closed to new replies.