//
/**
- * 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()
- * @since 2.5.1
*/
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.
* @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";
}
* @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";
}
* @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';
+ } else {
+ $taxonomy = $args['taxonomy'];
+ }
- if ( $taxonomy == 'category' )
+ if ( $taxonomy == '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 */
- $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>';
}
/**
* @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 an unordered list of checkbox <input> elements labelled
+ * Output an unordered list of checkbox input elements labelled
* with category names.
*
- * @see wp_terms_checklist()
* @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.
}
/**
- * 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
*
- * @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,
* @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;
+ } 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();
-
- 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 ) {
- $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 {
- $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 );
}
// 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
- 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
- * <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.
*
*
* @since 2.5.1
*
- * @param unknown_type $link_id
+ * @param int $link_id
*/
function wp_link_category_checklist( $link_id = 0 ) {
$default = 1;
*
* @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);
$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 ) {
+
echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
. esc_html( str_replace( ',', ', ', get_terms_to_edit( $post->ID, $taxonomy_name ) ) ) . '</div>';
+
}
}
*
* @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) {
<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>
*
* @since 1.2.0
*
- * @param unknown_type $meta
+ * @param array $meta
*/
function list_meta( $meta ) {
// Exit if no meta
*
* @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;
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 {
- // 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;
}
*
* @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
- HAVING meta_key NOT LIKE '\_%'
+ HAVING meta_key NOT LIKE %s
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';
*
* @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 ) {
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');
$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 ) . '>';
}
$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 */
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;
- 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";
}
?>
}
/**
- * 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
*
}
/**
- * 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
*
* @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;
}
/**
- * Print out <option> html elements for role selectors
+ * Print out option html elements for role selectors.
*
* @since 2.1.0
*
// 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 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;
- // 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'];
}
- // 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]);
}
*
* @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
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++;
}
}
}
- } while(0);
+ }
echo "</div>";
<?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 ) {
- 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++;
}
?>
<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 ); ?>
}
}
}
- } while(0);
+ }
?>
</ul><!-- .outer-border -->
</div><!-- .accordion-container -->
* @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;
*
* @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
- * @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;
- $new_error = array(
+ $wp_settings_errors[] = array(
'setting' => $setting,
- 'code' => $code,
+ 'code' => $code,
'message' => $message,
- 'type' => $type
+ 'type' => $type
);
- $wp_settings_errors[] = $new_error;
}
/**
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 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' );
}
- // 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();
- // 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 ) {
}
/**
- * 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.
*
- * 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 2.7.0
*
- * @param unknown_type $found_action
+ * @param string $found_action
*/
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.
*
- * @uses attr
* @since 2.7.0
*/
function the_post_password() {
* 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 );
* 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
*
*/
?>
</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(){
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.
*/
?>
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]>
-<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) ]><!-->
-<?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'); ?>" />
*/
$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',
$pointers = (array) $registered_pointers[ $hook_suffix ];
$caps_required = array(
- 'wp350_media' => array( 'upload_files' ),
'wp390_widgets' => array( 'edit_theme_options' ),
);
}
/**
- * Print the pointer javascript data.
+ * Print the pointer JavaScript data.
*
* @since 3.3.0
*
<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;
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() ) {
}
$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’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’re ready.' ) . '</p>';
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 {
- $selector = 'a[href="customize.php"]';
+ $selector = 'a[href^="customize.php"]';
if ( is_rtl() ) {
$position = array( 'edge' => 'right', 'align' => 'center', 'my' => 'right-5px' );
} else {
) );
}
+ 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 ) {
- 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' );
}
}
*/
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>
'number' => 0,
);
$r = wp_parse_args( $args, $defaults );
- extract( $r, EXTR_SKIP );
// 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
- if ( 'percent' == $type ) {
+ if ( 'percent' == $r['type'] ) {
$rating = round( $rating / 10, 0 ) / 2;
}
$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 */
- $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 ) . '">';
+ 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);