WordPress.org

Make WordPress Core

Changeset 11088


Ignore:
Timestamp:
04/26/09 05:34:06 (6 years ago)
Author:
azaozz
Message:

Fix conversion of old widget settings for Recent Posts, see #8441

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/default-widgets.php

    r11087 r11088  
    496496    function WP_Widget_Recent_Posts() { 
    497497        $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent posts on your blog") ); 
    498         $this->WP_Widget('recent_posts', __('Recent Posts'), $widget_ops); 
     498        $this->WP_Widget('recent-posts', __('Recent Posts'), $widget_ops); 
     499        $this->alt_option_name = 'widget_recent_entries'; 
    499500 
    500501        add_action( 'save_post', array(&$this, 'flush_widget_cache') ); 
     
    504505 
    505506    function widget($args, $instance) { 
    506         if ( $output = wp_cache_get('widget_recent_entries', 'widget') ) 
     507        if ( $output = wp_cache_get('widget_recent_posts' . $args['widget_id'], 'widget') ) 
    507508            return print($output); 
    508509 
    509510        ob_start(); 
    510      
    511511        extract($args); 
    512512 
     
    518518        else if ( $number > 15 ) 
    519519            $number = 15; 
    520      
     520 
    521521        $r = new WP_Query(array('showposts' => $number, 'what_to_show' => 'posts', 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1)); 
    522522        if ($r->have_posts()) : 
     
    533533            wp_reset_query();  // Restore global post data stomped by the_post(). 
    534534        endif; 
    535      
    536         wp_cache_add('widget_recent_entries', ob_get_flush(), 'widget'); 
     535 
     536        wp_cache_add('widget_recent_posts' . $args['widget_id'], ob_get_flush(), 'widget'); 
    537537    } 
    538538 
     
    542542        $instance['number'] = (int) $new_instance['number']; 
    543543        $this->flush_widget_cache(); 
     544         
     545        $alloptions = wp_cache_get( 'alloptions', 'options' ); 
     546        if ( isset($alloptions['widget_recent_entries']) ) 
     547            delete_option('widget_recent_entries'); 
    544548 
    545549        return $instance; 
  • trunk/wp-includes/widgets.php

    r11087 r11088  
    268268    function get_settings() { 
    269269        $settings = get_option($this->option_name); 
     270         
     271        if ( false === $settings && isset($this->alt_option_name) ) 
     272            $settings = get_option($this->alt_option_name); 
    270273 
    271274        if ( !is_array($settings) ) 
     
    977980        $single = true; 
    978981    } else { 
    979         if ( isset($settings['number']) ) 
    980             unset($settings['number']); 
    981982        foreach ( array_keys($settings) as $number ) { 
     983            if ( 'number' == $number ) 
     984                continue; 
    982985            if ( !is_numeric($number) ) { 
    983986                $single = true; 
Note: See TracChangeset for help on using the changeset viewer.