]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/template.php
WordPress 4.1.2
[autoinstalls/wordpress.git] / wp-admin / includes / template.php
index fb5814483c3a0c0440c24e9d8ec652bd6e735aba..1087837cd6eb1acbd1d930f2b85a3f941e680637 100644 (file)
 //
 
 /**
 //
 
 /**
- * Walker to output an unordered list of category checkbox <input> elements.
+ * Walker to output an unordered list of category checkbox input elements.
+ *
+ * @since 2.5.1
  *
  * @see Walker
  * @see wp_category_checklist()
  * @see wp_terms_checklist()
  *
  * @see Walker
  * @see wp_category_checklist()
  * @see wp_terms_checklist()
- * @since 2.5.1
  */
 class Walker_Category_Checklist extends Walker {
  */
 class Walker_Category_Checklist extends Walker {
-       var $tree_type = 'category';
-       var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
+       public $tree_type = 'category';
+       public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
 
        /**
         * Starts the list before the elements are added.
 
        /**
         * Starts the list before the elements are added.
@@ -35,7 +36,7 @@ class Walker_Category_Checklist extends Walker {
         * @param int    $depth  Depth of category. Used for tab indentation.
         * @param array  $args   An array of arguments. @see wp_terms_checklist()
         */
         * @param int    $depth  Depth of category. Used for tab indentation.
         * @param array  $args   An array of arguments. @see wp_terms_checklist()
         */
-       function start_lvl( &$output, $depth = 0, $args = array() ) {
+       public function start_lvl( &$output, $depth = 0, $args = array() ) {
                $indent = str_repeat("\t", $depth);
                $output .= "$indent<ul class='children'>\n";
        }
                $indent = str_repeat("\t", $depth);
                $output .= "$indent<ul class='children'>\n";
        }
@@ -51,7 +52,7 @@ class Walker_Category_Checklist extends Walker {
         * @param int    $depth  Depth of category. Used for tab indentation.
         * @param array  $args   An array of arguments. @see wp_terms_checklist()
         */
         * @param int    $depth  Depth of category. Used for tab indentation.
         * @param array  $args   An array of arguments. @see wp_terms_checklist()
         */
-       function end_lvl( &$output, $depth = 0, $args = array() ) {
+       public function end_lvl( &$output, $depth = 0, $args = array() ) {
                $indent = str_repeat("\t", $depth);
                $output .= "$indent</ul>\n";
        }
                $indent = str_repeat("\t", $depth);
                $output .= "$indent</ul>\n";
        }
@@ -69,20 +70,29 @@ class Walker_Category_Checklist extends Walker {
         * @param array  $args     An array of arguments. @see wp_terms_checklist()
         * @param int    $id       ID of the current term.
         */
         * @param array  $args     An array of arguments. @see wp_terms_checklist()
         * @param int    $id       ID of the current term.
         */
-       function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
-               extract($args);
-               if ( empty($taxonomy) )
+       public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
+               if ( empty( $args['taxonomy'] ) ) {
                        $taxonomy = 'category';
                        $taxonomy = 'category';
+               } else {
+                       $taxonomy = $args['taxonomy'];
+               }
 
 
-               if ( $taxonomy == 'category' )
+               if ( $taxonomy == 'category' ) {
                        $name = 'post_category';
                        $name = 'post_category';
-               else
-                       $name = 'tax_input['.$taxonomy.']';
+               } else {
+                       $name = 'tax_input[' . $taxonomy . ']';
+               }
+               $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
+               $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
 
 
-               $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
+               $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
 
                /** This filter is documented in wp-includes/category-template.php */
 
                /** This filter is documented in wp-includes/category-template.php */
-               $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters( 'the_category', $category->name ) ) . '</label>';
+               $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
+                       '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' .
+                       checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) .
+                       disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
+                       esc_html( apply_filters( 'the_category', $category->name ) ) . '</label>';
        }
 
        /**
        }
 
        /**
@@ -97,18 +107,21 @@ class Walker_Category_Checklist extends Walker {
         * @param int    $depth    Depth of the term in reference to parents. Default 0.
         * @param array  $args     An array of arguments. @see wp_terms_checklist()
         */
         * @param int    $depth    Depth of the term in reference to parents. Default 0.
         * @param array  $args     An array of arguments. @see wp_terms_checklist()
         */
-       function end_el( &$output, $category, $depth = 0, $args = array() ) {
+       public function end_el( &$output, $category, $depth = 0, $args = array() ) {
                $output .= "</li>\n";
        }
 }
 
 /**
                $output .= "</li>\n";
        }
 }
 
 /**
- * Output an unordered list of checkbox <input> elements labelled
+ * Output an unordered list of checkbox input elements labelled
  * with category names.
  *
  * with category names.
  *
- * @see wp_terms_checklist()
  * @since 2.5.1
  *
  * @since 2.5.1
  *
+ * @todo Properly document optional arguments as such.
+ *
+ * @see wp_terms_checklist()
+ *
  * @param int $post_id Mark categories associated with this post as checked. $selected_cats must not be an array.
  * @param int $descendants_and_self ID of the category to output along with its descendents.
  * @param bool|array $selected_cats List of categories to mark as checked.
  * @param int $post_id Mark categories associated with this post as checked. $selected_cats must not be an array.
  * @param int $descendants_and_self ID of the category to output along with its descendents.
  * @param bool|array $selected_cats List of categories to mark as checked.
@@ -128,15 +141,18 @@ function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $select
 }
 
 /**
 }
 
 /**
- * Output an unordered list of checkbox <input> elements labelled
- * with term names. Taxonomy independent version of wp_category_checklist().
+ * Output an unordered list of checkbox input elements labelled with term names.
+ *
+ * Taxonomy independent version of {@see wp_category_checklist()}.
  *
  * @since 3.0.0
  *
  *
  * @since 3.0.0
  *
- * @param int $post_id
- * @param array $args
+ * @todo Properly document optional default arguments.
+ *
+ * @param int   $post_id Post ID.
+ * @param array $args    Arguments to form the terms checklist.
  */
  */
-function wp_terms_checklist($post_id = 0, $args = array()) {
+function wp_terms_checklist( $post_id = 0, $args = array() ) {
        $defaults = array(
                'descendants_and_self' => 0,
                'selected_cats' => false,
        $defaults = array(
                'descendants_and_self' => 0,
                'selected_cats' => false,
@@ -156,41 +172,55 @@ function wp_terms_checklist($post_id = 0, $args = array()) {
         * @param array $args    An array of arguments.
         * @param int   $post_id The post ID.
         */
         * @param array $args    An array of arguments.
         * @param int   $post_id The post ID.
         */
-       $args = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
+       $params = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
 
 
-       extract( wp_parse_args($args, $defaults), EXTR_SKIP );
+       $r = wp_parse_args( $params, $defaults );
 
 
-       if ( empty($walker) || !is_a($walker, 'Walker') )
+       if ( empty( $r['walker'] ) || ! is_a( $r['walker'], 'Walker' ) ) {
                $walker = new Walker_Category_Checklist;
                $walker = new Walker_Category_Checklist;
+       } else {
+               $walker = $r['walker'];
+       }
 
 
-       $descendants_and_self = (int) $descendants_and_self;
+       $taxonomy = $r['taxonomy'];
+       $descendants_and_self = (int) $r['descendants_and_self'];
 
 
-       $args = array('taxonomy' => $taxonomy);
+       $args = array( 'taxonomy' => $taxonomy );
 
 
-       $tax = get_taxonomy($taxonomy);
-       $args['disabled'] = !current_user_can($tax->cap->assign_terms);
+       $tax = get_taxonomy( $taxonomy );
+       $args['disabled'] = ! current_user_can( $tax->cap->assign_terms );
 
 
-       if ( is_array( $selected_cats ) )
-               $args['selected_cats'] = $selected_cats;
-       elseif ( $post_id )
-               $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids')));
-       else
+       if ( is_array( $r['selected_cats'] ) ) {
+               $args['selected_cats'] = $r['selected_cats'];
+       } elseif ( $post_id ) {
+               $args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) );
+       } else {
                $args['selected_cats'] = array();
                $args['selected_cats'] = array();
-
-       if ( is_array( $popular_cats ) )
-               $args['popular_cats'] = $popular_cats;
-       else
-               $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
-
+       }
+       if ( is_array( $r['popular_cats'] ) ) {
+               $args['popular_cats'] = $r['popular_cats'];
+       } else {
+               $args['popular_cats'] = get_terms( $taxonomy, array(
+                       'fields' => 'ids',
+                       'orderby' => 'count',
+                       'order' => 'DESC',
+                       'number' => 10,
+                       'hierarchical' => false
+               ) );
+       }
        if ( $descendants_and_self ) {
        if ( $descendants_and_self ) {
-               $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) );
+               $categories = (array) get_terms( $taxonomy, array(
+                       'child_of' => $descendants_and_self,
+                       'hierarchical' => 0,
+                       'hide_empty' => 0
+               ) );
                $self = get_term( $descendants_and_self, $taxonomy );
                array_unshift( $categories, $self );
        } else {
                $self = get_term( $descendants_and_self, $taxonomy );
                array_unshift( $categories, $self );
        } else {
-               $categories = (array) get_terms($taxonomy, array('get' => 'all'));
+               $categories = (array) get_terms( $taxonomy, array( 'get' => 'all' ) );
        }
 
        }
 
-       if ( $checked_ontop ) {
+       if ( $r['checked_ontop'] ) {
                // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
                $checked_categories = array();
                $keys = array_keys( $categories );
                // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
                $checked_categories = array();
                $keys = array_keys( $categories );
@@ -203,17 +233,17 @@ function wp_terms_checklist($post_id = 0, $args = array()) {
                }
 
                // Put checked cats on top
                }
 
                // Put checked cats on top
-               echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
+               echo call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) );
        }
        // Then the rest of them
        }
        // Then the rest of them
