WordPress.org

Ready to get started?Download WordPress

Forums

Sponsors Carousel
Another patch - New Window and Auto scroll (2 posts)

  1. elija
    Member
    Plugin Author

    Posted 2 years ago #

    This patch contains both the previous new window functionality and the ability to turn auto scrolling on and off. On can be slow (10 second pause), medium (6 second pause) or fast (3 second pause). It defaults to off.

    I have tested both of these patches in my development environment and they are currently under-going UAT. Obviously, use these at your risk.

    --- /home/elija/Programming/php/prime/wp-content/plugins/copy of sponsors-carousel/sponsors-carousel.php
    +++ /home/elija/Programming/php/prime/wp-content/plugins/sponsors-carousel/sponsors-carousel.php
    @@ -48,6 +48,14 @@
     add_option("scwp_scroll_amount", "2", "", "yes");
     add_option("scwp_default_link", "", "", "yes");
     add_option("scwp_list", "", "", "yes");
    +
    +//  New option for opening links in new window / tab
    +//	Default new
    +add_option("scwp_link_target", "new");
    +
    +//  New option for auto scrolling speed
    +//	Default off
    +add_option("scwp_auto_scroll", 0);
    
     /*****************************
     * Enqueue jQuery & Scripts
    @@ -103,7 +111,12 @@
     //		wp_get_attachment_link($id, $size, true);
     		if (get_post($id)->post_excerpt <> '')$link = get_post($id)->post_excerpt;
     		else $link = get_option('scwp_default_link');
    -		$output .= "<li><a id=\"item".$i. "\" href=\"".$link."\" class=\"jcarousel-item\">";
    +		//  Relay link building code to include target
    +		$output .= "<li><a ";
    +		if ('new' == get_option('scwp_link_target')) {
    +			$output .= 'target="_blank"';
    +		}
    +		$output .= " id=\"item".$i. "\" href=\"".$link."\" class=\"jcarousel-item\">";
     		if (get_option('scwp_show_titles')=='true') $output .= wp_get_attachment_image( $id,$thumb_size );
     		else $output .= wp_get_attachment_image( $id,$thumb_size, false, array(title=>"") );
     		$output .= "</a></li>\n";
    @@ -129,10 +142,12 @@
      		else {
      		  $speed = stripslashes(get_option('scwp_animation_speed'));
      		}
    +		//  Add new auto option in here
      		$output .= "jQuery('#mycarousel".$randomid."').jcarousel({
      			scroll: ".stripslashes(get_option('scwp_scroll_amount'))."
      			,animation: ".$speed."
      			,wrap: 'circular'
    +			,auto: " . stripslashes(get_option('scwp_auto_scroll')) . "
    
      		});
    
    @@ -197,6 +212,14 @@
    
     		$scwp_default_link = $_POST["scwp_default_link"];
     		update_option("scwp_default_link", $scwp_default_link);
    +
    +		//  Save link target
    +		$scwp_link_target = $_POST["scwp_link_target"];
    +		update_option("scwp_link_target", $scwp_link_target);
    +
    +		//  Auto scrolling speed
    +		$scwp_auto_scroll = $_POST["scwp_auto_scroll"];
    +		update_option("scwp_auto_scroll", $scwp_auto_scroll);
    
     		$scwp_link_image = $_POST["scwp_link_image"];
     		if ($scwp_link_image > "")
    @@ -303,6 +326,28 @@
     					<input type="text" size="10" name="scwp_scroll_amount" id="scwp_scroll_amount" value="<?php echo stripslashes(get_option('scwp_scroll_amount')) ?>" />
     					<a title="<?php _e("How many items should the carousel scroll", 'sponsors-carousel') ?>" />?</a>
     					</p>
    + 		    <?php
    +			//  Output new option field for scrolling speed
    +		    ?>
    +                    <p><?php _e("Auto scroll:", 'sponsors-carousel'); ?>
    +					<select type="select" name="scwp_auto_scroll" id="scwp_auto_scroll">
    +						<option value="0" <?php if ('0' == stripslashes(get_option('scwp_auto_scroll'))) {  echo 'selected="selected"'; }?>>Off</option>
    +						<option value="3" <?php if ('3' == stripslashes(get_option('scwp_auto_scroll'))) {  echo 'selected="selected"'; }?>>Fast</option>
    +						<option value="6" <?php if ('6' == stripslashes(get_option('scwp_auto_scroll'))) {  echo 'selected="selected"'; }?>>Medium</option>
    +						<option value="10" <?php if ('10' == stripslashes(get_option('scwp_auto_scroll'))) {  echo 'selected="selected"'; }?>>Slow</option>
    +					</select>
    +					<a title="<?php _e("Select the auto scrolling speed.", 'sponsors-carousel') ?>" />?</a>
    +					</p>
    +		    <?php
    +			//  Output new option field for link target
    +		    ?>
    +                    <p><?php _e("Link target:", 'sponsors-carousel'); ?>
    +					<select type="select" name="scwp_link_target" id="scwp_link_target">
    +						<option value="new" <?php if ('new' == stripslashes(get_option('scwp_link_target'))) {  echo 'selected="selected"'; }?>>New Window or tab</option>
    +						<option value="" <?php if ('' == stripslashes(get_option('scwp_link_target'))) {  echo 'selected="selected"'; }?>>Same Window or tab</option>
    +					</select>
    +					<a title="<?php _e("Choose whether the links should open in the current window.", 'sponsors-carousel') ?>" />?</a>
    +					</p>
                          <p><?php _e("Default link:", 'sponsors-carousel'); ?>
     					<input type="text" size="50" name="scwp_default_link" id="scwp_default_link" value="<?php echo stripslashes(get_option('scwp_default_link')) ?>" />
     					<a title="<?php _e("Link to sponsors page. You can add custom link in image caption.", 'sponsors-carousel') ?>" />?</a>

    http://wordpress.org/extend/plugins/sponsors-carousel/

  2. elija
    Member
    Plugin Author

    Posted 2 years ago #

    I suppose I should have said that this patch is for V1.03 of the plug-in

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic