Plugin Directory

Changeset 6208


Ignore:
Timestamp:
07/04/2006 02:22:03 AM (20 years ago)
Author:
skeltoac
Message:

Merged patch from Sewar Jul 1 (#439)

Location:
widgets/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • widgets/trunk/delicious.php

    r5721 r6208  
    3030        ?>
    3131                                <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>
    3636                                <input type="hidden" name="delicious-submit" id="delicious-submit" value="1" />
    3737                                </div>
    … …  
    4444                $defaults = array('count' => 10, 'username' => 'wordpress');
    4545                $options = (array) get_option('widget_delicious');
    46        
     46
    4747                foreach ( $defaults as $key => $value )
    4848                        if ( !isset($options[$key]) )
    4949                                $options[$key] = $defaults[$key];
    50        
     50
    5151                $json_url = 'http://del.icio.us/feeds/json/' . rawurlencode($options['username']);
    5252                $json_url.= count($options['tags']) ? '/' . rawurlencode(implode('+', $options['tags'])) : '';
    … …  
    7575
    7676        // 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');
    7979       
    8080}
    8181
    8282// Delay plugin execution to ensure Dynamic Sidebar has a chance to load first
    83 add_action('plugins_loaded', 'widget_delicious_init');
     83add_action('init', 'widget_delicious_init');
    8484
    8585?>
  • widgets/trunk/gsearch.php

    r5614 r6208  
    4545                $options = get_option('widget_gsearch');
    4646                if ( !is_array($options) )
    47                         $options = array('title'=>'', 'buttontext'=>'Google Search');
     47                        $options = array('title'=>'', 'buttontext'=>__('Google Search', 'widgets'));
    4848                if ( $_POST['gsearch-submit'] ) {
    4949
    … …  
    6060                // Here is our little form segment. Notice that we don't need a
    6161                // 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>';
    6464                echo '<input type="hidden" id="gsearch-submit" name="gsearch-submit" value="1" />';
    6565        }
    … …  
    6767        // This registers our widget so it appears with the other available
    6868        // 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');
    7070
    7171        // This registers our optional widget control form. Because of this
    7272        // 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);
    7474}
    7575
  • widgets/trunk/widgets.php

    r6207 r6208  
    55Description: Adds "Sidebar Widgets" panel under Presentation menu
    66Author: Automattic, Inc.
     7Author URI: http://automattic.com/
    78Version: 1.0
    8 Author URI: http://automattic.com
    99*/
    1010
    … …  
    4949
    5050        $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 ),
    5253                'before_widget' => '<li id="%1$s" class="widget %2$s">',
    5354                'after_widget' => "</li>\n",
    … …  
    5859        $sidebar = array_merge($defaults, $args);
    5960
    60         $index = sanitize_title($sidebar['name']);
     61        $index = $sidebar['id'];
    6162
    6263        $registered_sidebars[$index] = $sidebar;
    … …  
    6869        global $registered_sidebars;
    6970
    70         $index = sanitize_title($name);
    71 
    72         unset( $registered_sidebars[$index] );
     71        unset( $registered_sidebars[$name]['id'] );
    7372}
    7473
    … …  
    123122        else
    124123                $registered_widget_controls[$name] = array(
     124                        'id' => $id,
    125125                        'callback' => $control_callback,
    126126                        'width' => $width,
    … …  
    137137        global $registered_sidebars, $registered_widgets;
    138138
    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        }
    143143
    144144        $sidebars_widgets = get_option('sidebars_widgets');
    … …  
    198198        $page = preg_replace('!^.*[\\\\/]wp-content[\\\\/][^\\\\/]*plugins[\\\\/]!', '', __FILE__);
    199199        $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');
    201201        if ( $_GET['page'] == $page ) {
    202202                add_action('admin_head', 'sidebar_admin_head');
    … …  
    408408                // <![CDATA[
    409409                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); ?>];
    411411                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']; ?>;
    416416<?php endforeach; ?>
    417417                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);}});
    422422                        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';
    424424<?php endforeach; ?>
    425425                        if ( true && window.opera )
    … …  
    459459                        el = o.element ? o.element : $(o);
    460460                        var p = Position.page(el);
    461                         var left = p[0];
     461                        var right = p[0];
    462462                        var top = p[1];
    463                         var right = $('shadow').offsetWidth - (el.offsetWidth + left);
     463                        var left = $('shadow').offsetWidth - (el.offsetWidth + left);
    464464                        var bottom = $('shadow').offsetHeight - (el.offsetHeight + top);
    465                         if ( left < 1 ) el.style.left = 0;
     465                        if ( right < 1 ) el.style.left = 0;
    466466                        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';
    468468                        if ( bottom < 1 ) el.style.top = (top + bottom) + 'px';
    469469                }
    … …  
    475475                        var y = ( document.body.parentNode.clientHeight - controldims[elm]['height'] ) / 2;
    476476                        el.style.position = 'absolute';
    477                         el.style.left = '' + x + 'px';
     477                        el.style.right = '' + x + 'px';
    478478                        el.style.top = '' + y + 'px';
    479479                        el.style.zIndex = 1000;
    … …  
    565565                                        if ( is_array($new_order) )
    566566                                                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'] )
    569569                                                                        $sidebars_widgets[$index][] = $name;
    570570                                }
    … …  
    577577
    578578        $inactive_widgets = array();
    579         foreach ( $registered_widgets as $name => $callback ) {
     579        foreach ( $registered_widgets as $name => $widget ) {
    580580                $is_active = false;
    581581                foreach ( $registered_sidebars as $index => $sidebar ) {
    … …  
    633633        <?php wp_nonce_field('widgets-save-widget-order'); ?>
    634634        <input type="hidden" name="action" id="action" value="save_widget_order" />
    635         <input type="submit" value="<?php _e('Save changes'); ?> &raquo;" />
     635        <input type="submit" value="<?php _e('Save Changes &raquo;', 'widgets'); ?>" />
    636636        </p>
    637637        <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">
    640640                        <span class="controlhandle"><?php echo $name; ?></span>
    641                         <span id="<?php echo sanitize_title($name); ?>closer" class="controlcloser">&#215;</span>
     641                        <span id="<?php echo $widget['id']; ?>closer" class="controlcloser">&#215;</span>
    642642                        <div class="controlform">
    643643<?php call_user_func_array($control['callback'], $control['params']); ?>
    … …  
    656656function widget_draggable($name) {
    657657        global $registered_widgets, $registered_widget_controls;
    658         $san_name = sanitize_title($name);
    659658        if ( !isset($registered_widgets[$name]) )
    660659                return;
    661         $poptitle = __('Configure');
     660        $san_name = sanitize_title($registered_widgets[$name]['id']);
     661        $poptitle = __('Configure', 'widgets');
    662662        $popper = $registered_widget_controls[$name] ? " <div class='popper' id='{$san_name}popper' title='$poptitle'>&#8801;</div>" : '';
    663663        echo "<li class='module' id='widgetprefix-$san_name'><span class='handle'>$name$popper</span></li>";
    … …  
    870870        <div class="wrap">
    871871                <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'); ?>
    874874                        <select id="text-number" name="text-number" value="<?php echo $options['number']; ?>">
    875875<?php for ( $i = 1; $i < 10; ++$i ) echo "<option value='$i' ".($options['number']==$i ? "selected='selected'" : '').">$i</option>"; ?>
    … …  
    887887        if ( $number > 9 ) $number = 9;
    888888        for ($i = 1; $i <= 9; $i++) {
    889                 $name = array('Text %s', null, $i);
     889                $name = array('Text %s', 'widgets', $i);
    890890                register_sidebar_widget($name, $i <= $number ? 'widget_text' : /* unregister */ '', $i);
    891891                register_widget_control($name, $i <= $number ? 'widget_text_control' : /* unregister */ '', 460, 350, $i);
    … …  
    927927?>
    928928                        <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>
    931931                        <input type="hidden" id="categories-submit" name="categories-submit" value="1" />
    932932<?php
    … …  
    935935function widget_recent_entries($args) {
    936936        extract($args);
    937         $title = __('Recent Posts');
     937        $title = __('Recent Posts', 'widgets');
    938938        $r = new WP_Query('showposts=10');
    939939        if ($r->have_posts()) :
    … …  
    955955        extract($args, EXTR_SKIP);
    956956        $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'];
    958958        $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");
    959959?>
    … …  
    992992
    993993function 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);
    996996       
    997997        if ( is_active_widget('widget_recent_comments') )
    … …  
    10251025                $title = $desc;
    10261026        if ( empty($title) )
    1027                 $title = "Unknown Feed";
     1027                $title = __('Unknown Feed', 'widgets');
    10281028        $url = wp_specialchars(strip_tags($url), 1);
    10291029        if ( file_exists(dirname(__FILE__) . '/rss.png') )
    … …  
    10561056                }
    10571057        } 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');
    10591059        }
    10601060?>
    … …  
    10801080        if ( empty($items) || $items < 1 ) $items = 10;
    10811081?>
    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>
    10831083                        <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>
    10851085                        <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>
    10871087                        <input type="hidden" id="rss-submit-<?php echo "$number"; ?>" name="rss-submit-<?php echo "$number"; ?>" value="1" />
    10881088<?php
    … …  
    11091109        <div class="wrap">
    11101110                <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'); ?>
    11131113                        <select id="rss-number" name="rss-number" value="<?php echo $options['number']; ?>">
    11141114<?php for ( $i = 1; $i < 10; ++$i ) echo "<option value='$i' ".($options['number']==$i ? "selected='selected'" : '').">$i</option>"; ?>
    … …  
    11261126        if ( $number > 9 ) $number = 9;
    11271127        for ($i = 1; $i <= 9; $i++) {
    1128                 $name = array('RSS %s', null, $i);
     1128                $name = array('RSS %s', 'widgets', $i);
    11291129                register_sidebar_widget($name, $i <= $number ? 'widget_rss' : /* unregister */ '', $i);
    11301130                register_widget_control($name, $i <= $number ? 'widget_rss_control' : /* unregister */ '', 410, 200, $i);
    … …  
    11451145
    11461146/////////////////////////////////////////////////////////// Actions and Registrations
     1147
     1148load_plugin_textdomain('widgets', 'wp-content/plugins/widgets');
    11471149
    11481150add_action('admin_menu', 'sidebar_admin_setup');
    … …  
    11531155register_sidebar_widget('Pages', 'widget_pages');
    11541156register_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);
     1157register_sidebar_widget(array('Calendar', 'widgets'), 'widget_calendar');
     1158register_widget_control(array('Calendar', 'widgets'), 'widget_calendar_control', 300, 90);
    11571159register_sidebar_widget('Archives', 'widget_archives');
    11581160register_widget_control('Archives', 'widget_archives_control', 300, 90);
    11591161register_sidebar_widget('Links', 'widget_links');
    1160 register_sidebar_widget('Meta', 'widget_meta');
    1161 register_widget_control('Meta', 'widget_meta_control', 300, 90);
     1162register_sidebar_widget(array('Meta', 'widgets'), 'widget_meta');
     1163register_widget_control(array('Meta', 'widgets'), 'widget_meta_control', 300, 90);
    11621164register_sidebar_widget('Search', 'widget_search');
    11631165register_sidebar_widget('Categories', 'widget_categories');
    11641166register_widget_control('Categories', 'widget_categories_control', 300, 150);
    1165 register_sidebar_widget('Recent Posts', 'widget_recent_entries');
    1166 
    1167 ?>
     1167register_sidebar_widget(array('Recent Posts', 'widgets'), 'widget_recent_entries');
     1168?>
Note: See TracChangeset for help on using the changeset viewer.