-       echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
+       echo call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) );
 }
 
 /**
  * Retrieve a list of the most popular terms from the specified taxonomy.
  *
  * If the $echo argument is true then the elements for a list of checkbox
 }
 
 /**
  * Retrieve a list of the most popular terms from the specified taxonomy.
  *
  * If the $echo argument is true then the elements for a list of checkbox
- * <input> elements labelled with the names of the selected terms is output.
+ * `<input>` elements labelled with the names of the selected terms is output.
  * If the $post_ID global isn't empty then the terms associated with that
  * post will be marked as checked.
  *
  * If the $post_ID global isn't empty then the terms associated with that
  * post will be marked as checked.
  *
@@ -266,7 +296,7 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ech
  *
  * @since 2.5.1
  *
  *
  * @since 2.5.1
  *
- * @param unknown_type $link_id
+ * @param int $link_id
  */
 function wp_link_category_checklist( $link_id = 0 ) {
        $default = 1;
  */
 function wp_link_category_checklist( $link_id = 0 ) {
        $default = 1;
@@ -301,7 +331,7 @@ function wp_link_category_checklist( $link_id = 0 ) {
  *
  * @since 2.7.0
  *
  *
  * @since 2.7.0
  *
- * @param unknown_type $post
+ * @param WP_Post $post
  */
 function get_inline_data($post) {
        $post_type_object = get_post_type_object($post->post_type);
  */
 function get_inline_data($post) {
        $post_type_object = get_post_type_object($post->post_type);
@@ -341,11 +371,21 @@ function get_inline_data($post) {
                $taxonomy = get_taxonomy( $taxonomy_name );
 
                if ( $taxonomy->hierarchical && $taxonomy->show_ui ) {
                $taxonomy = get_taxonomy( $taxonomy_name );
 
                if ( $taxonomy->hierarchical && $taxonomy->show_ui ) {
-                               echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">'
-                                       . implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array( 'fields' => 'ids' ) ) ) . '</div>';
+
+                       $terms = get_object_term_cache( $post->ID, $taxonomy_name );
+                       if ( false === $terms ) {
+                               $terms = wp_get_object_terms( $post->ID, $taxonomy_name );
+                               wp_cache_add( $post->ID, $terms, $taxonomy_name . '_relationships' );
+                       }
+                       $term_ids = empty( $terms ) ? array() : wp_list_pluck( $terms, 'term_id' );
+
+                       echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">' . implode( ',', $term_ids ) . '</div>';
+
                } elseif ( $taxonomy->show_ui ) {
                } elseif ( $taxonomy->show_ui ) {
+
                        echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
                                . esc_html( str_replace( ',', ', ', get_terms_to_edit( $post->ID, $taxonomy_name ) ) ) . '</div>';
                        echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
                                . esc_html( str_replace( ',', ', ', get_terms_to_edit( $post->ID, $taxonomy_name ) ) ) . '</div>';
+
                }
        }
 
                }
        }
 
@@ -363,9 +403,10 @@ function get_inline_data($post) {
  *
  * @since 2.7.0
  *
  *
  * @since 2.7.0
  *
- * @param unknown_type $position
- * @param unknown_type $checkbox
- * @param unknown_type $mode
+ * @param int $position
+ * @param bool $checkbox
+ * @param string $mode
+ * @param bool $table_row
  */
 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
 
  */
 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
 
@@ -419,7 +460,7 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single',
 
                <div class="inside">
                <label for="author-url"><?php _e('URL') ?></label>
 
                <div class="inside">
                <label for="author-url"><?php _e('URL') ?></label>
-               <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" />
+               <input type="text" id="author-url" name="newcomment_author_url" class="code" size="103" value="" />
                </div>
                <div style="clear:both;"></div>
        </div>
                </div>
                <div style="clear:both;"></div>
        </div>
@@ -485,7 +526,7 @@ function wp_comment_trashnotice() {
  *
  * @since 1.2.0
  *
  *
  * @since 1.2.0
  *
- * @param unknown_type $meta
+ * @param array $meta
  */
 function list_meta( $meta ) {
        // Exit if no meta
  */
 function list_meta( $meta ) {
        // Exit if no meta
@@ -528,9 +569,9 @@ function list_meta( $meta ) {
  *
  * @since 2.5.0
  *
  *
  * @since 2.5.0
  *
- * @param unknown_type $entry
- * @param unknown_type $count
- * @return unknown
+ * @param array $entry
+ * @param int   $count
+ * @return string
  */
 function _list_meta_row( $entry, &$count ) {
        static $update_nonce = false;
  */
 function _list_meta_row( $entry, &$count ) {
        static $update_nonce = false;
@@ -550,10 +591,10 @@ function _list_meta_row( $entry, &$count ) {
 
        if ( is_serialized( $entry['meta_value'] ) ) {
                if ( is_serialized_string( $entry['meta_value'] ) ) {
 
        if ( is_serialized( $entry['meta_value'] ) ) {
                if ( is_serialized_string( $entry['meta_value'] ) ) {
-                       // this is a serialized string, so we should display it
+                       // This is a serialized string, so we should display it.
                        $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
                } else {
                        $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
                } else {
-                       // this is a serialized array/object so we should NOT display it
+                       // This is a serialized array/object so we should NOT display it.
                        --$count;
                        return;
                }
                        --$count;
                        return;
                }
@@ -599,14 +640,14 @@ function meta_form( $post = null ) {
         *
         * @param int $limit Number of custom fields to retrieve. Default 30.
         */
         *
         * @param int $limit Number of custom fields to retrieve. Default 30.
         */
-       $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
-       $keys = $wpdb->get_col( "
-               SELECT meta_key
+       $limit = apply_filters( 'postmeta_form_limit', 30 );
+       $sql = "SELECT meta_key
                FROM $wpdb->postmeta
                GROUP BY meta_key
                FROM $wpdb->postmeta
                GROUP BY meta_key
-               HAVING meta_key NOT LIKE '\_%'
+               HAVING meta_key NOT LIKE %s
                ORDER BY meta_key
                ORDER BY meta_key
-               LIMIT $limit" );
+               LIMIT %d";
+       $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
        if ( $keys ) {
                natcasesort( $keys );
                $meta_key_input_id = 'metakeyselect';
        if ( $keys ) {
                natcasesort( $keys );
                $meta_key_input_id = 'metakeyselect';
@@ -666,10 +707,10 @@ function meta_form( $post = null ) {
  *
  * @since 0.71
  *
  *
  * @since 0.71
  *
- * @param int|bool $edit      Accepts 1|true for editing the date, 0|false for adding the date.
- * @param int|bool $for_post  Accepts 1|true for applying the date to a post, 0|false for a comment.
- * @param int|bool $tab_index The tabindex attribute to add. Default 0.
- * @param int|bool $multi     Optional. Whether the additional fields and buttons should be added.
+ * @param int $edit      Accepts 1|true for editing the date, 0|false for adding the date.
+ * @param int $for_post  Accepts 1|true for applying the date to a post, 0|false for a comment.
+ * @param int $tab_index The tabindex attribute to add. Default 0.
+ * @param int $multi     Optional. Whether the additional fields and buttons should be added.
  *                            Default 0|false.
  */
 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
  *                            Default 0|false.
  */
 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
@@ -683,6 +724,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
        if ( (int) $tab_index > 0 )
                $tab_index_attribute = " tabindex=\"$tab_index\"";
 
        if ( (int) $tab_index > 0 )
                $tab_index_attribute = " tabindex=\"$tab_index\"";
 
+       // todo: Remove this?
        // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
 
        $time_adj = current_time('timestamp');
        // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
 
        $time_adj = current_time('timestamp');
@@ -700,7 +742,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
        $cur_hh = gmdate( 'H', $time_adj );
        $cur_mn = gmdate( 'i', $time_adj );
 
        $cur_hh = gmdate( 'H', $time_adj );
        $cur_mn = gmdate( 'i', $time_adj );
 
-       $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
+       $month = '<label for="mm" class="screen-reader-text">' . __( 'Month' ) . '</label><select ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n";
        for ( $i = 1; $i < 13; $i = $i +1 ) {
                $monthnum = zeroise($i, 2);
                $month .= "\t\t\t" . '<option value="' . $monthnum . '" ' . selected( $monthnum, $mm, false ) . '>';
        for ( $i = 1; $i < 13; $i = $i +1 ) {
                $monthnum = zeroise($i, 2);
                $month .= "\t\t\t" . '<option value="' . $monthnum . '" ' . selected( $monthnum, $mm, false ) . '>';
@@ -709,10 +751,10 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
        }
        $month .= '</select>';
 
        }
        $month .= '</select>';
 
-       $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
-       $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
-       $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
-       $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
+       $day = '<label for="jj" class="screen-reader-text">' . __( 'Day' ) . '</label><input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
+       $year = '<label for="aa" class="screen-reader-text">' . __( 'Year' ) . '</label><input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
+       $hour = '<label for="hh" class="screen-reader-text">' . __( 'Hour' ) . '</label><input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
+       $minute = '<label for="mn" class="screen-reader-text">' . __( 'Minute' ) . '</label><input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
 
        echo '<div class="timestamp-wrap">';
        /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
 
        echo '<div class="timestamp-wrap">';
        /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
@@ -723,10 +765,19 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
        if ( $multi ) return;
 
        echo "\n\n";
        if ( $multi ) return;
 
        echo "\n\n";
-       foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
-               echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
+       $map = array(
+               'mm' => array( $mm, $cur_mm ),
+               'jj' => array( $jj, $cur_jj ),
+               'aa' => array( $aa, $cur_aa ),
+               'hh' => array( $hh, $cur_hh ),
+               'mn' => array( $mn, $cur_mn ),
+       );
+       foreach ( $map as $timeunit => $value ) {
+               list( $unit, $curr ) = $value;
+
+               echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $unit . '" />' . "\n";
                $cur_timeunit = 'cur_' . $timeunit;
                $cur_timeunit = 'cur_' . $timeunit;
-               echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
+               echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n";
        }
 ?>
 
        }
 ?>
 
@@ -738,7 +789,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
 }
 
 /**
 }
 
 /**
- * Print out <option> HTML elements for the page templates drop-down.
+ * Print out option HTML elements for the page templates drop-down.
  *
  * @since 1.5.0
  *
  *
  * @since 1.5.0
  *
@@ -754,7 +805,7 @@ function page_template_dropdown( $default = '' ) {
 }
 
 /**
 }
 
 /**
- * Print out <option> HTML elements for the page parents drop-down.
+ * Print out option HTML elements for the page parents drop-down.
  *
  * @since 1.5.0
  *
  *
  * @since 1.5.0
  *
@@ -762,7 +813,7 @@ function page_template_dropdown( $default = '' ) {
  * @param int $parent  Optional. The parent page ID. Default 0.
  * @param int $level   Optional. Page depth level. Default 0.
  *
  * @param int $parent  Optional. The parent page ID. Default 0.
  * @param int $level   Optional. Page depth level. Default 0.
  *
- * @return void|bool Boolean False if page has no children, otherwise print out html elements
+ * @return null|false Boolean False if page has no children, otherwise print out html elements
  */
 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
        global $wpdb;
  */
 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
        global $wpdb;
@@ -787,7 +838,7 @@ function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
 }
 
 /**
 }
 
 /**
- * Print out <option> html elements for role selectors
+ * Print out option html elements for role selectors.
  *
  * @since 2.1.0
  *
  *
  * @since 2.1.0
  *
@@ -898,23 +949,30 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan
                                // If core box previously deleted, don't add
                                if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
                                        return;
                                // If core box previously deleted, don't add
                                if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
                                        return;
-                               // If box was added with default priority, give it core priority to maintain sort order
+
+                               /*
+                                * If box was added with default priority, give it core priority to
+                                * maintain sort order.
+                                */
                                if ( 'default' == $a_priority ) {
                                        $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
                                        unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
                                }
                                return;
                        }
                                if ( 'default' == $a_priority ) {
                                        $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
                                        unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
                                }
                                return;
                        }
-                       // If no priority given and id already present, use existing priority
+                       // If no priority given and id already present, use existing priority.
                        if ( empty($priority) ) {
                                $priority = $a_priority;
                        if ( empty($priority) ) {
                                $priority = $a_priority;
-                       // else if we're adding to the sorted priority, we don't know the title or callback. Grab them from the previously added context/priority.
+                       /*
+                        * Else, if we're adding to the sorted priority, we don't know the title
+                        * or callback. Grab them from the previously added context/priority.
+                        */
                        } elseif ( 'sorted' == $priority ) {
                                $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
                                $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
                                $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
                        }
                        } elseif ( 'sorted' == $priority ) {
                                $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
                                $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
                                $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
                        }
-                       // An id can be in only one priority and one context
+                       // An id can be in only one priority and one context.
                        if ( $priority != $a_priority || $context != $a_context )
                                unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
                }
                        if ( $priority != $a_priority || $context != $a_context )
                                unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
                }
@@ -934,7 +992,8 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan
  *
  * @since 2.5.0
  *
  *
  * @since 2.5.0
  *
- * @param string|object $screen Screen identifier
+ * @staticvar bool $already_sorted
+ * @param string|WP_Screen $screen Screen identifier
  * @param string $context box context
  * @param mixed $object gets passed to the box callback function as first parameter
  * @return int number of meta_boxes
  * @param string $context box context
  * @param mixed $object gets passed to the box callback function as first parameter
  * @return int number of meta_boxes
@@ -954,25 +1013,25 @@ function do_meta_boxes( $screen, $context, $object ) {
 
        printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context));
 
 
        printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context));
 
-       $i = 0;
-       do {
-               // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
-               if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
-                       foreach ( $sorted as $box_context => $ids ) {
-                               foreach ( explode(',', $ids ) as $id ) {
-                                       if ( $id && 'dashboard_browser_nag' !== $id )
-                                               add_meta_box( $id, null, null, $screen, $box_context, 'sorted' );
+       // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
+       if ( ! $already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
+               foreach ( $sorted as $box_context => $ids ) {
+                       foreach ( explode( ',', $ids ) as $id ) {
+                               if ( $id && 'dashboard_browser_nag' !== $id ) {
+                                       add_meta_box( $id, null, null, $screen, $box_context, 'sorted' );
                                }
                        }
                }
                                }
                        }
                }
-               $already_sorted = true;
+       }
 
 
-               if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
-                       break;
+       $already_sorted = true;
 
 
-               foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
-                       if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
-                               foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
+       $i = 0;
+
+       if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
+               foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) {
+                       if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ]) ) {
+                               foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
                                        if ( false == $box || ! $box['title'] )
                                                continue;
                                        $i++;
                                        if ( false == $box || ! $box['title'] )
                                                continue;
                                        $i++;
@@ -988,7 +1047,7 @@ function do_meta_boxes( $screen, $context, $object ) {
                                }
                        }
                }
                                }
                        }
                }
