StudioPress Community Forums
  StudioPress Community Forums > Forums > General Discussion
For help and support, access to your downloads, or to manage your account please log into My StudioPress.

These forums have been set to read-only so you can browse the existing topics for any questions you may have.

For general discussion on WordPress, CSS and design (NOT for support) visit the new Community Forums.
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-31-2011, 09:32 PM
SWiz's Avatar
SWiz SWiz is offline
Registered User
Pro Plus Member
 
Join Date: Oct 2008
Posts: 214
Default How to get this plug open urls in new windows?

Simple Link List Widget

How do I change so that the urls opens up in a new window?

PHP Code:
<?php
/*
Plugin Name: Simple Link List Widget
Description: Enables a link list widget, in which you can display items in an ordered or unordered list.  Based on Frankie Roberto's List Widget
Author: James Bowles
Author URI: http://mesacc.edu/~chago
Version: 0.1
*/

class SimpleLinkListWidget extends WP_Widget {

    function 
SimpleLinkListWidget() {
        
$widget_ops = array('classname' => 'widget_link_list''description' => __('A link list.'));
        
$this->WP_Widget('list'__('Simple Link List'), $widget_ops$control_ops);
    }

    function 
widget$args$instance ) {
        
extract($args);
        
$title apply_filters('widget_title', empty($instance['title']) ? __('List') : $instance['title']);
        
$type = empty($instance['type']) ? 'unordered' $instance['type'] ;
        
$amount = empty($instance['amount']) ? $instance['amount'];
        
        for (
$i 1$i <= $amount$i++) {
            
$items[$i] = $instance['item' $i];
            
$item_links[$i] = $instance['item_link' $i];
            
$item_classes[$i] = $instance['item_class' $i];
        }

        echo 
$before_widget .  $before_title $title $after_title;  ?>
            <?php if ($type == "ordered") { echo "<ol ";} else { echo("<ul "); } ?> class="list">
                
                <?php foreach ($items as $num => $item) : 
                    if (!empty(
$item)) :
                        if (empty(
$item_links[$num])) :
                            echo(
"<li class='" $item_classes[$num] . "'>" $item "</li>");
                        else :
                            echo(
"<li class='" $item_classes[$num] . "'><a href='" $item_links[$num] . "'>" $item "</a></li>");
                        endif;
                    endif;
                 endforeach; 
?>
      <?php if ($type == "ordered") { echo "</ol>";} else { echo("</ul>"); } ?>
        <?php
        
echo $after_widget;
    }

    function 
update$new_instance$old_instance ) {
        
$instance $old_instance;
        
$instance['title'] = strip_tags($new_instance['title']);
        
$instance['title_link'] = $new_instance['title_link'];
        if (empty(
$new_instance['item' $new_instance['new_amount']])){
            
$instance['amount'] = $new_instance['amount'];
        }else{
            
$instance['amount'] = $new_instance['new_amount'];
        }

        for (
$i 1$i <= $instance['amount']; $i++) {
            
$instance['item' $i] = strip_tags($new_instance['item' $i]);
            
$instance['item_link' $i] = $new_instance['item_link' $i];
            
$instance['item_class' $i] = strip_tags($new_instance['item_class' $i]);
        }        
        
$instance['type'] = $new_instance['type'];
        
        return 
$instance;
    }

    function 
