X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/d3b1ea255664edd2deef17f900a655613d20820d..refs/tags/wordpress-2.9:/wp-admin/includes/dashboard.php diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index ec93fb0d..6137a93c 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -34,11 +34,12 @@ function wp_dashboard_setup() { // Incoming Links Widget if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) { $update = true; + $num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10; $widget_options['dashboard_incoming_links'] = array( 'home' => get_option('home'), - 'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), - 'url' => isset($widget_options['dashboard_incoming_links']['url']) ? apply_filters( 'dashboard_incoming_links_feed', $widget_options['dashboard_incoming_links']['url'] ) : apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&ie=utf-8&num=20&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), - 'items' => isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10, + 'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), + 'url' => isset($widget_options['dashboard_incoming_links']['url']) ? apply_filters( 'dashboard_incoming_links_feed', $widget_options['dashboard_incoming_links']['url'] ) : apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?scoring=d&ie=utf-8&num=' . $num_items . '&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), + 'items' => $num_items, 'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false ); } @@ -132,7 +133,7 @@ function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_ function _wp_dashboard_control_callback( $dashboard, $meta_box ) { echo '
'; wp_dashboard_trigger_widget_control( $meta_box['id'] ); - echo "

"; + echo '

'; echo '
'; } @@ -163,7 +164,7 @@ function wp_dashboard() { $hide2 = $hide3 = $hide4 = 'display:none;'; } ?> -
+
\n"; do_meta_boxes( 'dashboard', 'normal', '' ); @@ -179,7 +180,7 @@ function wp_dashboard() { ?>
-
+

total_comments); + $num = '' . number_format_i18n($num_comm->total_comments) . ''; $text = _n( 'Comment', 'Comments', $num_comm->total_comments ); if ( current_user_can( 'moderate_comments' ) ) { $num = "$num"; @@ -258,7 +259,7 @@ function wp_dashboard_right_now() { echo '' . $text . ''; // Approved Comments - $num = number_format_i18n($num_comm->approved); + $num = '' . number_format_i18n($num_comm->approved) . ''; $text = _nc( 'Approved|Right Now', 'Approved', $num_comm->approved ); if ( current_user_can( 'moderate_comments' ) ) { $num = "$num"; @@ -280,10 +281,10 @@ function wp_dashboard_right_now() { echo '' . $text . ''; // Pending Comments - $num = number_format_i18n($num_comm->moderated); + $num = '' . number_format_i18n($num_comm->moderated) . ''; $text = _n( 'Pending', 'Pending', $num_comm->moderated ); if ( current_user_can( 'moderate_comments' ) ) { - $num = "$num"; + $num = "$num"; $text = "$text"; } echo '' . $num . ''; @@ -339,9 +340,9 @@ function wp_dashboard_right_now() { } else { if ( current_user_can( 'switch_themes' ) ) { echo '' . __('Change Theme') . ''; - printf('Theme %1$s', $ct->title); + printf( __('Theme %1$s'), $ct->title ); } else { - printf('Theme %1$s', $ct->title); + printf( __('Theme %1$s'), $ct->title ); } } echo '

'; @@ -447,7 +448,7 @@ function wp_dashboard_recent_drafts( $drafts = false ) { foreach ( $drafts as $draft ) { $url = get_edit_post_link( $draft->ID ); $title = _draft_or_post_title( $draft->ID ); - $item = "

$title " . get_the_time( get_option( 'date_format' ), $draft ) . '

'; + $item = "

" . esc_html($title) . " " . get_the_time( get_option( 'date_format' ), $draft ) . '

'; if ( $the_content = preg_split( '#\s#', strip_tags( $draft->post_content ), 11, PREG_SPLIT_NO_EMPTY ) ) $item .= '

' . join( ' ', array_slice( $the_content, 0, 10 ) ) . ( 10 < count( $the_content ) ? '…' : '' ) . '

'; $list[] = $item; @@ -480,7 +481,7 @@ function wp_dashboard_recent_comments() { $comments = array(); $start = 0; - while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT $start, 50" ) ) { + while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) { foreach ( $possible as $comment ) { if ( count( $comments ) >= 5 ) @@ -509,6 +510,7 @@ function wp_dashboard_recent_comments() { @@ -527,24 +529,37 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { $comment_post_link = "$comment_post_title"; $comment_link = '#'; - $delete_url = esc_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); - $approve_url = esc_url( wp_nonce_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) ); - $unapprove_url = esc_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) ); - $spam_url = esc_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); - - $actions = array(); - $actions_string = ''; if ( current_user_can('edit_post', $comment->comment_post_ID) ) { + // preorder it: Approve | Reply | Edit | Spam | Trash + $actions = array( + 'approve' => '', 'unapprove' => '', + 'reply' => '', + 'edit' => '', + 'spam' => '', + 'trash' => '', 'delete' => '' + ); + + $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); + $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); + + $approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); + $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); + $spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); + $trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); + $delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); + $actions['approve'] = "" . __( 'Approve' ) . ''; $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; $actions['edit'] = "". __('Edit') . ''; - //$actions['quickedit'] = '' . __('Quick Edit') . ''; $actions['reply'] = '' . __('Reply') . ''; $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; - $actions['delete'] = "" . __('Delete') . ''; + if ( !EMPTY_TRASH_DAYS ) + $actions['delete'] = "" . __('Delete Permanently') . ''; + else + $actions['trash'] = "" . _x('Trash', 'verb') . ''; - $actions = apply_filters( 'comment_row_actions', $actions, $comment ); + $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment ); $i = 0; foreach ( $actions as $action => $link ) { @@ -567,7 +582,7 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
-

' . get_comment_author_link() . '', $comment_post_link." ".$comment_link, ' ' . __( '[Pending]' ) . '' ); ?>

+

' . get_comment_author_link() . '', $comment_post_link.' '.$comment_link, ' ' . __( '[Pending]' ) . '' ); ?>

-

$type", $comment_post_link ); ?>

+

$type", $comment_post_link." ".$comment_link ); ?>

- -
' . __( 'Loading…' ) . '

' . __('This widget requires JavaScript.') . '

'; } /** @@ -629,13 +636,17 @@ function wp_dashboard_incoming_links_output() { if ( !$rss->get_item_quantity() ) { echo '

' . __('This dashboard widget queries Google Blog Search so that when another blog links to your site it will show up here. It has found no incoming links… yet. It’s okay — there is no rush.') . "

\n"; + $rss->__destruct(); + unset($rss); return; } echo "\n"; - + $rss->__destruct(); + unset($rss); } function wp_dashboard_incoming_links_control() { @@ -684,7 +700,7 @@ function wp_dashboard_incoming_links_control() { } function wp_dashboard_primary() { - wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_rss_output' ); + echo '

' . __( 'Loading…' ) . '

' . __('This widget requires JavaScript.') . '

'; } function wp_dashboard_primary_control() { @@ -700,13 +716,13 @@ function wp_dashboard_primary_control() { */ function wp_dashboard_rss_output( $widget_id ) { $widgets = get_option( 'dashboard_widget_options' ); - echo "
"; + echo '
'; wp_widget_rss_output( $widgets[$widget_id] ); echo "
"; } function wp_dashboard_secondary() { - wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' ); + echo '

' . __( 'Loading…' ) . '

' . __('This widget requires JavaScript.') . '

'; } function wp_dashboard_secondary_control() { @@ -732,20 +748,20 @@ function wp_dashboard_secondary_output() { echo '

'; } } elseif ( !$rss->get_item_quantity() ) { + $rss->__destruct(); + unset($rss); return false; } else { echo '
'; wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] ); echo '
'; + $rss->__destruct(); + unset($rss); } } function wp_dashboard_plugins() { - wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array( - 'http://wordpress.org/extend/plugins/rss/browse/popular/', - 'http://wordpress.org/extend/plugins/rss/browse/new/', - 'http://wordpress.org/extend/plugins/rss/browse/updated/' - ) ); + echo '

' . __( 'Loading…' ) . '

' . __('This widget requires JavaScript.') . '

'; } /** @@ -823,6 +839,9 @@ function wp_dashboard_plugins_output() { echo "

$label

\n"; echo "
$title
 (" . __( 'Install' ) . ")\n"; echo "

$description

\n"; + + $$feed->__destruct(); + unset($$feed); } } @@ -916,10 +935,13 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { // title is optional. If black, fill it if possible if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) { $rss = fetch_feed($widget_options[$widget_id]['url']); - if ( ! is_wp_error($rss) ) - $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title())); - else + if ( is_wp_error($rss) ) { $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed')); + } else { + $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title())); + $rss->__destruct(); + unset($rss); + } } update_option( 'dashboard_widget_options', $widget_options ); }