WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Sponsors Carousel] Patch to add new functionality

[Plugin: Sponsors Carousel] Patch to add new functionality

  • I have been unable to find a way of contacting the author so am posting my patch to add the ability to open sponsor links in a new window here.

    Hoping the author sees these posts 🙂

    --- /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,10 @@
     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");
    
     /*****************************
     * Enqueue jQuery & Scripts
    @@ -103,7 +107,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";
    @@ -197,6 +206,10 @@
    
     		$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);
    
     		$scwp_link_image = $_POST["scwp_link_image"];
     		if ($scwp_link_image > "")
    @@ -303,6 +316,16 @@
     					<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 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>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Sponsors Carousel] Patch to add new functionality’ is closed to new replies.
Skip to toolbar