~canonical-sysadmins/wordpress/3.9.x

« back to all changes in this revision

Viewing changes to wp-admin/includes/dashboard.php

  • Committer: Chris Jones
  • Date: 2010-01-19 13:17:33 UTC
  • Revision ID: cmsj@tenshu.net-20100119131733-rf31jv9k1v0xzo2h
[CJ] Import wordpress 2.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
        // Incoming Links Widget
35
35
        if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) {
36
36
                $update = true;
 
37
                $num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10;
37
38
                $widget_options['dashboard_incoming_links'] = array(
38
39
                        'home' => get_option('home'),
39
 
                        'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
40
 
                        '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') ) ),
41
 
                        'items' => isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10,
 
40
                        'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
 
41
                        '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') ) ),
 
42
                        'items' => $num_items,
42
43
                        'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false
43
44
                );
44
45
        }
132
133
function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
133
134
        echo '<form action="" method="post" class="dashboard-widget-control-form">';
134
135
        wp_dashboard_trigger_widget_control( $meta_box['id'] );
135
 
        echo "<p class='submit'><input type='hidden' name='widget_id' value='" . esc_attr($meta_box['id']) . "' /><input type='submit' value='" . esc_attr__( 'Submit' ) . "' /></p>";
 
136
        echo '<p class="submit"><input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" /><input type="submit" value="' . esc_attr__( 'Submit' ) . '" /></p>';
136
137
 
137
138
        echo '</form>';
138
139
}
163
164
                        $hide2 = $hide3 = $hide4 = 'display:none;';
164
165
        }
165
166
?>
166
 
<div id='dashboard-widgets' class='metabox-holder'>
 
167
<div id="dashboard-widgets" class="metabox-holder">
167
168
<?php
168
169
        echo "\t<div class='postbox-container' style='$width'>\n";
169
170
        do_meta_boxes( 'dashboard', 'normal', '' );
179
180
?>
180
181
</div></div>
181
182
 
182
 
<form style='display: none' method='get' action=''>
 
183
<form style="display:none" method="get" action="">
183
184
        <p>
184
185
<?php
185
186
        wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
236
237
        */
237
238
 
238
239
        // Total Comments
239
 
        $num = number_format_i18n($num_comm->total_comments);
 
240
        $num = '<span class="total-count">' . number_format_i18n($num_comm->total_comments) . '</span>';
240
241
        $text = _n( 'Comment', 'Comments', $num_comm->total_comments );