-       } while(0);
+       }
 
        echo "</div>";
 
 
        echo "</div>";
 
@@ -1061,13 +1120,11 @@ function do_accordion_sections( $screen, $context, $object ) {
        <?php
        $i = 0;
        $first_open = false;
        <?php
        $i = 0;
        $first_open = false;
-       do {
-               if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) )
-                       break;
 
 
+       if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
                foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
                foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
-                       if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) {
-                               foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
+                       if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
+                               foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
                                        if ( false == $box || ! $box['title'] )
                                                continue;
                                        $i++;
                                        if ( false == $box || ! $box['title'] )
                                                continue;
                                        $i++;
@@ -1080,7 +1137,10 @@ function do_accordion_sections( $screen, $context, $object ) {
                                        }
                                        ?>
                                        <li class="control-section accordion-section <?php echo $hidden_class; ?> <?php echo $open_class; ?> <?php echo esc_attr( $box['id'] ); ?>" id="<?php echo esc_attr( $box['id'] ); ?>">
                                        }
                                        ?>
                                        <li class="control-section accordion-section <?php echo $hidden_class; ?> <?php echo $open_class; ?> <?php echo esc_attr( $box['id'] ); ?>" id="<?php echo esc_attr( $box['id'] ); ?>">
-                                               <h3 class="accordion-section-title hndle" tabindex="0" title="<?php echo esc_attr( $box['title'] ); ?>"><?php echo esc_html( $box['title'] ); ?></h3>
+                                               <h3 class="accordion-section-title hndle" tabindex="0">
+                                                       <?php echo esc_html( $box['title'] ); ?>
+                                                       <span class="screen-reader-text"><?php _e( 'Press return or enter to expand' ); ?></span>
+                                               </h3>
                                                <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>">
                                                        <div class="inside">
                                                                <?php call_user_func( $box['callback'], $object, $box ); ?>
                                                <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>">
                                                        <div class="inside">
                                                                <?php call_user_func( $box['callback'], $object, $box ); ?>
