]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/includes/dashboard.php
WordPress 3.8
[autoinstalls/wordpress.git] / wp-admin / includes / dashboard.php
1 <?php
2 /**
3  * WordPress Dashboard Widget Administration Screen API
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 /**
10  * Registers dashboard widgets.
11  *
12  * Handles POST data, sets up filters.
13  *
14  * @since 2.5.0
15  */
16 function wp_dashboard_setup() {
17         global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
18         $wp_dashboard_control_callbacks = array();
19         $screen = get_current_screen();
20
21         $update = false;
22         $widget_options = get_option( 'dashboard_widget_options' );
23         if ( !$widget_options || !is_array($widget_options) )
24                 $widget_options = array();
25
26         /* Register Widgets and Controls */
27
28         $response = wp_check_browser_version();
29
30         if ( $response && $response['upgrade'] ) {
31                 add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
32                 if ( $response['insecure'] )
33                         wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
34                 else
35                         wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
36         }
37
38         // Right Now
39         if ( is_blog_admin() && current_user_can('edit_posts') )
40                 wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' );
41
42         if ( is_network_admin() )
43                 wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' );
44
45         // Activity Widget
46         if ( is_blog_admin() ) {
47                 wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' );
48         }
49
50         // QuickPress Widget
51         if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) {
52                 $quick_draft_title = sprintf( '<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __( 'Quick Draft' ), __( 'Drafts' ) );
53                 wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' );
54         }
55
56         // WordPress News
57         wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress News' ), 'wp_dashboard_primary' );
58
59         // Hook to register new widgets
60         // Filter widget order
61         if ( is_network_admin() ) {
62                 do_action( 'wp_network_dashboard_setup' );
63                 $dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() );
64         } elseif ( is_user_admin() ) {
65                 do_action( 'wp_user_dashboard_setup' );
66                 $dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() );
67         } else {
68                 do_action( 'wp_dashboard_setup' );
69                 $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
70         }
71
72         foreach ( $dashboard_widgets as $widget_id ) {
73                 $name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __('View all') . '</a>';
74                 wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] );
75         }
76
77         if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) {
78                 check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' );
79                 ob_start(); // hack - but the same hack wp-admin/widgets.php uses
80                 wp_dashboard_trigger_widget_control( $_POST['widget_id'] );
81                 ob_end_clean();
82                 wp_redirect( remove_query_arg( 'edit' ) );
83                 exit;
84         }
85
86         if ( $update )
87                 update_option( 'dashboard_widget_options', $widget_options );
88
89         /** This action is documented in wp-admin/edit-form-advanced.php */
90         do_action('do_meta_boxes', $screen->id, 'normal', '');
91         /** This action is documented in wp-admin/edit-form-advanced.php */
92         do_action('do_meta_boxes', $screen->id, 'side', '');
93 }
94
95 function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) {
96         $screen = get_current_screen();
97         global $wp_dashboard_control_callbacks;
98
99         if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) {
100                 $wp_dashboard_control_callbacks[$widget_id] = $control_callback;
101                 if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) {
102                         list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
103                         $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>';
104                         $callback = '_wp_dashboard_control_callback';
105                 } else {
106                         list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
107                         $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
108                 }
109         }
110
111         $side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' );
112
113         $location = 'normal';
114         if ( in_array($widget_id, $side_widgets) )
115                 $location = 'side';
116
117         $priority = 'core';
118         if ( 'dashboard_browser_nag' === $widget_id )
119                 $priority = 'high';
120
121         add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args );
122 }
123
124 function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
125         echo '<form action="" method="post" class="dashboard-widget-control-form">';
126         wp_dashboard_trigger_widget_control( $meta_box['id'] );
127         wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' );
128         echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />';
129         submit_button( __('Submit') );
130         echo '</form>';
131 }
132
133 /**
134  * Displays the dashboard.
135  *
136  * @since 2.5.0
137  */
138 function wp_dashboard() {
139         $screen = get_current_screen();
140         $columns = absint( $screen->get_columns() );
141         $columns_css = '';
142         if ( $columns ) {
143                 $columns_css = " columns-$columns";
144         }
145
146 ?>
147 <div id="dashboard-widgets" class="metabox-holder<?php echo $columns_css; ?>">
148         <div id='postbox-container-1' class='postbox-container'>
149         <?php do_meta_boxes( $screen->id, 'normal', '' ); ?>
150         </div>
151         <div id='postbox-container-2' class='postbox-container'>
152         <?php do_meta_boxes( $screen->id, 'side', '' ); ?>
153         </div>
154         <div id='postbox-container-3' class='postbox-container'>
155         <?php do_meta_boxes( $screen->id, 'column3', '' ); ?>
156         </div>
157         <div id='postbox-container-4' class='postbox-container'>
158         <?php do_meta_boxes( $screen->id, 'column4', '' ); ?>
159         </div>
160 </div>
161
162 <?php
163         wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
164         wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
165
166 }
167
168 /* Dashboard Widgets */
169
170 /**
171  * Dashboard widget that displays some basic stats about the site.
172  *
173  * Formerly 'Right Now'. A streamlined 'At a Glance' as of 3.8.
174  *
175  * @since 2.7.0
176  */
177 function wp_dashboard_right_now() {
178         $theme = wp_get_theme();
179         if ( current_user_can( 'switch_themes' ) )
180                 $theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme->display('Name') );
181         else
182                 $theme_name = $theme->display('Name');
183 ?>
184         <div class="main">
185         <ul>
186         <?php
187         // Posts and Pages
188         foreach ( array( 'post', 'page' ) as $post_type ) {
189                 $num_posts = wp_count_posts( $post_type );
190                 if ( $num_posts && $num_posts->publish ) {
191                         if ( 'post' == $post_type ) {
192                                 $text = _n( '%s Post', '%s Posts', $num_posts->publish );
193                         } else {
194                                 $text = _n( '%s Page', '%s Pages', $num_posts->publish );
195                         }
196                         $text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
197                         printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text );
198                 }
199         }
200         // Comments
201         $num_comm = wp_count_comments();
202         if ( $num_comm && $num_comm->total_comments ) {
203                 $text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->total_comments ), number_format_i18n( $num_comm->total_comments ) );
204                 ?>
205                 <li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li>
206                 <?php
207                 if ( $num_comm->moderated ) {
208                         /* translators: Number of comments in moderation */
209                         $text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), number_format_i18n( $num_comm->moderated ) );
210                         ?>
211                         <li class="comment-mod-count"><a href="edit-comments.php?comment_status=moderated"><?php echo $text; ?></a></li>
212                         <?php
213                 }
214         }
215
216         /**
217          * Include additional elements in the 'At a Glance' dashboard widget.
218          * This widget was previously 'Right Now'.
219          *
220          * @since 3.8.0
221          * @param array $items Array of items.
222          */
223         $elements = apply_filters( 'dashboard_glance_items', array() );
224         if ( $elements ) {
225                 echo '<li>' . implode( "</li>\n<li>", $elements ) . "</li>\n";
226         }
227
228         ?>
229         </ul>
230         <p><?php printf( __( 'WordPress %1$s running %2$s theme.' ), get_bloginfo( 'version', 'display' ), $theme_name ); ?></p>
231         <?php
232
233         // Check if search engines are asked not to index this site.
234         if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '1' != get_option( 'blog_public' ) ) {
235
236                 /**
237                  * Filter the title attribute for the link displayed in Site Content metabox when search engines are discouraged from indexing the site.
238                  *
239                  * @since 3.0.0
240                  *
241                  * @param string Default attribute text.
242                  */
243                 $title = apply_filters( 'privacy_on_link_title', __( 'Your site is asking search engines not to index its content' ) );
244
245                 /**
246                  * Filter the text for the link displayed in Site Content metabox when search engines are discouraged from indexing the site.
247                  *
248                  * @since 3.0.0
249                  *
250                  * @param string Default text.
251                  */
252                 $content = apply_filters( 'privacy_on_link_text' , __( 'Search Engines Discouraged' ) );
253
254                 echo "<p><a href='options-reading.php' title='$title'>$content</a></p>";
255         }
256         ?>
257         </div>
258         <?php
259         // activity_box_end has a core action, but only prints content when multisite.
260         // Using an output buffer is the only way to really check if anything's displayed here.
261         ob_start();
262         do_action( 'rightnow_end' );
263         do_action( 'activity_box_end' );
264         $actions = ob_get_clean();
265
266         if ( !empty( $actions ) ) : ?>
267         <div class="sub">
268                 <?php echo $actions; ?>
269         </div>
270         <?php endif;
271 }
272
273 function wp_network_dashboard_right_now() {
274         $actions = array();
275         if ( current_user_can('create_sites') )
276                 $actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>';
277         if ( current_user_can('create_users') )
278                 $actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>';
279
280         $c_users = get_user_count();
281         $c_blogs = get_blog_count();
282
283         $user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) );
284         $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) );
285
286         $sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text );
287
288         if ( $actions ) {
289                 echo '<ul class="subsubsub">';
290                 foreach ( $actions as $class => $action ) {
291                          $actions[ $class ] = "\t<li class='$class'>$action";
292                 }
293                 echo implode( " |</li>\n", $actions ) . "</li>\n";
294                 echo '</ul>';
295         }
296 ?>
297         <br class="clear" />
298
299         <p class="youhave"><?php echo $sentence; ?></p>
300         <?php do_action( 'wpmuadminresult', '' ); ?>
301
302         <form action="<?php echo network_admin_url('users.php'); ?>" method="get">
303                 <p>
304                         <input type="search" name="s" value="" size="30" autocomplete="off" />
305                         <?php submit_button( __( 'Search Users' ), 'button', 'submit', false, array( 'id' => 'submit_users' ) ); ?>
306                 </p>
307         </form>
308
309         <form action="<?php echo network_admin_url('sites.php'); ?>" method="get">
310                 <p>
311                         <input type="search" name="s" value="" size="30" autocomplete="off" />
312                         <?php submit_button( __( 'Search Sites' ), 'button', 'submit', false, array( 'id' => 'submit_sites' ) ); ?>
313                 </p>
314         </form>
315 <?php
316         do_action( 'mu_rightnow_end' );
317         do_action( 'mu_activity_box_end' );
318 }
319
320 /**
321  * The Quick Draft widget display and creation of drafts.
322  *
323  * @since 3.8.0
324  *
325  * @param string $error_msg Optional. Error message. Default false.
326  */
327 function wp_dashboard_quick_press( $error_msg = false ) {
328         global $post_ID;
329
330         /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
331         $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
332         if ( $last_post_id ) {
333                 $post = get_post( $last_post_id );
334                 if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
335                         $post = get_default_post_to_edit( 'post', true );
336                         update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
337                 } else {
338                         $post->post_title = ''; // Remove the auto draft title
339                 }
340         } else {
341                 $post = get_default_post_to_edit( 'post' , true);
342                 $user_id = get_current_user_id();
343                 // Don't create an option if this is a super admin who does not belong to this site.
344                 if ( ! ( is_super_admin( $user_id ) && ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) )
345                         update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
346         }
347
348         $post_ID = (int) $post->ID;
349 ?>
350
351         <form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js">
352
353                 <?php if ( $error_msg ) : ?>
354                 <div class="error"><?php echo $error_msg; ?></div>
355                 <?php endif; ?>
356
357                 <div class="input-text-wrap" id="title-wrap">
358                         <label class="screen-reader-text prompt" for="title" id="title-prompt-text"><?php echo apply_filters( 'enter_title_here', __( 'Title' ), $post ); ?></label>
359                         <input type="text" name="post_title" id="title" autocomplete="off" />
360                 </div>
361
362                 <div class="textarea-wrap" id="description-wrap">
363                         <label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( 'What&#8217;s on your mind?' ); ?></label>
364                         <textarea name="content" id="content" class="mceEditor" rows="3" cols="15"></textarea>
365                 </div>
366
367                 <p class="submit">
368                         <input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" />
369                         <input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" />
370                         <input type="hidden" name="post_type" value="post" />
371                         <?php wp_nonce_field( 'add-post' ); ?>
372                         <?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?>
373                         <br class="clear" />
374                 </p>
375
376         </form>
377         <?php
378         wp_dashboard_recent_drafts();
379 }
380
381 /**
382  * Show recent drafts of the user on the dashboard.
383  *
384  * @since 2.7.0
385  */
386 function wp_dashboard_recent_drafts( $drafts = false ) {
387         if ( ! $drafts ) {
388                 $query_args = array(
389                         'post_type'      => 'post',
390                         'post_status'    => 'draft',
391                         'author'         => get_current_user_id(),
392                         'posts_per_page' => 4,
393                         'orderby'        => 'modified',
394                         'order'          => 'DESC'
395                 );
396                 $drafts = get_posts( $query_args );
397                 if ( ! $drafts ) {
398                         return;
399                 }
400         }
401
402         echo '<div class="drafts">';
403         if ( count( $drafts ) > 3 ) {
404                 echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . _x( 'View all', 'drafts' ) . "</a></p>\n";
405         }
406         echo '<h4 class="hide-if-no-js">' . __( 'Drafts' ) . "</h4>\n<ul>";
407
408         $drafts = array_slice( $drafts, 0, 3 );
409         foreach ( $drafts as $draft ) {
410                 $url = get_edit_post_link( $draft->ID );
411                 $title = _draft_or_post_title( $draft->ID );
412                 echo "<li>\n";
413                 echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . esc_html( $title ) . '</a>';
414                 echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( get_option( 'date_format' ), $draft ) . '</time></div>';
415                 if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) {
416                         echo '<p>' . $the_content . '</p>';
417                 }
418                 echo "</li>\n";
419         }
420         echo "</ul>\n</div>";
421 }
422
423 function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
424         $GLOBALS['comment'] =& $comment;
425
426         $comment_post_url = get_edit_post_link( $comment->comment_post_ID );
427         $comment_post_title = strip_tags(get_the_title( $comment->comment_post_ID ));
428         $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
429         $comment_link = '<a class="comment-link" href="' . esc_url(get_comment_link()) . '">#</a>';
430
431         $actions_string = '';
432         if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
433                 // preorder it: Approve | Reply | Edit | Spam | Trash
434                 $actions = array(
435                         'approve' => '', 'unapprove' => '',
436                         'reply' => '',
437                         'edit' => '',
438                         'spam' => '',
439                         'trash' => '', 'delete' => ''
440                 );
441
442                 $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
443                 $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
444
445                 $approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
446                 $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
447                 $spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
448                 $trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
449                 $delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
450
451                 $actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
452                 $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
453                 $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>';
454                 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
455                 $actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
456                 if ( !EMPTY_TRASH_DAYS )
457                         $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
458                 else
459                         $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>';
460
461                 $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
462
463                 $i = 0;
464                 foreach ( $actions as $action => $link ) {
465                         ++$i;
466                         ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
467
468                         // Reply and quickedit need a hide-if-no-js span
469                         if ( 'reply' == $action || 'quickedit' == $action )
470                                 $action .= ' hide-if-no-js';
471
472                         $actions_string .= "<span class='$action'>$sep$link</span>";
473                 }
474         }
475
476 ?>
477
478                 <div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status($comment->comment_ID) ) ); ?>>
479                         <?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?>
480
481                         <?php echo get_avatar( $comment, 50, 'mystery' ); ?>
482
483                         <div class="dashboard-comment-wrap">
484                         <h4 class="comment-meta">
485                                 <?php printf( /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */__( 'From %1$s on %2$s%3$s' ),
486                                         '<cite class="comment-author">' . get_comment_author_link() . '</cite>', $comment_post_link.' '.$comment_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?>
487                         </h4>
488
489                         <?php
490                         else :
491                                 switch ( $comment->comment_type ) :
492                                 case 'pingback' :
493                                         $type = __( 'Pingback' );
494                                         break;
495                                 case 'trackback' :
496                                         $type = __( 'Trackback' );
497                                         break;
498                                 default :
499                                         $type = ucwords( $comment->comment_type );
500                                 endswitch;
501                                 $type = esc_html( $type );
502                         ?>
503                         <div class="dashboard-comment-wrap">
504                         <?php /* translators: %1$s is type of comment, %2$s is link to the post */ ?>
505                         <h4 class="comment-meta"><?php printf( _x( '%1$s on %2$s', 'dashboard' ), "<strong>$type</strong>", $comment_post_link." ".$comment_link ); ?></h4>
506                         <p class="comment-author"><?php comment_author_link(); ?></p>
507
508                         <?php endif; // comment_type ?>
509                         <blockquote><p><?php comment_excerpt(); ?></p></blockquote>
510                         <p class="row-actions"><?php echo $actions_string; ?></p>
511                         </div>
512                 </div>
513 <?php
514 }
515
516 /**
517  * Callback function for Activity widget.
518  *
519  * @since 3.8.0
520  */
521 function wp_dashboard_site_activity() {
522
523         echo '<div id="activity-widget">';
524
525         $future_posts = wp_dashboard_recent_posts( array(
526                 'display' => 2,
527                 'max'     => 5,
528                 'status'  => 'future',
529                 'order'   => 'ASC',
530                 'title'   => __( 'Publishing Soon' ),
531                 'id'      => 'future-posts',
532         ) );
533         $recent_posts = wp_dashboard_recent_posts( array(
534                 'display' => 2,
535                 'max'     => 5,
536                 'status'  => 'publish',
537                 'order'   => 'DESC',
538                 'title'   => __( 'Recently Published' ),
539                 'id'      => 'published-posts',
540         ) );
541
542         $recent_comments = wp_dashboard_recent_comments();
543
544         if ( !$future_posts && !$recent_posts && !$recent_comments ) {
545                 echo '<div class="no-activity">';
546                 echo '<p class="smiley"></p>';
547                 echo '<p>' . __( 'No activity yet!' ) . '</p>';
548                 echo '</div>';
549         }
550
551         echo '</div>';
552 }
553
554 /**
555  * Generates Publishing Soon and Recently Published sections.
556  *
557  * @since 3.8.0
558  *
559  * @param array $args {
560  *     An array of query and display arguments.
561  *
562  *     @type int    $display Number of posts to display.
563  *     @type int    $max     Maximum number of posts to query.
564  *     @type string $status  Post status.
565  *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
566  *     @type string $title   Section title.
567  *     @type string $id      The container id.
568  * }
569  * @return bool False if no posts were found. True otherwise.
570  */
571 function wp_dashboard_recent_posts( $args ) {
572         $query_args = array(
573                 'post_type'      => 'post',
574                 'post_status'    => $args['status'],
575                 'orderby'        => 'date',
576                 'order'          => $args['order'],
577                 'posts_per_page' => intval( $args['max'] ),
578                 'no_found_rows'  => true,
579                 'cache_results'  => false
580         );
581         $posts = new WP_Query( $query_args );
582
583         if ( $posts->have_posts() ) {
584
585                 echo '<div id="' . $args['id'] . '" class="activity-block">';
586
587                 if ( $posts->post_count > $args['display'] ) {
588                         echo '<small class="show-more hide-if-no-js"><a href="#">' . sprintf( __( 'See %s more&hellip;'), $posts->post_count - intval( $args['display'] ) ) . '</a></small>';
589                 }
590
591                 echo '<h4>' . $args['title'] . '</h4>';
592
593                 echo '<ul>';
594
595                 $i = 0;
596                 $today    = date( 'Y-m-d', current_time( 'timestamp' ) );
597                 $tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
598
599                 while ( $posts->have_posts() ) {
600                         $posts->the_post();
601
602                         $time = get_the_time( 'U' );
603                         if ( date( 'Y-m-d', $time ) == $today ) {
604                                 $relative = __( 'Today' );
605                         } elseif ( date( 'Y-m-d', $time ) == $tomorrow ) {
606                                 $relative = __( 'Tomorrow' );
607                         } else {
608                                 /* translators: date and time format for recent posts on the dashboard, see http://php.net/date */
609                                 $relative = date_i18n( __( 'M jS' ), $time );
610                         }
611
612                         $text = sprintf(
613                                 /* translators: 1: relative date, 2: time, 4: post title */
614                                 __( '<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>' ),
615                                 $relative,
616                                 get_the_time(),
617                                 get_edit_post_link(),
618                                 _draft_or_post_title()
619                         );
620
621                         $hidden = $i >= $args['display'] ? ' class="hidden"' : '';
622                         echo "<li{$hidden}>$text</li>";
623                         $i++;
624                 }
625
626                 echo '</ul>';
627                 echo '</div>';
628
629         } else {
630                 return false;
631         }
632
633         wp_reset_postdata();
634
635         return true;
636 }
637
638 /**
639  * Show Comments section.
640  *
641  * @since 3.8.0
642  *
643  * @param int $total_items Optional. Number of comments to query. Default 5.
644  * @return bool False if no comments were found. True otherwise.
645  */
646 function wp_dashboard_recent_comments( $total_items = 5 ) {
647         global $wpdb;
648
649         // Select all comment types and filter out spam later for better query performance.
650         $comments = array();
651         $start = 0;
652
653         $comments_query = array(
654                 'number' => $total_items * 5,
655                 'offset' => 0
656         );
657         if ( ! current_user_can( 'edit_posts' ) )
658                 $comments_query['status'] = 'approve';
659
660         while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
661                 foreach ( $possible as $comment ) {
662                         if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) )
663                                 continue;
664                         $comments[] = $comment;
665                         if ( count( $comments ) == $total_items )
666                                 break 2;
667                 }
668                 $comments_query['offset'] += $comments_query['number'];
669                 $comments_query['number'] = $total_items * 10;
670         }
671
672
673
674         if ( $comments ) {
675                 echo '<div id="latest-comments" class="activity-block">';
676                 echo '<h4>' . __( 'Comments' ) . '</h4>';
677
678                 echo '<div id="the-comment-list" data-wp-lists="list:comment">';
679                 foreach ( $comments as $comment )
680                         _wp_dashboard_recent_comments_row( $comment );
681                 echo '</div>';
682
683                 if ( current_user_can('edit_posts') )
684                         _get_list_table('WP_Comments_List_Table')->views();
685
686                 wp_comment_reply( -1, false, 'dashboard', false );
687                 wp_comment_trashnotice();
688
689                 echo '</div>';
690         } else {
691                 return false;
692         }
693         return true;
694 }
695
696 /**
697  * Display generic dashboard RSS widget feed.
698  *
699  * @since 2.5.0
700  *
701  * @param string $widget_id
702  */
703 function wp_dashboard_rss_output( $widget_id ) {
704         $widgets = get_option( 'dashboard_widget_options' );
705         echo '<div class="rss-widget">';
706         wp_widget_rss_output( $widgets[ $widget_id ] );
707         echo "</div>";
708 }
709
710 /**
711  * Checks to see if all of the feed url in $check_urls are cached.
712  *
713  * If $check_urls is empty, look for the rss feed url found in the dashboard
714  * widget options of $widget_id. If cached, call $callback, a function that
715  * echoes out output for this widget. If not cache, echo a "Loading..." stub
716  * which is later replaced by AJAX call (see top of /wp-admin/index.php)
717  *
718  * @since 2.5.0
719  *
720  * @param string $widget_id
721  * @param callback $callback
722  * @param array $check_urls RSS feeds
723  * @return bool False on failure. True on success.
724  */
725 function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
726         $loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>';
727         $doing_ajax = ( defined('DOING_AJAX') && DOING_AJAX );
728
729         if ( empty($check_urls) ) {
730                 $widgets = get_option( 'dashboard_widget_options' );
731                 if ( empty($widgets[$widget_id]['url']) && ! $doing_ajax ) {
732                         echo $loading;
733                         return false;
734                 }
735                 $check_urls = array( $widgets[$widget_id]['url'] );
736         }
737
738         $cache_key = 'dash_' . md5( $widget_id );
739         if ( false !== ( $output = get_transient( $cache_key ) ) ) {
740                 echo $output;
741                 return true;
742         }
743
744         if ( ! $doing_ajax ) {
745                 echo $loading;
746                 return false;
747         }
748
749         if ( $callback && is_callable( $callback ) ) {
750                 $args = array_slice( func_get_args(), 2 );
751                 array_unshift( $args, $widget_id );
752                 ob_start();
753                 call_user_func_array( $callback, $args );
754                 set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
755         }
756
757         return true;
758 }
759
760 /* Dashboard Widgets Controls */
761
762 // Calls widget_control callback
763 /**
764  * Calls widget control callback.
765  *
766  * @since 2.5.0
767  *
768  * @param int $widget_control_id Registered Widget ID.
769  */
770 function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
771         global $wp_dashboard_control_callbacks;
772
773         if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id]) ) {
774                 call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) );
775         }
776 }
777
778 /**
779  * The RSS dashboard widget control.
780  *
781  * Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
782  * from RSS-type widgets.
783  *
784  * @since 2.5.0
785  *
786  * @param string $widget_id
787  * @param array $form_inputs
788  */
789 function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
790         if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
791                 $widget_options = array();
792
793         if ( !isset($widget_options[$widget_id]) )
794                 $widget_options[$widget_id] = array();
795
796         $number = 1; // Hack to use wp_widget_rss_form()
797         $widget_options[$widget_id]['number'] = $number;
798
799         if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) {
800                 $_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] );
801                 $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );
802                 $widget_options[$widget_id]['number'] = $number;
803                 // title is optional. If black, fill it if possible
804                 if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
805                         $rss = fetch_feed($widget_options[$widget_id]['url']);
806                         if ( is_wp_error($rss) ) {
807                                 $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed'));
808                         } else {
809                                 $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));
810                                 $rss->__destruct();
811                                 unset($rss);
812                         }
813                 }
814                 update_option( 'dashboard_widget_options', $widget_options );
815                 $cache_key = 'dash_' . md5( $widget_id );
816                 delete_transient( $cache_key );
817         }
818
819         wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
820 }
821
822 /**
823  * WordPress News dashboard widget.
824  *
825  * @since 2.7.0
826  */
827 function wp_dashboard_primary() {
828         $feeds = array(
829                 'news'   => array(
830                         'link'         => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ),
831                         'url'          => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ),
832                         'title'        => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
833                         'items'        => 1,
834                         'show_summary' => 1,
835                         'show_author'  => 0,
836                         'show_date'    => 1,
837                 ),
838                 'planet' => array(
839                         'link'         => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ),
840                         'url'          => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ),
841                         'title'        => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
842                         'items'        => 3,
843                         'show_summary' => 0,
844                         'show_author'  => 0,
845                         'show_date'    => 0,
846                 )
847         );
848
849         if ( ( ! is_multisite() && is_blog_admin() && current_user_can( 'install_plugins' ) ) || ( is_network_admin() && current_user_can( 'manage_network_plugins' ) && current_user_can( 'install_plugins' ) ) ) {
850                 $feeds['plugins'] = array(
851                         'link'         => '',
852                         'url'          => array(
853                                 'popular' => 'http://wordpress.org/plugins/rss/browse/popular/',
854                         ),
855                         'title'        => '',
856                         'items'        => 1,
857                         'show_summary' => 0,
858                         'show_author'  => 0,
859                         'show_date'    => 0,
860                 );
861         }
862
863         wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds );
864 }
865
866 /**
867  * Display the WordPress news feeds.
868  *
869  * @since 3.8.0
870  *
871  * @param string $widget_id Widget ID.
872  * @param array  $feeds     Array of RSS feeds.
873  */
874 function wp_dashboard_primary_output( $widget_id, $feeds ) {
875         foreach( $feeds as $type => $args ) {
876                 $args['type'] = $type;
877                 echo '<div class="rss-widget">';
878                 if ( $type === 'plugins' ) {
879                         wp_dashboard_plugins_output( $args['url'], $args );
880                 } else {
881                         wp_widget_rss_output( $args['url'], $args );
882                 }
883                 echo "</div>";
884         }
885 }
886
887 /**
888  * Display plugins text for the WordPress news widget.
889  *
890  * @since 2.5.0
891  */
892 function wp_dashboard_plugins_output( $rss, $args = array() ) {
893         // Plugin feeds plus link to install them
894         $popular = fetch_feed( $args['url']['popular'] );
895
896         if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
897                 $plugin_slugs = array_keys( get_plugins() );
898                 set_transient( 'plugin_slugs', $plugin_slugs, DAY_IN_SECONDS );
899         }
900
901         echo '<ul>';
902
903         foreach ( array(
904                 'popular' => __( 'Popular Plugin' )
905         ) as $feed => $label ) {
906                 if ( is_wp_error($$feed) || !$$feed->get_item_quantity() )
907                         continue;
908
909                 $items = $$feed->get_items(0, 5);
910
911                 // Pick a random, non-installed plugin
912                 while ( true ) {
913                         // Abort this foreach loop iteration if there's no plugins left of this type
914                         if ( 0 == count($items) )
915                                 continue 2;
916
917                         $item_key = array_rand($items);
918                         $item = $items[$item_key];
919
920                         list($link, $frag) = explode( '#', $item->get_link() );
921
922                         $link = esc_url($link);
923                         if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) )
924                                 $slug = $matches[1];
925                         else {
926                                 unset( $items[$item_key] );
927                                 continue;
928                         }
929
930                         // Is this random plugin's slug already installed? If so, try again.
931                         reset( $plugin_slugs );
932                         foreach ( $plugin_slugs as $plugin_slug ) {
933                                 if ( $slug == substr( $plugin_slug, 0, strlen( $slug ) ) ) {
934                                         unset( $items[$item_key] );
935                                         continue 2;
936                                 }
937                         }
938
939                         // If we get to this point, then the random plugin isn't installed and we can stop the while().
940                         break;
941                 }
942
943                 // Eliminate some common badly formed plugin descriptions
944                 while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
945                         unset($items[$item_key]);
946
947                 if ( !isset($items[$item_key]) )
948                         continue;
949
950                 $title = esc_html( $item->get_title() );
951
952                 $description = esc_html( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) );
953
954                 $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&amp;TB_iframe=true&amp;width=600&amp;height=800';
955
956                 echo "<li class='dashboard-news-plugin'><span>$label:</span> <a href='$link' class='dashboard-news-plugin-link'>$title</a></h5>&nbsp;<span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span></li>";
957
958                 $$feed->__destruct();
959                 unset( $$feed );
960         }
961
962         echo '</ul>';
963 }
964
965 /**
966  * Display file upload quota on dashboard.
967  *
968  * Runs on the activity_box_end hook in wp_dashboard_right_now().
969  *
970  * @since 3.0.0
971  *
972  * @return bool True if not multisite, user can't upload files, or the space check option is disabled.
973 */
974 function wp_dashboard_quota() {
975         if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) )
976                 return true;
977
978         $quota = get_space_allowed();
979         $used = get_space_used();
980
981         if ( $used > $quota )
982                 $percentused = '100';
983         else
984                 $percentused = ( $used / $quota ) * 100;
985         $used_class = ( $percentused >= 70 ) ? ' warning' : '';
986         $used = round( $used, 2 );
987         $percentused = number_format( $percentused );
988
989         ?>
990         <h4 class="mu-storage"><?php _e( 'Storage Space' ); ?></h4>
991         <div class="mu-storage">
992         <ul>
993                 <li class="storage-count">
994                         <?php $text = sprintf(
995                                 /* translators: number of megabytes */
996                                 __( '%s MB Space Allowed' ),
997                                 number_format_i18n( $quota )
998                         );
999                         printf(
1000                                 '<a href="%1$s" title="%2$s">%3$s</a>',
1001                                 esc_url( admin_url( 'upload.php' ) ),
1002                                 __( 'Manage Uploads' ),
1003                                 $text
1004                         ); ?>
1005                 </li><li class="storage-count <?php echo $used_class; ?>">
1006                         <?php $text = sprintf(
1007                                 /* translators: 1: number of megabytes, 2: percentage */
1008                                 __( '%1$s MB (%2$s%%) Space Used' ),
1009                                 number_format_i18n( $used, 2 ),
1010                                 $percentused
1011                         );
1012                         printf(
1013                                 '<a href="%1$s" title="%2$s" class="musublink">%3$s</a>',
1014                                 esc_url( admin_url( 'upload.php' ) ),
1015                                 __( 'Manage Uploads' ),
1016                                 $text
1017                         ); ?>
1018                 </li>
1019         </ul>
1020         </div>
1021         <?php
1022 }
1023 add_action( 'activity_box_end', 'wp_dashboard_quota' );
1024
1025 // Display Browser Nag Meta Box
1026 function wp_dashboard_browser_nag() {
1027         $notice = '';
1028         $response = wp_check_browser_version();
1029
1030         if ( $response ) {
1031                 if ( $response['insecure'] ) {
1032                         $msg = sprintf( __( "It looks like you're using an insecure version of <a href='%s'>%s</a>. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ) );
1033                 } else {
1034                         $msg = sprintf( __( "It looks like you're using an old version of <a href='%s'>%s</a>. For the best WordPress experience, please update your browser." ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ) );
1035                 }
1036
1037                 $browser_nag_class = '';
1038                 if ( !empty( $response['img_src'] ) ) {
1039                         $img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src'];
1040
1041                         $notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';
1042                         $browser_nag_class = ' has-browser-icon';
1043                 }
1044                 $notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>";
1045
1046                 $browsehappy = 'http://browsehappy.com/';
1047                 $locale = get_locale();
1048                 if ( 'en_US' !== $locale )
1049                         $browsehappy = add_query_arg( 'locale', $locale, $browsehappy );
1050
1051                 $notice .= '<p>' . sprintf( __( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>';
1052                 $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss">' . __( 'Dismiss' ) . '</a></p>';
1053                 $notice .= '<div class="clear"></div>';
1054         }
1055
1056         echo apply_filters( 'browse-happy-notice', $notice, $response );
1057 }
1058
1059 function dashboard_browser_nag_class( $classes ) {
1060         $response = wp_check_browser_version();
1061
1062         if ( $response && $response['insecure'] )
1063                 $classes[] = 'browser-insecure';
1064
1065         return $classes;
1066 }
1067
1068 /**
1069  * Check if the user needs a browser update
1070  *
1071  * @since 3.2.0
1072  *
1073  * @return array|bool False on failure, array of browser data on success.
1074  */
1075 function wp_check_browser_version() {
1076         if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1077                 return false;
1078
1079         $key = md5( $_SERVER['HTTP_USER_AGENT'] );
1080
1081         if ( false === ($response = get_site_transient('browser_' . $key) ) ) {
1082                 global $wp_version;
1083
1084                 $options = array(
1085                         'body'                  => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
1086                         'user-agent'    => 'WordPress/' . $wp_version . '; ' . home_url()
1087                 );
1088
1089                 $response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.1/', $options );
1090
1091                 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
1092                         return false;
1093
1094                 /**
1095                  * Response should be an array with:
1096                  *  'name' - string - A user friendly browser name
1097                  *  'version' - string - The most recent version of the browser
1098                  *  'current_version' - string - The version of the browser the user is using
1099                  *  'upgrade' - boolean - Whether the browser needs an upgrade
1100                  *  'insecure' - boolean - Whether the browser is deemed insecure
1101                  *  'upgrade_url' - string - The url to visit to upgrade
1102                  *  'img_src' - string - An image representing the browser
1103                  *  'img_src_ssl' - string - An image (over SSL) representing the browser
1104                  */
1105                 $response = json_decode( wp_remote_retrieve_body( $response ), true );
1106
1107                 if ( ! is_array( $response ) )
1108                         return false;
1109
1110                 set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS );
1111         }
1112
1113         return $response;
1114 }
1115
1116 /**
1117  * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
1118  */
1119 function wp_dashboard_empty() {}
1120
1121 /**
1122  * Displays a welcome panel to introduce users to WordPress.
1123  *
1124  * @since 3.3.0
1125  */
1126 function wp_welcome_panel() {
1127         ?>
1128         <div class="welcome-panel-content">
1129         <h3><?php _e( 'Welcome to WordPress!' ); ?></h3>
1130         <p class="about-description"><?php _e( 'We&#8217;ve assembled some links to get you started:' ); ?></p>
1131         <div class="welcome-panel-column-container">
1132         <div class="welcome-panel-column">
1133                 <h4><?php _e( 'Get Started' ); ?></h4>
1134                 <a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e( 'Customize Your Site' ); ?></a>
1135                 <a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a>
1136                 <?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?>
1137                         <p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">change your theme completely</a>' ), admin_url( 'themes.php' ) ); ?></p>
1138                 <?php endif; ?>
1139         </div>
1140         <div class="welcome-panel-column">
1141                 <h4><?php _e( 'Next Steps' ); ?></h4>
1142                 <ul>
1143                 <?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?>
1144                         <li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
1145                         <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
1146                 <?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?>
1147                         <li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
1148                         <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
1149                         <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
1150                 <?php else : ?>
1151                         <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
1152                         <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add an About page' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
1153                 <?php endif; ?>
1154                         <li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li>
1155                 </ul>
1156         </div>
1157         <div class="welcome-panel-column welcome-panel-last">
1158                 <h4><?php _e( 'More Actions' ); ?></h4>
1159                 <ul>
1160                         <li><?php printf( '<div class="welcome-icon welcome-widgets-menus">' . __( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ) . '</div>', admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) ); ?></li>
1161                         <li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>
1162                         <li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'http://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li>
1163                 </ul>
1164         </div>
1165         </div>
1166         </div>
1167         <?php
1168 }