X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/8f374b7233bc2815ccc387e448d208c5434eb961..61343b82c4f0da4c68e4c6373daafff4a81efdd1:/wp-admin/includes/dashboard.php diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 6e7d5f0d..657402f9 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -131,6 +131,7 @@ function wp_dashboard_setup() { } if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) { + check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' ); ob_start(); // hack - but the same hack wp-admin/widgets.php uses wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); ob_end_clean(); @@ -182,6 +183,7 @@ function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_ function _wp_dashboard_control_callback( $dashboard, $meta_box ) { echo '
'; wp_dashboard_trigger_widget_control( $meta_box['id'] ); + wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' ); echo ''; submit_button( __('Submit') ); echo '
'; @@ -230,7 +232,7 @@ function wp_dashboard_right_now() { $num_tags = wp_count_terms('post_tag'); - $num_comm = wp_count_comments( ); + $num_comm = wp_count_comments(); echo "\n\t".'
'; echo "\n\t".'

' . __('Content') . '

'."\n\t".''; @@ -392,12 +394,12 @@ function wp_dashboard_right_now() { } echo '

'; - // Check if search engines are blocked. + // Check if search engines are asked not to index this site. if ( !is_network_admin() && !is_user_admin() && current_user_can('manage_options') && '1' != get_option('blog_public') ) { $title = apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content') ); - $content = apply_filters('privacy_on_link_text', __('Search Engines Blocked') ); + $content = apply_filters('privacy_on_link_text', __('Search Engines Discouraged') ); - echo "

$content

"; + echo "

$content

"; } update_right_now_message(); @@ -480,7 +482,7 @@ function wp_dashboard_quick_press() { if ( $drafts_query->posts ) $drafts =& $drafts_query->posts; } - printf('

' . __('You can also try %s, easy blogging from anywhere on the Web.') . '

', '' . __('Press This') . '' ); + printf('

' . __('You can also try %s, easy blogging from anywhere on the Web.') . '

', '' . __('Press This') . '' ); $_REQUEST = array(); // hack for get_default_post_to_edit() } @@ -490,22 +492,35 @@ function wp_dashboard_quick_press() { $post = get_post( $last_post_id ); if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore $post = get_default_post_to_edit('post', true); - update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID + update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID } else { $post->post_title = ''; // Remove the auto draft title } } else { - $post = get_default_post_to_edit('post', true); - update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID + $post = get_default_post_to_edit( 'post' , true); + $user_id = get_current_user_id(); + // Don't create an option if this is a super admin who does not belong to this site. + if ( ! ( is_super_admin( $user_id ) && ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) ) + update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID } $post_ID = (int) $post->ID; + + $media_settings = array( + 'id' => $post->ID, + 'nonce' => wp_create_nonce( 'update-post_' . $post->ID ), + ); + + if ( current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ) ) { + $featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true ); + $media_settings['featuredImageId'] = $featured_image_id ? $featured_image_id : -1; + } ?> -

-
- +
+ +
@@ -514,29 +529,37 @@ function wp_dashboard_quick_press() {
-

- + +
- + -

-
- +
+ +

+ + + + - 'save-post', 'tabindex'=> 4 ) ); ?> + 'save-post' ) ); ?> - - - -