@@ -1091,7 +1151,7 @@ function do_accordion_sections( $screen, $context, $object ) {
                                }
                        }
                }
                                }
                        }
                }
-       } while(0);
+       }
        ?>
                </ul><!-- .outer-border -->
        </div><!-- .accordion-container -->
        ?>
                </ul><!-- .outer-border -->
        </div><!-- .accordion-container -->
@@ -1219,7 +1279,7 @@ function do_settings_sections( $page ) {
  * @since 2.7.0
  *
  * @param string $page Slug title of the admin page who's settings fields you want to show.
  * @since 2.7.0
  *
  * @param string $page Slug title of the admin page who's settings fields you want to show.
- * @param section $section Slug title of the settings section who's fields you want to show.
+ * @param string $section Slug title of the settings section who's fields you want to show.
  */
 function do_settings_fields($page, $section) {
        global $wp_settings_fields;
  */
 function do_settings_fields($page, $section) {
        global $wp_settings_fields;
@@ -1255,23 +1315,25 @@ function do_settings_fields($page, $section) {
  *
  * @since 3.0.0
  *
  *
  * @since 3.0.0
  *
+ * @todo Properly document optional arguments as such.
+ *
  * @global array $wp_settings_errors Storage array of errors registered during this pageload
  *
  * @param string $setting Slug title of the setting to which this error applies
  * @global array $wp_settings_errors Storage array of errors registered during this pageload
  *
  * @param string $setting Slug title of the setting to which this error applies
- * @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
- * @param string $message The formatted message text to display to the user (will be shown inside styled <div> and <p>)
- * @param string $type The type of message it is, controls HTML class. Use 'error' or 'updated'.
+ * @param string $code    Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
+ * @param string $message The formatted message text to display to the user (will be shown inside styled
+ *                        `<div>` and `<p>` tags).
+ * @param string $type    The type of message it is, controls HTML class. Use 'error' or 'updated'.
  */
 function add_settings_error( $setting, $code, $message, $type = 'error' ) {
        global $wp_settings_errors;
 
  */
 function add_settings_error( $setting, $code, $message, $type = 'error' ) {
        global $wp_settings_errors;
 
-       $new_error = array(
+       $wp_settings_errors[] = array(
                'setting' => $setting,
                'setting' => $setting,
-               'code' => $code,
+               'code'    => $code,
                'message' => $message,
                'message' => $message,
-               'type' => $type
+               'type'    => $type
        );
        );
-       $wp_settings_errors[] = $new_error;
 }
 
 /**
 }
 
 /**
@@ -1299,23 +1361,25 @@ function add_settings_error( $setting, $code, $message, $type = 'error' ) {
 function get_settings_errors( $setting = '', $sanitize = false ) {
        global $wp_settings_errors;
 
 function get_settings_errors( $setting = '', $sanitize = false ) {
        global $wp_settings_errors;
 
-       // If $sanitize is true, manually re-run the sanitization for this option
-       // This allows the $sanitize_callback from register_setting() to run, adding
-       // any settings errors you want to show by default.
+       /*
+        * If $sanitize is true, manually re-run the sanitization for this option
+        * This allows the $sanitize_callback from register_setting() to run, adding
+        * any settings errors you want to show by default.
+        */
        if ( $sanitize )
                sanitize_option( $setting, get_option( $setting ) );
 
        if ( $sanitize )
                sanitize_option( $setting, get_option( $setting ) );
 
-       // If settings were passed back from options.php then use them
+       // If settings were passed back from options.php then use them.
        if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
                $wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) );
                delete_transient( 'settings_errors' );
        }
 
        if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
                $wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) );
                delete_transient( 'settings_errors' );
        }
 
