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/clone/wp-inclu...
File: taxonomy.php
* attached to other object types, such as users.
[500] Fix | Delete
* @type string|array $default_term {
[501] Fix | Delete
* Default term to be used for the taxonomy.
[502] Fix | Delete
*
[503] Fix | Delete
* @type string $name Name of default term.
[504] Fix | Delete
* @type string $slug Slug for default term. Default empty.
[505] Fix | Delete
* @type string $description Description for default term. Default empty.
[506] Fix | Delete
* }
[507] Fix | Delete
* @type bool $sort Whether terms in this taxonomy should be sorted in the order they are
[508] Fix | Delete
* provided to `wp_set_object_terms()`. Default null which equates to false.
[509] Fix | Delete
* @type array $args Array of arguments to automatically use inside `wp_get_object_terms()`
[510] Fix | Delete
* for this taxonomy.
[511] Fix | Delete
* @type bool $_builtin This taxonomy is a "built-in" taxonomy. INTERNAL USE ONLY!
[512] Fix | Delete
* Default false.
[513] Fix | Delete
* }
[514] Fix | Delete
* @return WP_Taxonomy|WP_Error The registered taxonomy object on success, WP_Error object on failure.
[515] Fix | Delete
*/
[516] Fix | Delete
function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
[517] Fix | Delete
global $wp_taxonomies;
[518] Fix | Delete
[519] Fix | Delete
if ( ! is_array( $wp_taxonomies ) ) {
[520] Fix | Delete
$wp_taxonomies = array();
[521] Fix | Delete
}
[522] Fix | Delete
[523] Fix | Delete
$args = wp_parse_args( $args );
[524] Fix | Delete
[525] Fix | Delete
if ( empty( $taxonomy ) || strlen( $taxonomy ) > 32 ) {
[526] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Taxonomy names must be between 1 and 32 characters in length.' ), '4.2.0' );
[527] Fix | Delete
return new WP_Error( 'taxonomy_length_invalid', __( 'Taxonomy names must be between 1 and 32 characters in length.' ) );
[528] Fix | Delete
}
[529] Fix | Delete
[530] Fix | Delete
$taxonomy_object = new WP_Taxonomy( $taxonomy, $object_type, $args );
[531] Fix | Delete
$taxonomy_object->add_rewrite_rules();
[532] Fix | Delete
[533] Fix | Delete
$wp_taxonomies[ $taxonomy ] = $taxonomy_object;
[534] Fix | Delete
[535] Fix | Delete
$taxonomy_object->add_hooks();
[536] Fix | Delete
[537] Fix | Delete
// Add default term.
[538] Fix | Delete
if ( ! empty( $taxonomy_object->default_term ) ) {
[539] Fix | Delete
$term = term_exists( $taxonomy_object->default_term['name'], $taxonomy );
[540] Fix | Delete
if ( $term ) {
[541] Fix | Delete
update_option( 'default_term_' . $taxonomy_object->name, $term['term_id'] );
[542] Fix | Delete
} else {
[543] Fix | Delete
$term = wp_insert_term(
[544] Fix | Delete
$taxonomy_object->default_term['name'],
[545] Fix | Delete
$taxonomy,
[546] Fix | Delete
array(
[547] Fix | Delete
'slug' => sanitize_title( $taxonomy_object->default_term['slug'] ),
[548] Fix | Delete
'description' => $taxonomy_object->default_term['description'],
[549] Fix | Delete
)
[550] Fix | Delete
);
[551] Fix | Delete
[552] Fix | Delete
// Update `term_id` in options.
[553] Fix | Delete
if ( ! is_wp_error( $term ) ) {
[554] Fix | Delete
update_option( 'default_term_' . $taxonomy_object->name, $term['term_id'] );
[555] Fix | Delete
}
[556] Fix | Delete
}
[557] Fix | Delete
}
[558] Fix | Delete
[559] Fix | Delete
/**
[560] Fix | Delete
* Fires after a taxonomy is registered.
[561] Fix | Delete
*
[562] Fix | Delete
* @since 3.3.0
[563] Fix | Delete
*
[564] Fix | Delete
* @param string $taxonomy Taxonomy slug.
[565] Fix | Delete
* @param array|string $object_type Object type or array of object types.
[566] Fix | Delete
* @param array $args Array of taxonomy registration arguments.
[567] Fix | Delete
*/
[568] Fix | Delete
do_action( 'registered_taxonomy', $taxonomy, $object_type, (array) $taxonomy_object );
[569] Fix | Delete
[570] Fix | Delete
/**
[571] Fix | Delete
* Fires after a specific taxonomy is registered.
[572] Fix | Delete
*
[573] Fix | Delete
* The dynamic portion of the filter name, `$taxonomy`, refers to the taxonomy key.
[574] Fix | Delete
*
[575] Fix | Delete
* Possible hook names include:
[576] Fix | Delete
*
[577] Fix | Delete
* - `registered_taxonomy_category`
[578] Fix | Delete
* - `registered_taxonomy_post_tag`
[579] Fix | Delete
*
[580] Fix | Delete
* @since 6.0.0
[581] Fix | Delete
*
[582] Fix | Delete
* @param string $taxonomy Taxonomy slug.
[583] Fix | Delete
* @param array|string $object_type Object type or array of object types.
[584] Fix | Delete
* @param array $args Array of taxonomy registration arguments.
[585] Fix | Delete
*/
[586] Fix | Delete
do_action( "registered_taxonomy_{$taxonomy}", $taxonomy, $object_type, (array) $taxonomy_object );
[587] Fix | Delete
[588] Fix | Delete
return $taxonomy_object;
[589] Fix | Delete
}
[590] Fix | Delete
[591] Fix | Delete
/**
[592] Fix | Delete
* Unregisters a taxonomy.
[593] Fix | Delete
*
[594] Fix | Delete
* Can not be used to unregister built-in taxonomies.
[595] Fix | Delete
*
[596] Fix | Delete
* @since 4.5.0
[597] Fix | Delete
*
[598] Fix | Delete
* @global WP_Taxonomy[] $wp_taxonomies List of taxonomies.
[599] Fix | Delete
*
[600] Fix | Delete
* @param string $taxonomy Taxonomy name.
[601] Fix | Delete
* @return true|WP_Error True on success, WP_Error on failure or if the taxonomy doesn't exist.
[602] Fix | Delete
*/
[603] Fix | Delete
function unregister_taxonomy( $taxonomy ) {
[604] Fix | Delete
global $wp_taxonomies;
[605] Fix | Delete
[606] Fix | Delete
if ( ! taxonomy_exists( $taxonomy ) ) {
[607] Fix | Delete
return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
[608] Fix | Delete
}
[609] Fix | Delete
[610] Fix | Delete
$taxonomy_object = get_taxonomy( $taxonomy );
[611] Fix | Delete
[612] Fix | Delete
// Do not allow unregistering internal taxonomies.
[613] Fix | Delete
if ( $taxonomy_object->_builtin ) {
[614] Fix | Delete
return new WP_Error( 'invalid_taxonomy', __( 'Unregistering a built-in taxonomy is not allowed.' ) );
[615] Fix | Delete
}
[616] Fix | Delete
[617] Fix | Delete
$taxonomy_object->remove_rewrite_rules();
[618] Fix | Delete
$taxonomy_object->remove_hooks();
[619] Fix | Delete
[620] Fix | Delete
// Remove the taxonomy.
[621] Fix | Delete
unset( $wp_taxonomies[ $taxonomy ] );
[622] Fix | Delete
[623] Fix | Delete
/**
[624] Fix | Delete
* Fires after a taxonomy is unregistered.
[625] Fix | Delete
*
[626] Fix | Delete
* @since 4.5.0
[627] Fix | Delete
*
[628] Fix | Delete
* @param string $taxonomy Taxonomy name.
[629] Fix | Delete
*/
[630] Fix | Delete
do_action( 'unregistered_taxonomy', $taxonomy );
[631] Fix | Delete
[632] Fix | Delete
return true;
[633] Fix | Delete
}
[634] Fix | Delete
[635] Fix | Delete
/**
[636] Fix | Delete
* Builds an object with all taxonomy labels out of a taxonomy object.
[637] Fix | Delete
*
[638] Fix | Delete
* @since 3.0.0
[639] Fix | Delete
* @since 4.3.0 Added the `no_terms` label.
[640] Fix | Delete
* @since 4.4.0 Added the `items_list_navigation` and `items_list` labels.
[641] Fix | Delete
* @since 4.9.0 Added the `most_used` and `back_to_items` labels.
[642] Fix | Delete
* @since 5.7.0 Added the `filter_by_item` label.
[643] Fix | Delete
* @since 5.8.0 Added the `item_link` and `item_link_description` labels.
[644] Fix | Delete
* @since 5.9.0 Added the `name_field_description`, `slug_field_description`,
[645] Fix | Delete
* `parent_field_description`, and `desc_field_description` labels.
[646] Fix | Delete
* @since 6.6.0 Added the `template_name` label.
[647] Fix | Delete
*
[648] Fix | Delete
* @param WP_Taxonomy $tax Taxonomy object.
[649] Fix | Delete
* @return object {
[650] Fix | Delete
* Taxonomy labels object. The first default value is for non-hierarchical taxonomies
[651] Fix | Delete
* (like tags) and the second one is for hierarchical taxonomies (like categories).
[652] Fix | Delete
*
[653] Fix | Delete
* @type string $name General name for the taxonomy, usually plural. The same
[654] Fix | Delete
* as and overridden by `$tax->label`. Default 'Tags'/'Categories'.
[655] Fix | Delete
* @type string $singular_name Name for one object of this taxonomy. Default 'Tag'/'Category'.
[656] Fix | Delete
* @type string $search_items Default 'Search Tags'/'Search Categories'.
[657] Fix | Delete
* @type string $popular_items This label is only used for non-hierarchical taxonomies.
[658] Fix | Delete
* Default 'Popular Tags'.
[659] Fix | Delete
* @type string $all_items Default 'All Tags'/'All Categories'.
[660] Fix | Delete
* @type string $parent_item This label is only used for hierarchical taxonomies. Default
[661] Fix | Delete
* 'Parent Category'.
[662] Fix | Delete
* @type string $parent_item_colon The same as `parent_item`, but with colon `:` in the end.
[663] Fix | Delete
* @type string $name_field_description Description for the Name field on Edit Tags screen.
[664] Fix | Delete
* Default 'The name is how it appears on your site'.
[665] Fix | Delete
* @type string $slug_field_description Description for the Slug field on Edit Tags screen.
[666] Fix | Delete
* Default 'The “slug” is the URL-friendly version
[667] Fix | Delete
* of the name. It is usually all lowercase and contains
[668] Fix | Delete
* only letters, numbers, and hyphens'.
[669] Fix | Delete
* @type string $parent_field_description Description for the Parent field on Edit Tags screen.
[670] Fix | Delete
* Default 'Assign a parent term to create a hierarchy.
[671] Fix | Delete
* The term Jazz, for example, would be the parent
[672] Fix | Delete
* of Bebop and Big Band'.
[673] Fix | Delete
* @type string $desc_field_description Description for the Description field on Edit Tags screen.
[674] Fix | Delete
* Default 'The description is not prominent by default;
[675] Fix | Delete
* however, some themes may show it'.
[676] Fix | Delete
* @type string $edit_item Default 'Edit Tag'/'Edit Category'.
[677] Fix | Delete
* @type string $view_item Default 'View Tag'/'View Category'.
[678] Fix | Delete
* @type string $update_item Default 'Update Tag'/'Update Category'.
[679] Fix | Delete
* @type string $add_new_item Default 'Add New Tag'/'Add New Category'.
[680] Fix | Delete
* @type string $new_item_name Default 'New Tag Name'/'New Category Name'.
[681] Fix | Delete
* @type string $template_name Default 'Tag Archives'/'Category Archives'.
[682] Fix | Delete
* @type string $separate_items_with_commas This label is only used for non-hierarchical taxonomies. Default
[683] Fix | Delete
* 'Separate tags with commas', used in the meta box.
[684] Fix | Delete
* @type string $add_or_remove_items This label is only used for non-hierarchical taxonomies. Default
[685] Fix | Delete
* 'Add or remove tags', used in the meta box when JavaScript
[686] Fix | Delete
* is disabled.
[687] Fix | Delete
* @type string $choose_from_most_used This label is only used on non-hierarchical taxonomies. Default
[688] Fix | Delete
* 'Choose from the most used tags', used in the meta box.
[689] Fix | Delete
* @type string $not_found Default 'No tags found'/'No categories found', used in
[690] Fix | Delete
* the meta box and taxonomy list table.
[691] Fix | Delete
* @type string $no_terms Default 'No tags'/'No categories', used in the posts and media
[692] Fix | Delete
* list tables.
[693] Fix | Delete
* @type string $filter_by_item This label is only used for hierarchical taxonomies. Default
[694] Fix | Delete
* 'Filter by category', used in the posts list table.
[695] Fix | Delete
* @type string $items_list_navigation Label for the table pagination hidden heading.
[696] Fix | Delete
* @type string $items_list Label for the table hidden heading.
[697] Fix | Delete
* @type string $most_used Title for the Most Used tab. Default 'Most Used'.
[698] Fix | Delete
* @type string $back_to_items Label displayed after a term has been updated.
[699] Fix | Delete
* @type string $item_link Used in the block editor. Title for a navigation link block variation.
[700] Fix | Delete
* Default 'Tag Link'/'Category Link'.
[701] Fix | Delete
* @type string $item_link_description Used in the block editor. Description for a navigation link block
[702] Fix | Delete
* variation. Default 'A link to a tag'/'A link to a category'.
[703] Fix | Delete
* }
[704] Fix | Delete
*/
[705] Fix | Delete
function get_taxonomy_labels( $tax ) {
[706] Fix | Delete
$tax->labels = (array) $tax->labels;
[707] Fix | Delete
[708] Fix | Delete
if ( isset( $tax->helps ) && empty( $tax->labels['separate_items_with_commas'] ) ) {
[709] Fix | Delete
$tax->labels['separate_items_with_commas'] = $tax->helps;
[710] Fix | Delete
}
[711] Fix | Delete
[712] Fix | Delete
if ( isset( $tax->no_tagcloud ) && empty( $tax->labels['not_found'] ) ) {
[713] Fix | Delete
$tax->labels['not_found'] = $tax->no_tagcloud;
[714] Fix | Delete
}
[715] Fix | Delete
[716] Fix | Delete
$nohier_vs_hier_defaults = WP_Taxonomy::get_default_labels();
[717] Fix | Delete
[718] Fix | Delete
$nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];
[719] Fix | Delete
[720] Fix | Delete
$labels = _get_custom_object_labels( $tax, $nohier_vs_hier_defaults );
[721] Fix | Delete
[722] Fix | Delete
if ( ! isset( $tax->labels->template_name ) && isset( $labels->singular_name ) ) {
[723] Fix | Delete
/* translators: %s: Taxonomy name. */
[724] Fix | Delete
$labels->template_name = sprintf( _x( '%s Archives', 'taxonomy template name' ), $labels->singular_name );
[725] Fix | Delete
}
[726] Fix | Delete
[727] Fix | Delete
$taxonomy = $tax->name;
[728] Fix | Delete
[729] Fix | Delete
$default_labels = clone $labels;
[730] Fix | Delete
[731] Fix | Delete
/**
[732] Fix | Delete
* Filters the labels of a specific taxonomy.
[733] Fix | Delete
*
[734] Fix | Delete
* The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
[735] Fix | Delete
*
[736] Fix | Delete
* Possible hook names include:
[737] Fix | Delete
*
[738] Fix | Delete
* - `taxonomy_labels_category`
[739] Fix | Delete
* - `taxonomy_labels_post_tag`
[740] Fix | Delete
*
[741] Fix | Delete
* @since 4.4.0
[742] Fix | Delete
*
[743] Fix | Delete
* @see get_taxonomy_labels() for the full list of taxonomy labels.
[744] Fix | Delete
*
[745] Fix | Delete
* @param object $labels Object with labels for the taxonomy as member variables.
[746] Fix | Delete
*/
[747] Fix | Delete
$labels = apply_filters( "taxonomy_labels_{$taxonomy}", $labels );
[748] Fix | Delete
[749] Fix | Delete
// Ensure that the filtered labels contain all required default values.
[750] Fix | Delete
$labels = (object) array_merge( (array) $default_labels, (array) $labels );
[751] Fix | Delete
[752] Fix | Delete
return $labels;
[753] Fix | Delete
}
[754] Fix | Delete
[755] Fix | Delete
/**
[756] Fix | Delete
* Adds an already registered taxonomy to an object type.
[757] Fix | Delete
*
[758] Fix | Delete
* @since 3.0.0
[759] Fix | Delete
*
[760] Fix | Delete
* @global WP_Taxonomy[] $wp_taxonomies The registered taxonomies.
[761] Fix | Delete
*
[762] Fix | Delete
* @param string $taxonomy Name of taxonomy object.
[763] Fix | Delete
* @param string $object_type Name of the object type.
[764] Fix | Delete
* @return bool True if successful, false if not.
[765] Fix | Delete
*/
[766] Fix | Delete
function register_taxonomy_for_object_type( $taxonomy, $object_type ) {
[767] Fix | Delete
global $wp_taxonomies;
[768] Fix | Delete
[769] Fix | Delete
if ( ! isset( $wp_taxonomies[ $taxonomy ] ) ) {
[770] Fix | Delete
return false;
[771] Fix | Delete
}
[772] Fix | Delete
[773] Fix | Delete
if ( ! get_post_type_object( $object_type ) ) {
[774] Fix | Delete
return false;
[775] Fix | Delete
}
[776] Fix | Delete
[777] Fix | Delete
if ( ! in_array( $object_type, $wp_taxonomies[ $taxonomy ]->object_type, true ) ) {
[778] Fix | Delete
$wp_taxonomies[ $taxonomy ]->object_type[] = $object_type;
[779] Fix | Delete
}
[780] Fix | Delete
[781] Fix | Delete
// Filter out empties.
[782] Fix | Delete
$wp_taxonomies[ $taxonomy ]->object_type = array_filter( $wp_taxonomies[ $taxonomy ]->object_type );
[783] Fix | Delete
[784] Fix | Delete
/**
[785] Fix | Delete
* Fires after a taxonomy is registered for an object type.
[786] Fix | Delete
*
[787] Fix | Delete
* @since 5.1.0
[788] Fix | Delete
*
[789] Fix | Delete
* @param string $taxonomy Taxonomy name.
[790] Fix | Delete
* @param string $object_type Name of the object type.
[791] Fix | Delete
*/
[792] Fix | Delete
do_action( 'registered_taxonomy_for_object_type', $taxonomy, $object_type );
[793] Fix | Delete
[794] Fix | Delete
return true;
[795] Fix | Delete
}
[796] Fix | Delete
[797] Fix | Delete
/**
[798] Fix | Delete
* Removes an already registered taxonomy from an object type.
[799] Fix | Delete
*
[800] Fix | Delete
* @since 3.7.0
[801] Fix | Delete
*
[802] Fix | Delete
* @global WP_Taxonomy[] $wp_taxonomies The registered taxonomies.
[803] Fix | Delete
*
[804] Fix | Delete
* @param string $taxonomy Name of taxonomy object.
[805] Fix | Delete
* @param string $object_type Name of the object type.
[806] Fix | Delete
* @return bool True if successful, false if not.
[807] Fix | Delete
*/
[808] Fix | Delete
function unregister_taxonomy_for_object_type( $taxonomy, $object_type ) {
[809] Fix | Delete
global $wp_taxonomies;
[810] Fix | Delete
[811] Fix | Delete
if ( ! isset( $wp_taxonomies[ $taxonomy ] ) ) {
[812] Fix | Delete
return false;
[813] Fix | Delete
}
[814] Fix | Delete
[815] Fix | Delete
if ( ! get_post_type_object( $object_type ) ) {
[816] Fix | Delete
return false;
[817] Fix | Delete
}
[818] Fix | Delete
[819] Fix | Delete
$key = array_search( $object_type, $wp_taxonomies[ $taxonomy ]->object_type, true );
[820] Fix | Delete
if ( false === $key ) {
[821] Fix | Delete
return false;
[822] Fix | Delete
}
[823] Fix | Delete
[824] Fix | Delete
unset( $wp_taxonomies[ $taxonomy ]->object_type[ $key ] );
[825] Fix | Delete
[826] Fix | Delete
/**
[827] Fix | Delete
* Fires after a taxonomy is unregistered for an object type.
[828] Fix | Delete
*
[829] Fix | Delete
* @since 5.1.0
[830] Fix | Delete
*
[831] Fix | Delete
* @param string $taxonomy Taxonomy name.
[832] Fix | Delete
* @param string $object_type Name of the object type.
[833] Fix | Delete
*/
[834] Fix | Delete
do_action( 'unregistered_taxonomy_for_object_type', $taxonomy, $object_type );
[835] Fix | Delete
[836] Fix | Delete
return true;
[837] Fix | Delete
}
[838] Fix | Delete
[839] Fix | Delete
//
[840] Fix | Delete
// Term API.
[841] Fix | Delete
//
[842] Fix | Delete
[843] Fix | Delete
/**
[844] Fix | Delete
* Retrieves object IDs of valid taxonomy and term.
[845] Fix | Delete
*
[846] Fix | Delete
* The strings of `$taxonomies` must exist before this function will continue.
[847] Fix | Delete
* On failure of finding a valid taxonomy, it will return a WP_Error.
[848] Fix | Delete
*
[849] Fix | Delete
* The `$terms` aren't checked the same as `$taxonomies`, but still need to exist
[850] Fix | Delete
* for object IDs to be returned.
[851] Fix | Delete
*
[852] Fix | Delete
* It is possible to change the order that object IDs are returned by using `$args`
[853] Fix | Delete
* with either ASC or DESC array. The value should be in the key named 'order'.
[854] Fix | Delete
*
[855] Fix | Delete
* @since 2.3.0
[856] Fix | Delete
*
[857] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[858] Fix | Delete
*
[859] Fix | Delete
* @param int|int[] $term_ids Term ID or array of term IDs of terms that will be used.
[860] Fix | Delete
* @param string|string[] $taxonomies String of taxonomy name or Array of string values of taxonomy names.
[861] Fix | Delete
* @param array|string $args {
[862] Fix | Delete
* Change the order of the object IDs.
[863] Fix | Delete
*
[864] Fix | Delete
* @type string $order Order to retrieve terms. Accepts 'ASC' or 'DESC'. Default 'ASC'.
[865] Fix | Delete
* }
[866] Fix | Delete
* @return string[]|WP_Error An array of object IDs as numeric strings on success,
[867] Fix | Delete
* WP_Error if the taxonomy does not exist.
[868] Fix | Delete
*/
[869] Fix | Delete
function get_objects_in_term( $term_ids, $taxonomies, $args = array() ) {
[870] Fix | Delete
global $wpdb;
[871] Fix | Delete
[872] Fix | Delete
if ( ! is_array( $term_ids ) ) {
[873] Fix | Delete
$term_ids = array( $term_ids );
[874] Fix | Delete
}
[875] Fix | Delete
if ( ! is_array( $taxonomies ) ) {
[876] Fix | Delete
$taxonomies = array( $taxonomies );
[877] Fix | Delete
}
[878] Fix | Delete
foreach ( (array) $taxonomies as $taxonomy ) {
[879] Fix | Delete
if ( ! taxonomy_exists( $taxonomy ) ) {
[880] Fix | Delete
return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
[881] Fix | Delete
}
[882] Fix | Delete
}
[883] Fix | Delete
[884] Fix | Delete
$defaults = array( 'order' => 'ASC' );
[885] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[886] Fix | Delete
[887] Fix | Delete
$order = ( 'desc' === strtolower( $args['order'] ) ) ? 'DESC' : 'ASC';
[888] Fix | Delete
[889] Fix | Delete
$term_ids = array_map( 'intval', $term_ids );
[890] Fix | Delete
[891] Fix | Delete
$taxonomies = "'" . implode( "', '", array_map( 'esc_sql', $taxonomies ) ) . "'";
[892] Fix | Delete
$term_ids = "'" . implode( "', '", $term_ids ) . "'";
[893] Fix | Delete
[894] Fix | Delete
$sql = "SELECT tr.object_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tt.term_id IN ($term_ids) ORDER BY tr.object_id $order";
[895] Fix | Delete
[896] Fix | Delete
$last_changed = wp_cache_get_last_changed( 'terms' );
[897] Fix | Delete
$cache_key = 'get_objects_in_term:' . md5( $sql ) . ":$last_changed";
[898] Fix | Delete
$cache = wp_cache_get( $cache_key, 'term-queries' );
[899] Fix | Delete
if ( false === $cache ) {
[900] Fix | Delete
$object_ids = $wpdb->get_col( $sql );
[901] Fix | Delete
wp_cache_set( $cache_key, $object_ids, 'term-queries' );
[902] Fix | Delete
} else {
[903] Fix | Delete
$object_ids = (array) $cache;
[904] Fix | Delete
}
[905] Fix | Delete
[906] Fix | Delete
if ( ! $object_ids ) {
[907] Fix | Delete
return array();
[908] Fix | Delete
}
[909] Fix | Delete
return $object_ids;
[910] Fix | Delete
}
[911] Fix | Delete
[912] Fix | Delete
/**
[913] Fix | Delete
* Given a taxonomy query, generates SQL to be appended to a main query.
[914] Fix | Delete
*
[915] Fix | Delete
* @since 3.1.0
[916] Fix | Delete
*
[917] Fix | Delete
* @see WP_Tax_Query
[918] Fix | Delete
*
[919] Fix | Delete
* @param array $tax_query A compact tax query
[920] Fix | Delete
* @param string $primary_table
[921] Fix | Delete
* @param string $primary_id_column
[922] Fix | Delete
* @return string[]
[923] Fix | Delete
*/
[924] Fix | Delete
function get_tax_sql( $tax_query, $primary_table, $primary_id_column ) {
[925] Fix | Delete
$tax_query_obj = new WP_Tax_Query( $tax_query );
[926] Fix | Delete
return $tax_query_obj->get_sql( $primary_table, $primary_id_column );
[927] Fix | Delete
}
[928] Fix | Delete
[929] Fix | Delete
/**
[930] Fix | Delete
* Gets all term data from database by term ID.
[931] Fix | Delete
*
[932] Fix | Delete
* The usage of the get_term function is to apply filters to a term object. It
[933] Fix | Delete
* is possible to get a term object from the database before applying the
[934] Fix | Delete
* filters.
[935] Fix | Delete
*
[936] Fix | Delete
* $term ID must be part of $taxonomy, to get from the database. Failure, might
[937] Fix | Delete
* be able to be captured by the hooks. Failure would be the same value as $wpdb
[938] Fix | Delete
* returns for the get_row method.
[939] Fix | Delete
*
[940] Fix | Delete
* There are two hooks, one is specifically for each term, named 'get_term', and
[941] Fix | Delete
* the second is for the taxonomy name, 'term_$taxonomy'. Both hooks gets the
[942] Fix | Delete
* term object, and the taxonomy name as parameters. Both hooks are expected to
[943] Fix | Delete
* return a term object.
[944] Fix | Delete
*
[945] Fix | Delete
* {@see 'get_term'} hook - Takes two parameters the term Object and the taxonomy name.
[946] Fix | Delete
* Must return term object. Used in get_term() as a catch-all filter for every
[947] Fix | Delete
* $term.
[948] Fix | Delete
*
[949] Fix | Delete
* {@see 'get_$taxonomy'} hook - Takes two parameters the term Object and the taxonomy
[950] Fix | Delete
* name. Must return term object. $taxonomy will be the taxonomy name, so for
[951] Fix | Delete
* example, if 'category', it would be 'get_category' as the filter name. Useful
[952] Fix | Delete
* for custom taxonomies or plugging into default taxonomies.
[953] Fix | Delete
*
[954] Fix | Delete
* @todo Better formatting for DocBlock
[955] Fix | Delete
*
[956] Fix | Delete
* @since 2.3.0
[957] Fix | Delete
* @since 4.4.0 Converted to return a WP_Term object if `$output` is `OBJECT`.
[958] Fix | Delete
* The `$taxonomy` parameter was made optional.
[959] Fix | Delete
*
[960] Fix | Delete
* @see sanitize_term_field() The $context param lists the available values for get_term_by() $filter param.
[961] Fix | Delete
*
[962] Fix | Delete
* @param int|WP_Term|object $term If integer, term data will be fetched from the database,
[963] Fix | Delete
* or from the cache if available.
[964] Fix | Delete
* If stdClass object (as in the results of a database query),
[965] Fix | Delete
* will apply filters and return a `WP_Term` object with the `$term` data.
[966] Fix | Delete
* If `WP_Term`, will return `$term`.
[967] Fix | Delete
* @param string $taxonomy Optional. Taxonomy name that `$term` is part of.
[968] Fix | Delete
* @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
[969] Fix | Delete
* correspond to a WP_Term object, an associative array, or a numeric array,
[970] Fix | Delete
* respectively. Default OBJECT.
[971] Fix | Delete
* @param string $filter Optional. How to sanitize term fields. Default 'raw'.
[972] Fix | Delete
* @return WP_Term|array|WP_Error|null WP_Term instance (or array) on success, depending on the `$output` value.
[973] Fix | Delete
* WP_Error if `$taxonomy` does not exist. Null for miscellaneous failure.
[974] Fix | Delete
*/
[975] Fix | Delete
function get_term( $term, $taxonomy = '', $output = OBJECT, $filter = 'raw' ) {
[976] Fix | Delete
if ( empty( $term ) ) {
[977] Fix | Delete
return new WP_Error( 'invalid_term', __( 'Empty Term.' ) );
[978] Fix | Delete
}
[979] Fix | Delete
[980] Fix | Delete
if ( $taxonomy && ! taxonomy_exists( $taxonomy ) ) {
[981] Fix | Delete
return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
[982] Fix | Delete
}
[983] Fix | Delete
[984] Fix | Delete
if ( $term instanceof WP_Term ) {
[985] Fix | Delete
$_term = $term;
[986] Fix | Delete
} elseif ( is_object( $term ) ) {
[987] Fix | Delete
if ( empty( $term->filter ) || 'raw' === $term->filter ) {
[988] Fix | Delete
$_term = sanitize_term( $term, $taxonomy, 'raw' );
[989] Fix | Delete
$_term = new WP_Term( $_term );
[990] Fix | Delete
} else {
[991] Fix | Delete
$_term = WP_Term::get_instance( $term->term_id );
[992] Fix | Delete
}
[993] Fix | Delete
} else {
[994] Fix | Delete
$_term = WP_Term::get_instance( $term, $taxonomy );
[995] Fix | Delete
}
[996] Fix | Delete
[997] Fix | Delete
if ( is_wp_error( $_term ) ) {
[998] Fix | Delete
return $_term;
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function