Changeset 6208
- Timestamp:
- 07/04/2006 02:22:03 AM (20 years ago)
- Location:
- widgets/trunk
- Files:
-
- 3 edited
-
delicious.php (modified) (3 diffs)
-
gsearch.php (modified) (3 diffs)
-
widgets.php (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
widgets/trunk/delicious.php
r5721 r6208 30 30 ?> 31 31 <div style="text-align:right"> 32 <label for="delicious-title" style="line-height:35px;display:block;"> Widget title: <input type="text" id="delicious-title" name="delicious-title" value="<?php echo htmlspecialchars($options['title']); ?>" /></label>33 <label for="delicious-username" style="line-height:35px;display:block;"> del.icio.us login: <input type="text" id="delicious-username" name="delicious-username" value="<?php echo htmlspecialchars($options['username']); ?>" /></label>34 <label for="delicious-count" style="line-height:35px;display:block;"> Number of links:<input type="text" id="delicious-count" name="delicious-count" value="<?php echo $options['count']; ?>" /></label>35 <label for="delicious-tags" style="line-height:35px;display:block;"> Show only these tags (separated by spaces): <textarea id="delicious-tags" name="delicious-tags" style="width:290px;height:20px;"><?php echo htmlspecialchars(implode(' ', (array) $options['tags'])); ?></textarea></label>32 <label for="delicious-title" style="line-height:35px;display:block;"><?php _e('Widget title:', 'widgets'); ?> <input type="text" id="delicious-title" name="delicious-title" value="<?php echo wp_specialchars($options['title'], true); ?>" /></label> 33 <label for="delicious-username" style="line-height:35px;display:block;"><?php _e('del.icio.us login:', 'widgets'); ?> <input type="text" id="delicious-username" name="delicious-username" value="<?php echo wp_specialchars($options['username'], true); ?>" /></label> 34 <label for="delicious-count" style="line-height:35px;display:block;"><?php _e('Number of links:', 'widgets'); ?> <input type="text" id="delicious-count" name="delicious-count" value="<?php echo $options['count']; ?>" /></label> 35 <label for="delicious-tags" style="line-height:35px;display:block;"><?php _e('Show only these tags (separated by spaces):', 'widgets'); ?> <textarea id="delicious-tags" name="delicious-tags" style="width:290px;height:20px;"><?php echo wp_specialchars(implode(' ', (array) $options['tags']), true); ?></textarea></label> 36 36 <input type="hidden" name="delicious-submit" id="delicious-submit" value="1" /> 37 37 </div> … … 44 44 $defaults = array('count' => 10, 'username' => 'wordpress'); 45 45 $options = (array) get_option('widget_delicious'); 46 46 47 47 foreach ( $defaults as $key => $value ) 48 48 if ( !isset($options[$key]) ) 49 49 $options[$key] = $defaults[$key]; 50 50 51 51 $json_url = 'http://del.icio.us/feeds/json/' . rawurlencode($options['username']); 52 52 $json_url.= count($options['tags']) ? '/' . rawurlencode(implode('+', $options['tags'])) : ''; … … 75 75 76 76 // Tell Dynamic Sidebar about our new widget and its control 77 register_sidebar_widget( 'del.icio.us', 'widget_delicious');78 register_widget_control( 'del.icio.us', 'widget_delicious_control');77 register_sidebar_widget(array('del.icio.us', 'widgets'), 'widget_delicious'); 78 register_widget_control(array('del.icio.us', 'widgets'), 'widget_delicious_control'); 79 79 80 80 } 81 81 82 82 // Delay plugin execution to ensure Dynamic Sidebar has a chance to load first 83 add_action(' plugins_loaded', 'widget_delicious_init');83 add_action('init', 'widget_delicious_init'); 84 84 85 85 ?> -
widgets/trunk/gsearch.php
r5614 r6208 45 45 $options = get_option('widget_gsearch'); 46 46 if ( !is_array($options) ) 47 $options = array('title'=>'', 'buttontext'=> 'Google Search');47 $options = array('title'=>'', 'buttontext'=>__('Google Search', 'widgets')); 48 48 if ( $_POST['gsearch-submit'] ) { 49 49 … … 60 60 // Here is our little form segment. Notice that we don't need a 61 61 // complete form. This will be embedded into the existing form. 62 echo '<p style="text-align:right;"><label for="gsearch-title"> Title:<input style="width: 200px;" id="gsearch-title" name="gsearch-title" type="text" value="'.$title.'" /></label></p>';63 echo '<p style="text-align:right;"><label for="gsearch-buttontext"> Button Text:<input style="width: 200px;" id="gsearch-buttontext" name="gsearch-buttontext" type="text" value="'.$buttontext.'" /></label></p>';62 echo '<p style="text-align:right;"><label for="gsearch-title">' . __('Title:') . ' <input style="width: 200px;" id="gsearch-title" name="gsearch-title" type="text" value="'.$title.'" /></label></p>'; 63 echo '<p style="text-align:right;"><label for="gsearch-buttontext">' . __('Button Text:', 'widgets') . ' <input style="width: 200px;" id="gsearch-buttontext" name="gsearch-buttontext" type="text" value="'.$buttontext.'" /></label></p>'; 64 64 echo '<input type="hidden" id="gsearch-submit" name="gsearch-submit" value="1" />'; 65 65 } … … 67 67 // This registers our widget so it appears with the other available 68 68 // widgets and can be dragged and dropped into any active sidebars. 69 register_sidebar_widget( 'Google Search', 'widget_gsearch');69 register_sidebar_widget(array('Google Search', 'widgets'), 'widget_gsearch'); 70 70 71 71 // This registers our optional widget control form. Because of this 72 72 // our widget will have a button that reveals a 300x100 pixel form. 73 register_widget_control( 'Google Search', 'widget_gsearch_control', 300, 100);73 register_widget_control(array('Google Search', 'widgets'), 'widget_gsearch_control', 300, 100); 74 74 } 75 75 -
widgets/trunk/widgets.php
r6207 r6208 5 5 Description: Adds "Sidebar Widgets" panel under Presentation menu 6 6 Author: Automattic, Inc. 7 Author URI: http://automattic.com/ 7 8 Version: 1.0 8 Author URI: http://automattic.com9 9 */ 10 10 … … 49 49 50 50 $defaults = array( 51 'name' => sprintf(__('Sidebar %d'), count($registered_sidebars) + 1 ), 51 'id' => sanitize_title(sprintf('Sidebar %d', count($registered_sidebars) + 1)), 52 'name' => sprintf(__('Sidebar %d', 'widgets'), count($registered_sidebars) + 1 ), 52 53 'before_widget' => '<li id="%1$s" class="widget %2$s">', 53 54 'after_widget' => "</li>\n", … … 58 59 $sidebar = array_merge($defaults, $args); 59 60 60 $index = sanitize_title($sidebar['name']);61 $index = $sidebar['id']; 61 62 62 63 $registered_sidebars[$index] = $sidebar; … … 68 69 global $registered_sidebars; 69 70 70 $index = sanitize_title($name); 71 72 unset( $registered_sidebars[$index] ); 71 unset( $registered_sidebars[$name]['id'] ); 73 72 } 74 73 … … 123 122 else 124 123 $registered_widget_controls[$name] = array( 124 'id' => $id, 125 125 'callback' => $control_callback, 126 126 'width' => $width, … … 137 137 global $registered_sidebars, $registered_widgets; 138 138 139 if ( is_int($name) ) 140 $ name = "Sidebar $name";141 142 $index = sanitize_title($name);139 if ( is_int($name) ) { 140 $index = sanitize_title('Sidebar ' . $name); 141 $name = sprintf(__('Sidebar %d', 'widgets'), $name); 142 } 143 143 144 144 $sidebars_widgets = get_option('sidebars_widgets'); … … 198 198 $page = preg_replace('!^.*[\\\\/]wp-content[\\\\/][^\\\\/]*plugins[\\\\/]!', '', __FILE__); 199 199 $page = str_replace('\\', '/', $page); 200 add_submenu_page('themes.php', 'Sidebar Widgets', 'Sidebar Widgets', 5, $page, 'sidebar_admin_page');200 add_submenu_page('themes.php', __('Sidebar Widgets', 'widgets'), __('Sidebar Widgets', 'widgets'), 5, $page, 'sidebar_admin_page'); 201 201 if ( $_GET['page'] == $page ) { 202 202 add_action('admin_head', 'sidebar_admin_head'); … … 408 408 // <![CDATA[ 409 409 var cols = [<?php $a = array(); foreach ( $registered_sidebars as $index => $sidebar ) $a[] = "'$index'"; echo implode(', ', $a); ?>]; 410 var widgets = [<?php $a = array(); foreach ( $registered_widgets as $name => $widget ) $a[] = "' " . sanitize_title($name) . "'"; echo implode(', ', $a); ?>];410 var widgets = [<?php $a = array(); foreach ( $registered_widgets as $name => $widget ) $a[] = "'{$widget['id']}'"; echo implode(', ', $a); ?>]; 411 411 var controldims = new Array; 412 <?php foreach ( $registered_widget_controls as $name => $ control) : ?>413 controldims['<?php echo sanitize_title($name); ?>control'] = new Array;414 controldims['<?php echo sanitize_title($name); ?>control']['width'] = <?php echo (int) $control['width']; ?>;415 controldims['<?php echo sanitize_title($name); ?>control']['height'] = <?php echo (int) $control['height']; ?>;412 <?php foreach ( $registered_widget_controls as $name => $widget ) : ?> 413 controldims['<?php echo $widget['id']; ?>control'] = new Array; 414 controldims['<?php echo $widget['id']; ?>control']['width'] = <?php echo (int) $widget['width']; ?>; 415 controldims['<?php echo $widget['id']; ?>control']['height'] = <?php echo (int) $widget['height']; ?>; 416 416 <?php endforeach; ?> 417 417 function initWidgets() { 418 <?php foreach ( $registered_widget_controls as $name => $ control ) : $san_name = sanitize_title($name);?>419 $('<?php echo $ san_name; ?>popper').onclick = function() {popControl('<?php echo $san_name; ?>control');};420 $('<?php echo $ san_name; ?>closer').onclick = function() {unpopControl('<?php echo $san_name; ?>control');};421 new Draggable('<?php echo sanitize_title($name); ?>control', {revert:false,handle:'controlhandle',starteffect:function(){},endeffect:function(){},change:function(o){dragChange(o);}});418 <?php foreach ( $registered_widget_controls as $name => $widget ) : ?> 419 $('<?php echo $widget['id']; ?>popper').onclick = function() {popControl('<?php echo $widget['id']; ?>control');}; 420 $('<?php echo $widget['id']; ?>closer').onclick = function() {unpopControl('<?php echo $widget['id']; ?>control');}; 421 new Draggable('<?php echo $widget['id']; ?>control', {revert:false,handle:'controlhandle',starteffect:function(){},endeffect:function(){},change:function(o){dragChange(o);}}); 422 422 if ( true && window.opera ) 423 $('<?php echo sanitize_title($name); ?>control').style.border = '1px solid #bbb';423 $('<?php echo $widget['id']; ?>control').style.border = '1px solid #bbb'; 424 424 <?php endforeach; ?> 425 425 if ( true && window.opera ) … … 459 459 el = o.element ? o.element : $(o); 460 460 var p = Position.page(el); 461 var left = p[0];461 var right = p[0]; 462 462 var top = p[1]; 463 var right = $('shadow').offsetWidth - (el.offsetWidth + left);463 var left = $('shadow').offsetWidth - (el.offsetWidth + left); 464 464 var bottom = $('shadow').offsetHeight - (el.offsetHeight + top); 465 if ( left < 1 ) el.style.left = 0;465 if ( right < 1 ) el.style.left = 0; 466 466 if ( top < 1 ) el.style.top = 0; 467 if ( right < 1 ) el.style.left = (left + right) + 'px';467 if ( left < 1 ) el.style.left = (left + right) + 'px'; 468 468 if ( bottom < 1 ) el.style.top = (top + bottom) + 'px'; 469 469 } … … 475 475 var y = ( document.body.parentNode.clientHeight - controldims[elm]['height'] ) / 2; 476 476 el.style.position = 'absolute'; 477 el.style. left = '' + x + 'px';477 el.style.right = '' + x + 'px'; 478 478 el.style.top = '' + y + 'px'; 479 479 el.style.zIndex = 1000; … … 565 565 if ( is_array($new_order) ) 566 566 foreach ( $new_order as $sanitized_name ) 567 foreach ( $registered_widgets as $name => $ callback)568 if ( $sanitized_name == sanitize_title($name))567 foreach ( $registered_widgets as $name => $widget ) 568 if ( $sanitized_name == $widget['id'] ) 569 569 $sidebars_widgets[$index][] = $name; 570 570 } … … 577 577 578 578 $inactive_widgets = array(); 579 foreach ( $registered_widgets as $name => $ callback) {579 foreach ( $registered_widgets as $name => $widget ) { 580 580 $is_active = false; 581 581 foreach ( $registered_sidebars as $index => $sidebar ) { … … 633 633 <?php wp_nonce_field('widgets-save-widget-order'); ?> 634 634 <input type="hidden" name="action" id="action" value="save_widget_order" /> 635 <input type="submit" value="<?php _e('Save changes'); ?> »" />635 <input type="submit" value="<?php _e('Save Changes »', 'widgets'); ?>" /> 636 636 </p> 637 637 <div id="controls"> 638 <?php foreach ( $registered_widget_controls as $name => $ control) : ?>639 <div class="hidden" id="<?php echo sanitize_title($name); ?>control">638 <?php foreach ( $registered_widget_controls as $name => $widget ) : ?> 639 <div class="hidden" id="<?php echo $widget['id']; ?>control"> 640 640 <span class="controlhandle"><?php echo $name; ?></span> 641 <span id="<?php echo sanitize_title($name); ?>closer" class="controlcloser">×</span>641 <span id="<?php echo $widget['id']; ?>closer" class="controlcloser">×</span> 642 642 <div class="controlform"> 643 643 <?php call_user_func_array($control['callback'], $control['params']); ?> … … 656 656 function widget_draggable($name) { 657 657 global $registered_widgets, $registered_widget_controls; 658 $san_name = sanitize_title($name);659 658 if ( !isset($registered_widgets[$name]) ) 660 659 return; 661 $poptitle = __('Configure'); 660 $san_name = sanitize_title($registered_widgets[$name]['id']); 661 $poptitle = __('Configure', 'widgets'); 662 662 $popper = $registered_widget_controls[$name] ? " <div class='popper' id='{$san_name}popper' title='$poptitle'>≡</div>" : ''; 663 663 echo "<li class='module' id='widgetprefix-$san_name'><span class='handle'>$name$popper</span></li>"; … … 870 870 <div class="wrap"> 871 871 <form method="POST"> 872 <h2> Text Widgets</h2>873 <p style="line-height: 30px;"><?php _e('How many text widgets would you like?' ); ?>872 <h2><?php _e('Text Widgets', 'widgets'); ?></h2> 873 <p style="line-height: 30px;"><?php _e('How many text widgets would you like?', 'widgets'); ?> 874 874 <select id="text-number" name="text-number" value="<?php echo $options['number']; ?>"> 875 875 <?php for ( $i = 1; $i < 10; ++$i ) echo "<option value='$i' ".($options['number']==$i ? "selected='selected'" : '').">$i</option>"; ?> … … 887 887 if ( $number > 9 ) $number = 9; 888 888 for ($i = 1; $i <= 9; $i++) { 889 $name = array('Text %s', null, $i);889 $name = array('Text %s', 'widgets', $i); 890 890 register_sidebar_widget($name, $i <= $number ? 'widget_text' : /* unregister */ '', $i); 891 891 register_widget_control($name, $i <= $number ? 'widget_text_control' : /* unregister */ '', 460, 350, $i); … … 927 927 ?> 928 928 <p><label for="categories-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="categories-title" name="categories-title" type="text" value="<?php echo $title; ?>" /></label></p> 929 <p style="text-align:right;margin-right:40px;"><label for="categories-count"> Show post counts<input class="checkbox" type="checkbox" <?php echo $count; ?> id="categories-count" name="categories-count" /></label></p>930 <p style="text-align:right;margin-right:40px;"><label for="categories-hierarchical" style="text-align:right;"> Show hierarchy<input class="checkbox" type="checkbox" <?php echo $hierarchical; ?> id="categories-hierarchical" name="categories-hierarchical" /></label></p>929 <p style="text-align:right;margin-right:40px;"><label for="categories-count"><?php _e('Show post counts', 'widgets'); ?> <input class="checkbox" type="checkbox" <?php echo $count; ?> id="categories-count" name="categories-count" /></label></p> 930 <p style="text-align:right;margin-right:40px;"><label for="categories-hierarchical" style="text-align:right;"><?php _e('Show hierarchy', 'widgets'); ?> <input class="checkbox" type="checkbox" <?php echo $hierarchical; ?> id="categories-hierarchical" name="categories-hierarchical" /></label></p> 931 931 <input type="hidden" id="categories-submit" name="categories-submit" value="1" /> 932 932 <?php … … 935 935 function widget_recent_entries($args) { 936 936 extract($args); 937 $title = __('Recent Posts' );937 $title = __('Recent Posts', 'widgets'); 938 938 $r = new WP_Query('showposts=10'); 939 939 if ($r->have_posts()) : … … 955 955 extract($args, EXTR_SKIP); 956 956 $options = get_option('widget_recent_comments'); 957 $title = empty($options['title']) ? __('Recent Comments' ) : $options['title'];957 $title = empty($options['title']) ? __('Recent Comments', 'widgets') : $options['title']; 958 958 $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 5"); 959 959 ?> … … 992 992 993 993 function widget_recent_comments_register() { 994 register_sidebar_widget( 'Recent Comments', 'widget_recent_comments');995 register_widget_control( 'Recent Comments', 'widget_recent_comments_control', 300, 90);994 register_sidebar_widget(array('Recent Comments', 'widgets'), 'widget_recent_comments'); 995 register_widget_control(array('Recent Comments', 'widgets'), 'widget_recent_comments_control', 300, 90); 996 996 997 997 if ( is_active_widget('widget_recent_comments') ) … … 1025 1025 $title = $desc; 1026 1026 if ( empty($title) ) 1027 $title = "Unknown Feed";1027 $title = __('Unknown Feed', 'widgets'); 1028 1028 $url = wp_specialchars(strip_tags($url), 1); 1029 1029 if ( file_exists(dirname(__FILE__) . '/rss.png') ) … … 1056 1056 } 1057 1057 } else { 1058 echo "<li>An error has occured; the feed is probably down. Try again later.</li>";1058 echo __('<li>An error has occured; the feed is probably down. Try again later.</li>', 'widgets'); 1059 1059 } 1060 1060 ?> … … 1080 1080 if ( empty($items) || $items < 1 ) $items = 10; 1081 1081 ?> 1082 <p style="text-align:center;"> Enter the RSS feed URL here:</p>1082 <p style="text-align:center;"><?php _e('Enter the RSS feed URL here:', 'widgets'); ?></p> 1083 1083 <input style="width: 400px;" id="rss-url-<?php echo "$number"; ?>" name="rss-url-<?php echo "$number"; ?>" type="text" value="<?php echo $url; ?>" /> 1084 <p style="text-align:center;"> Give the feed a title (optional):</p>1084 <p style="text-align:center;"><?php _e('Give the feed a title (optional):', 'widgets'); ?></p> 1085 1085 <input style="width: 400px;" id="rss-title-<?php echo "$number"; ?>" name="rss-title-<?php echo "$number"; ?>" type="text" value="<?php echo $title; ?>" /> 1086 <p style="text-align:center; line-height: 30px;"><?php _e('How many items would you like to display?' ); ?> <select id="rss-items-<?php echo $number; ?>" name="rss-items-<?php echo $number; ?>"><?php for ( $i = 1; $i <= 10; ++$i ) echo "<option value='$i' ".($items==$i ? "selected='selected'" : '').">$i</option>"; ?></select></p>1086 <p style="text-align:center; line-height: 30px;"><?php _e('How many items would you like to display?', 'widgets'); ?> <select id="rss-items-<?php echo $number; ?>" name="rss-items-<?php echo $number; ?>"><?php for ( $i = 1; $i <= 10; ++$i ) echo "<option value='$i' ".($items==$i ? "selected='selected'" : '').">$i</option>"; ?></select></p> 1087 1087 <input type="hidden" id="rss-submit-<?php echo "$number"; ?>" name="rss-submit-<?php echo "$number"; ?>" value="1" /> 1088 1088 <?php … … 1109 1109 <div class="wrap"> 1110 1110 <form method="POST"> 1111 <h2> RSS Feed Widgets</h2>1112 <p style="line-height: 30px;"><?php _e('How many RSS widgets would you like?' ); ?>1111 <h2><?php _e('RSS Feed Widgets', 'widgets'); ?></h2> 1112 <p style="line-height: 30px;"><?php _e('How many RSS widgets would you like?', 'widgets'); ?> 1113 1113 <select id="rss-number" name="rss-number" value="<?php echo $options['number']; ?>"> 1114 1114 <?php for ( $i = 1; $i < 10; ++$i ) echo "<option value='$i' ".($options['number']==$i ? "selected='selected'" : '').">$i</option>"; ?> … … 1126 1126 if ( $number > 9 ) $number = 9; 1127 1127 for ($i = 1; $i <= 9; $i++) { 1128 $name = array('RSS %s', null, $i);1128 $name = array('RSS %s', 'widgets', $i); 1129 1129 register_sidebar_widget($name, $i <= $number ? 'widget_rss' : /* unregister */ '', $i); 1130 1130 register_widget_control($name, $i <= $number ? 'widget_rss_control' : /* unregister */ '', 410, 200, $i); … … 1145 1145 1146 1146 /////////////////////////////////////////////////////////// Actions and Registrations 1147 1148 load_plugin_textdomain('widgets', 'wp-content/plugins/widgets'); 1147 1149 1148 1150 add_action('admin_menu', 'sidebar_admin_setup'); … … 1153 1155 register_sidebar_widget('Pages', 'widget_pages'); 1154 1156 register_widget_control('Pages', 'widget_pages_control', 300, 90); 1155 register_sidebar_widget( 'Calendar', 'widget_calendar');1156 register_widget_control( 'Calendar', 'widget_calendar_control', 300, 90);1157 register_sidebar_widget(array('Calendar', 'widgets'), 'widget_calendar'); 1158 register_widget_control(array('Calendar', 'widgets'), 'widget_calendar_control', 300, 90); 1157 1159 register_sidebar_widget('Archives', 'widget_archives'); 1158 1160 register_widget_control('Archives', 'widget_archives_control', 300, 90); 1159 1161 register_sidebar_widget('Links', 'widget_links'); 1160 register_sidebar_widget( 'Meta', 'widget_meta');1161 register_widget_control( 'Meta', 'widget_meta_control', 300, 90);1162 register_sidebar_widget(array('Meta', 'widgets'), 'widget_meta'); 1163 register_widget_control(array('Meta', 'widgets'), 'widget_meta_control', 300, 90); 1162 1164 register_sidebar_widget('Search', 'widget_search'); 1163 1165 register_sidebar_widget('Categories', 'widget_categories'); 1164 1166 register_widget_control('Categories', 'widget_categories_control', 300, 150); 1165 register_sidebar_widget('Recent Posts', 'widget_recent_entries'); 1166 1167 ?> 1167 register_sidebar_widget(array('Recent Posts', 'widgets'), 'widget_recent_entries'); 1168 ?>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)