X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/542cf06a610bc430421351ace7a2cc45f393b990..9c2096d803812dacbdf6cf8efe90053e39f00b96:/wp-includes/default-widgets.php diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index 2c9ec067..df7ef39a 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -1,5 +1,4 @@ 'widget_pages', 'description' => __( 'Your site’s WordPress Pages') ); - $this->WP_Widget('pages', __('Pages'), $widget_ops); + parent::__construct('pages', __('Pages'), $widget_ops); } function widget( $args, $instance ) { @@ -90,9 +89,9 @@ class WP_Widget_Pages extends WP_Widget { */ class WP_Widget_Links extends WP_Widget { - function WP_Widget_Links() { + function __construct() { $widget_ops = array('description' => __( "Your blogroll" ) ); - $this->WP_Widget('links', __('Links'), $widget_ops); + parent::__construct('links', __('Links'), $widget_ops); } function widget( $args, $instance ) { @@ -106,7 +105,7 @@ class WP_Widget_Links extends WP_Widget { if ( is_admin() && !$category ) { // Display All Links widget as such in the widgets screen - echo $before_widget . $before_title. __('All Links') . $after_title . $after_widget; + echo $before_widget . $before_title . _x('All Links', 'links widget') . $after_title . $after_widget; return; } @@ -141,7 +140,7 @@ class WP_Widget_Links extends WP_Widget {
/>
-
+
/>
@@ -510,9 +509,9 @@ class WP_Widget_Categories extends WP_Widget {
*/
class WP_Widget_Recent_Posts extends WP_Widget {
- function WP_Widget_Recent_Posts() {
+ function __construct() {
$widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent posts on your site") );
- $this->WP_Widget('recent-posts', __('Recent Posts'), $widget_ops);
+ parent::__construct('recent-posts', __('Recent Posts'), $widget_ops);
$this->alt_option_name = 'widget_recent_entries';
add_action( 'save_post', array(&$this, 'flush_widget_cache') );
@@ -526,8 +525,11 @@ class WP_Widget_Recent_Posts extends WP_Widget {
if ( !is_array($cache) )
$cache = array();
- if ( isset($cache[$args['widget_id']]) ) {
- echo $cache[$args['widget_id']];
+ if ( ! isset( $args['widget_id'] ) )
+ $args['widget_id'] = $this->id;
+
+ if ( isset( $cache[ $args['widget_id'] ] ) ) {
+ echo $cache[ $args['widget_id'] ];
return;
}
@@ -535,14 +537,10 @@ class WP_Widget_Recent_Posts extends WP_Widget {
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
- if ( !$number = (int) $instance['number'] )
- $number = 10;
- else if ( $number < 1 )
- $number = 1;
- else if ( $number > 15 )
- $number = 15;
-
- $r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1));
+ if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
+ $number = 10;
+
+ $r = new WP_Query(array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true));
if ($r->have_posts()) :
?>
@@ -582,8 +580,7 @@ class WP_Widget_Recent_Posts extends WP_Widget {
function form( $instance ) {
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
- if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
- $number = 5;
+ $number = isset($instance['number']) ? absint($instance['number']) : 5;
?>
@@ -601,9 +598,9 @@ class WP_Widget_Recent_Posts extends WP_Widget { */ class WP_Widget_Recent_Comments extends WP_Widget { - function WP_Widget_Recent_Comments() { + function __construct() { $widget_ops = array('classname' => 'widget_recent_comments', 'description' => __( 'The most recent comments' ) ); - $this->WP_Widget('recent-comments', __('Recent Comments'), $widget_ops); + parent::__construct('recent-comments', __('Recent Comments'), $widget_ops); $this->alt_option_name = 'widget_recent_comments'; if ( is_active_widget(false, false, $this->id_base) ) @@ -613,7 +610,11 @@ class WP_Widget_Recent_Comments extends WP_Widget { add_action( 'transition_comment_status', array(&$this, 'flush_widget_cache') ); } - function recent_comments_style() { ?> + function recent_comments_style() { + if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876 + || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) + return; + ?> id; + + if ( isset( $cache[ $args['widget_id'] ] ) ) { + echo $cache[ $args['widget_id'] ]; return; } extract($args, EXTR_SKIP); $output = ''; - $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']); + $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments' ) : $instance['title'], $instance, $this->id_base ); - if ( ! $number = (int) $instance['number'] ) + if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) $number = 5; - else if ( $number < 1 ) - $number = 1; - $comments = get_comments( array( 'number' => $number, 'status' => 'approve' ) ); + $comments = get_comments( array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ); $output .= $before_widget; if ( $title ) $output .= $before_title . $title . $after_title; @@ -666,7 +668,7 @@ class WP_Widget_Recent_Comments extends WP_Widget { function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); - $instance['number'] = (int) $new_instance['number']; + $instance['number'] = absint( $new_instance['number'] ); $this->flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); @@ -696,10 +698,10 @@ class WP_Widget_Recent_Comments extends WP_Widget { */ class WP_Widget_RSS extends WP_Widget { - function WP_Widget_RSS() { + function __construct() { $widget_ops = array( 'description' => __('Entries from any RSS or Atom feed') ); $control_ops = array( 'width' => 400, 'height' => 200 ); - $this->WP_Widget( 'rss', __('RSS'), $widget_ops, $control_ops ); + parent::__construct( 'rss', __('RSS'), $widget_ops, $control_ops ); } function widget($args, $instance) { @@ -709,13 +711,17 @@ class WP_Widget_RSS extends WP_Widget { extract($args, EXTR_SKIP); - $url = $instance['url']; + $url = ! empty( $instance['url'] ) ? $instance['url'] : ''; while ( stristr($url, 'http') != $url ) $url = substr($url, 1); if ( empty($url) ) return; + // self-url destruction sequence + if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) + return; + $rss = fetch_feed($url); $title = $instance['title']; $desc = ''; @@ -751,7 +757,7 @@ class WP_Widget_RSS extends WP_Widget { } function update($new_instance, $old_instance) { - $testurl = ( isset($new_instance['url']) && ($new_instance['url'] != $old_instance['url']) ); + $testurl = ( isset( $new_instance['url'] ) && ( !isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) ); return wp_widget_rss_process( $new_instance, $testurl ); } @@ -836,13 +842,10 @@ function wp_widget_rss_output( $rss, $args = array() ) { $date = ''; if ( $show_date ) { - $date = $item->get_date(); + $date = $item->get_date( 'U' ); if ( $date ) { - if ( $date_stamp = strtotime( $date ) ) - $date = ' ' . date_i18n( get_option( 'date_format' ), $date_stamp ) . ''; - else - $date = ''; + $date = ' ' . date_i18n( get_option( 'date_format' ), $date ) . ''; } } @@ -988,9 +991,9 @@ function wp_widget_rss_process( $widget_rss, $check_feed = true ) { */ class WP_Widget_Tag_Cloud extends WP_Widget { - function WP_Widget_Tag_Cloud() { + function __construct() { $widget_ops = array( 'description' => __( "Your most used tags in cloud format") ); - $this->WP_Widget('tag_cloud', __('Tag Cloud'), $widget_ops); + parent::__construct('tag_cloud', __('Tag Cloud'), $widget_ops); } function widget( $args, $instance ) { @@ -1011,7 +1014,7 @@ class WP_Widget_Tag_Cloud extends WP_Widget { echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; - echo '