@@ -566,8 +589,8 @@ function wp_dashboard_recent_drafts( $drafts = false ) { $url = get_edit_post_link( $draft->ID ); $title = _draft_or_post_title( $draft->ID ); $item = "

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

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

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

'; + if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) + $item .= '

' . $the_content . '

'; $list[] = $item; } ?> @@ -614,7 +637,7 @@ function wp_dashboard_recent_comments() { } if ( $comments ) { - echo '
'; + echo '
'; foreach ( $comments as $comment ) _wp_dashboard_recent_comments_row( $comment ); echo '
'; @@ -657,15 +680,15 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { $trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); $delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); - $actions['approve'] = "" . __( 'Approve' ) . ''; - $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; + $actions['approve'] = "" . __( 'Approve' ) . ''; + $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; $actions['edit'] = "". __('Edit') . ''; $actions['reply'] = '' . __('Reply') . ''; - $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; + $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; if ( !EMPTY_TRASH_DAYS ) - $actions['delete'] = "" . __('Delete Permanently') . ''; + $actions['delete'] = "" . __('Delete Permanently') . ''; else - $actions['trash'] = "" . _x('Trash', 'verb') . ''; + $actions['trash'] = "" . _x('Trash', 'verb') . ''; $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment ); @@ -804,7 +827,7 @@ function wp_dashboard_incoming_links_output() { $publisher = "$publisher"; $content = $item->get_content(); - $content = wp_html_excerpt($content, 50) . ' ...'; + $content = wp_html_excerpt( $content, 50, ' …' ); if ( $link ) /* translators: incoming links feed, %1$s is other person, %3$s is content */ @@ -813,10 +836,13 @@ function wp_dashboard_incoming_links_output() { /* translators: incoming links feed, %1$s is other person, %3$s is content */ $text = __( '%1$s linked here saying, "%3$s"' ); - if ( !empty($show_date) ) { - if ( !empty($show_author) || !empty($show_summary) ) - /* translators: incoming links feed, %4$s is the date */ - $text .= ' ' . __( 'on %4$s' ); + if ( !empty( $show_date ) ) { + if ( $link ) + /* translators: incoming links feed, %1$s is other person, %3$s is content, %4$s is the date */ + $text = __( '%1$s linked here saying, "%3$s" on %4$s' ); + else + /* translators: incoming links feed, %1$s is other person, %3$s is content, %4$s is the date */ + $text = __( '%1$s linked here saying, "%3$s" on %4$s' ); $date = esc_html( strip_tags( $item->get_date() ) ); $date = strtotime( $date ); $date = gmdate( get_option( 'date_format' ), $date ); @@ -843,7 +869,7 @@ function wp_dashboard_primary_control() { } /** - * {@internal Missing Short Description}} + * Display primary dashboard RSS widget feed. * * @since 2.5.0 * @@ -897,8 +923,8 @@ function wp_dashboard_secondary_output() { function wp_dashboard_plugins() { wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array( - 'http://wordpress.org/extend/plugins/rss/browse/popular/', - 'http://wordpress.org/extend/plugins/rss/browse/new/' + 'http://wordpress.org/plugins/rss/browse/popular/', + 'http://wordpress.org/plugins/rss/browse/new/' ) ); } @@ -908,12 +934,12 @@ function wp_dashboard_plugins() { * @since 2.5.0 */ function wp_dashboard_plugins_output() { - $popular = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/popular/' ); - $new = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/new/' ); + $popular = fetch_feed( 'http://wordpress.org/plugins/rss/browse/popular/' ); + $new = fetch_feed( 'http://wordpress.org/plugins/rss/browse/new/' ); if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) { $plugin_slugs = array_keys( get_plugins() ); - set_transient( 'plugin_slugs', $plugin_slugs, 86400 ); + set_transient( 'plugin_slugs', $plugin_slugs, DAY_IN_SECONDS ); } foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins') ) as $feed => $label ) { @@ -961,12 +987,7 @@ function wp_dashboard_plugins_output() { if ( !isset($items[$item_key]) ) continue; - // current bbPress feed item titles are: user on "topic title" - if ( preg_match( '/"(.*)"/s', $item->get_title(), $matches ) ) - $title = $matches[1]; - else // but let's make it forward compatible if things change - $title = $item->get_title(); - $title = esc_html( $title ); + $title = esc_html( $item->get_title() ); $description = esc_html( strip_tags(@html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset'))) ); @@ -1026,7 +1047,7 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar array_unshift( $args, $widget_id ); ob_start(); call_user_func_array( $callback, $args ); - set_transient( $cache_key, ob_get_flush(), 43200); // Default lifetime in cache of 12 hours (same as the feeds) + set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds) } return true; @@ -1072,7 +1093,7 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { $widget_options[$widget_id]['number'] = $number; if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) { - $_POST['widget-rss'][$number] = stripslashes_deep( $_POST['widget-rss'][$number] ); + $_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] ); $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] ); // title is optional. If black, fill it if possible if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) { @@ -1093,13 +1114,21 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { wp_widget_rss_form( $widget_options[$widget_id], $form_inputs ); } -// Display File upload quota on dashboard +/** + * Display file upload quota on dashboard. + * + * Runs on the activity_box_end hook in wp_dashboard_right_now(). + * + * @since 3.0.0 + * + * @return bool True if not multisite, user can't upload files, or the space check option is disabled. +*/ function wp_dashboard_quota() { if ( !is_multisite() || !current_user_can('upload_files') || get_site_option( 'upload_space_check_disabled' ) ) return true; $quota = get_space_allowed(); - $used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024; + $used = get_space_used(); if ( $used > $quota ) $percentused = '100'; @@ -1114,7 +1143,7 @@ function wp_dashboard_quota() {
- +
%2$sMB' ), esc_url( admin_url( 'upload.php' ) ), $quota ); ?>%2$sMB' ), esc_url( admin_url( 'upload.php' ) ), number_format_i18n( $quota ) ); ?>
@@ -1122,7 +1151,7 @@ function wp_dashboard_quota() {
- +
%2$sMB (%3$s%%)' ), esc_url( admin_url( 'upload.php' ) ), $used, $percentused ); ?>%2$sMB (%3$s%%)' ), esc_url( admin_url( 'upload.php' ) ), number_format_i18n( $used, 2 ), $percentused ); ?>
@@ -1217,7 +1246,7 @@ function wp_check_browser_version() { if ( ! is_array( $response ) ) return false; - set_site_transient( 'browser_' . $key, $response, 604800 ); // cache for 1 week + set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS ); } return $response; @@ -1234,92 +1263,44 @@ function wp_dashboard_empty() {} * @since 3.3.0 */ function wp_welcome_panel() { - global $wp_version; - - if ( ! current_user_can( 'edit_theme_options' ) ) - return; - - $classes = 'welcome-panel'; - - $option = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); - // 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner - $hide = 0 == $option || ( 2 == $option && wp_get_current_user()->user_email != get_option( 'admin_email' ) ); - if ( $hide ) - $classes .= ' hidden'; - - list( $display_version ) = explode( '-', $wp_version ); ?> -
- - -
-
-

-

First Steps with WordPress. If you’d rather dive right in, here are a few things most people do first when they set up a new WordPress site. If you need help, use the Help tabs in the upper right corner to get information on how to use your current screen and where to go for more assistance.' ); ?>

+

+

-

-

-
    -
  • Choose your privacy setting' ), esc_url( admin_url('options-privacy.php') ) ); ?>
  • -
  • Select your tagline and time zone' ), esc_url( admin_url('options-general.php') ) ); ?>
  • -
  • Turn comments on or off' ), esc_url( admin_url('options-discussion.php') ) ); ?>
  • -
  • Fill in your profile' ), esc_url( admin_url('profile.php') ) ); ?>
  • -
+

+ + + true ) ) ) > 1 ) ) : ?> +

