X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/78ff9d91a14da1f53bd3f1ffcab1264d92359b72..888fa4ed68091f3314f711c5f6fe75858bf5410b:/wp-admin/includes/dashboard.php diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 0f62ebc7..fb50197e 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -56,16 +56,56 @@ function wp_dashboard_setup() { // WordPress News wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress News' ), 'wp_dashboard_primary' ); - // Hook to register new widgets - // Filter widget order if ( is_network_admin() ) { + + /** + * Fires after core widgets for the Network Admin dashboard have been registered. + * + * @since 3.1.0 + */ do_action( 'wp_network_dashboard_setup' ); + + /** + * Filter the list of widgets to load for the Network Admin dashboard. + * + * @since 3.1.0 + * + * @param array $dashboard_widgets An array of dashboard widgets. + */ $dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() ); } elseif ( is_user_admin() ) { + + /** + * Fires after core widgets for the User Admin dashboard have been registered. + * + * @since 3.1.0 + */ do_action( 'wp_user_dashboard_setup' ); + + /** + * Filter the list of widgets to load for the User Admin dashboard. + * + * @since 3.1.0 + * + * @param array $dashboard_widgets An array of dashboard widgets. + */ $dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() ); } else { + + /** + * Fires after core widgets for the admin dashboard have been registered. + * + * @since 2.5.0 + */ do_action( 'wp_dashboard_setup' ); + + /** + * Filter the list of widgets to load for the admin dashboard. + * + * @since 2.5.0 + * + * @param array $dashboard_widgets An array of dashboard widgets. + */ $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() ); } @@ -87,9 +127,10 @@ function wp_dashboard_setup() { update_option( 'dashboard_widget_options', $widget_options ); /** This action is documented in wp-admin/edit-form-advanced.php */ - do_action('do_meta_boxes', $screen->id, 'normal', ''); + do_action( 'do_meta_boxes', $screen->id, 'normal', '' ); + /** This action is documented in wp-admin/edit-form-advanced.php */ - do_action('do_meta_boxes', $screen->id, 'side', ''); + do_action( 'do_meta_boxes', $screen->id, 'side', '' ); } function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) { @@ -165,7 +206,9 @@ function wp_dashboard() { } -/* Dashboard Widgets */ +// +// Dashboard Widgets +// /** * Dashboard widget that displays some basic stats about the site. @@ -220,40 +263,51 @@ function wp_dashboard_right_now() { } /** - * Include additional elements in the 'At a Glance' dashboard widget. - * This widget was previously 'Right Now'. + * Filter the array of extra elements to list in the 'At a Glance' + * dashboard widget. + * + * Prior to 3.8.0, the widget was named 'Right Now'. Each element + * is wrapped in list-item tags on output. * * @since 3.8.0 - * @param array $items Array of items. + * + * @param array $items Array of extra 'At a Glance' widget items. */ $elements = apply_filters( 'dashboard_glance_items', array() ); + if ( $elements ) { echo '
'; $future_posts = wp_dashboard_recent_posts( array( - 'display' => 2, 'max' => 5, 'status' => 'future', 'order' => 'ASC', @@ -537,7 +656,6 @@ function wp_dashboard_site_activity() { 'id' => 'future-posts', ) ); $recent_posts = wp_dashboard_recent_posts( array( - 'display' => 2, 'max' => 5, 'status' => 'publish', 'order' => 'DESC', @@ -565,8 +683,7 @@ function wp_dashboard_site_activity() { * @param array $args { * An array of query and display arguments. * - * @type int $display Number of posts to display. - * @type int $max Maximum number of posts to query. + * @type int $max Number of posts to display. * @type string $status Post status. * @type string $order Designates ascending ('ASC') or descending ('DESC') order. * @type string $title Section title. @@ -582,7 +699,8 @@ function wp_dashboard_recent_posts( $args ) { 'order' => $args['order'], 'posts_per_page' => intval( $args['max'] ), 'no_found_rows' => true, - 'cache_results' => false + 'cache_results' => false, + 'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable', ); $posts = new WP_Query( $query_args ); @@ -590,10 +708,6 @@ function wp_dashboard_recent_posts( $args ) { echo '';
- if ( $posts->post_count > $args['display'] ) {
- echo '' . sprintf( __( 'See %s more…'), $posts->post_count - intval( $args['display'] ) ) . '';
- }
-
echo '$label: $title (" . __( 'Install' ) . ") ";
+ echo "$label: $title (" . __( 'Install' ) . ") ";
$$feed->__destruct();
unset( $$feed );
@@ -1059,6 +1218,14 @@ function wp_dashboard_browser_nag() {
$notice .= '';
}
+ /**
+ * Filter the notice output for the 'Browse Happy' nag meta box.
+ *
+ * @since 3.2.0
+ *
+ * @param string $notice The notice content.
+ * @param array $response An array containing web browser information.
+ */
echo apply_filters( 'browse-happy-notice', $notice, $response );
}
@@ -1163,8 +1330,21 @@ function wp_welcome_panel() {
', admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) ); ?>
+
+ widgets or menus' ),
+ admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) );
+ } elseif ( current_theme_supports( 'widgets' ) ) {
+ echo '' . __( 'Manage widgets' ) . '';
+ } else {
+ echo '' . __( 'Manage menus' ) . '';
+ }
+ ?>
+
+
' . __( 'Turn comments on or off' ) . '', admin_url( 'options-discussion.php' ) ); ?>
+
' . __( 'Learn more about getting started' ) . '', __( 'http://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?>
' . $args['title'] . '
'; echo ''; @@ -615,18 +729,15 @@ function wp_dashboard_recent_posts( $args ) { $relative = date_i18n( __( 'M jS' ), $time ); } - $text = sprintf( - /* translators: 1: relative date, 2: time, 4: post title */ - __( '%1$s, %2$s %4$s' ), - $relative, - get_the_time(), - get_edit_post_link(), - _draft_or_post_title() - ); - - $hidden = $i >= $args['display'] ? ' class="hidden"' : ''; - echo "- $text
";
- $i++;
+ if ( current_user_can( 'edit_post', get_the_ID() ) ) {
+ /* translators: 1: relative date, 2: time, 3: post edit link, 4: post title */
+ $format = __( '%1$s, %2$s %4$s' );
+ printf( "- $format
", $relative, get_the_time(), get_edit_post_link(), _draft_or_post_title() );
+ } else {
+ /* translators: 1: relative date, 2: time, 3: post title */
+ $format = __( '%1$s, %2$s %3$s' );
+ printf( "- $format
", $relative, get_the_time(), _draft_or_post_title() );
+ }
}
echo '
'; @@ -832,9 +943,33 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { */ function wp_dashboard_primary() { $feeds = array( - 'news' => array( - 'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ), - 'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ), + 'news' => array( + + /** + * Filter the primary link URL for the 'WordPress News' dashboard widget. + * + * @since 2.5.0 + * + * @param string $link The widget's primary link URL. + */ + 'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ), + + /** + * Filter the primary feed URL for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $url The widget's primary feed URL. + */ + 'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ), + + /** + * Filter the primary link title for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $title Title attribute for the widget's primary link. + */ 'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ), 'items' => 1, 'show_summary' => 1, @@ -842,8 +977,32 @@ function wp_dashboard_primary() { 'show_date' => 1, ), 'planet' => array( - 'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ), - 'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ), + + /** + * Filter the secondary link URL for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $link The widget's secondary link URL. + */ + 'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ), + + /** + * Filter the secondary feed URL for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $url The widget's secondary feed URL. + */ + 'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ), + + /** + * Filter the secondary link title for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $title Title attribute for the widget's secondary link. + */ 'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ), 'items' => 3, 'show_summary' => 0, @@ -959,7 +1118,7 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) { $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&TB_iframe=true&width=600&height=800'; - echo "-- ' . __( 'Manage widgets or menus' ) . '