X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/78ff9d91a14da1f53bd3f1ffcab1264d92359b72..9e77185fafaf4e60e2b73821e0e4b9b1a11fb85f:/wp-admin/includes/dashboard.php
diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php
index 0f62ebc7..2a5e74be 100644
--- a/wp-admin/includes/dashboard.php
+++ b/wp-admin/includes/dashboard.php
@@ -18,11 +18,6 @@ function wp_dashboard_setup() {
$wp_dashboard_control_callbacks = array();
$screen = get_current_screen();
- $update = false;
- $widget_options = get_option( 'dashboard_widget_options' );
- if ( !$widget_options || !is_array($widget_options) )
- $widget_options = array();
-
/* Register Widgets and Controls */
$response = wp_check_browser_version();
@@ -56,16 +51,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() );
}
@@ -83,13 +118,11 @@ function wp_dashboard_setup() {
exit;
}
- if ( $update )
- 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 ) {
@@ -145,16 +178,16 @@ function wp_dashboard() {
?>
-
+
id, 'normal', '' ); ?>
-
+
id, 'side', '' ); ?>
-
+
id, 'column3', '' ); ?>
-
+
id, 'column4', '' ); ?>
@@ -165,7 +198,9 @@ function wp_dashboard() {
}
-/* Dashboard Widgets */
+//
+// Dashboard Widgets
+//
/**
* Dashboard widget that displays some basic stats about the site.
@@ -175,11 +210,6 @@ function wp_dashboard() {
* @since 2.7.0
*/
function wp_dashboard_right_now() {
- $theme = wp_get_theme();
- if ( current_user_can( 'switch_themes' ) )
- $theme_name = sprintf( '%1$s', $theme->display('Name') );
- else
- $theme_name = $theme->display('Name');
?>
@@ -220,40 +250,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 '
comment_type ) : - case 'pingback' : - $type = __( 'Pingback' ); - break; - case 'trackback' : - $type = __( 'Trackback' ); - break; - default : - $type = ucwords( $comment->comment_type ); - endswitch; + switch ( $comment->comment_type ) { + case 'pingback' : + $type = __( 'Pingback' ); + break; + case 'trackback' : + $type = __( 'Trackback' ); + break; + default : + $type = ucwords( $comment->comment_type ); + } $type = esc_html( $type ); ?>
@@ -529,7 +636,6 @@ function wp_dashboard_site_activity() {
echo '';
$future_posts = wp_dashboard_recent_posts( array(
- 'display' => 2,
'max' => 5,
'status' => 'future',
'order' => 'ASC',
@@ -537,7 +643,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 +670,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 +686,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,15 +695,10 @@ 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 '';
echo '
-
-
+
+
+
+
true ) ) ) > 1 ) ) : ?>
', 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 ''; - $i = 0; $today = date( 'Y-m-d', current_time( 'timestamp' ) ); $tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) ); @@ -615,18 +715,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 '
'; @@ -650,11 +747,8 @@ function wp_dashboard_recent_posts( $args ) { * @return bool False if no comments were found. True otherwise. */ function wp_dashboard_recent_comments( $total_items = 5 ) { - global $wpdb; - // Select all comment types and filter out spam later for better query performance. $comments = array(); - $start = 0; $comments_query = array( 'number' => $total_items * 5, @@ -675,8 +769,6 @@ function wp_dashboard_recent_comments( $total_items = 5 ) { $comments_query['number'] = $total_items * 10; } - - if ( $comments ) { echo '' . __( 'Comments' ) . '
'; @@ -753,8 +845,8 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar } if ( $callback && is_callable( $callback ) ) { - $args = array_slice( func_get_args(), 2 ); - array_unshift( $args, $widget_id ); + $args = array_slice( func_get_args(), 3 ); + array_unshift( $args, $widget_id, $check_urls ); ob_start(); call_user_func_array( $callback, $args ); set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds) @@ -806,7 +898,8 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { $_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] ); $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] ); $widget_options[$widget_id]['number'] = $number; - // title is optional. If black, fill it if possible + + // 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) ) { @@ -832,9 +925,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 +959,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, @@ -906,13 +1047,11 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) { echo ''; - foreach ( array( - 'popular' => __( 'Popular Plugin' ) - ) as $feed => $label ) { - if ( is_wp_error($$feed) || !$$feed->get_item_quantity() ) + foreach ( array( $popular ) as $feed ) { + if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() ) continue; - $items = $$feed->get_items(0, 5); + $items = $feed->get_items(0, 5); // Pick a random, non-installed plugin while ( true ) { @@ -955,14 +1094,11 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) { $title = esc_html( $item->get_title() ); - $description = esc_html( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) ); - $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&TB_iframe=true&width=600&height=800'; + echo "- " . __( 'Popular Plugin' ) . ": $title (" . __( 'Install' ) . ")
";
- echo "- $label: $title (" . __( 'Install' ) . ")
";
-
- $$feed->__destruct();
- unset( $$feed );
+ $feed->__destruct();
+ unset( $feed );
}
echo '
'; @@ -1059,6 +1195,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 ); } @@ -1136,8 +1280,10 @@ function wp_welcome_panel() {change your theme completely' ), admin_url( 'themes.php' ) ); ?>
@@ -1163,8 +1309,21 @@ function wp_welcome_panel() {-- ' . __( 'Manage widgets or menus' ) . '