change your theme completely' ), admin_url( 'themes.php' ) ); ?>

+
-

-

+

    -
  • sample page and post' ), esc_url( get_permalink( 2 ) ), esc_url( get_permalink( 1 ) ) ); ?>
  • -
  • sample page and post' ), esc_url( admin_url('edit.php?post_type=page') ), esc_url( admin_url('edit.php') ) ); ?>
  • -
  • Create an About Me page' ), esc_url( admin_url('edit.php?post_type=page') ) ); ?>
  • -
  • Write your first post' ), esc_url( admin_url('post-new.php') ) ); ?>
  • + +
  • ' . __( 'Edit your front page' ) . '', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?>
  • +
  • ' . __( 'Add additional pages' ) . '', admin_url( 'post-new.php?post_type=page' ) ); ?>
  • + +
  • ' . __( 'Edit your front page' ) . '', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?>
  • +
  • ' . __( 'Add additional pages' ) . '', admin_url( 'post-new.php?post_type=page' ) ); ?>
  • +
  • ' . __( 'Add a blog post' ) . '', admin_url( 'post-new.php' ) ); ?>
  • + +
  • ' . __( 'Write your first blog post' ) . '', admin_url( 'post-new.php' ) ); ?>
  • +
  • ' . __( 'Add an About page' ) . '', admin_url( 'post-new.php?post_type=page' ) ); ?>
  • + +
  • ' . __( 'View your site' ) . '', home_url( '/' ) ); ?>
-

- errors() ) : - echo '

'; - printf( __( 'Install a theme to get started customizing your site.' ), esc_url( admin_url( 'themes.php' ) ) ); - echo '

'; - else: - $customize_links = array(); - if ( 'twentyeleven' == $theme->get_stylesheet() ) - $customize_links[] = sprintf( __( 'Choose light or dark' ), esc_url( admin_url( 'themes.php?page=theme_options' ) ) ); - - if ( current_theme_supports( 'custom-background' ) ) - $customize_links[] = sprintf( __( 'Set a background color' ), esc_url( admin_url( 'themes.php?page=custom-background' ) ) ); - - if ( current_theme_supports( 'custom-header' ) ) - $customize_links[] = sprintf( __( 'Select a new header image' ), esc_url( admin_url( 'themes.php?page=custom-header' ) ) ); - - if ( current_theme_supports( 'widgets' ) ) - $customize_links[] = sprintf( __( 'Add some widgets' ), esc_url( admin_url( 'widgets.php' ) ) ); - - if ( ! empty( $customize_links ) ) { - echo '

'; - printf( __( 'Use the current theme — %1$s — or choose a new one. If you stick with %1$s, here are a few ways to make your site look unique.' ), $theme->display('Name'), esc_url( admin_url( 'themes.php' ) ) ); - echo '

'; - ?> -
    - -
  • - -
- '; - printf( __( 'Use the current theme — %1$s — or choose a new one.' ), $theme->display('Name'), esc_url( admin_url( 'themes.php' ) ) ); - echo '

'; - } - endif; ?> -
+

+
', admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) ); ?> +
  • ' . __( 'Turn comments on or off' ) . '', admin_url( 'options-discussion.php' ) ); ?>
  • +
  • ' . __( 'Learn more about getting started' ) . '', __( 'http://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?>
  • +
    -

    Dismiss this message.' ), esc_url( admin_url( '?welcome=0' ) ) ); ?>