241
242
        if ( current_user_can( 'moderate_comments' ) ) {
242
243
                $num = "<a href='edit-comments.php'>$num</a>";
258
259
        echo '<td class="t pages">' . $text . '</td>';
259
260
 
260
261
        // Approved Comments
261
 
        $num = number_format_i18n($num_comm->approved);
 
262
        $num = '<span class="approved-count">' . number_format_i18n($num_comm->approved) . '</span>';
262
263
        $text = _nc( 'Approved|Right Now', 'Approved', $num_comm->approved );
263
264
        if ( current_user_can( 'moderate_comments' ) ) {
264
265
                $num = "<a href='edit-comments.php?comment_status=approved'>$num</a>";
280
281
        echo '<td class="t cats">' . $text . '</td>';
281
282
 
282
283
        // Pending Comments
283
 
        $num = number_format_i18n($num_comm->moderated);
 
284
        $num = '<span class="pending-count">' . number_format_i18n($num_comm->moderated) . '</span>';
284
285
        $text = _n( 'Pending', 'Pending', $num_comm->moderated );
285
286
        if ( current_user_can( 'moderate_comments' ) ) {
286
 
                $num = "<a href='edit-comments.php?comment_status=moderated'><span class='pending-count'>$num</span></a>";
 
287
                $num = "<a href='edit-comments.php?comment_status=moderated'>$num</a>";
287
288
                $text = "<a class='waiting' href='edit-comments.php?comment_status=moderated'>$text</a>";
288
289
        }
289
290
        echo '<td class="b b-waiting">' . $num . '</td>';
339
340
        } else {
340
341
                if ( current_user_can( 'switch_themes' ) ) {
341
342
                        echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>';
342
 
                        printf('Theme <span class="b"><a href="themes.php">%1$s</a></span>', $ct->title);
 
343
                        printf( __('Theme <span class="b"><a href="themes.php">%1$s</a></span>'), $ct->title );
343
344
                } else {
344
 
                        printf('Theme <span class="b">%1$s</span>', $ct->title);
 
345
                        printf( __('Theme <span class="b">%1$s</span>'), $ct->title );
345
346
                }
346
347
        }
347
348
        echo '</p>';
447
448
                foreach ( $drafts as $draft ) {
448
449
                        $url = get_edit_post_link( $draft->ID );
449
450
                        $title = _draft_or_post_title( $draft->ID );
450
 
                        $item = "<h4><a href='$url' title='" . sprintf( __( 'Edit &#8220;%s&#8221;' ), esc_attr( $title ) ) . "'>$title</a> <abbr title='" . get_the_time(__('Y/m/d g:i:s A'), $draft) . "'>" . get_the_time( get_option( 'date_format' ), $draft ) . '</abbr></h4>';
 
451
                        $item = "<h4><a href='$url' title='" . sprintf( __( 'Edit &#8220;%s&#8221;' ), esc_attr( $title ) ) . "'>" . esc_html($title) . "</a> <abbr title='" . get_the_time(__('Y/m/d g:i:s A'), $draft) . "'>" . get_the_time( get_option( 'date_format' ), $draft ) . '</abbr></h4>';
451
452
                        if ( $the_content = preg_split( '#\s#', strip_tags( $draft->post_content ), 11, PREG_SPLIT_NO_EMPTY ) )
452
453
                                $item .= '<p>' . join( ' ', array_slice( $the_content, 0, 10 ) ) . ( 10 < count( $the_content ) ? '&hellip;' : '' ) . '</p>';
453
454
                        $list[] = $item;
480
481
        $comments = array();
481
482
        $start = 0;
482
483
 
483
 
        while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT $start, 50" ) ) {
 
484
        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" ) ) {
484
485
 
485
486
                foreach ( $possible as $comment ) {
486
487
                        if ( count( $comments ) >= 5 )
509
510
<?php   }
510
511
 
511
512
                wp_comment_reply( -1, false, 'dashboard', false );
 
513
                wp_comment_trashnotice();
512
514
 
513
515
        else :
514
516
?>
527
529
        $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
528
530
        $comment_link = '<a class="comment-link" href="' . esc_url(get_comment_link()) . '">#</a>';
529
531
 
530
 
        $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" ) );
531
 
        $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" ) );
532
 
        $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" ) );
533
 
        $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" ) );
534
 
 
535
 
        $actions = array();
536
 
 
537
532
        $actions_string = '';
538
533
        if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
 
534
                // preorder it: Approve | Reply | Edit | Spam | Trash
 
535
                $actions = array(
 
536
                        'approve' => '', 'unapprove' => '',
 
537
                        'reply' => '',
 
538
                        'edit' => '',
 
539
                        'spam' => '',
 
540
                        'trash' => '', 'delete' => ''
 
541
                );
 
542
 
 
543
                $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
 
544
                $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
 
545
 
 
546
                $approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
 
547
                $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
 
548
                $spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
 
549
                $trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
 
550
                $delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
 
551
 
539
552
                $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
540
553
                $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
541
554
                $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
542
 
                //$actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick&nbsp;Edit') . '</a>';
543
555
                $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
544
556
                $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */  _x( 'Spam', 'verb' ) . '</a>';
545
 
                $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
 
557
                if ( !EMPTY_TRASH_DAYS )
 
558
                        $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
 
559
                else
 
560
                        $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . __( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>';
546
561
 
547
 
                $actions = apply_filters( 'comment_row_actions', $actions, $comment );
 
562
                $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
548
563
 
549
564
                $i = 0;
550
565
                foreach ( $actions as $action => $link ) {
567
582
                        <?php echo get_avatar( $comment, 50 ); ?>
568
583
 
569
584
                        <div class="dashboard-comment-wrap">
570
 
                        <h4 class="comment-meta"><?php printf( __( 'From %1$s on %2$s%3$s' ), '<cite class="comment-author">' . get_comment_author_link() . '</cite>', $comment_post_link." ".$comment_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?></h4>
 
585
                        <h4 class="comment-meta"><?php printf( __( 'From %1$s on %2$s%3$s' ), '<cite class="comment-author">' . get_comment_author_link() . '</cite>', $comment_post_link.' '.$comment_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?></h4>
571
586
 
572
587
                        <?php
573
588
                        else :
585
600
                        ?>
586
601
                        <div class="dashboard-comment-wrap">
587
602
                        <?php /* translators: %1$s is type of comment, %2$s is link to the post */ ?>
588
 
                        <h4 class="comment-meta"><?php printf( _x( '%1$s on %2$s', 'dashboard' ), "<strong>$type</strong>", $comment_post_link ); ?></h4>
 
603
                        <h4 class="comment-meta"><?php printf( _x( '%1$s on %2$s', 'dashboard' ), "<strong>$type</strong>", $comment_post_link." ".$comment_link ); ?></h4>
589
604
                        <p class="comment-author"><?php comment_author_link(); ?></p>
590
605
 
591
606
                        <?php endif; // comment_type ?>
592
607
                        <blockquote><p><?php comment_excerpt(); ?></p></blockquote>
593
608
                        <p class="row-actions"><?php echo $actions_string; ?></p>
594
 
 
595
 
                        <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
596
 
                                <textarea class="comment" rows="3" cols="10"><?php echo $comment->comment_content; ?></textarea>
597
 
                                <div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>
598
 
                                <div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>
599
 
                                <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
600
 
                                <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
601
 
                        </div>
602
609
                        </div>
603
610
                </div>
604
611
<?php
629
636
 
630
637
        if ( !$rss->get_item_quantity() ) {
631
638
                echo '<p>' . __('This dashboard widget queries <a href="http://blogsearch.google.com/">Google Blog Search</a> so that when another blog links to your site it will show up here. It has found no incoming links&hellip; yet. It&#8217;s okay &#8212; there is no rush.') . "</p>\n";
 
639
                $rss->__destruct(); 
 
640
                unset($rss);
632
641
                return;
633
642
        }
634
643
 
682
691
        }
683
692
 
684
693
        echo "</ul>\n";
685
 
 
 
694
        $rss->__destruct(); 
 
695
        unset($rss);
686
696
}
687
697
 
688
698
function wp_dashboard_incoming_links_control() {
706
716
 */
707
717
function wp_dashboard_rss_output( $widget_id ) {
708
718
        $widgets = get_option( 'dashboard_widget_options' );
709
 
        echo "<div class='rss-widget'>";
 
719
        echo '<div class="rss-widget">';
710
720
        wp_widget_rss_output( $widgets[$widget_id] );
711
721
        echo "</div>";
712
722
}
738
748
                        echo '</p></div>';
739
749
                }
740
750
        } elseif ( !$rss->get_item_quantity() ) {
 
751
                $rss->__destruct(); 
 
752
                unset($rss);
741
753
                return false;
742
754
        } else {
743
755
                echo '<div class="rss-widget">';
744
756
                wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] );
745
757
                echo '</div>';
 
758
                $rss->__destruct(); 
 
759
                unset($rss);
746
760
        }
747
761
}
748
762
 
825
839
                echo "<h4>$label</h4>\n";
826
840
                echo "<h5><a href='$link'>$title</a></h5>&nbsp;<span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span>\n";
827
841
                echo "<p>$description</p>\n";
 
842
                
 
843
                $$feed->__destruct();
 
844
                unset($$feed);
828
845
        }
829
846
}
830
847
 
918
935
                // title is optional.  If black, fill it if possible
919
936
                if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
920
937
                        $rss = fetch_feed($widget_options[$widget_id]['url']);
921
 
                        if ( ! is_wp_error($rss) )
922
 
                                $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));
923
 
                        else
 
938
                        if ( is_wp_error($rss) ) {
924
939
                                $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed'));
 
940
                        } else {
 
941
                                $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));     
 
942
                                $rss->__destruct();
 
943
                                unset($rss);                            
 
944
                        }
925
945
                }
926
946
                update_option( 'dashboard_widget_options', $widget_options );
927
947
        }