-       // Check global in case errors have been added on this pageload
+       // Check global in case errors have been added on this pageload.
        if ( ! count( $wp_settings_errors ) )
                return array();
 
        if ( ! count( $wp_settings_errors ) )
                return array();
 
-       // Filter the results to those of a specific setting if one was set
+       // Filter the results to those of a specific setting if one was set.
        if ( $setting ) {
                $setting_errors = array();
                foreach ( (array) $wp_settings_errors as $key => $details ) {
        if ( $setting ) {
                $setting_errors = array();
                foreach ( (array) $wp_settings_errors as $key => $details ) {
@@ -1329,20 +1393,24 @@ function get_settings_errors( $setting = '', $sanitize = false ) {
 }
 
 /**
 }
 
 /**
- * Display settings errors registered by add_settings_error()
+ * Display settings errors registered by {@see add_settings_error()}.
  *
  *
- * Part of the Settings API. Outputs a <div> for each error retrieved by get_settings_errors().
+ * Part of the Settings API. Outputs a div for each error retrieved by
+ * {@see get_settings_errors()}.
  *
  *
- * This is called automatically after a settings page based on the Settings API is submitted.
- * Errors should be added during the validation callback function for a setting defined in register_setting()
+ * This is called automatically after a settings page based on the
+ * Settings API is submitted. Errors should be added during the validation
+ * callback function for a setting defined in {@see register_setting()}
  *
  *
- * The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization
+ * The $sanitize option is passed into {@see get_settings_errors()} and will
+ * re-run the setting sanitization
  * on its current value.
  *
  * on its current value.
  *
- * The $hide_on_update option will cause errors to only show when the settings page is first loaded.
- * if the user has already saved new values it will be hidden to avoid repeating messages already
- * shown in the default error reporting after submission. This is useful to show general errors like missing
- * settings when the user arrives at the settings page.
+ * The $hide_on_update option will cause errors to only show when the settings
+ * page is first loaded. if the user has already saved new values it will be
+ * hidden to avoid repeating messages already shown in the default error
+ * reporting after submission. This is useful to show general errors like
+ * missing settings when the user arrives at the settings page.
  *
  * @since 3.0.0
  *
  *
  * @since 3.0.0
  *
@@ -1376,7 +1444,7 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa
  *
  * @since 2.7.0
  *
  *
  * @since 2.7.0
  *
- * @param unknown_type $found_action
+ * @param string $found_action
  */
 function find_posts_div($found_action = '') {
 ?>
  */
 function find_posts_div($found_action = '') {
 ?>
@@ -1414,7 +1482,6 @@ function find_posts_div($found_action = '') {
  * The password is passed through {@link esc_attr()} to ensure that it
  * is safe for placing in an html attribute.
  *
  * The password is passed through {@link esc_attr()} to ensure that it
  * is safe for placing in an html attribute.
  *
- * @uses attr
  * @since 2.7.0
  */
 function the_post_password() {
  * @since 2.7.0
  */
 function the_post_password() {
@@ -1430,14 +1497,15 @@ function the_post_password() {
  * returned.
  *
  * @since 2.7.0
  * returned.
  *
  * @since 2.7.0
- * @param mixed $post Post id or object. If not supplied the global $post is used.
- * @return string The post title if set
+ *
+ * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
+ * @return string The post title if set.
  */
 function _draft_or_post_title( $post = 0 ) {
        $title = get_the_title( $post );
        if ( empty( $title ) )
                $title = __( '(no title)' );
  */
 function _draft_or_post_title( $post = 0 ) {
        $title = get_the_title( $post );
        if ( empty( $title ) )
                $title = __( '(no title)' );
-       return $title;
+       return esc_html( $title );
 }
 
 /**
 }
 
 /**
@@ -1446,7 +1514,6 @@ function _draft_or_post_title( $post = 0 ) {
  * A simple wrapper to display the "s" parameter in a GET URI. This function
  * should only be used when {@link the_search_query()} cannot.
  *
  * A simple wrapper to display the "s" parameter in a GET URI. This function
  * should only be used when {@link the_search_query()} cannot.
  *
- * @uses attr
  * @since 2.7.0
  *
  */
  * @since 2.7.0
  *
  */
@@ -1518,8 +1585,11 @@ if ( is_rtl() )
 
 ?>
 </head>
 
 ?>
 </head>
-<?php /** This filter is documented in wp-admin/admin-header.php */ ?>
-<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo apply_filters( 'admin_body_class', '' ) . ' ' . $admin_body_class; ?>">
+<?php
+/** This filter is documented in wp-admin/admin-header.php */
+$admin_body_classes = apply_filters( 'admin_body_class', '' );
+?>
+<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
 <script type="text/javascript">
 //<![CDATA[
 (function(){
 <script type="text/javascript">
 //<![CDATA[
 (function(){
@@ -1541,7 +1611,7 @@ document.body.className = c;
 function iframe_footer() {
        /*
         * We're going to hide any footer output on iFrame pages,
 function iframe_footer() {
        /*
         * We're going to hide any footer output on iFrame pages,
-        * but run the hooks anyway since they output Javascript
+        * but run the hooks anyway since they output JavaScript
         * or other needed content.
         */
         ?>
         * or other needed content.
         */
         ?>
@@ -1801,19 +1871,23 @@ function _wp_admin_html_begin() {
        if ( $is_IE )
                @header('X-UA-Compatible: IE=edge');
 
        if ( $is_IE )
                @header('X-UA-Compatible: IE=edge');
 
-/**
- * Fires inside the HTML tag in the admin header.
- *
- * @since 2.2.0
- */
 ?>
 <!DOCTYPE html>
 <!--[if IE 8]>
 ?>
 <!DOCTYPE html>
 <!--[if IE 8]>
-<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" <?php do_action( 'admin_xml_ns' ); ?> <?php language_attributes(); ?>>
+<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" <?php
+       /**
+        * Fires inside the HTML tag in the admin header.
+        *
+        * @since 2.2.0
+        */
+       do_action( 'admin_xml_ns' );
+?> <?php language_attributes(); ?>>
 <![endif]-->
 <!--[if !(IE 8) ]><!-->
 <![endif]-->
 <!--[if !(IE 8) ]><!-->
-<?php /** This action is documented in wp-admin/includes/template.php */ ?>
-<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php do_action( 'admin_xml_ns' ); ?> <?php language_attributes(); ?>>
+<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php
+       /** This action is documented in wp-admin/includes/template.php */
+       do_action( 'admin_xml_ns' );
+?> <?php language_attributes(); ?>>
 <!--<![endif]-->
 <head>
 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
 <!--<![endif]-->
 <head>
 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
@@ -1839,8 +1913,8 @@ final class WP_Internal_Pointers {
                 */
 
                $registered_pointers = array(
                 */
 
                $registered_pointers = array(
-                       'post-new.php' => 'wp350_media',
-                       'post.php'     => array( 'wp350_media', 'wp360_revisions' ),
+                       'post-new.php' => 'wp410_dfw',
+                       'post.php'     => 'wp410_dfw',
                        'edit.php'     => 'wp360_locks',
                        'widgets.php'  => 'wp390_widgets',
                        'themes.php'   => 'wp390_widgets',
                        'edit.php'     => 'wp360_locks',
                        'widgets.php'  => 'wp390_widgets',
                        'themes.php'   => 'wp390_widgets',
@@ -1853,7 +1927,6 @@ final class WP_Internal_Pointers {
                $pointers = (array) $registered_pointers[ $hook_suffix ];
 
                $caps_required = array(
                $pointers = (array) $registered_pointers[ $hook_suffix ];
 
                $caps_required = array(
-                       'wp350_media' => array( 'upload_files' ),
                        'wp390_widgets' => array( 'edit_theme_options' ),
                );
 
                        'wp390_widgets' => array( 'edit_theme_options' ),
                );
 
@@ -1883,7 +1956,7 @@ final class WP_Internal_Pointers {
        }
 
        /**
        }
 
        /**
-        * Print the pointer javascript data.
+        * Print the pointer JavaScript data.
         *
         * @since 3.3.0
         *
         *
         * @since 3.3.0
         *
@@ -1899,7 +1972,7 @@ final class WP_Internal_Pointers {
                <script type="text/javascript">
                //<![CDATA[
                (function($){
                <script type="text/javascript">
                //<![CDATA[
                (function($){
-                       var options = <?php echo json_encode( $args ); ?>, setup;
+                       var options = <?php echo wp_json_encode( $args ); ?>, setup;
 
                        if ( ! options )
                                return;
 
                        if ( ! options )
                                return;
@@ -1933,26 +2006,8 @@ final class WP_Internal_Pointers {
        public static function pointer_wp330_saving_widgets() {}
        public static function pointer_wp340_customize_current_theme_link() {}
        public static function pointer_wp340_choose_image_from_library() {}
        public static function pointer_wp330_saving_widgets() {}
        public static function pointer_wp340_customize_current_theme_link() {}
        public static function pointer_wp340_choose_image_from_library() {}
-
-       public static function pointer_wp350_media() {
-               $content  = '<h3>' . __( 'New Media Manager' ) . '</h3>';
-               $content .= '<p>' . __( 'Uploading files and creating image galleries has a whole new look. Check it out!' ) . '</p>';
-
-               self::print_js( 'wp350_media', '.insert-media', array(
-                       'content'  => $content,
-                       'position' => array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' ),
-               ) );
-       }
-
-       public static function pointer_wp360_revisions() {
-               $content  = '<h3>' . __( 'Compare Revisions' ) . '</h3>';
-               $content .= '<p>' . __( 'View, compare, and restore other versions of this content on the improved revisions screen.' ) . '</p>';
-
-               self::print_js( 'wp360_revisions', '.misc-pub-section.misc-pub-revisions', array(
-                       'content' => $content,
-                       'position' => array( 'edge' => is_rtl() ? 'left' : 'right', 'align' => 'center', 'my' => is_rtl() ? 'left' : 'right-14px' ),
-               ) );
-       }
+       public static function pointer_wp350_media() {}
+       public static function pointer_wp360_revisions() {}
 
        public static function pointer_wp360_locks() {
                if ( ! is_multi_author() ) {
 
        public static function pointer_wp360_locks() {
                if ( ! is_multi_author() ) {
@@ -1974,13 +2029,13 @@ final class WP_Internal_Pointers {
                }
 
                $content  = '<h3>' . __( 'New Feature: Live Widget Previews' ) . '</h3>';
                }
 
                $content  = '<h3>' . __( 'New Feature: Live Widget Previews' ) . '</h3>';
-               $content .= '<p>' . __( 'Add, edit, and play around with your widgets from the theme customizer.' ) . ' ' . __( 'Preview your changes in real-time and only save them when you&#8217;re ready.' ) . '</p>';
+               $content .= '<p>' . __( 'Add, edit, and play around with your widgets from the Customizer.' ) . ' ' . __( 'Preview your changes in real-time and only save them when you&#8217;re ready.' ) . '</p>';
 
                if ( 'themes' === get_current_screen()->id ) {
                        $selector = '.theme.active .customize';
 
                if ( 'themes' === get_current_screen()->id ) {
                        $selector = '.theme.active .customize';
-                       $position = array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center', 'my' => is_rtl() ? 'right-13px' : '' );
+                       $position = array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' );
                } else {
                } else {
-                       $selector = 'a[href="customize.php"]';
+                       $selector = 'a[href^="customize.php"]';
                        if ( is_rtl() ) {
                                $position = array( 'edge' => 'right', 'align' => 'center', 'my' => 'right-5px' );
                        } else {
                        if ( is_rtl() ) {
                                $position = array( 'edge' => 'right', 'align' => 'center', 'my' => 'right-5px' );
                        } else {
@@ -1994,13 +2049,34 @@ final class WP_Internal_Pointers {
                ) );
        }
 
                ) );
        }
 
+       public static function pointer_wp410_dfw() {
+               // Don't show when editor-scrolling is not used.
+               if ( empty( $GLOBALS['_wp_editor_expand'] ) ) {
+                       return;
+               }
+
+               $content  = '<h3>' . __( 'Distraction-Free Writing' ) . '</h3>';
+               $content .= '<p>' . __( 'Enable distraction-free writing mode, and everything surrounding the editor will fade away when you start typing. Move your mouse out of the editor to reveal everything again.' ) . '</p>';
+
+               if ( is_rtl() ) {
+                       $position = array( 'edge' => 'left', 'align' => 'center', 'my' => 'left+40 top-11', 'at' => 'left top' );
+               } else {
+                       $position = array( 'edge' => 'right', 'align' => 'center', 'my' => 'right-40 top-11', 'at' => 'right top' );
+               }
+
+               self::print_js( 'wp410_dfw', '#wp-content-wrap', array(
+                       'content' => $content,
+                       'position' => $position,
+               ) );
+       }
+
        /**
         * Prevents new users from seeing existing 'new feature' pointers.
         *
         * @since 3.3.0
         */
        public static function dismiss_pointers_for_new_users( $user_id ) {
        /**
         * Prevents new users from seeing existing 'new feature' pointers.
         *
         * @since 3.3.0
         */
        public static function dismiss_pointers_for_new_users( $user_id ) {
-               add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp350_media,wp360_revisions,wp360_locks,wp390_widgets' );
+               add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp360_locks,wp390_widgets' );
        }
 }
 
        }
 }
 
@@ -2032,7 +2108,7 @@ function convert_to_screen( $hook_name ) {
  */
 function _local_storage_notice() {
        ?>
  */
 function _local_storage_notice() {
        ?>
-       <div id="local-storage-notice" class="hidden">
+       <div id="local-storage-notice" class="hidden notice">
        <p class="local-restore">
                <?php _e('The backup of this post in your browser is different from the version below.'); ?>
                <a class="restore-backup" href="#"><?php _e('Restore the backup.'); ?></a>
        <p class="local-restore">
                <?php _e('The backup of this post in your browser is different from the version below.'); ?>
                <a class="restore-backup" href="#"><?php _e('Restore the backup.'); ?></a>
@@ -2070,13 +2146,12 @@ function wp_star_rating( $args = array() ) {
                'number' => 0,
        );
        $r = wp_parse_args( $args, $defaults );
                'number' => 0,
        );
        $r = wp_parse_args( $args, $defaults );
-       extract( $r, EXTR_SKIP );
 
        // Non-english decimal places when the $rating is coming from a string
 
        // Non-english decimal places when the $rating is coming from a string
-       $rating = str_replace( ',', '.', $rating );
+       $rating = str_replace( ',', '.', $r['rating'] );
 
        // Convert Percentage to star rating, 0..5 in .5 increments
 
        // Convert Percentage to star rating, 0..5 in .5 increments
-       if ( 'percent' == $type ) {
+       if ( 'percent' == $r['type'] ) {
                $rating = round( $rating / 10, 0 ) / 2;
        }
 
                $rating = round( $rating / 10, 0 ) / 2;
        }
 
@@ -2085,16 +2160,17 @@ function wp_star_rating( $args = array() ) {
        $half_stars = ceil( $rating - $full_stars );
        $empty_stars = 5 - $full_stars - $half_stars;
 
        $half_stars = ceil( $rating - $full_stars );
        $empty_stars = 5 - $full_stars - $half_stars;
 
-       if ( $number ) {
+       if ( $r['number'] ) {
                /* translators: 1: The rating, 2: The number of ratings */
                /* translators: 1: The rating, 2: The number of ratings */
-               $title = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $number );
-               $title = sprintf( $title, number_format_i18n( $rating, 1 ), number_format_i18n( $number ) );
+               $format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number'] );
+               $title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $r['number'] ) );
        } else {
                /* translators: 1: The rating */
                $title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
        }
 
        echo '<div class="star-rating" title="' . esc_attr( $title ) . '">';
        } else {
                /* translators: 1: The rating */
                $title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
        }
 
        echo '<div class="star-rating" title="' . esc_attr( $title ) . '">';
+       echo '<span class="screen-reader-text">' . $title . '</span>';
        echo str_repeat( '<div class="star star-full"></div>', $full_stars );
        echo str_repeat( '<div class="star star-half"></div>', $half_stars );
        echo str_repeat( '<div class="star star-empty"></div>', $empty_stars);
        echo str_repeat( '<div class="star star-full"></div>', $full_stars );
        echo str_repeat( '<div class="star star-half"></div>', $half_stars );
        echo str_repeat( '<div class="star star-empty"></div>', $empty_stars);