Changeset 1447608
- Timestamp:
- 07/02/2016 03:46:49 AM (10 years ago)
- Location:
- links-dropdown-widget
- Files:
-
- 9 edited
-
assets/screenshot-1.png (modified) (previous)
-
assets/screenshot-2.png (modified) (previous)
-
trunk/css/widget.css (modified) (1 diff)
-
trunk/plugin.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/screenshot-1.png (modified) (previous)
-
trunk/screenshot-2.png (modified) (previous)
-
trunk/views/admin.php (modified) (1 diff)
-
trunk/views/widget.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
links-dropdown-widget/trunk/css/widget.css
r844340 r1447608 10 10 #link-dropdown-widget option{ 11 11 font-size: 1em !important; 12 padding: 2px 4px; 12 13 } -
links-dropdown-widget/trunk/plugin.php
r844340 r1447608 2 2 /* 3 3 Plugin Name: Links Dropdown Widget 4 Plugin URI: http://s omeblog.vv.si/4 Plugin URI: http://sihung.net/plugins/links-dropdown-widget 5 5 Description: Display links as dropdown 6 Version: 1. 07 Author: Trang Si Hung8 Author URI: http://s omeblog.vv.si/6 Version: 1.1 7 Author: Hung Trang Si 8 Author URI: http://sihung.net 9 9 Author Email: trangsihung@gmail.com 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html 12 Text Domain: linkdrop 12 13 13 Copyright 201 3 Someblog14 Copyright 2016 Hung Trang Si 14 15 15 16 This program is free software; you can redistribute it and/or modify … … 71 72 $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Links' ) : $instance['title'], $instance, $this->id_base); 72 73 $default_option = $instance['default_option']; 74 $link_cat = $instance['link_cat']; 75 $open_same_window = $instance['open_same_window']; 76 73 77 echo $before_widget; 74 78 … … 93 97 $instance['title'] = strip_tags($new_instance['title']); 94 98 $instance['default_option'] = strip_tags($new_instance['default_option']); 99 $instance['link_cat'] = (int)($new_instance['link_cat']); 100 $instance['open_same_window'] = $new_instance['open_same_window']; 95 101 96 102 return $instance; … … 107 113 $instance = wp_parse_args( 108 114 (array) $instance, 109 array( 'title' => '', 'default_option' => 'Select Option') 115 array( 116 'title' => '', 117 'default_option' => 'Select Option', 118 'link_cat' => 0 119 ) 110 120 ); 111 121 112 122 $title = esc_attr( $instance['title'] ); 113 123 $default_option = esc_attr( $instance['default_option'] ); 124 $link_cat = (int) $instance['link_cat']; 125 $open_same_window = $instance['open_same_window']; 114 126 115 127 // Display the admin form … … 130 142 131 143 add_action( 'widgets_init', create_function( '', 'register_widget("Links_Dropdown_Widget");' ) ); 144 145 146 function linkdrop_categories_to_array($taxonomy){ 147 $terms = get_terms($taxonomy,array( 148 'hide_empty'=>false 149 )); 150 $terms_production = array(); 151 foreach ($terms as $key=>$term){ 152 $terms_production[$term->term_id] = $term->name; 153 } 154 $terms_production[0] = __('All', 'linkdrop'); 155 return $terms_production; 156 } -
links-dropdown-widget/trunk/readme.txt
r857943 r1447608 1 1 === Dropdown Links Widget === 2 2 Contributors: jacking83 3 Donate link: 3 Donate link: 4 4 Tags: widget, links manager, links 5 5 Requires at least: 3.3 6 Tested up to: 3.87 Stable tag: 1. 06 Tested up to: 4.5.3 7 Stable tag: 1.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 24 24 1. Widget Ready 25 25 2. Display on front-end 26 27 == Changelog == 28 29 = v1.1 = 30 31 * Allow choose links category on widget panel 32 * Open links in new tab (or new windows) by default -
links-dropdown-widget/trunk/views/admin.php
r844340 r1447608 1 <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 $title; ?>" /></p> 2 <p><label for="<?php echo $this->get_field_id('default_option'); ?>"><?php _e('Default Option:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('default_option'); ?>" name="<?php echo $this->get_field_name('default_option'); ?>" type="text" value="<?php echo $default_option; ?>" /></p> 1 <?php 2 $links_category = linkdrop_categories_to_array('link_category'); 3 ksort($links_category); 4 ?> 5 6 <p> 7 <label for="<?php echo $this->get_field_id('title'); ?>"> 8 <?php _e('Title:', 'linkdrop'); ?></label> 9 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /> 10 </p> 11 12 <p> 13 <label for="<?php echo $this->get_field_id('default_option'); ?>"> 14 <?php _e('Default Option:', 'linkdrop'); ?></label> 15 <input class="widefat" id="<?php echo $this->get_field_id('default_option'); ?>" name="<?php echo $this->get_field_name('default_option'); ?>" type="text" value="<?php echo $default_option; ?>" /> 16 </p> 17 18 <p> 19 <label for="<?php echo $this->get_field_id('link_cat'); ?>"> 20 <?php _e('Link Category:', 'linkdrop'); ?></label> 21 <select class="widefat" 22 id="<?php echo $this->get_field_id('link_cat'); ?>" 23 name="<?php echo $this->get_field_name('link_cat'); ?>"> 24 <?php foreach ($links_category as $key => $cat ): ?> 25 <option <?php selected($link_cat, $key) ?> value="<?php echo $key ?>"><?php echo $cat ?></option> 26 <?php endforeach ?> 27 </select> 28 </select> 29 </p> 30 31 <p> 32 <label for="<?php echo $this->get_field_id('open_same_window'); ?>"> 33 <input <?php checked($open_same_window, 1) ?> 34 type="checkbox" name="<?php echo $this->get_field_name('open_same_window') ?>" 35 id="<?php echo $this->get_field_id('open_same_window') ?>" value="1"> 36 <?php _e('Open links in same window', 'linkdrop'); ?></label> 37 </p> -
links-dropdown-widget/trunk/views/widget.php
r844340 r1447608 1 1 <?php 2 $output = ''; $bookmarks = get_bookmarks(); 2 $output = ''; 3 4 if ( $link_cat == 0 ) { 5 $bookmarks = get_bookmarks(); 6 } else { 7 $bookmarks = get_bookmarks(array('category' => $link_cat)); 8 } 9 3 10 foreach ($bookmarks as $bookmark) { $output .= '<option value="'.$bookmark->link_url.'">'.$bookmark->link_name.'</option>'; } 11 12 $target = $open_same_window == 1 ? '_self' : '_blank'; 4 13 ?> 5 14 6 <select id="link-dropdown-widget" onchange="document.location.href=this.options[this.selectedIndex].value;"name="link-dropdown">15 <select id="link-dropdown-widget" name="link-dropdown"> 7 16 <option value=""><?php echo $default_option ?></option> 8 17 <?php echo $output ?> 9 18 </select> 19 20 <script type="text/javascript"> 21 var selectLink = document.getElementById( 'link-dropdown-widget' ); 22 selectLink.onchange = function() { 23 window.open( this.options[ this.selectedIndex ].value , '<?php echo $target ?>'); 24 }; 25 </script>
Note: See TracChangeset
for help on using the changeset viewer.