Edit File by line
/home/zeestwma/ceyloniy.../wp-inclu...
File: category-template.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Taxonomy API: Core category-specific template tags
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Template
[5] Fix | Delete
* @since 1.2.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Retrieves category link URL.
[10] Fix | Delete
*
[11] Fix | Delete
* @since 1.0.0
[12] Fix | Delete
*
[13] Fix | Delete
* @see get_term_link()
[14] Fix | Delete
*
[15] Fix | Delete
* @param int|object $category Category ID or object.
[16] Fix | Delete
* @return string Link on success, empty string if category does not exist.
[17] Fix | Delete
*/
[18] Fix | Delete
function get_category_link( $category ) {
[19] Fix | Delete
if ( ! is_object( $category ) ) {
[20] Fix | Delete
$category = (int) $category;
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
$category = get_term_link( $category );
[24] Fix | Delete
[25] Fix | Delete
if ( is_wp_error( $category ) ) {
[26] Fix | Delete
return '';
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
return $category;
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Retrieves category parents with separator.
[34] Fix | Delete
*
[35] Fix | Delete
* @since 1.2.0
[36] Fix | Delete
* @since 4.8.0 The `$visited` parameter was deprecated and renamed to `$deprecated`.
[37] Fix | Delete
*
[38] Fix | Delete
* @param int $category_id Category ID.
[39] Fix | Delete
* @param bool $link Optional. Whether to format with link. Default false.
[40] Fix | Delete
* @param string $separator Optional. How to separate categories. Default '/'.
[41] Fix | Delete
* @param bool $nicename Optional. Whether to use nice name for display. Default false.
[42] Fix | Delete
* @param array $deprecated Not used.
[43] Fix | Delete
* @return string|WP_Error A list of category parents on success, WP_Error on failure.
[44] Fix | Delete
*/
[45] Fix | Delete
function get_category_parents( $category_id, $link = false, $separator = '/', $nicename = false, $deprecated = array() ) {
[46] Fix | Delete
[47] Fix | Delete
if ( ! empty( $deprecated ) ) {
[48] Fix | Delete
_deprecated_argument( __FUNCTION__, '4.8.0' );
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
$format = $nicename ? 'slug' : 'name';
[52] Fix | Delete
[53] Fix | Delete
$args = array(
[54] Fix | Delete
'separator' => $separator,
[55] Fix | Delete
'link' => $link,
[56] Fix | Delete
'format' => $format,
[57] Fix | Delete
);
[58] Fix | Delete
[59] Fix | Delete
return get_term_parents_list( $category_id, 'category', $args );
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Retrieves post categories.
[64] Fix | Delete
*
[65] Fix | Delete
* This tag may be used outside The Loop by passing a post ID as the parameter.
[66] Fix | Delete
*
[67] Fix | Delete
* Note: This function only returns results from the default "category" taxonomy.
[68] Fix | Delete
* For custom taxonomies use get_the_terms().
[69] Fix | Delete
*
[70] Fix | Delete
* @since 0.71
[71] Fix | Delete
*
[72] Fix | Delete
* @param int|false $post_id Optional. The post ID. Defaults to current post ID.
[73] Fix | Delete
* @return WP_Term[] Array of WP_Term objects, one for each category assigned to the post.
[74] Fix | Delete
*/
[75] Fix | Delete
function get_the_category( $post_id = false ) {
[76] Fix | Delete
$categories = get_the_terms( $post_id, 'category' );
[77] Fix | Delete
if ( ! $categories || is_wp_error( $categories ) ) {
[78] Fix | Delete
$categories = array();
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
$categories = array_values( $categories );
[82] Fix | Delete
[83] Fix | Delete
foreach ( array_keys( $categories ) as $key ) {
[84] Fix | Delete
_make_cat_compat( $categories[ $key ] );
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Filters the array of categories to return for a post.
[89] Fix | Delete
*
[90] Fix | Delete
* @since 3.1.0
[91] Fix | Delete
* @since 4.4.0 Added the `$post_id` parameter.
[92] Fix | Delete
*
[93] Fix | Delete
* @param WP_Term[] $categories An array of categories to return for the post.
[94] Fix | Delete
* @param int|false $post_id The post ID.
[95] Fix | Delete
*/
[96] Fix | Delete
return apply_filters( 'get_the_categories', $categories, $post_id );
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Retrieves category name based on category ID.
[101] Fix | Delete
*
[102] Fix | Delete
* @since 0.71
[103] Fix | Delete
*
[104] Fix | Delete
* @param int $cat_id Category ID.
[105] Fix | Delete
* @return string|WP_Error Category name on success, WP_Error on failure.
[106] Fix | Delete
*/
[107] Fix | Delete
function get_the_category_by_ID( $cat_id ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
[108] Fix | Delete
$cat_id = (int) $cat_id;
[109] Fix | Delete
$category = get_term( $cat_id );
[110] Fix | Delete
[111] Fix | Delete
if ( is_wp_error( $category ) ) {
[112] Fix | Delete
return $category;
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
return ( $category ) ? $category->name : '';
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
/**
[119] Fix | Delete
* Retrieves category list for a post in either HTML list or custom format.
[120] Fix | Delete
*
[121] Fix | Delete
* Generally used for quick, delimited (e.g. comma-separated) lists of categories,
[122] Fix | Delete
* as part of a post entry meta.
[123] Fix | Delete
*
[124] Fix | Delete
* For a more powerful, list-based function, see wp_list_categories().
[125] Fix | Delete
*
[126] Fix | Delete
* @since 1.5.1
[127] Fix | Delete
*
[128] Fix | Delete
* @see wp_list_categories()
[129] Fix | Delete
*
[130] Fix | Delete
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
[131] Fix | Delete
*
[132] Fix | Delete
* @param string $separator Optional. Separator between the categories. By default, the links are placed
[133] Fix | Delete
* in an unordered list. An empty string will result in the default behavior.
[134] Fix | Delete
* @param string $parents Optional. How to display the parents. Accepts 'multiple', 'single', or empty.
[135] Fix | Delete
* Default empty string.
[136] Fix | Delete
* @param int|false $post_id Optional. ID of the post to retrieve categories for. Defaults to the current post.
[137] Fix | Delete
* @return string Category list for a post.
[138] Fix | Delete
*/
[139] Fix | Delete
function get_the_category_list( $separator = '', $parents = '', $post_id = false ) {
[140] Fix | Delete
global $wp_rewrite;
[141] Fix | Delete
[142] Fix | Delete
if ( ! is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) ) {
[143] Fix | Delete
/** This filter is documented in wp-includes/category-template.php */
[144] Fix | Delete
return apply_filters( 'the_category', '', $separator, $parents );
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
/**
[148] Fix | Delete
* Filters the categories before building the category list.
[149] Fix | Delete
*
[150] Fix | Delete
* @since 4.4.0
[151] Fix | Delete
*
[152] Fix | Delete
* @param WP_Term[] $categories An array of the post's categories.
[153] Fix | Delete
* @param int|false $post_id ID of the post to retrieve categories for.
[154] Fix | Delete
* When `false`, defaults to the current post in the loop.
[155] Fix | Delete
*/
[156] Fix | Delete
$categories = apply_filters( 'the_category_list', get_the_category( $post_id ), $post_id );
[157] Fix | Delete
[158] Fix | Delete
if ( empty( $categories ) ) {
[159] Fix | Delete
/** This filter is documented in wp-includes/category-template.php */
[160] Fix | Delete
return apply_filters( 'the_category', __( 'Uncategorized' ), $separator, $parents );
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
[164] Fix | Delete
[165] Fix | Delete
$thelist = '';
[166] Fix | Delete
if ( '' === $separator ) {
[167] Fix | Delete
$thelist .= '<ul class="post-categories">';
[168] Fix | Delete
foreach ( $categories as $category ) {
[169] Fix | Delete
$thelist .= "\n\t<li>";
[170] Fix | Delete
switch ( strtolower( $parents ) ) {
[171] Fix | Delete
case 'multiple':
[172] Fix | Delete
if ( $category->parent ) {
[173] Fix | Delete
$thelist .= get_category_parents( $category->parent, true, $separator );
[174] Fix | Delete
}
[175] Fix | Delete
$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name . '</a></li>';
[176] Fix | Delete
break;
[177] Fix | Delete
case 'single':
[178] Fix | Delete
$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>';
[179] Fix | Delete
if ( $category->parent ) {
[180] Fix | Delete
$thelist .= get_category_parents( $category->parent, false, $separator );
[181] Fix | Delete
}
[182] Fix | Delete
$thelist .= $category->name . '</a></li>';
[183] Fix | Delete
break;
[184] Fix | Delete
case '':
[185] Fix | Delete
default:
[186] Fix | Delete
$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name . '</a></li>';
[187] Fix | Delete
}
[188] Fix | Delete
}
[189] Fix | Delete
$thelist .= '</ul>';
[190] Fix | Delete
} else {
[191] Fix | Delete
$i = 0;
[192] Fix | Delete
foreach ( $categories as $category ) {
[193] Fix | Delete
if ( 0 < $i ) {
[194] Fix | Delete
$thelist .= $separator;
[195] Fix | Delete
}
[196] Fix | Delete
switch ( strtolower( $parents ) ) {
[197] Fix | Delete
case 'multiple':
[198] Fix | Delete
if ( $category->parent ) {
[199] Fix | Delete
$thelist .= get_category_parents( $category->parent, true, $separator );
[200] Fix | Delete
}
[201] Fix | Delete
$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name . '</a>';
[202] Fix | Delete
break;
[203] Fix | Delete
case 'single':
[204] Fix | Delete
$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>';
[205] Fix | Delete
if ( $category->parent ) {
[206] Fix | Delete
$thelist .= get_category_parents( $category->parent, false, $separator );
[207] Fix | Delete
}
[208] Fix | Delete
$thelist .= "$category->name</a>";
[209] Fix | Delete
break;
[210] Fix | Delete
case '':
[211] Fix | Delete
default:
[212] Fix | Delete
$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name . '</a>';
[213] Fix | Delete
}
[214] Fix | Delete
++$i;
[215] Fix | Delete
}
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
/**
[219] Fix | Delete
* Filters the category or list of categories.
[220] Fix | Delete
*
[221] Fix | Delete
* @since 1.2.0
[222] Fix | Delete
*
[223] Fix | Delete
* @param string $thelist List of categories for the current post.
[224] Fix | Delete
* @param string $separator Separator used between the categories.
[225] Fix | Delete
* @param string $parents How to display the category parents. Accepts 'multiple',
[226] Fix | Delete
* 'single', or empty.
[227] Fix | Delete
*/
[228] Fix | Delete
return apply_filters( 'the_category', $thelist, $separator, $parents );
[229] Fix | Delete
}
[230] Fix | Delete
[231] Fix | Delete
/**
[232] Fix | Delete
* Checks if the current post is within any of the given categories.
[233] Fix | Delete
*
[234] Fix | Delete
* The given categories are checked against the post's categories' term_ids, names and slugs.
[235] Fix | Delete
* Categories given as integers will only be checked against the post's categories' term_ids.
[236] Fix | Delete
*
[237] Fix | Delete
* Prior to v2.5 of WordPress, category names were not supported.
[238] Fix | Delete
* Prior to v2.7, category slugs were not supported.
[239] Fix | Delete
* Prior to v2.7, only one category could be compared: in_category( $single_category ).
[240] Fix | Delete
* Prior to v2.7, this function could only be used in the WordPress Loop.
[241] Fix | Delete
* As of 2.7, the function can be used anywhere if it is provided a post ID or post object.
[242] Fix | Delete
*
[243] Fix | Delete
* For more information on this and similar theme functions, check out
[244] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[245] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[246] Fix | Delete
*
[247] Fix | Delete
* @since 1.2.0
[248] Fix | Delete
* @since 2.7.0 The `$post` parameter was added.
[249] Fix | Delete
*
[250] Fix | Delete
* @param int|string|int[]|string[] $category Category ID, name, slug, or array of such
[251] Fix | Delete
* to check against.
[252] Fix | Delete
* @param int|null|WP_Post $post Optional. Post to check. Defaults to the current post.
[253] Fix | Delete
* @return bool True if the current post is in any of the given categories.
[254] Fix | Delete
*/
[255] Fix | Delete
function in_category( $category, $post = null ) {
[256] Fix | Delete
if ( empty( $category ) ) {
[257] Fix | Delete
return false;
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
return has_category( $category, $post );
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
/**
[264] Fix | Delete
* Displays category list for a post in either HTML list or custom format.
[265] Fix | Delete
*
[266] Fix | Delete
* @since 0.71
[267] Fix | Delete
*
[268] Fix | Delete
* @param string $separator Optional. Separator between the categories. By default, the links are placed
[269] Fix | Delete
* in an unordered list. An empty string will result in the default behavior.
[270] Fix | Delete
* @param string $parents Optional. How to display the parents. Accepts 'multiple', 'single', or empty.
[271] Fix | Delete
* Default empty string.
[272] Fix | Delete
* @param int|false $post_id Optional. ID of the post to retrieve categories for. Defaults to the current post.
[273] Fix | Delete
*/
[274] Fix | Delete
function the_category( $separator = '', $parents = '', $post_id = false ) {
[275] Fix | Delete
echo get_the_category_list( $separator, $parents, $post_id );
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
/**
[279] Fix | Delete
* Retrieves category description.
[280] Fix | Delete
*
[281] Fix | Delete
* @since 1.0.0
[282] Fix | Delete
*
[283] Fix | Delete
* @param int $category Optional. Category ID. Defaults to the current category ID.
[284] Fix | Delete
* @return string Category description, if available.
[285] Fix | Delete
*/
[286] Fix | Delete
function category_description( $category = 0 ) {
[287] Fix | Delete
return term_description( $category );
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
/**
[291] Fix | Delete
* Displays or retrieves the HTML dropdown list of categories.
[292] Fix | Delete
*
[293] Fix | Delete
* The 'hierarchical' argument, which is disabled by default, will override the
[294] Fix | Delete
* depth argument, unless it is true. When the argument is false, it will
[295] Fix | Delete
* display all of the categories. When it is enabled it will use the value in
[296] Fix | Delete
* the 'depth' argument.
[297] Fix | Delete
*
[298] Fix | Delete
* @since 2.1.0
[299] Fix | Delete
* @since 4.2.0 Introduced the `value_field` argument.
[300] Fix | Delete
* @since 4.6.0 Introduced the `required` argument.
[301] Fix | Delete
* @since 6.1.0 Introduced the `aria_describedby` argument.
[302] Fix | Delete
*
[303] Fix | Delete
* @param array|string $args {
[304] Fix | Delete
* Optional. Array or string of arguments to generate a categories drop-down element. See WP_Term_Query::__construct()
[305] Fix | Delete
* for information on additional accepted arguments.
[306] Fix | Delete
*
[307] Fix | Delete
* @type string $show_option_all Text to display for showing all categories. Default empty.
[308] Fix | Delete
* @type string $show_option_none Text to display for showing no categories. Default empty.
[309] Fix | Delete
* @type string $option_none_value Value to use when no category is selected. Default empty.
[310] Fix | Delete
* @type string $orderby Which column to use for ordering categories. See get_terms() for a list
[311] Fix | Delete
* of accepted values. Default 'id' (term_id).
[312] Fix | Delete
* @type bool $pad_counts See get_terms() for an argument description. Default false.
[313] Fix | Delete
* @type bool|int $show_count Whether to include post counts. Accepts 0, 1, or their bool equivalents.
[314] Fix | Delete
* Default 0.
[315] Fix | Delete
* @type bool|int $echo Whether to echo or return the generated markup. Accepts 0, 1, or their
[316] Fix | Delete
* bool equivalents. Default 1.
[317] Fix | Delete
* @type bool|int $hierarchical Whether to traverse the taxonomy hierarchy. Accepts 0, 1, or their bool
[318] Fix | Delete
* equivalents. Default 0.
[319] Fix | Delete
* @type int $depth Maximum depth. Default 0.
[320] Fix | Delete
* @type int $tab_index Tab index for the select element. Default 0 (no tabindex).
[321] Fix | Delete
* @type string $name Value for the 'name' attribute of the select element. Default 'cat'.
[322] Fix | Delete
* @type string $id Value for the 'id' attribute of the select element. Defaults to the value
[323] Fix | Delete
* of `$name`.
[324] Fix | Delete
* @type string $class Value for the 'class' attribute of the select element. Default 'postform'.
[325] Fix | Delete
* @type int|string $selected Value of the option that should be selected. Default 0.
[326] Fix | Delete
* @type string $value_field Term field that should be used to populate the 'value' attribute
[327] Fix | Delete
* of the option elements. Accepts any valid term field: 'term_id', 'name',
[328] Fix | Delete
* 'slug', 'term_group', 'term_taxonomy_id', 'taxonomy', 'description',
[329] Fix | Delete
* 'parent', 'count'. Default 'term_id'.
[330] Fix | Delete
* @type string|array $taxonomy Name of the taxonomy or taxonomies to retrieve. Default 'category'.
[331] Fix | Delete
* @type bool $hide_if_empty True to skip generating markup if no categories are found.
[332] Fix | Delete
* Default false (create select element even if no categories are found).
[333] Fix | Delete
* @type bool $required Whether the `<select>` element should have the HTML5 'required' attribute.
[334] Fix | Delete
* Default false.
[335] Fix | Delete
* @type Walker $walker Walker object to use to build the output. Default empty which results in a
[336] Fix | Delete
* Walker_CategoryDropdown instance being used.
[337] Fix | Delete
* @type string $aria_describedby The 'id' of an element that contains descriptive text for the select.
[338] Fix | Delete
* Default empty string.
[339] Fix | Delete
* }
[340] Fix | Delete
* @return string HTML dropdown list of categories.
[341] Fix | Delete
*/
[342] Fix | Delete
function wp_dropdown_categories( $args = '' ) {
[343] Fix | Delete
$defaults = array(
[344] Fix | Delete
'show_option_all' => '',
[345] Fix | Delete
'show_option_none' => '',
[346] Fix | Delete
'orderby' => 'id',
[347] Fix | Delete
'order' => 'ASC',
[348] Fix | Delete
'show_count' => 0,
[349] Fix | Delete
'hide_empty' => 1,
[350] Fix | Delete
'child_of' => 0,
[351] Fix | Delete
'exclude' => '',
[352] Fix | Delete
'echo' => 1,
[353] Fix | Delete
'selected' => 0,
[354] Fix | Delete
'hierarchical' => 0,
[355] Fix | Delete
'name' => 'cat',
[356] Fix | Delete
'id' => '',
[357] Fix | Delete
'class' => 'postform',
[358] Fix | Delete
'depth' => 0,
[359] Fix | Delete
'tab_index' => 0,
[360] Fix | Delete
'taxonomy' => 'category',
[361] Fix | Delete
'hide_if_empty' => false,
[362] Fix | Delete
'option_none_value' => -1,
[363] Fix | Delete
'value_field' => 'term_id',
[364] Fix | Delete
'required' => false,
[365] Fix | Delete
'aria_describedby' => '',
[366] Fix | Delete
);
[367] Fix | Delete
[368] Fix | Delete
$defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0;
[369] Fix | Delete
[370] Fix | Delete
// Back compat.
[371] Fix | Delete
if ( isset( $args['type'] ) && 'link' === $args['type'] ) {
[372] Fix | Delete
_deprecated_argument(
[373] Fix | Delete
__FUNCTION__,
[374] Fix | Delete
'3.0.0',
[375] Fix | Delete
sprintf(
[376] Fix | Delete
/* translators: 1: "type => link", 2: "taxonomy => link_category" */
[377] Fix | Delete
__( '%1$s is deprecated. Use %2$s instead.' ),
[378] Fix | Delete
'<code>type => link</code>',
[379] Fix | Delete
'<code>taxonomy => link_category</code>'
[380] Fix | Delete
)
[381] Fix | Delete
);
[382] Fix | Delete
$args['taxonomy'] = 'link_category';
[383] Fix | Delete
}
[384] Fix | Delete
[385] Fix | Delete
// Parse incoming $args into an array and merge it with $defaults.
[386] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[387] Fix | Delete
[388] Fix | Delete
$option_none_value = $parsed_args['option_none_value'];
[389] Fix | Delete
[390] Fix | Delete
if ( ! isset( $parsed_args['pad_counts'] ) && $parsed_args['show_count'] && $parsed_args['hierarchical'] ) {
[391] Fix | Delete
$parsed_args['pad_counts'] = true;
[392] Fix | Delete
}
[393] Fix | Delete
[394] Fix | Delete
$tab_index = $parsed_args['tab_index'];
[395] Fix | Delete
[396] Fix | Delete
$tab_index_attribute = '';
[397] Fix | Delete
if ( (int) $tab_index > 0 ) {
[398] Fix | Delete
$tab_index_attribute = " tabindex=\"$tab_index\"";
[399] Fix | Delete
}
[400] Fix | Delete
[401] Fix | Delete
// Avoid clashes with the 'name' param of get_terms().
[402] Fix | Delete
$get_terms_args = $parsed_args;
[403] Fix | Delete
unset( $get_terms_args['name'] );
[404] Fix | Delete
$categories = get_terms( $get_terms_args );
[405] Fix | Delete
[406] Fix | Delete
$name = esc_attr( $parsed_args['name'] );
[407] Fix | Delete
$class = esc_attr( $parsed_args['class'] );
[408] Fix | Delete
$id = $parsed_args['id'] ? esc_attr( $parsed_args['id'] ) : $name;
[409] Fix | Delete
$required = $parsed_args['required'] ? 'required' : '';
[410] Fix | Delete
[411] Fix | Delete
$aria_describedby_attribute = $parsed_args['aria_describedby'] ? ' aria-describedby="' . esc_attr( $parsed_args['aria_describedby'] ) . '"' : '';
[412] Fix | Delete
[413] Fix | Delete
if ( ! $parsed_args['hide_if_empty'] || ! empty( $categories ) ) {
[414] Fix | Delete
$output = "<select $required name='$name' id='$id' class='$class'$tab_index_attribute$aria_describedby_attribute>\n";
[415] Fix | Delete
} else {
[416] Fix | Delete
$output = '';
[417] Fix | Delete
}
[418] Fix | Delete
if ( empty( $categories ) && ! $parsed_args['hide_if_empty'] && ! empty( $parsed_args['show_option_none'] ) ) {
[419] Fix | Delete
[420] Fix | Delete
/**
[421] Fix | Delete
* Filters a taxonomy drop-down display element.
[422] Fix | Delete
*
[423] Fix | Delete
* A variety of taxonomy drop-down display elements can be modified
[424] Fix | Delete
* just prior to display via this filter. Filterable arguments include
[425] Fix | Delete
* 'show_option_none', 'show_option_all', and various forms of the
[426] Fix | Delete
* term name.
[427] Fix | Delete
*
[428] Fix | Delete
* @since 1.2.0
[429] Fix | Delete
*
[430] Fix | Delete
* @see wp_dropdown_categories()
[431] Fix | Delete
*
[432] Fix | Delete
* @param string $element Category name.
[433] Fix | Delete
* @param WP_Term|null $category The category object, or null if there's no corresponding category.
[434] Fix | Delete
*/
[435] Fix | Delete
$show_option_none = apply_filters( 'list_cats', $parsed_args['show_option_none'], null );
[436] Fix | Delete
$output .= "\t<option value='" . esc_attr( $option_none_value ) . "' selected='selected'>$show_option_none</option>\n";
[437] Fix | Delete
}
[438] Fix | Delete
[439] Fix | Delete
if ( ! empty( $categories ) ) {
[440] Fix | Delete
[441] Fix | Delete
if ( $parsed_args['show_option_all'] ) {
[442] Fix | Delete
[443] Fix | Delete
/** This filter is documented in wp-includes/category-template.php */
[444] Fix | Delete
$show_option_all = apply_filters( 'list_cats', $parsed_args['show_option_all'], null );
[445] Fix | Delete
$selected = ( '0' === (string) $parsed_args['selected'] ) ? " selected='selected'" : '';
[446] Fix | Delete
$output .= "\t<option value='0'$selected>$show_option_all</option>\n";
[447] Fix | Delete
}
[448] Fix | Delete
[449] Fix | Delete
if ( $parsed_args['show_option_none'] ) {
[450] Fix | Delete
[451] Fix | Delete
/** This filter is documented in wp-includes/category-template.php */
[452] Fix | Delete
$show_option_none = apply_filters( 'list_cats', $parsed_args['show_option_none'], null );
[453] Fix | Delete
$selected = selected( $option_none_value, $parsed_args['selected'], false );
[454] Fix | Delete
$output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$selected>$show_option_none</option>\n";
[455] Fix | Delete
}
[456] Fix | Delete
[457] Fix | Delete
if ( $parsed_args['hierarchical'] ) {
[458] Fix | Delete
$depth = $parsed_args['depth']; // Walk the full depth.
[459] Fix | Delete
} else {
[460] Fix | Delete
$depth = -1; // Flat.
[461] Fix | Delete
}
[462] Fix | Delete
$output .= walk_category_dropdown_tree( $categories, $depth, $parsed_args );
[463] Fix | Delete
}
[464] Fix | Delete
[465] Fix | Delete
if ( ! $parsed_args['hide_if_empty'] || ! empty( $categories ) ) {
[466] Fix | Delete
$output .= "</select>\n";
[467] Fix | Delete
}
[468] Fix | Delete
[469] Fix | Delete
/**
[470] Fix | Delete
* Filters the taxonomy drop-down output.
[471] Fix | Delete
*
[472] Fix | Delete
* @since 2.1.0
[473] Fix | Delete
*
[474] Fix | Delete
* @param string $output HTML output.
[475] Fix | Delete
* @param array $parsed_args Arguments used to build the drop-down.
[476] Fix | Delete
*/
[477] Fix | Delete
$output = apply_filters( 'wp_dropdown_cats', $output, $parsed_args );
[478] Fix | Delete
[479] Fix | Delete
if ( $parsed_args['echo'] ) {
[480] Fix | Delete
echo $output;
[481] Fix | Delete
}
[482] Fix | Delete
[483] Fix | Delete
return $output;
[484] Fix | Delete
}
[485] Fix | Delete
[486] Fix | Delete
/**
[487] Fix | Delete
* Displays or retrieves the HTML list of categories.
[488] Fix | Delete
*
[489] Fix | Delete
* @since 2.1.0
[490] Fix | Delete
* @since 4.4.0 Introduced the `hide_title_if_empty` and `separator` arguments.
[491] Fix | Delete
* @since 4.4.0 The `current_category` argument was modified to optionally accept an array of values.
[492] Fix | Delete
* @since 6.1.0 Default value of the 'use_desc_for_title' argument was changed from 1 to 0.
[493] Fix | Delete
*
[494] Fix | Delete
* @param array|string $args {
[495] Fix | Delete
* Array of optional arguments. See get_categories(), get_terms(), and WP_Term_Query::__construct()
[496] Fix | Delete
* for information on additional accepted arguments.
[497] Fix | Delete
*
[498] Fix | Delete
* @type int|int[] $current_category ID of category, or array of IDs of categories, that should get the
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function