X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/a6f44f0edcda2471c5a33e4156c1c9488c7f3210..5d244c8fd9a27c9f89dd08da2af6fbc67d4fce63:/wp-admin/includes/template.php
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index 18349644..1087837c 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -13,53 +13,115 @@
//
/**
- * Walker to output an unordered list of category checkbox 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
- function start_lvl( &$output, $depth = 0, $args = array() ) {
+ /**
+ * Starts the list before the elements are added.
+ *
+ * @see Walker:start_lvl()
+ *
+ * @since 2.5.1
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param int $depth Depth of category. Used for tab indentation.
+ * @param array $args An array of arguments. @see wp_terms_checklist()
+ */
+ public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "$indent
\n";
}
- function end_lvl( &$output, $depth = 0, $args = array() ) {
+ /**
+ * Ends the list of after the elements are added.
+ *
+ * @see Walker::end_lvl()
+ *
+ * @since 2.5.1
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param int $depth Depth of category. Used for tab indentation.
+ * @param array $args An array of arguments. @see wp_terms_checklist()
+ */
+ public function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "$indent
\n";
}
- function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
- extract($args);
- if ( empty($taxonomy) )
+ /**
+ * Start the element output.
+ *
+ * @see Walker::start_el()
+ *
+ * @since 2.5.1
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $category The current term object.
+ * @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 $id ID of the current term.
+ */
+ 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"' : '';
+
+ $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
- $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
- $output .= "\n
" . '';
+ /** This filter is documented in wp-includes/category-template.php */
+ $output .= "\n
" .
+ '';
}
- function end_el( &$output, $category, $depth = 0, $args = array() ) {
+ /**
+ * Ends the element output, if needed.
+ *
+ * @see Walker::end_el()
+ *
+ * @since 2.5.1
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $category The current term object.
+ * @param int $depth Depth of the term in reference to parents. Default 0.
+ * @param array $args An array of arguments. @see wp_terms_checklist()
+ */
+ public function end_el( &$output, $category, $depth = 0, $args = array() ) {
$output .= "
\n";
}
}
/**
- * Output an unordered list of checkbox 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.
@@ -79,15 +141,18 @@ function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $select
}
/**
- * Output an unordered list of checkbox 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,
@@ -96,41 +161,66 @@ function wp_terms_checklist($post_id = 0, $args = array()) {
'taxonomy' => 'category',
'checked_ontop' => true
);
- $args = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
- extract( wp_parse_args($args, $defaults), EXTR_SKIP );
+ /**
+ * Filter the taxonomy terms checklist arguments.
+ *
+ * @since 3.4.0
+ *
+ * @see wp_terms_checklist()
+ *
+ * @param array $args An array of arguments.
+ * @param int $post_id The post ID.
+ */
+ $params = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
- if ( empty($walker) || !is_a($walker, 'Walker') )
+ $r = wp_parse_args( $params, $defaults );
+
+ 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 );
@@ -143,17 +233,17 @@ function wp_terms_checklist($post_id = 0, $args = array()) {
}
// 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
- * elements labelled with the names of the selected terms is output.
+ * `` 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.
*
@@ -188,8 +278,11 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ech
';
+
}
}
@@ -297,13 +403,29 @@ function get_inline_data($post) {
*
* @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) {
- // allow plugin to replace the popup content
- $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
+
+ /**
+ * Filter the in-line comment reply-to form output in the Comments
+ * list table.
+ *
+ * Returning a non-empty value here will short-circuit display
+ * of the in-line comment-reply form in the Comments list table,
+ * echoing the returned value instead.
+ *
+ * @since 2.7.0
+ *
+ * @see wp_comment_reply()
+ *
+ * @param string $content The reply-to form content.
+ * @param array $args An array of default args.
+ */
+ $content = apply_filters( 'wp_comment_reply', '', array( 'position' => $position, 'checkbox' => $checkbox, 'mode' => $mode ) );
if ( ! empty($content) ) {
echo $content;
@@ -338,7 +460,7 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single',
-
+
@@ -404,7 +526,7 @@ function wp_comment_trashnotice() {
*
* @since 1.2.0
*
- * @param unknown_type $meta
+ * @param array $meta
*/
function list_meta( $meta ) {
// Exit if no meta
@@ -447,9 +569,9 @@ function list_meta( $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;
@@ -469,10 +591,10 @@ function _list_meta_row( $entry, &$count ) {
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;
}
@@ -485,7 +607,7 @@ function _list_meta_row( $entry, &$count ) {
$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
$r .= "\n\t