wppaste
WordPress

Walker_Category::start_el( string $output, WP_Term $data_object, int $depth = 0, array $args = array(), int $current_object_id = 0 )

Since
2.1.0, 5.9.0
Source
wp-includes/class-walker-category.php:101
Starts the element output.

Parameters

$outputstring
Used to append additional content (passed by reference).
$data_objectWP_Term
Category data object.
$depthintoptional
Depth of category in reference to parents. Default 0.Default: 0
$argsarrayoptional
An array of arguments. See wp_list_categories(). Default empty array.Default: array()
$current_object_idintoptional
ID of the current category. Default 0.Default: 0

Hooks fired · 4

4 hooks fire while Walker_Category::start_el() runs, in this order:

  1. apply_filters( list_cats )filterline 106 (+5 into the body)

    Filters a taxonomy drop-down display element.

  2. apply_filters( category_description )filterline 125 (+24 into the body)

    Filters the category description for display.

  3. apply_filters( category_list_link_attributes )filterline 144 (+43 into the body)

    Filters the HTML attributes applied to a category list item's anchor element.

  4. apply_filters( category_css_class )filterline 245 (+144 into the body)

    Filters the list of CSS classes to include with each category in the list.

Uses · 9

Source

	public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {		// Restores the more descriptive, specific name for use within this method.		$category = $data_object; 		/** This filter is documented in wp-includes/category-template.php */		$cat_name = apply_filters( 'list_cats', esc_attr( $category->name ), $category ); 		// Don't generate an element if the category name is empty.		if ( '' === $cat_name ) {			return;		} 		$atts         = array();		$atts['href'] = get_term_link( $category ); 		if ( $args['use_desc_for_title'] && ! empty( $category->description ) ) {			/**			 * Filters the category description for display.			 *			 * @since 1.2.0			 *			 * @param string  $description Category description.			 * @param WP_Term $category    Category object.			 */			$atts['title'] = strip_tags( apply_filters( 'category_description', $category->description, $category ) );		} 		/**		 * Filters the HTML attributes applied to a category list item's anchor element.		 *		 * @since 5.2.0		 *		 * @param array   $atts {		 *     The HTML attributes applied to the list item's `<a>` element, empty strings are ignored.		 *		 *     @type string $href  The href attribute.		 *     @type string $title The title attribute.		 * }		 * @param WP_Term $category          Term data object.		 * @param int     $depth             Depth of category, used for padding.		 * @param array   $args              An array of arguments.		 * @param int     $current_object_id ID of the current category.		 */		$atts = apply_filters( 'category_list_link_attributes', $atts, $category, $depth, $args, $current_object_id ); 		$attributes = '';		foreach ( $atts as $attr => $value ) {			if ( is_scalar( $value ) && '' !== $value && false !== $value ) {				$value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );				$attributes .= ' ' . $attr . '="' . $value . '"';			}		} 		$link = sprintf(			'<a%s>%s</a>',			$attributes,			$cat_name		); 		if ( ! empty( $args['feed_image'] ) || ! empty( $args['feed'] ) ) {			$link .= ' '; 			if ( empty( $args['feed_image'] ) ) {				$link .= '(';			} 			$link .= '<a href="' . esc_url( get_term_feed_link( $category, $category->taxonomy, $args['feed_type'] ) ) . '"'; 			if ( empty( $args['feed'] ) ) {				/* translators: %s: Category name. */				$alt = ' alt="' . sprintf( __( 'Feed for all posts filed under %s' ), $cat_name ) . '"';			} else {				$alt   = ' alt="' . $args['feed'] . '"';				$name  = $args['feed'];				$link .= empty( $args['title'] ) ? '' : $args['title'];			} 			$link .= '>'; 			if ( empty( $args['feed_image'] ) ) {

History

Introduced in 2.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.9.0
Renamed $category to $data_object and $id to $current_object_id to match parent class for PHP 8 named parameter support.from the docblock
2.1.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/class-walker-category.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.