Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-inclu...
File: class-wp-term-query.php
)
[500] Fix | Delete
)
[501] Fix | Delete
);
[502] Fix | Delete
}
[503] Fix | Delete
[504] Fix | Delete
$exclusions = array_merge( $excluded_children, $exclusions );
[505] Fix | Delete
}
[506] Fix | Delete
[507] Fix | Delete
if ( ! empty( $exclude ) ) {
[508] Fix | Delete
$exclusions = array_merge( wp_parse_id_list( $exclude ), $exclusions );
[509] Fix | Delete
}
[510] Fix | Delete
[511] Fix | Delete
// 'childless' terms are those without an entry in the flattened term hierarchy.
[512] Fix | Delete
$childless = (bool) $args['childless'];
[513] Fix | Delete
if ( $childless ) {
[514] Fix | Delete
foreach ( $taxonomies as $_tax ) {
[515] Fix | Delete
$term_hierarchy = _get_term_hierarchy( $_tax );
[516] Fix | Delete
$exclusions = array_merge( array_keys( $term_hierarchy ), $exclusions );
[517] Fix | Delete
}
[518] Fix | Delete
}
[519] Fix | Delete
[520] Fix | Delete
if ( ! empty( $exclusions ) ) {
[521] Fix | Delete
$exclusions = 't.term_id NOT IN (' . implode( ',', array_map( 'intval', $exclusions ) ) . ')';
[522] Fix | Delete
} else {
[523] Fix | Delete
$exclusions = '';
[524] Fix | Delete
}
[525] Fix | Delete
[526] Fix | Delete
/**
[527] Fix | Delete
* Filters the terms to exclude from the terms query.
[528] Fix | Delete
*
[529] Fix | Delete
* @since 2.3.0
[530] Fix | Delete
*
[531] Fix | Delete
* @param string $exclusions `NOT IN` clause of the terms query.
[532] Fix | Delete
* @param array $args An array of terms query arguments.
[533] Fix | Delete
* @param string[] $taxonomies An array of taxonomy names.
[534] Fix | Delete
*/
[535] Fix | Delete
$exclusions = apply_filters( 'list_terms_exclusions', $exclusions, $args, $taxonomies );
[536] Fix | Delete
[537] Fix | Delete
if ( ! empty( $exclusions ) ) {
[538] Fix | Delete
// Strip leading 'AND'. Must do string manipulation here for backward compatibility with filter.
[539] Fix | Delete
$this->sql_clauses['where']['exclusions'] = preg_replace( '/^\s*AND\s*/', '', $exclusions );
[540] Fix | Delete
}
[541] Fix | Delete
[542] Fix | Delete
if ( '' === $args['name'] ) {
[543] Fix | Delete
$args['name'] = array();
[544] Fix | Delete
} else {
[545] Fix | Delete
$args['name'] = (array) $args['name'];
[546] Fix | Delete
}
[547] Fix | Delete
[548] Fix | Delete
if ( ! empty( $args['name'] ) ) {
[549] Fix | Delete
$names = $args['name'];
[550] Fix | Delete
[551] Fix | Delete
foreach ( $names as &$_name ) {
[552] Fix | Delete
// `sanitize_term_field()` returns slashed data.
[553] Fix | Delete
$_name = stripslashes( sanitize_term_field( 'name', $_name, 0, reset( $taxonomies ), 'db' ) );
[554] Fix | Delete
}
[555] Fix | Delete
[556] Fix | Delete
$this->sql_clauses['where']['name'] = "t.name IN ('" . implode( "', '", array_map( 'esc_sql', $names ) ) . "')";
[557] Fix | Delete
}
[558] Fix | Delete
[559] Fix | Delete
if ( '' === $args['slug'] ) {
[560] Fix | Delete
$args['slug'] = array();
[561] Fix | Delete
} else {
[562] Fix | Delete
$args['slug'] = array_map( 'sanitize_title', (array) $args['slug'] );
[563] Fix | Delete
}
[564] Fix | Delete
[565] Fix | Delete
if ( ! empty( $args['slug'] ) ) {
[566] Fix | Delete
$slug = implode( "', '", $args['slug'] );
[567] Fix | Delete
[568] Fix | Delete
$this->sql_clauses['where']['slug'] = "t.slug IN ('" . $slug . "')";
[569] Fix | Delete
}
[570] Fix | Delete
[571] Fix | Delete
if ( '' === $args['term_taxonomy_id'] ) {
[572] Fix | Delete
$args['term_taxonomy_id'] = array();
[573] Fix | Delete
} else {
[574] Fix | Delete
$args['term_taxonomy_id'] = array_map( 'intval', (array) $args['term_taxonomy_id'] );
[575] Fix | Delete
}
[576] Fix | Delete
[577] Fix | Delete
if ( ! empty( $args['term_taxonomy_id'] ) ) {
[578] Fix | Delete
$tt_ids = implode( ',', $args['term_taxonomy_id'] );
[579] Fix | Delete
[580] Fix | Delete
$this->sql_clauses['where']['term_taxonomy_id'] = "tt.term_taxonomy_id IN ({$tt_ids})";
[581] Fix | Delete
}
[582] Fix | Delete
[583] Fix | Delete
if ( ! empty( $args['name__like'] ) ) {
[584] Fix | Delete
$this->sql_clauses['where']['name__like'] = $wpdb->prepare(
[585] Fix | Delete
't.name LIKE %s',
[586] Fix | Delete
'%' . $wpdb->esc_like( $args['name__like'] ) . '%'
[587] Fix | Delete
);
[588] Fix | Delete
}
[589] Fix | Delete
[590] Fix | Delete
if ( ! empty( $args['description__like'] ) ) {
[591] Fix | Delete
$this->sql_clauses['where']['description__like'] = $wpdb->prepare(
[592] Fix | Delete
'tt.description LIKE %s',
[593] Fix | Delete
'%' . $wpdb->esc_like( $args['description__like'] ) . '%'
[594] Fix | Delete
);
[595] Fix | Delete
}
[596] Fix | Delete
[597] Fix | Delete
if ( '' === $args['object_ids'] ) {
[598] Fix | Delete
$args['object_ids'] = array();
[599] Fix | Delete
} else {
[600] Fix | Delete
$args['object_ids'] = array_map( 'intval', (array) $args['object_ids'] );
[601] Fix | Delete
}
[602] Fix | Delete
[603] Fix | Delete
if ( ! empty( $args['object_ids'] ) ) {
[604] Fix | Delete
$object_ids = implode( ', ', $args['object_ids'] );
[605] Fix | Delete
[606] Fix | Delete
$this->sql_clauses['where']['object_ids'] = "tr.object_id IN ($object_ids)";
[607] Fix | Delete
}
[608] Fix | Delete
[609] Fix | Delete
/*
[610] Fix | Delete
* When querying for object relationships, the 'count > 0' check
[611] Fix | Delete
* added by 'hide_empty' is superfluous.
[612] Fix | Delete
*/
[613] Fix | Delete
if ( ! empty( $args['object_ids'] ) ) {
[614] Fix | Delete
$args['hide_empty'] = false;
[615] Fix | Delete
}
[616] Fix | Delete
[617] Fix | Delete
if ( '' !== $parent ) {
[618] Fix | Delete
$parent = (int) $parent;
[619] Fix | Delete
$this->sql_clauses['where']['parent'] = "tt.parent = '$parent'";
[620] Fix | Delete
}
[621] Fix | Delete
[622] Fix | Delete
$hierarchical = $args['hierarchical'];
[623] Fix | Delete
if ( 'count' === $args['fields'] ) {
[624] Fix | Delete
$hierarchical = false;
[625] Fix | Delete
}
[626] Fix | Delete
if ( $args['hide_empty'] && ! $hierarchical ) {
[627] Fix | Delete
$this->sql_clauses['where']['count'] = 'tt.count > 0';
[628] Fix | Delete
}
[629] Fix | Delete
[630] Fix | Delete
$number = $args['number'];
[631] Fix | Delete
$offset = $args['offset'];
[632] Fix | Delete
[633] Fix | Delete
// Don't limit the query results when we have to descend the family tree.
[634] Fix | Delete
if ( $number && ! $hierarchical && ! $child_of && '' === $parent ) {
[635] Fix | Delete
if ( $offset ) {
[636] Fix | Delete
$limits = 'LIMIT ' . $offset . ',' . $number;
[637] Fix | Delete
} else {
[638] Fix | Delete
$limits = 'LIMIT ' . $number;
[639] Fix | Delete
}
[640] Fix | Delete
} else {
[641] Fix | Delete
$limits = '';
[642] Fix | Delete
}
[643] Fix | Delete
[644] Fix | Delete
if ( ! empty( $args['search'] ) ) {
[645] Fix | Delete
$this->sql_clauses['where']['search'] = $this->get_search_sql( $args['search'] );
[646] Fix | Delete
}
[647] Fix | Delete
[648] Fix | Delete
// Meta query support.
[649] Fix | Delete
$join = '';
[650] Fix | Delete
$distinct = '';
[651] Fix | Delete
[652] Fix | Delete
// Reparse meta_query query_vars, in case they were modified in a 'pre_get_terms' callback.
[653] Fix | Delete
$this->meta_query->parse_query_vars( $this->query_vars );
[654] Fix | Delete
$mq_sql = $this->meta_query->get_sql( 'term', 't', 'term_id' );
[655] Fix | Delete
$meta_clauses = $this->meta_query->get_clauses();
[656] Fix | Delete
[657] Fix | Delete
if ( ! empty( $meta_clauses ) ) {
[658] Fix | Delete
$join .= $mq_sql['join'];
[659] Fix | Delete
[660] Fix | Delete
// Strip leading 'AND'.
[661] Fix | Delete
$this->sql_clauses['where']['meta_query'] = preg_replace( '/^\s*AND\s*/', '', $mq_sql['where'] );
[662] Fix | Delete
[663] Fix | Delete
$distinct .= 'DISTINCT';
[664] Fix | Delete
[665] Fix | Delete
}
[666] Fix | Delete
[667] Fix | Delete
$selects = array();
[668] Fix | Delete
switch ( $args['fields'] ) {
[669] Fix | Delete
case 'count':
[670] Fix | Delete
$orderby = '';
[671] Fix | Delete
$order = '';
[672] Fix | Delete
$selects = array( 'COUNT(*)' );
[673] Fix | Delete
break;
[674] Fix | Delete
default:
[675] Fix | Delete
$selects = array( 't.term_id' );
[676] Fix | Delete
if ( 'all_with_object_id' === $args['fields'] && ! empty( $args['object_ids'] ) ) {
[677] Fix | Delete
$selects[] = 'tr.object_id';
[678] Fix | Delete
}
[679] Fix | Delete
break;
[680] Fix | Delete
}
[681] Fix | Delete
[682] Fix | Delete
$_fields = $args['fields'];
[683] Fix | Delete
[684] Fix | Delete
/**
[685] Fix | Delete
* Filters the fields to select in the terms query.
[686] Fix | Delete
*
[687] Fix | Delete
* Field lists modified using this filter will only modify the term fields returned
[688] Fix | Delete
* by the function when the `$fields` parameter set to 'count' or 'all'. In all other
[689] Fix | Delete
* cases, the term fields in the results array will be determined by the `$fields`
[690] Fix | Delete
* parameter alone.
[691] Fix | Delete
*
[692] Fix | Delete
* Use of this filter can result in unpredictable behavior, and is not recommended.
[693] Fix | Delete
*
[694] Fix | Delete
* @since 2.8.0
[695] Fix | Delete
*
[696] Fix | Delete
* @param string[] $selects An array of fields to select for the terms query.
[697] Fix | Delete
* @param array $args An array of term query arguments.
[698] Fix | Delete
* @param string[] $taxonomies An array of taxonomy names.
[699] Fix | Delete
*/
[700] Fix | Delete
$fields = implode( ', ', apply_filters( 'get_terms_fields', $selects, $args, $taxonomies ) );
[701] Fix | Delete
[702] Fix | Delete
$join .= " INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id";
[703] Fix | Delete
[704] Fix | Delete
if ( ! empty( $this->query_vars['object_ids'] ) ) {
[705] Fix | Delete
$join .= " INNER JOIN {$wpdb->term_relationships} AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id";
[706] Fix | Delete
$distinct = 'DISTINCT';
[707] Fix | Delete
}
[708] Fix | Delete
[709] Fix | Delete
$where = implode( ' AND ', $this->sql_clauses['where'] );
[710] Fix | Delete
[711] Fix | Delete
$pieces = array( 'fields', 'join', 'where', 'distinct', 'orderby', 'order', 'limits' );
[712] Fix | Delete
[713] Fix | Delete
/**
[714] Fix | Delete
* Filters the terms query SQL clauses.
[715] Fix | Delete
*
[716] Fix | Delete
* @since 3.1.0
[717] Fix | Delete
*
[718] Fix | Delete
* @param string[] $clauses {
[719] Fix | Delete
* Associative array of the clauses for the query.
[720] Fix | Delete
*
[721] Fix | Delete
* @type string $fields The SELECT clause of the query.
[722] Fix | Delete
* @type string $join The JOIN clause of the query.
[723] Fix | Delete
* @type string $where The WHERE clause of the query.
[724] Fix | Delete
* @type string $distinct The DISTINCT clause of the query.
[725] Fix | Delete
* @type string $orderby The ORDER BY clause of the query.
[726] Fix | Delete
* @type string $order The ORDER clause of the query.
[727] Fix | Delete
* @type string $limits The LIMIT clause of the query.
[728] Fix | Delete
* }
[729] Fix | Delete
* @param string[] $taxonomies An array of taxonomy names.
[730] Fix | Delete
* @param array $args An array of term query arguments.
[731] Fix | Delete
*/
[732] Fix | Delete
$clauses = apply_filters( 'terms_clauses', compact( $pieces ), $taxonomies, $args );
[733] Fix | Delete
[734] Fix | Delete
$fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
[735] Fix | Delete
$join = isset( $clauses['join'] ) ? $clauses['join'] : '';
[736] Fix | Delete
$where = isset( $clauses['where'] ) ? $clauses['where'] : '';
[737] Fix | Delete
$distinct = isset( $clauses['distinct'] ) ? $clauses['distinct'] : '';
[738] Fix | Delete
$orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : '';
[739] Fix | Delete
$order = isset( $clauses['order'] ) ? $clauses['order'] : '';
[740] Fix | Delete
$limits = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
[741] Fix | Delete
[742] Fix | Delete
$fields_is_filtered = implode( ', ', $selects ) !== $fields;
[743] Fix | Delete
[744] Fix | Delete
if ( $where ) {
[745] Fix | Delete
$where = "WHERE $where";
[746] Fix | Delete
}
[747] Fix | Delete
[748] Fix | Delete
$this->sql_clauses['select'] = "SELECT $distinct $fields";
[749] Fix | Delete
$this->sql_clauses['from'] = "FROM $wpdb->terms AS t $join";
[750] Fix | Delete
$this->sql_clauses['orderby'] = $orderby ? "$orderby $order" : '';
[751] Fix | Delete
$this->sql_clauses['limits'] = $limits;
[752] Fix | Delete
[753] Fix | Delete
// Beginning of the string is on a new line to prevent leading whitespace. See https://core.trac.wordpress.org/ticket/56841.
[754] Fix | Delete
$this->request =
[755] Fix | Delete
"{$this->sql_clauses['select']}
[756] Fix | Delete
{$this->sql_clauses['from']}
[757] Fix | Delete
{$where}
[758] Fix | Delete
{$this->sql_clauses['orderby']}
[759] Fix | Delete
{$this->sql_clauses['limits']}";
[760] Fix | Delete
[761] Fix | Delete
$this->terms = null;
[762] Fix | Delete
[763] Fix | Delete
/**
[764] Fix | Delete
* Filters the terms array before the query takes place.
[765] Fix | Delete
*
[766] Fix | Delete
* Return a non-null value to bypass WordPress' default term queries.
[767] Fix | Delete
*
[768] Fix | Delete
* @since 5.3.0
[769] Fix | Delete
*
[770] Fix | Delete
* @param array|null $terms Return an array of term data to short-circuit WP's term query,
[771] Fix | Delete
* or null to allow WP queries to run normally.
[772] Fix | Delete
* @param WP_Term_Query $query The WP_Term_Query instance, passed by reference.
[773] Fix | Delete
*/
[774] Fix | Delete
$this->terms = apply_filters_ref_array( 'terms_pre_query', array( $this->terms, &$this ) );
[775] Fix | Delete
[776] Fix | Delete
if ( null !== $this->terms ) {
[777] Fix | Delete
return $this->terms;
[778] Fix | Delete
}
[779] Fix | Delete
[780] Fix | Delete
if ( $args['cache_results'] ) {
[781] Fix | Delete
$cache_key = $this->generate_cache_key( $args, $this->request );
[782] Fix | Delete
$cache = wp_cache_get( $cache_key, 'term-queries' );
[783] Fix | Delete
[784] Fix | Delete
if ( false !== $cache ) {
[785] Fix | Delete
if ( 'ids' === $_fields ) {
[786] Fix | Delete
$cache = array_map( 'intval', $cache );
[787] Fix | Delete
} elseif ( 'count' !== $_fields ) {
[788] Fix | Delete
if ( ( 'all_with_object_id' === $_fields && ! empty( $args['object_ids'] ) )
[789] Fix | Delete
|| ( 'all' === $_fields && $args['pad_counts'] || $fields_is_filtered )
[790] Fix | Delete
) {
[791] Fix | Delete
$term_ids = wp_list_pluck( $cache, 'term_id' );
[792] Fix | Delete
} else {
[793] Fix | Delete
$term_ids = array_map( 'intval', $cache );
[794] Fix | Delete
}
[795] Fix | Delete
[796] Fix | Delete
_prime_term_caches( $term_ids, $args['update_term_meta_cache'] );
[797] Fix | Delete
[798] Fix | Delete
$term_objects = $this->populate_terms( $cache );
[799] Fix | Delete
$cache = $this->format_terms( $term_objects, $_fields );
[800] Fix | Delete
}
[801] Fix | Delete
[802] Fix | Delete
$this->terms = $cache;
[803] Fix | Delete
return $this->terms;
[804] Fix | Delete
}
[805] Fix | Delete
}
[806] Fix | Delete
[807] Fix | Delete
if ( 'count' === $_fields ) {
[808] Fix | Delete
$count = $wpdb->get_var( $this->request ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
[809] Fix | Delete
if ( $args['cache_results'] ) {
[810] Fix | Delete
wp_cache_set( $cache_key, $count, 'term-queries' );
[811] Fix | Delete
}
[812] Fix | Delete
return $count;
[813] Fix | Delete
}
[814] Fix | Delete
[815] Fix | Delete
$terms = $wpdb->get_results( $this->request ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
[816] Fix | Delete
[817] Fix | Delete
if ( empty( $terms ) ) {
[818] Fix | Delete
if ( $args['cache_results'] ) {
[819] Fix | Delete
wp_cache_add( $cache_key, array(), 'term-queries' );
[820] Fix | Delete
}
[821] Fix | Delete
return array();
[822] Fix | Delete
}
[823] Fix | Delete
[824] Fix | Delete
$term_ids = wp_list_pluck( $terms, 'term_id' );
[825] Fix | Delete
_prime_term_caches( $term_ids, false );
[826] Fix | Delete
$term_objects = $this->populate_terms( $terms );
[827] Fix | Delete
[828] Fix | Delete
if ( $child_of ) {
[829] Fix | Delete
foreach ( $taxonomies as $_tax ) {
[830] Fix | Delete
$children = _get_term_hierarchy( $_tax );
[831] Fix | Delete
if ( ! empty( $children ) ) {
[832] Fix | Delete
$term_objects = _get_term_children( $child_of, $term_objects, $_tax );
[833] Fix | Delete
}
[834] Fix | Delete
}
[835] Fix | Delete
}
[836] Fix | Delete
[837] Fix | Delete
// Update term counts to include children.
[838] Fix | Delete
if ( $args['pad_counts'] && 'all' === $_fields ) {
[839] Fix | Delete
foreach ( $taxonomies as $_tax ) {
[840] Fix | Delete
_pad_term_counts( $term_objects, $_tax );
[841] Fix | Delete
}
[842] Fix | Delete
}
[843] Fix | Delete
[844] Fix | Delete
// Make sure we show empty categories that have children.
[845] Fix | Delete
if ( $hierarchical && $args['hide_empty'] && is_array( $term_objects ) ) {
[846] Fix | Delete
foreach ( $term_objects as $k => $term ) {
[847] Fix | Delete
if ( ! $term->count ) {
[848] Fix | Delete
$children = get_term_children( $term->term_id, $term->taxonomy );
[849] Fix | Delete
[850] Fix | Delete
if ( is_array( $children ) ) {
[851] Fix | Delete
foreach ( $children as $child_id ) {
[852] Fix | Delete
$child = get_term( $child_id, $term->taxonomy );
[853] Fix | Delete
if ( $child->count ) {
[854] Fix | Delete
continue 2;
[855] Fix | Delete
}
[856] Fix | Delete
}
[857] Fix | Delete
}
[858] Fix | Delete
[859] Fix | Delete
// It really is empty.
[860] Fix | Delete
unset( $term_objects[ $k ] );
[861] Fix | Delete
}
[862] Fix | Delete
}
[863] Fix | Delete
}
[864] Fix | Delete
[865] Fix | Delete
// Hierarchical queries are not limited, so 'offset' and 'number' must be handled now.
[866] Fix | Delete
if ( $hierarchical && $number && is_array( $term_objects ) ) {
[867] Fix | Delete
if ( $offset >= count( $term_objects ) ) {
[868] Fix | Delete
$term_objects = array();
[869] Fix | Delete
} else {
[870] Fix | Delete
$term_objects = array_slice( $term_objects, $offset, $number, true );
[871] Fix | Delete
}
[872] Fix | Delete
}
[873] Fix | Delete
[874] Fix | Delete
// Prime termmeta cache.
[875] Fix | Delete
if ( $args['update_term_meta_cache'] ) {
[876] Fix | Delete
$term_ids = wp_list_pluck( $term_objects, 'term_id' );
[877] Fix | Delete
wp_lazyload_term_meta( $term_ids );
[878] Fix | Delete
}
[879] Fix | Delete
[880] Fix | Delete
if ( 'all_with_object_id' === $_fields && ! empty( $args['object_ids'] ) ) {
[881] Fix | Delete
$term_cache = array();
[882] Fix | Delete
foreach ( $term_objects as $term ) {
[883] Fix | Delete
$object = new stdClass();
[884] Fix | Delete
$object->term_id = $term->term_id;
[885] Fix | Delete
$object->object_id = $term->object_id;
[886] Fix | Delete
$term_cache[] = $object;
[887] Fix | Delete
}
[888] Fix | Delete
} elseif ( 'all' === $_fields && $args['pad_counts'] ) {
[889] Fix | Delete
$term_cache = array();
[890] Fix | Delete
foreach ( $term_objects as $term ) {
[891] Fix | Delete
$object = new stdClass();
[892] Fix | Delete
$object->term_id = $term->term_id;
[893] Fix | Delete
$object->count = $term->count;
[894] Fix | Delete
$term_cache[] = $object;
[895] Fix | Delete
}
[896] Fix | Delete
} elseif ( $fields_is_filtered ) {
[897] Fix | Delete
$term_cache = $term_objects;
[898] Fix | Delete
} else {
[899] Fix | Delete
$term_cache = wp_list_pluck( $term_objects, 'term_id' );
[900] Fix | Delete
}
[901] Fix | Delete
[902] Fix | Delete
if ( $args['cache_results'] ) {
[903] Fix | Delete
wp_cache_add( $cache_key, $term_cache, 'term-queries' );
[904] Fix | Delete
}
[905] Fix | Delete
[906] Fix | Delete
$this->terms = $this->format_terms( $term_objects, $_fields );
[907] Fix | Delete
[908] Fix | Delete
return $this->terms;
[909] Fix | Delete
}
[910] Fix | Delete
[911] Fix | Delete
/**
[912] Fix | Delete
* Parse and sanitize 'orderby' keys passed to the term query.
[913] Fix | Delete
*
[914] Fix | Delete
* @since 4.6.0
[915] Fix | Delete
*
[916] Fix | Delete
* @param string $orderby_raw Alias for the field to order by.
[917] Fix | Delete
* @return string|false Value to used in the ORDER clause. False otherwise.
[918] Fix | Delete
*/
[919] Fix | Delete
protected function parse_orderby( $orderby_raw ) {
[920] Fix | Delete
$_orderby = strtolower( $orderby_raw );
[921] Fix | Delete
$maybe_orderby_meta = false;
[922] Fix | Delete
[923] Fix | Delete
if ( in_array( $_orderby, array( 'term_id', 'name', 'slug', 'term_group' ), true ) ) {
[924] Fix | Delete
$orderby = "t.$_orderby";
[925] Fix | Delete
} elseif ( in_array( $_orderby, array( 'count', 'parent', 'taxonomy', 'term_taxonomy_id', 'description' ), true ) ) {
[926] Fix | Delete
$orderby = "tt.$_orderby";
[927] Fix | Delete
} elseif ( 'term_order' === $_orderby ) {
[928] Fix | Delete
$orderby = 'tr.term_order';
[929] Fix | Delete
} elseif ( 'include' === $_orderby && ! empty( $this->query_vars['include'] ) ) {
[930] Fix | Delete
$include = implode( ',', wp_parse_id_list( $this->query_vars['include'] ) );
[931] Fix | Delete
$orderby = "FIELD( t.term_id, $include )";
[932] Fix | Delete
} elseif ( 'slug__in' === $_orderby && ! empty( $this->query_vars['slug'] ) && is_array( $this->query_vars['slug'] ) ) {
[933] Fix | Delete
$slugs = implode( "', '", array_map( 'sanitize_title_for_query', $this->query_vars['slug'] ) );
[934] Fix | Delete
$orderby = "FIELD( t.slug, '" . $slugs . "')";
[935] Fix | Delete
} elseif ( 'none' === $_orderby ) {
[936] Fix | Delete
$orderby = '';
[937] Fix | Delete
} elseif ( empty( $_orderby ) || 'id' === $_orderby || 'term_id' === $_orderby ) {
[938] Fix | Delete
$orderby = 't.term_id';
[939] Fix | Delete
} else {
[940] Fix | Delete
$orderby = 't.name';
[941] Fix | Delete
[942] Fix | Delete
// This may be a value of orderby related to meta.
[943] Fix | Delete
$maybe_orderby_meta = true;
[944] Fix | Delete
}
[945] Fix | Delete
[946] Fix | Delete
/**
[947] Fix | Delete
* Filters the ORDERBY clause of the terms query.
[948] Fix | Delete
*
[949] Fix | Delete
* @since 2.8.0
[950] Fix | Delete
*
[951] Fix | Delete
* @param string $orderby `ORDERBY` clause of the terms query.
[952] Fix | Delete
* @param array $args An array of term query arguments.
[953] Fix | Delete
* @param string[] $taxonomies An array of taxonomy names.
[954] Fix | Delete
*/
[955] Fix | Delete
$orderby = apply_filters( 'get_terms_orderby', $orderby, $this->query_vars, $this->query_vars['taxonomy'] );
[956] Fix | Delete
[957] Fix | Delete
// Run after the 'get_terms_orderby' filter for backward compatibility.
[958] Fix | Delete
if ( $maybe_orderby_meta ) {
[959] Fix | Delete
$maybe_orderby_meta = $this->parse_orderby_meta( $_orderby );
[960] Fix | Delete
if ( $maybe_orderby_meta ) {
[961] Fix | Delete
$orderby = $maybe_orderby_meta;
[962] Fix | Delete
}
[963] Fix | Delete
}
[964] Fix | Delete
[965] Fix | Delete
return $orderby;
[966] Fix | Delete
}
[967] Fix | Delete
[968] Fix | Delete
/**
[969] Fix | Delete
* Format response depending on field requested.
[970] Fix | Delete
*
[971] Fix | Delete
* @since 6.0.0
[972] Fix | Delete
*
[973] Fix | Delete
* @param WP_Term[] $term_objects Array of term objects.
[974] Fix | Delete
* @param string $_fields Field to format.
[975] Fix | Delete
*
[976] Fix | Delete
* @return WP_Term[]|int[]|string[] Array of terms / strings / ints depending on field requested.
[977] Fix | Delete
*/
[978] Fix | Delete
protected function format_terms( $term_objects, $_fields ) {
[979] Fix | Delete
$_terms = array();
[980] Fix | Delete
if ( 'id=>parent' === $_fields ) {
[981] Fix | Delete
foreach ( $term_objects as $term ) {
[982] Fix | Delete
$_terms[ $term->term_id ] = $term->parent;
[983] Fix | Delete
}
[984] Fix | Delete
} elseif ( 'ids' === $_fields ) {
[985] Fix | Delete
foreach ( $term_objects as $term ) {
[986] Fix | Delete
$_terms[] = (int) $term->term_id;
[987] Fix | Delete
}
[988] Fix | Delete
} elseif ( 'tt_ids' === $_fields ) {
[989] Fix | Delete
foreach ( $term_objects as $term ) {
[990] Fix | Delete
$_terms[] = (int) $term->term_taxonomy_id;
[991] Fix | Delete
}
[992] Fix | Delete
} elseif ( 'names' === $_fields ) {
[993] Fix | Delete
foreach ( $term_objects as $term ) {
[994] Fix | Delete
$_terms[] = $term->name;
[995] Fix | Delete
}
[996] Fix | Delete
} elseif ( 'slugs' === $_fields ) {
[997] Fix | Delete
foreach ( $term_objects as $term ) {
[998] Fix | Delete
$_terms[] = $term->slug;
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function