Ticket #4280: 4280.diff

File 4280.diff, 31.8 KB (added by DD32, 4 years ago)

Patch based on attached files;

  • wp-admin/includes/widgets.php

     
    2121                $no_widgets_shown = true; 
    2222                $already_shown = array(); 
    2323                foreach ( $wp_registered_widgets as $name => $widget ) : 
    24                         if ( 'all' == $show && in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget 
     24                        if ( in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget 
    2525                                continue; 
    2626 
    2727                        if ( $search_terms ) { 
     
    4747                                continue; 
    4848 
    4949                        ob_start(); 
    50                                 $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template', '_show' => $show ), 1 => $widget['params'][0] ) ); 
     50                                $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' ) ) ); 
    5151                                $sidebar_args = call_user_func_array( 'wp_widget_control', $args ); 
    5252                        $widget_control_template = ob_get_contents(); 
    5353                        ob_end_clean(); 
     
    6161                                        'key' => false, 
    6262                                        'edit' => false 
    6363                                ); 
    64                                 if ( 'all' == $show && $is_multi ) { 
     64                                if ( $is_multi ) { 
    6565                                        // it's a multi-widget.  We only need to show it in the list once. 
    6666                                        $already_shown[] = $widget['callback']; 
    67                                         $num = (int) array_pop( explode( '-', $widget['id'] ) ); 
     67                                        $num = array_pop( explode( '-', $widget['id'] ) ); 
    6868                                        $id_base = $wp_registered_widget_controls[$widget['id']]['id_base']; 
    6969                                        // so that we always add a new one when clicking "add" 
    7070                                        while ( isset($wp_registered_widgets["$id_base-$num"]) ) 
     
    7676                                } 
    7777                                $add_query['add'] = $widget['id']; 
    7878                                $action = 'add'; 
    79                                 $add_url = clean_url( wp_nonce_url( add_query_arg( $add_query ), "add-widget_$widget[id]" ) ); 
     79                                $add_url = wp_nonce_url( add_query_arg( $add_query ), "add-widget_$widget[id]" ); 
    8080                        } else { 
    8181                                $action = 'edit'; 
    8282                                $edit_url = clean_url( add_query_arg( array( 
     
    9292 
    9393                        $no_widgets_shown = false; 
    9494 
    95  
    96                         if ( 'all' != $show && $sidebar_args['_widget_title'] ) 
    97                                 $widget_title = $sidebar_args['_widget_title']; 
    98                         else 
    99                                 $widget_title = $widget['name']; 
    10095                ?> 
    10196 
    10297                <li id="widget-list-item-<?php echo attribute_escape( $widget['id'] ); ?>" class="widget-list-item"> 
    10398                        <h4 class="widget-title widget-draggable"> 
    10499 
    105                                 <span><?php echo $widget_title; ?></span> 
     100                                <?php echo wp_specialchars( $widget['name'] ); ?> 
    106101 
    107102                                <?php if ( 'add' == $action ) : ?> 
    108103 
     
    116111 
    117112                                <?php endif; ?> 
    118113 
    119                                 <br class="clear" /> 
    120  
    121114                        </h4> 
    122115 
    123116 
     
    199192 
    200193        $id_format = $widget['id']; 
    201194        // We aren't showing a widget control, we're outputing a template for a mult-widget control 
    202         if ( 'all' == $sidebar_args['_show'] && 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) { 
     195        if ( 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) { 
    203196                // number == -1 implies a template where id numbers are replaced by a generic '%i%' 
    204197                $control['params'][0]['number'] = -1; 
    205198                // if given, id_base means widget id's should be constructed like {$id_base}-{$id_number} 
     
    209202 
    210203        $widget_title = ''; 
    211204        // We grab the normal widget output to find the widget's title 
    212         if ( ( 'all' != $sidebar_args['_show'] || 'template' != $sidebar_args['_display'] ) && is_callable( $widget['_callback'] ) ) { 
     205        if ( is_callable( $widget['_callback'] ) ) { 
    213206                ob_start(); 
    214207                $args = func_get_args(); 
    215208                call_user_func_array( $widget['_callback'], $args ); 
     
    219212        $wp_registered_widgets[$widget_id]['callback'] = $wp_registered_widgets[$widget_id]['_callback']; 
    220213        unset($wp_registered_widgets[$widget_id]['_callback']); 
    221214 
    222         if ( $widget_title && $widget_title != $sidebar_args['widget_name'] ) 
     215        if ( $widget_title ) 
    223216                $widget_title = sprintf( _c('%1$s: %2$s|1: widget name, 2: widget title' ), $sidebar_args['widget_name'], $widget_title ); 
    224217        else 
    225218                $widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) ); 
    226219 
    227         $sidebar_args['_widget_title'] = $widget_title; 
    228  
    229220        if ( empty($sidebar_args['_display']) || 'template' != $sidebar_args['_display'] ) 
    230221                echo $sidebar_args['before_widget']; 
    231222?> 
    232                 <div class="widget-top"> 
    233                 <h4 class="widget-title"><span><?php echo $widget_title ?></span> 
     223                <h4 class="widget-title"><?php echo $widget_title ?> 
    234224 
    235225                        <?php if ( $edit ) : ?> 
    236226 
    237                         <a class="widget-action widget-control-edit" href="<?php echo clean_url( remove_query_arg( array( 'edit', 'key' ) ) ); ?>"><?php _e('Cancel'); ?></a> 
     227                        <a class="widget-action widget-control-edit" href="<?php echo remove_query_arg( array( 'edit', 'key' ) ); ?>"><?php _e('Cancel'); ?></a> 
    238228 
    239229                        <?php else : ?> 
    240230 
     
    242232 
    243233                        <?php endif; ?> 
    244234 
    245                         <br class="clear" /> 
     235                </h4> 
    246236 
    247                 </h4></div> 
    248  
    249237                <div class="widget-control"<?php if ( $edit ) echo ' style="display: block;"'; ?>> 
    250  
     238                                <!--allen's change begins--> 
    251239                        <?php 
     240                                        global $wpdb,$post,$wp_registered_widget_controls; 
    252241                        if ( $control ) 
    253242                                call_user_func_array( $control['callback'], $control['params'] ); 
    254243                        else 
     
    257246 
    258247                        <input type="hidden" name="widget-id[]" value="<?php echo $id_format; ?>" /> 
    259248                        <input type="hidden" class="widget-width" value="<?php echo $control['width']; ?>" /> 
     249                        <?php 
     250                                $widget_display_options=get_option('widget_display_option'); 
     251                                $widget_dipslay_array=array_keys((array)$widget_display_options); 
     252                                foreach($widget_dipslay_array as $widget_display) { 
     253                                        $display_checked[$widget_display]="checked='checked'"; 
     254                                } 
     255                                foreach ((array)$widget_display_options as $widget_display_key=>$widget_display_on) { 
     256                                        if (!is_array($widget_display_options[$id_format.'-display'])) { 
     257                                                $all_checked='1'; 
     258                                        }else{ 
     259                                                $all_checked='0'; 
     260                                        } 
     261                                        if (($widget_display_key==$id_format.'-display') && (!$all_checked)) { 
     262                                                if (is_array($widget_display_options[$widget_display_key]['page_id'])) 
     263                                                        $widget_dipslay_pages=array_keys($widget_display_options[$widget_display_key]['page_id']); 
     264                                                if (is_array($widget_display_options[$widget_display_key]['post_id'])) 
     265                                                        $widget_dipslay_posts=array_keys($widget_display_options[$widget_display_key]['post_id']); 
     266                                        } 
     267                                } 
     268                        ?> 
     269                        <p><label for="<?php echo $id_format; ?>-title"><?php _e('Display on:'); ?> </label><br> 
     270                        <input <?php echo $display_checked[$id_format."-display-frontpage"];?> id="<?php echo $id_format; ?>-display-frontpage" name="<?php echo $id_format; ?>-display-frontpage" type="checkbox" /><label for="<?php echo $id_format; ?>-display-frontpage"><?php _e('Front Page'); ?></label><br> 
     271                        <input <?php echo $display_checked[$id_format."-display-category"];?> id="<?php echo $id_format; ?>-display-category" name="<?php echo $id_format; ?>-display-category" type="checkbox" /><label for="<?php echo $id_format; ?>-display-category"><?php _e('Category'); ?></label><br> 
     272                        <input <?php echo $display_checked[$id_format."-display-archive"];?> id="<?php echo $id_format; ?>-display-archive" name="<?php echo $id_format; ?>-display-archive" type="checkbox" /><label for="<?php echo $id_format; ?>-display-archive"><?php _e('Archives'); ?></label><br> 
     273                        <input <?php echo $display_checked[$id_format."-display-search"];?> id="<?php echo $id_format; ?>-display-search" name="<?php echo $id_format; ?>-display-search" type="checkbox" /><label for="<?php echo $id_format; ?>-display-search"><?php _e('Search Results'); ?></label><br> 
     274                        <?php _e('Static pages'); ?><br> 
    260275 
     276                        <?php 
     277//                                      echo ("<pre>".print_r(get_option("widget_display_option"),1)."</pre>"); 
     278                        $type='page'; 
     279                        $posts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'page' ORDER BY menu_order"); 
     280                        ?> 
     281                        <div id="<?php echo($type); ?>-ids" class="checkbox-list" style="height:100px;overflow:auto;border:1px solid #999999;background-color:white;padding:0 0 0 3px;margin:-3px 0 3px 0px;"> 
     282                        <a style="cursor:pointer;" onclick="jQuery('input[@id^=\'display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids\'][@type=\'checkbox\']').each(function() {this.checked = true; });">Check All</a> 
     283                        | 
     284                        <a style="cursor:pointer;" onclick="jQuery('input[@id^=\'display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids\'][@type=\'checkbox\']').each(function() {this.checked = false; });">Uncheck All</a> 
     285                        <?php foreach($posts as $post): 
     286                                        if (is_array($widget_dipslay_pages)) { 
     287                                                if ($all_checked=='1') { 
     288                                                        $checked="checked='checked'"; 
     289                                                } else { 
     290                                                        if (in_array($post->ID,$widget_dipslay_pages)) 
     291                                                                $checked="checked='checked'"; 
     292                                                        else 
     293                                                                $checked=""; 
     294                                                } 
     295                                        } 
     296                        ?> 
     297                                         
     298                        <p><input <?php echo $checked ?> id="display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids-<?php echo($post->ID); ?>" name="<?php echo $id_format; ?>-display[<?php echo($type); ?>_id][<?php echo($post->ID); ?>]" type="checkbox"<?php checked($module->display[$type . '_id']['ids'][$post->ID], true); ?> /> <label for="display-<?php echo($type); ?>-id-ids-<?php echo($post->ID); ?>"><?php the_title(); ?></label></p> 
     299                        <?php endforeach; ?> 
     300                        </div> 
     301                        <?php _e('Single posts'); ?><br> 
     302                        <?php 
     303                                        $type='post'; 
     304                        $posts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type != 'page' ORDER BY post_date_gmt DESC"); 
     305 
     306                        ?> 
     307                                        <div id="<?php echo($type); ?>-ids" class="checkbox-list" style="height:100px;overflow:auto;border:1px solid #999999;background-color:white;padding:0 0 0 3px;margin:3px 0 3px 0px;"> 
     308                        <a style="cursor:pointer;" onclick="jQuery('input[@id^=\'display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids\'][@type=\'checkbox\']').each(function() {this.checked = true; });">Check All</a> 
     309                        | 
     310                        <a style="cursor:pointer;" onclick="jQuery('input[@id^=\'display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids\'][@type=\'checkbox\']').each(function() {this.checked = false; });">Uncheck All</a> 
     311                        <?php foreach($posts as $post):  
     312                                        if (is_array($widget_dipslay_posts)) { 
     313                                                if ($all_checked=='1') { 
     314                                                        $checked=""; 
     315                                                } else { 
     316                                                        if (in_array($post->ID,$widget_dipslay_posts)) 
     317                                                                $checked="checked='checked'"; 
     318                                                        else 
     319                                                                $checked=""; 
     320                                                } 
     321                                        } 
     322                                         
     323//                                       
     324                                         
     325                        ?> 
     326                <p><input <?php echo $checked;?> id="display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids-<?php echo($post->ID); ?>" name="<?php echo $id_format; ?>-display[<?php echo($type); ?>_id][<?php echo($post->ID); ?>]" type="checkbox"<?php checked($module->display[$type . '_id']['ids'][$post->ID], true); ?> /> <label for="display-<?php echo($type); ?>-id-ids-<?php echo($post->ID); ?>"><?php the_title(); ?></label></p> 
     327                        <?php endforeach; ?> 
     328                        </div> 
     329                        </p> 
     330                        <!--allen's change ends--> 
    261331                        <div class="widget-control-actions"> 
    262332 
    263333                                <?php if ( $control ) : ?> 
     
    282352        if ( false === $end = strpos( $string, '%END_OF_TITLE%' ) ) 
    283353                return ''; 
    284354        $string = substr( $string, $beg + 14 , $end - $beg - 14); 
    285         $string = str_replace( '&nbsp;', ' ', $string ); 
    286         return trim( wp_specialchars( strip_tags( $string ) ) ); 
     355        return wp_specialchars( strip_tags( $string ) ); 
    287356} 
    288357 
    289 ?> 
     358?> 
     359 No newline at end of file 
  • wp-admin/widgets.php

     
    77        wp_die( __( 'Cheatin&#8217; uh?' )); 
    88 
    99wp_enqueue_script( array( 'wp-lists', 'admin-widgets' ) ); 
    10 wp_admin_css( 'widgets' ); 
    1110 
    1211do_action( 'sidebar_admin_setup' ); 
    1312 
    1413$title = __( 'Widgets' ); 
    1514$parent_file = 'themes.php'; 
    1615 
     16add_action( 'admin_head', 'widget_css' ); 
     17function widget_css() { 
     18        wp_admin_css( 'css/widgets' ); 
     19} 
     20 
    1721// $sidebar = What sidebar are we editing? 
    1822if ( isset($_GET['sidebar']) && isset($wp_registered_sidebars[$_GET['sidebar']]) ) { 
    1923        $sidebar = attribute_escape( $_GET['sidebar'] ); 
    2024} elseif ( is_array($wp_registered_sidebars) && !empty($wp_registered_sidebars) ) { 
    2125        // By default we look at the first defined sidebar 
    22         $sidebar = array_shift( $keys = array_keys($wp_registered_sidebars) ); 
     26        $sidebar = array_shift( array_keys($wp_registered_sidebars) ); 
    2327} else { 
    2428        // If no sidebars, die. 
    2529        require_once( 'admin-header.php' ); 
     
    5256// We're updating a sidebar 
    5357if ( $http_post && isset($sidebars_widgets[$_POST['sidebar']]) ) { 
    5458        check_admin_referer( 'edit-sidebar_' . $_POST['sidebar'] ); 
    55  
     59        $temp_display_keys=array_keys($_POST); 
     60        foreach($temp_display_keys as $name => $key) { 
     61                if (preg_match(':display:',$key)) { 
     62                        $display_info[$key]=$_POST[$key]; 
     63                } 
     64        } 
     65        update_option('widget_display_option',$display_info); 
    5666        /* Hack #1 
    5767         * The widget_control is overloaded.  It updates the widget's options AND echoes out the widget's HTML form. 
    5868         * Since we want to update before sending out any headers, we have to catch it with an output buffer, 
     
    92102        exit; 
    93103} 
    94104 
    95  
    96  
    97  
    98105// What widget (if any) are we editing 
    99106$edit_widget = -1; 
    100107 
     
    135142                 
    136143                        <ul class="widget-control-list"> 
    137144                                <li class="widget-list-control-item"> 
    138                                         <div class="widget-top"> 
    139145                                        <h4 class="widget-title"><?php echo $control['name']; ?></h4> 
    140                                         </div> 
    141146                                        <div class="widget-control" style="display: block;"> 
    142147        <?php 
    143148                                                call_user_func_array( $control_callback, $control['params'] ); 
     
    235240 
    236241        <h2><?php _e( 'Widgets' ); ?></h2> 
    237242        <p id="widget-search"> 
    238                 <label class="hidden" for="widget-search-input"><?php _e( 'Search Widgets' ); ?>:</label> 
    239243                <input type="text" id="widget-search-input" name="s" value="<?php echo attribute_escape( $widget_search ); ?>" /> 
    240244                <input type="submit" class="button" value="<?php _e( 'Search Widgets' ); ?>" /> 
    241245        </p> 
    242246 
    243247        <div class="widget-liquid-left-holder"> 
    244248        <div id="available-widgets-filter" class="widget-liquid-left"> 
    245                 <h3><label for="show"><?php _e('Available Widgets'); ?></label></h3> 
     249                <h3><?php _e('Available Widgets'); ?></h3> 
    246250                <div class="nav"> 
    247                         <select name="show" id="show"> 
     251                        <select name="show"> 
    248252<?php foreach ( $show_values as $show_value => $show_text ) : $show_value = attribute_escape( $show_value ); ?> 
    249253                                <option value='<?php echo $show_value; ?>'<?php selected( $show_value, $show ); ?>><?php echo wp_specialchars( $show_text ); ?></option> 
    250254<?php endforeach; ?> 
     
    258262        </div> 
    259263 
    260264        <div id="available-sidebars" class="widget-liquid-right"> 
    261                 <h3><label for="sidebar-selector"><?php _e('Current Widgets'); ?></label></h3> 
     265                <h3><?php _e('Current Widgets'); ?></h3> 
    262266 
    263267                <div class="nav"> 
    264268                        <select id="sidebar-selector" name="sidebar"> 
     
    318322        </form> 
    319323 
    320324</div> 
    321  
    322325<?php do_action( 'sidebar_admin_page' ); ?> 
    323  
    324 <br class="clear" /> 
    325  
    326 <?php require_once( 'admin-footer.php' ); ?> 
    327  
     326<?php require_once( 'admin-footer.php' ); ?> 
     327 No newline at end of file 
  • wp-includes/widgets.php

     
    9595function wp_register_sidebar_widget($id, $name, $output_callback, $options = array()) { 
    9696        global $wp_registered_widgets; 
    9797 
    98         $id = strtolower($id); 
    99  
    10098        if ( empty($output_callback) ) { 
    10199                unset($wp_registered_widgets[$id]); 
    102100                return; 
     
    166164 */ 
    167165function wp_register_widget_control($id, $name, $control_callback, $options = array()) { 
    168166        global $wp_registered_widget_controls; 
    169          
    170         $id = strtolower($id); 
    171167 
    172168        if ( empty($control_callback) ) { 
    173169                unset($wp_registered_widget_controls[$id]); 
     
    202198} 
    203199 
    204200function dynamic_sidebar($index = 1) { 
    205         global $wp_registered_sidebars, $wp_registered_widgets; 
    206  
     201        global $wp_registered_sidebars, $wp_registered_widgets,$wp_query; 
     202         
    207203        if ( is_int($index) ) { 
    208204                $index = "sidebar-$index"; 
    209205        } else { 
     
    215211                        } 
    216212                } 
    217213        } 
    218  
    219214        $sidebars_widgets = wp_get_sidebars_widgets(); 
    220  
    221215        if ( empty($wp_registered_sidebars[$index]) || !array_key_exists($index, $sidebars_widgets) || !is_array($sidebars_widgets[$index]) || empty($sidebars_widgets[$index]) ) 
    222216                return false; 
    223217 
     
    229223                        array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ), 
    230224                        (array) $wp_registered_widgets[$id]['params'] 
    231225                ); 
    232  
     226                 
     227                 
     228//              allen's change begins 
     229                $widget_display_options=get_option('widget_display_option'); 
     230                $display_registered_widgets = $sidebars_widgets[$index]; 
     231                 
     232                if (is_front_page())  
     233                        $current_page='frontpage'; 
     234                else if ((is_home()) && (!is_front_page)) 
     235                        $current_page='blog'; 
     236                else if(is_category()) 
     237                        $current_page='category'; 
     238                else if(is_archive()) 
     239                        $current_page='archive'; 
     240                else if(is_search()) 
     241                        $current_page='search'; 
     242                else if(is_page()) { 
     243                        $current_page='pages'; 
     244                        $display_id=$wp_query->get_queried_object_id(); 
     245                } else if(is_tag()) { 
     246                        $current_page='tag'; 
     247                } else if(is_single()) { 
     248                        $current_page='post'; 
     249                        $display_id=$wp_query->get_queried_object_id(); 
     250                } 
     251                if (array_key_exists($id."-display-".$current_page, (array)$widget_display_options)){ 
     252                        $display='1'; 
     253                } else { 
     254                        $display='0'; 
     255                } 
     256                if (($current_page=='pages') && ($display_id!='')) { 
     257                        $dispaly_pages=$widget_display_options[$id."-display"]['page_id']; 
     258                        if (is_array($dispaly_pages)){ 
     259                                if (array_key_exists($display_id,$dispaly_pages)) { 
     260                                        $display='1'; 
     261                                } else { 
     262                                        $display='0'; 
     263                                } 
     264                        } 
     265                } 
     266                 
     267                if (($current_page=='post') && ($display_id!='')) { 
     268//                      exit("<pre>".print_r($widget_display_options[$id."-display"]['post_id'],1)."</pre>"); 
     269                        $dispaly_pages=$widget_display_options[$id."-display"]['post_id']; 
     270                        if (is_array($dispaly_pages)){ 
     271                                if (array_key_exists($display_id, (array)$dispaly_pages)) { 
     272                                        $display='1'; 
     273                                } else { 
     274                                        $display='0'; 
     275                                } 
     276                        } else { 
     277                                $display='0'; 
     278                        } 
     279                } 
     280                 
     281                // allen's change ends 
    233282                // Substitute HTML id and class attributes into before_widget 
    234283                $classname_ = ''; 
    235284                foreach ( (array) $wp_registered_widgets[$id]['classname'] as $cn ) { 
     
    242291                $params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_); 
    243292 
    244293                $params = apply_filters( 'dynamic_sidebar_params', $params ); 
     294                 
     295                if ((!is_admin()) && !$display){ 
     296                 
     297                } else { 
     298                        $callback = $wp_registered_widgets[$id]['callback']; 
     299                        if ( is_callable($callback) ) { 
     300                                call_user_func_array($callback, $params); 
     301                                $did_one = true; 
     302                        } 
     303                } 
    245304 
    246                 $callback = $wp_registered_widgets[$id]['callback']; 
    247  
    248                 if ( is_callable($callback) ) { 
    249                         call_user_func_array($callback, $params); 
    250                         $did_one = true; 
    251                 } 
    252305        } 
    253306 
    254307        return $did_one; 
     
    310363                                        $_sidebars_widgets[$index][$i] = $id; 
    311364                                        continue; 
    312365                                } 
    313  
    314                                 $found = false; 
    315  
    316                                 foreach ( $wp_registered_widgets as $widget_id => $widget ) { 
    317                                         if ( strtolower($widget['name']) == strtolower($name) ) { 
    318                                                 $_sidebars_widgets[$index][$i] = $widget['id']; 
    319                                                 $found = true; 
    320                                                 break; 
    321                                         } elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) { 
    322                                                 $_sidebars_widgets[$index][$i] = $widget['id']; 
    323                                                 $found = true; 
    324                                                 break; 
    325                                         } 
    326                                 } 
    327  
    328                                 if ( $found ) 
    329                                         continue; 
    330  
    331366                                unset($_sidebars_widgets[$index][$i]); 
    332367                        } 
    333368                        $_sidebars_widgets['array_version'] = 2; 
     
    385420        extract( $args ); 
    386421        $options = get_option( 'widget_pages' ); 
    387422 
    388         $title = empty( $options['title'] ) ? __( 'Pages' ) : apply_filters('widget_title', $options['title']); 
     423        $title = empty( $options['title'] ) ? __( 'Pages' ) : $options['title']; 
    389424        $sortby = empty( $options['sortby'] ) ? 'menu_order' : $options['sortby']; 
    390425        $exclude = empty( $options['exclude'] ) ? '' : $options['exclude']; 
    391426 
     
    450485 
    451486function wp_widget_links($args) { 
    452487        extract($args, EXTR_SKIP); 
    453  
    454         $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget); 
    455         wp_list_bookmarks(apply_filters('widget_links_args', array( 
     488        wp_list_bookmarks(array( 
    456489                'title_before' => $before_title, 'title_after' => $after_title, 
    457490                'category_before' => $before_widget, 'category_after' => $after_widget, 
    458491                'show_images' => true, 'class' => 'linkcat widget' 
    459         ))); 
     492        )); 
    460493} 
    461494 
    462495function wp_widget_search($args) { 
     
    465498                <?php echo $before_widget; ?> 
    466499                        <form id="searchform" method="get" action="<?php bloginfo('home'); ?>"> 
    467500                        <div> 
    468                         <label class="hidden" for="s"><?php _e('Search for:'); ?></label> 
    469501                        <input type="text" name="s" id="s" size="15" /><br /> 
    470502                        <input type="submit" value="<?php echo attribute_escape(__('Search')); ?>" /> 
    471503                        </div> 
     
    479511        $options = get_option('widget_archives'); 
    480512        $c = $options['count'] ? '1' : '0'; 
    481513        $d = $options['dropdown'] ? '1' : '0'; 
    482         $title = empty($options['title']) ? __('Archives') : apply_filters('widget_title', $options['title']); 
     514        $title = empty($options['title']) ? __('Archives') : $options['title']; 
    483515 
    484516        echo $before_widget; 
    485517        echo $before_title . $title . $after_title; 
     
    527559function wp_widget_meta($args) { 
    528560        extract($args); 
    529561        $options = get_option('widget_meta'); 
    530         $title = empty($options['title']) ? __('Meta') : apply_filters('widget_title', $options['title']); 
     562        $title = empty($options['title']) ? __('Meta') : $options['title']; 
    531563?> 
    532564                <?php echo $before_widget; ?> 
    533565                        <?php echo $before_title . $title . $after_title; ?> 
     
    561593function wp_widget_calendar($args) { 
    562594        extract($args); 
    563595        $options = get_option('widget_calendar'); 
    564         $title = apply_filters('widget_title', $options['title']); 
     596        $title = $options['title']; 
    565597        if ( empty($title) ) 
    566598                $title = '&nbsp;'; 
    567599        echo $before_widget . $before_title . $title . $after_title; 
     
    570602        echo '</div>'; 
    571603        echo $after_widget; 
    572604} 
     605 
    573606function wp_widget_calendar_control() { 
    574607        $options = $newoptions = get_option('widget_calendar'); 
    575608        if ( $_POST["calendar-submit"] ) { 
    576609                $newoptions['title'] = strip_tags(stripslashes($_POST["calendar-title"])); 
     610                $newoptions['displayon'] = $_POST['calendar-display-frontpage']; 
    577611        } 
    578612        if ( $options != $newoptions ) { 
    579613                $options = $newoptions; 
     
    581615        } 
    582616        $title = attribute_escape($options['title']); 
    583617?> 
    584                         <p><label for="calendar-title"><?php _e('Title:'); ?> <input class="widefat" id="calendar-title" name="calendar-title" type="text" value="<?php echo $title; ?>" /></label></p> 
    585                         <input type="hidden" id="calendar-submit" name="calendar-submit" value="1" /> 
     618                <p><label for="calendar-title"><?php _e('Title:'); ?> <input class="widefat" id="calendar-title" name="calendar-title" type="text" value="<?php echo $title; ?>" /></label></p> 
     619                <input type="hidden" id="calendar-submit" name="calendar-submit" value="1" /> 
    586620<?php 
    587621} 
    588622 
     
    598632        if ( !isset($options[$number]) ) 
    599633                return; 
    600634 
    601         $title = apply_filters('widget_title', $options[$number]['title']); 
     635        $title = $options[$number]['title']; 
    602636        $text = apply_filters( 'widget_text', $options[$number]['text'] ); 
    603637?> 
    604638                <?php echo $before_widget; ?> 
     
    639673                } 
    640674 
    641675                foreach ( (array) $_POST['widget-text'] as $widget_number => $widget_text ) { 
    642                         if ( !isset($widget_text['text']) && isset($options[$widget_number]) ) // user clicked cancel 
    643                                 continue; 
    644676                        $title = strip_tags(stripslashes($widget_text['title'])); 
    645677                        if ( current_user_can('unfiltered_html') ) 
    646678                                $text = stripslashes( $widget_text['text'] ); 
     
    665697                <p> 
    666698                        <input class="widefat" id="text-title-<?php echo $number; ?>" name="widget-text[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" /> 
    667699                        <textarea class="widefat" rows="16" cols="20" id="text-text-<?php echo $number; ?>" name="widget-text[<?php echo $number; ?>][text]"><?php echo $text; ?></textarea> 
    668                         <input type="hidden" name="widget-text[<?php echo $number; ?>][submit]" value="1" /> 
     700                        <input type="hidden" id="text-submit-<?php echo $number; ?>" name="text-submit-<?php echo $number; ?>" value="1" /> 
    669701                </p> 
    670702<?php 
    671703} 
     
    710742        $h = $options[$number]['hierarchical'] ? '1' : '0'; 
    711743        $d = $options[$number]['dropdown'] ? '1' : '0'; 
    712744 
    713         $title = empty($options[$number]['title']) ? __('Categories') : apply_filters('widget_title', $options[$number]['title']); 
     745        $title = empty($options[$number]['title']) ? __('Categories') : $options[$number]['title']; 
    714746 
    715747        echo $before_widget; 
    716748        echo $before_title . $title . $after_title; 
    717749 
    718         $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); 
     750        $cat_args = "orderby=name&show_count={$c}&hierarchical={$h}"; 
    719751 
    720752        if ( $d ) { 
    721                 $cat_args['show_option_none'] = __('Select Category'); 
    722                 wp_dropdown_categories($cat_args); 
     753                wp_dropdown_categories($cat_args . '&show_option_none= ' . __('Select Category')); 
    723754?> 
    724755 
    725756<script type='text/javascript'> 
     
    738769        } else { 
    739770?> 
    740771                <ul> 
    741                 <?php  
    742                         $cat_args['title_li'] = ''; 
    743                         wp_list_categories($cat_args);  
    744                 ?> 
     772                <?php wp_list_categories($cat_args . '&title_li='); ?> 
    745773                </ul> 
    746774<?php 
    747775        } 
     
    781809                } 
    782810 
    783811                foreach ( (array) $_POST['widget-categories'] as $widget_number => $widget_cat ) { 
    784                         if ( !isset($widget_cat['title']) && isset($options[$widget_number]) ) // user clicked cancel 
    785                                 continue; 
    786812                        $title = trim(strip_tags(stripslashes($widget_cat['title']))); 
    787813                        $count = isset($widget_cat['count']); 
    788814                        $hierarchical = isset($widget_cat['hierarchical']); 
     
    831857                                </label> 
    832858                        </p> 
    833859 
    834                         <input type="hidden" name="widget-categories[<?php echo $number; ?>][submit]" value="1" /> 
     860                        <input type="hidden" id="categories-submit-<?php echo $number; ?>" name="categories-submit-<?php echo $number; ?>" value="1" /> 
    835861<?php 
    836862} 
    837863 
     
    891917} 
    892918 
    893919function wp_widget_recent_entries($args) { 
    894         if ( '%BEG_OF_TITLE%' != $args['before_title'] ) { 
    895                 if ( $output = wp_cache_get('widget_recent_entries', 'widget') ) 
    896                         return print($output); 
    897                 ob_start(); 
    898         } 
     920        if ( $output = wp_cache_get('widget_recent_entries', 'widget') ) 
     921                return print($output); 
    899922 
     923        ob_start(); 
    900924        extract($args); 
    901925        $options = get_option('widget_recent_entries'); 
    902         $title = empty($options['title']) ? __('Recent Posts') : apply_filters('widget_title', $options['title']); 
     926        $title = empty($options['title']) ? __('Recent Posts') : $options['title']; 
    903927        if ( !$number = (int) $options['number'] ) 
    904928                $number = 10; 
    905929        else if ( $number < 1 ) 
     
    907931        else if ( $number > 15 ) 
    908932                $number = 15; 
    909933 
    910         $r = new WP_Query(array('showposts' => $number, 'what_to_show' => 'posts', 'nopaging' => 0, 'post_status' => 'publish')); 
     934        $r = new WP_Query("showposts=$number&what_to_show=posts&nopaging=0&post_status=publish"); 
    911935        if ($r->have_posts()) : 
    912936?> 
    913937                <?php echo $before_widget; ?> 
     
    921945<?php 
    922946                wp_reset_query();  // Restore global post data stomped by the_post(). 
    923947        endif; 
    924  
    925         if ( '%BEG_OF_TITLE%' != $args['before_title'] ) 
    926                 wp_cache_add('widget_recent_entries', ob_get_flush(), 'widget'); 
     948        wp_cache_add('widget_recent_entries', ob_get_flush(), 'widget'); 
    927949} 
    928950 
    929951function wp_flush_widget_recent_entries() { 
     
    964986        global $wpdb, $comments, $comment; 
    965987        extract($args, EXTR_SKIP); 
    966988        $options = get_option('widget_recent_comments'); 
    967         $title = empty($options['title']) ? __('Recent Comments') : apply_filters('widget_title', $options['title']); 
     989        $title = empty($options['title']) ? __('Recent Comments') : $options['title']; 
    968990        if ( !$number = (int) $options['number'] ) 
    969991                $number = 5; 
    970992        else if ( $number < 1 ) 
     
    10701092                $title = $desc; 
    10711093        if ( empty($title) ) 
    10721094                $title = __('Unknown Feed'); 
    1073         $title = apply_filters('widget_title', $title ); 
    10741095        $url = clean_url(strip_tags($url)); 
    10751096        if ( file_exists(dirname(__FILE__) . '/rss.png') ) 
    1076                 $icon = str_replace(ABSPATH, site_url() . '/', dirname(__FILE__)) . '/rss.png'; 
     1097                $icon = str_replace(ABSPATH, get_option('siteurl').'/', dirname(__FILE__)) . '/rss.png'; 
    10771098        else 
    1078                 $icon = includes_url('images/rss.png'); 
     1099                $icon = get_option('siteurl').'/wp-includes/images/rss.png'; 
    10791100        $title = "<a class='rsswidget' href='$url' title='" . attribute_escape(__('Syndicate this content')) ."'><img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>"; 
    10801101 
    10811102        echo $before_widget; 
     
    11501171 
    11511172                                if ( $date ) { 
    11521173                                        if ( $date_stamp = strtotime( $date ) ) 
    1153                                                 $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date_stamp ) . '</span>'; 
     1174                                                $date = '<span class="rss-date">' . gmdate( get_option( 'date_format' ), $date_stamp ) . '</span>'; 
    11541175                                        else 
    11551176                                                $date = ''; 
    11561177                                } 
     
    12081229                } 
    12091230 
    12101231                foreach( (array) $_POST['widget-rss'] as $widget_number => $widget_rss ) { 
    1211                         if ( !isset($widget_rss['url']) && isset($options[$widget_number]) ) // user clicked cancel 
    1212                                 continue; 
    12131232                        $widget_rss = stripslashes_deep( $widget_rss ); 
    12141233                        $url = sanitize_url(strip_tags($widget_rss['url'])); 
    12151234                        $options[$widget_number] = wp_widget_rss_process( $widget_rss, !isset($urls[$url]) ); 
     
    12941313                        <?php _e('Display item date?'); ?> 
    12951314                </label> 
    12961315        </p> 
    1297         <input type="hidden" name="widget-rss[<?php echo $number; ?>][submit]" value="1" /> 
     1316        <input type="hidden" id="rss-submit-<?php echo $number; ?>" name="rss-submit-<?php echo $number; ?>" value="1" /> 
    12981317<?php 
    12991318        endif; 
    13001319        foreach ( array_keys($default_inputs) as $input ) : 
     
    13631382function wp_widget_tag_cloud($args) { 
    13641383        extract($args); 
    13651384        $options = get_option('widget_tag_cloud'); 
    1366         $title = empty($options['title']) ? __('Tags') : apply_filters('widget_title', $options['title']); 
     1385        $title = empty($options['title']) ? __('Tags') : $options['title']; 
    13671386 
    13681387        echo $before_widget; 
    13691388        echo $before_title . $title . $after_title; 
     
    13921411<?php 
    13931412} 
    13941413 
     1414 
    13951415function wp_widgets_init() { 
    13961416        if ( !is_blog_installed() ) 
    13971417                return; 
     
    14041424        wp_register_sidebar_widget('calendar', __('Calendar'), 'wp_widget_calendar', $widget_ops); 
    14051425        wp_register_widget_control('calendar', __('Calendar'), 'wp_widget_calendar_control' ); 
    14061426 
     1427 
    14071428        $widget_ops = array('classname' => 'widget_archive', 'description' => __( "A monthly archive of your blog's posts") ); 
    14081429        wp_register_sidebar_widget('archives', __('Archives'), 'wp_widget_archives', $widget_ops); 
    14091430        wp_register_widget_control('archives', __('Archives'), 'wp_widget_archives_control' ); 
     
    15001521 
    15011522                foreach ( (array) $_POST['widget-many'] as $widget_number => $widget_many_instance ) { 
    15021523                        // compile data from $widget_many_instance 
    1503                         if ( !isset($widget_many_instance['something']) && isset($options[$widget_number]) ) // user clicked cancel 
    1504                                 continue; 
    15051524                        $something = wp_specialchars( $widget_many_instance['something'] ); 
    15061525                        $options[$widget_number] = array( 'something' => $something );  // Even simple widgets should store stuff in array, rather than in scalar 
    15071526                } 
    15081527 
    1509                 update_option('widget_many', $options); 
     1528                update_option('widget_text', $options); 
    15101529 
    15111530                $updated = true; // So that we don't go through this more than once 
    15121531        } 
     
    15251544?> 
    15261545                <p> 
    15271546                        <input class="widefat" id="widget-many-something-<?php echo $number; ?>" name="widget-many[<?php echo $number; ?>][something]" type="text" value="<?php echo $data; ?>" /> 
    1528                         <input type="hidden" id="widget-many-submit-<?php echo $number; ?>" name="widget-many[<?php echo $number; ?>][submit]" value="1" /> 
     1547                        <input type="hidden" id="widget-many-submit-<?php echo $number; ?>" name="widget-many-<?php echo $number; ?>" value="1" /> 
    15291548                </p> 
    15301549<?php 
    15311550} 
     
    15481567                // $id should look like {$id_base}-{$o} 
    15491568                $id = "many-$o"; // Never never never translate an id 
    15501569                $registered = true; 
    1551                 wp_register_sidebar_widget( $id, $name, 'widget_many', $widget_ops, array( 'number' => $o ) ); 
    1552                 wp_register_widget_control( $id, $name, 'widget_many_control', $control_ops, array( 'number' => $o ) ); 
     1570                wp_register_sidebar_widget( $id, $name, 'wp_widget_text', $widget_ops, array( 'number' => $o ) ); 
     1571                wp_register_widget_control( $id, $name, 'wp_widget_text_control', $control_ops, array( 'number' => $o ) ); 
    15531572        } 
    15541573 
    15551574        // If there are none, we register the widget's existance with a generic template 
     
    15641583 
    15651584*/ 
    15661585 
    1567 ?> 
     1586?> 
     1587 No newline at end of file