wp/wp-includes/category-template.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
   101 /**
   101 /**
   102  * Retrieves category name based on category ID.
   102  * Retrieves category name based on category ID.
   103  *
   103  *
   104  * @since 0.71
   104  * @since 0.71
   105  *
   105  *
   106  * @param int $cat_ID Category ID.
   106  * @param int $cat_id Category ID.
   107  * @return string|WP_Error Category name on success, WP_Error on failure.
   107  * @return string|WP_Error Category name on success, WP_Error on failure.
   108  */
   108  */
   109 function get_the_category_by_ID( $cat_ID ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
   109 function get_the_category_by_ID( $cat_id ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
   110 	$cat_ID   = (int) $cat_ID;
   110 	$cat_id   = (int) $cat_id;
   111 	$category = get_term( $cat_ID );
   111 	$category = get_term( $cat_id );
   112 
   112 
   113 	if ( is_wp_error( $category ) ) {
   113 	if ( is_wp_error( $category ) ) {
   114 		return $category;
   114 		return $category;
   115 	}
   115 	}
   116 
   116 
   329  *     @type string|array $taxonomy          Name of the taxonomy or taxonomies to retrieve. Default 'category'.
   329  *     @type string|array $taxonomy          Name of the taxonomy or taxonomies to retrieve. Default 'category'.
   330  *     @type bool         $hide_if_empty     True to skip generating markup if no categories are found.
   330  *     @type bool         $hide_if_empty     True to skip generating markup if no categories are found.
   331  *                                           Default false (create select element even if no categories are found).
   331  *                                           Default false (create select element even if no categories are found).
   332  *     @type bool         $required          Whether the `<select>` element should have the HTML5 'required' attribute.
   332  *     @type bool         $required          Whether the `<select>` element should have the HTML5 'required' attribute.
   333  *                                           Default false.
   333  *                                           Default false.
       
   334  *     @type Walker       $walker            Walker object to use to build the output. Default empty which results in a
       
   335  *                                           Walker_CategoryDropdown instance being used.
   334  * }
   336  * }
   335  * @return string HTML dropdown list of categories.
   337  * @return string HTML dropdown list of categories.
   336  */
   338  */
   337 function wp_dropdown_categories( $args = '' ) {
   339 function wp_dropdown_categories( $args = '' ) {
   338 	$defaults = array(
   340 	$defaults = array(
   516  *     @type string       $taxonomy              Name of the taxonomy to retrieve. Default 'category'.
   518  *     @type string       $taxonomy              Name of the taxonomy to retrieve. Default 'category'.
   517  *     @type string       $title_li              Text to use for the list title `<li>` element. Pass an empty string
   519  *     @type string       $title_li              Text to use for the list title `<li>` element. Pass an empty string
   518  *                                               to disable. Default 'Categories'.
   520  *                                               to disable. Default 'Categories'.
   519  *     @type bool|int     $use_desc_for_title    Whether to use the category description as the title attribute.
   521  *     @type bool|int     $use_desc_for_title    Whether to use the category description as the title attribute.
   520  *                                               Accepts 0, 1, or their bool equivalents. Default 1.
   522  *                                               Accepts 0, 1, or their bool equivalents. Default 1.
       
   523  *     @type Walker       $walker                Walker object to use to build the output. Default empty which results
       
   524  *                                               in a Walker_Category instance being used.
   521  * }
   525  * }
   522  * @return void|string|false Void if 'echo' argument is true, HTML list of categories if 'echo' is false.
   526  * @return void|string|false Void if 'echo' argument is true, HTML list of categories if 'echo' is false.
   523  *                           False if the taxonomy does not exist.
   527  *                           False if the taxonomy does not exist.
   524  */
   528  */
   525 function wp_list_categories( $args = '' ) {
   529 function wp_list_categories( $args = '' ) {
   659 	/**
   663 	/**
   660 	 * Filters the HTML output of a taxonomy list.
   664 	 * Filters the HTML output of a taxonomy list.
   661 	 *
   665 	 *
   662 	 * @since 2.1.0
   666 	 * @since 2.1.0
   663 	 *
   667 	 *
   664 	 * @param string $output HTML output.
   668 	 * @param string       $output HTML output.
   665 	 * @param array  $args   An array of taxonomy-listing arguments. See wp_list_categories()
   669 	 * @param array|string $args   An array or query string of taxonomy-listing arguments. See
   666 	 *                       for information on accepted arguments.
   670 	 *                             wp_list_categories() for information on accepted arguments.
   667 	 */
   671 	 */
   668 	$html = apply_filters( 'wp_list_categories', $output, $args );
   672 	$html = apply_filters( 'wp_list_categories', $output, $args );
   669 
   673 
   670 	if ( $parsed_args['echo'] ) {
   674 	if ( $parsed_args['echo'] ) {
   671 		echo $html;
   675 		echo $html;
   735 		return;
   739 		return;
   736 	}
   740 	}
   737 
   741 
   738 	foreach ( $tags as $key => $tag ) {
   742 	foreach ( $tags as $key => $tag ) {
   739 		if ( 'edit' === $args['link'] ) {
   743 		if ( 'edit' === $args['link'] ) {
   740 			$link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
   744 			$link = get_edit_term_link( $tag, $tag->taxonomy, $args['post_type'] );
   741 		} else {
   745 		} else {
   742 			$link = get_term_link( (int) $tag->term_id, $tag->taxonomy );
   746 			$link = get_term_link( $tag, $tag->taxonomy );
   743 		}
   747 		}
   744 
   748 
   745 		if ( is_wp_error( $link ) ) {
   749 		if ( is_wp_error( $link ) ) {
   746 			return;
   750 			return;
   747 		}
   751 		}
  1341 	}
  1345 	}
  1342 
  1346 
  1343 	/**
  1347 	/**
  1344 	 * Filters the term links for a given taxonomy.
  1348 	 * Filters the term links for a given taxonomy.
  1345 	 *
  1349 	 *
  1346 	 * The dynamic portion of the filter name, `$taxonomy`, refers
  1350 	 * The dynamic portion of the hook name, `$taxonomy`, refers
  1347 	 * to the taxonomy slug.
  1351 	 * to the taxonomy slug.
       
  1352 	 *
       
  1353 	 * Possible hook names include:
       
  1354 	 *
       
  1355 	 *  - `term_links-category`
       
  1356 	 *  - `term_links-post_tag`
       
  1357 	 *  - `term_links-post_format`
  1348 	 *
  1358 	 *
  1349 	 * @since 2.5.0
  1359 	 * @since 2.5.0
  1350 	 *
  1360 	 *
  1351 	 * @param string[] $links An array of term links.
  1361 	 * @param string[] $links An array of term links.
  1352 	 */
  1362 	 */