form$instance ) {
        
$instance wp_parse_args( (array) $instance, array( 'title' => '''text' => '''title_link' => '' ) );
        
$title strip_tags($instance['title']);
        
$amount = empty($instance['amount']) ? $instance['amount'];
        
$new_amount $amount 1;
        for (
$i 1$i <= $amount$i++) {
            
$items[$i] = $instance['item' $i];
            
$item_links[$i] = $instance['item_link' $i];
            
$item_classes[$i] = $instance['item_class' $i];
        }
        
$title_link $instance['title_link'];        
        
$type = empty($instance['type']) ? 'unordered' $instance['type'] ;
        
$text format_to_edit($instance['text']);
?>
        <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
        <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
        <p><small>Leave the Link and Custom Style Class fields blank if not desired. Click Save for additional blank fields.</small></p>
        <ol>
        <?php foreach ($items as $num => $item) : ?>
        
            <li>
                <label for="<?php echo $this->get_field_id('item' $num); ?>">Text:</label>
                <input class="widefat" id="<?php echo $this->get_field_id('item' $num); ?>" name="<?php echo $this->get_field_name('item' $num); ?>" type="text" value="<?php echo esc_attr($item); ?>" />
                <label for="<?php echo $this->get_field_id('item_link' $num); ?>">Link:</label>
                <input class="widefat" id="<?php echo $this->get_field_id('item_link' $num); ?>" name="<?php echo $this->get_field_name('item_link' $num); ?>" type="text" value="<?php echo esc_attr($item_links[$num]); ?>" />
                <label for="<?php echo $this->get_field_id('item_class' $num); ?>">Custom Style Class:</label>
                <input class="widefat" id="<?php echo $this->get_field_id('item_class' $num); ?>" name="<?php echo $this->get_field_name('item_class' $num); ?>" type="text" value="<?php echo esc_attr($item_classes[$num]); ?>" />
            </li>
        <?php endforeach; ?>
        
        <?php //Additional form fields to add one more item ?>
        
            <li>
                <label for="<?php echo $this->get_field_id('item' $new_amount); ?>">Text:</label>
                <input class="widefat" id="<?php echo $this->get_field_id('item' $new_amount); ?>" name="<?php echo $this->get_field_name('item' $new_amount); ?>" type="text" value="" />
                <label for="<?php echo $this->get_field_id('item_link' $new_amount); ?>">Link:</label>
                <input class="widefat" id="<?php echo $this->get_field_id('item_link' $new_amount); ?>" name="<?php echo $this->get_field_name('item_link' $new_amount); ?>" type="text" value="" />
                <label for="<?php echo $this->get_field_id('item_class' $new_amount); ?>">Custom Style Class:</label>
                <input class="widefat" id="<?php echo $this->get_field_id('item_class' $new_amount); ?>" name="<?php echo $this->get_field_name('item_class' $new_amount); ?>" type="text" value="" />
            </li>
        </ol>
        <input type="hidden" id="<?php echo $this->get_field_id('amount'); ?>" name="<?php echo $this->get_field_name('amount'); ?>" value="<?php echo $amount ?>" />
        <input type="hidden" id="<?php echo $this->get_field_id('new_amount'); ?>" name="<?php echo $this->get_field_name('new_amount'); ?>" value="<?php echo $new_amount ?>" />

        <label for="<?php echo $this->get_field_id('ordered'); ?>"><input type="radio" name="<?php echo $this->get_field_name('type'); ?>" value="ordered" id="<?php echo $this->get_field_id('ordered'); ?><?php checked($type"ordered"); ?>></input>  Ordered</label>
        <label for="<?php echo $this->get_field_id('unordered'); ?>"><input type="radio" name="<?php echo $this->get_field_name('type'); ?>" value="unordered" id="<?php echo $this->get_field_id('unordered'); ?><?php checked($type"unordered"); ?>></input> Unordered</label>

<?php
    
}
}

add_action('widgets_init'create_function('''return register_widget("SimpleLinkListWidget");'));

?>
__________________
http://www.veggiemind.com
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Old Site With Non-SEF Joomla Urls, Simple Rewrite to Wordpress SEF URLs noxbane General Discussion 3 04-06-2011 01:06 AM
Windows & Permalinks ddunn General Discussion 5 07-16-2010 02:37 PM
PNG Transparency for Windows IE 6 fawazmt General Discussion 1 06-02-2010 08:59 AM


All times are GMT -5. The time now is 06:51 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.