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
* @param int $new_term_id ID of the new term created for the $term_taxonomy_id.
[4500] Fix | Delete
* @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split.
[4501] Fix | Delete
* @param string $taxonomy Taxonomy for the split term.
[4502] Fix | Delete
*/
[4503] Fix | Delete
function _wp_check_split_terms_in_menus( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
[4504] Fix | Delete
global $wpdb;
[4505] Fix | Delete
$post_ids = $wpdb->get_col(
[4506] Fix | Delete
$wpdb->prepare(
[4507] Fix | Delete
"SELECT m1.post_id
[4508] Fix | Delete
FROM {$wpdb->postmeta} AS m1
[4509] Fix | Delete
INNER JOIN {$wpdb->postmeta} AS m2 ON ( m2.post_id = m1.post_id )
[4510] Fix | Delete
INNER JOIN {$wpdb->postmeta} AS m3 ON ( m3.post_id = m1.post_id )
[4511] Fix | Delete
WHERE ( m1.meta_key = '_menu_item_type' AND m1.meta_value = 'taxonomy' )
[4512] Fix | Delete
AND ( m2.meta_key = '_menu_item_object' AND m2.meta_value = %s )
[4513] Fix | Delete
AND ( m3.meta_key = '_menu_item_object_id' AND m3.meta_value = %d )",
[4514] Fix | Delete
$taxonomy,
[4515] Fix | Delete
$term_id
[4516] Fix | Delete
)
[4517] Fix | Delete
);
[4518] Fix | Delete
[4519] Fix | Delete
if ( $post_ids ) {
[4520] Fix | Delete
foreach ( $post_ids as $post_id ) {
[4521] Fix | Delete
update_post_meta( $post_id, '_menu_item_object_id', $new_term_id, $term_id );
[4522] Fix | Delete
}
[4523] Fix | Delete
}
[4524] Fix | Delete
}
[4525] Fix | Delete
[4526] Fix | Delete
/**
[4527] Fix | Delete
* If the term being split is a nav_menu, changes associations.
[4528] Fix | Delete
*
[4529] Fix | Delete
* @ignore
[4530] Fix | Delete
* @since 4.3.0
[4531] Fix | Delete
*
[4532] Fix | Delete
* @param int $term_id ID of the formerly shared term.
[4533] Fix | Delete
* @param int $new_term_id ID of the new term created for the $term_taxonomy_id.
[4534] Fix | Delete
* @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split.
[4535] Fix | Delete
* @param string $taxonomy Taxonomy for the split term.
[4536] Fix | Delete
*/
[4537] Fix | Delete
function _wp_check_split_nav_menu_terms( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
[4538] Fix | Delete
if ( 'nav_menu' !== $taxonomy ) {
[4539] Fix | Delete
return;
[4540] Fix | Delete
}
[4541] Fix | Delete
[4542] Fix | Delete
// Update menu locations.
[4543] Fix | Delete
$locations = get_nav_menu_locations();
[4544] Fix | Delete
foreach ( $locations as $location => $menu_id ) {
[4545] Fix | Delete
if ( $term_id === $menu_id ) {
[4546] Fix | Delete
$locations[ $location ] = $new_term_id;
[4547] Fix | Delete
}
[4548] Fix | Delete
}
[4549] Fix | Delete
set_theme_mod( 'nav_menu_locations', $locations );
[4550] Fix | Delete
}
[4551] Fix | Delete
[4552] Fix | Delete
/**
[4553] Fix | Delete
* Gets data about terms that previously shared a single term_id, but have since been split.
[4554] Fix | Delete
*
[4555] Fix | Delete
* @since 4.2.0
[4556] Fix | Delete
*
[4557] Fix | Delete
* @param int $old_term_id Term ID. This is the old, pre-split term ID.
[4558] Fix | Delete
* @return array Array of new term IDs, keyed by taxonomy.
[4559] Fix | Delete
*/
[4560] Fix | Delete
function wp_get_split_terms( $old_term_id ) {
[4561] Fix | Delete
$split_terms = get_option( '_split_terms', array() );
[4562] Fix | Delete
[4563] Fix | Delete
$terms = array();
[4564] Fix | Delete
if ( isset( $split_terms[ $old_term_id ] ) ) {
[4565] Fix | Delete
$terms = $split_terms[ $old_term_id ];
[4566] Fix | Delete
}
[4567] Fix | Delete
[4568] Fix | Delete
return $terms;
[4569] Fix | Delete
}
[4570] Fix | Delete
[4571] Fix | Delete
/**
[4572] Fix | Delete
* Gets the new term ID corresponding to a previously split term.
[4573] Fix | Delete
*
[4574] Fix | Delete
* @since 4.2.0
[4575] Fix | Delete
*
[4576] Fix | Delete
* @param int $old_term_id Term ID. This is the old, pre-split term ID.
[4577] Fix | Delete
* @param string $taxonomy Taxonomy that the term belongs to.
[4578] Fix | Delete
* @return int|false If a previously split term is found corresponding to the old term_id and taxonomy,
[4579] Fix | Delete
* the new term_id will be returned. If no previously split term is found matching
[4580] Fix | Delete
* the parameters, returns false.
[4581] Fix | Delete
*/
[4582] Fix | Delete
function wp_get_split_term( $old_term_id, $taxonomy ) {
[4583] Fix | Delete
$split_terms = wp_get_split_terms( $old_term_id );
[4584] Fix | Delete
[4585] Fix | Delete
$term_id = false;
[4586] Fix | Delete
if ( isset( $split_terms[ $taxonomy ] ) ) {
[4587] Fix | Delete
$term_id = (int) $split_terms[ $taxonomy ];
[4588] Fix | Delete
}
[4589] Fix | Delete
[4590] Fix | Delete
return $term_id;
[4591] Fix | Delete
}
[4592] Fix | Delete
[4593] Fix | Delete
/**
[4594] Fix | Delete
* Determines whether a term is shared between multiple taxonomies.
[4595] Fix | Delete
*
[4596] Fix | Delete
* Shared taxonomy terms began to be split in 4.3, but failed cron tasks or
[4597] Fix | Delete
* other delays in upgrade routines may cause shared terms to remain.
[4598] Fix | Delete
*
[4599] Fix | Delete
* @since 4.4.0
[4600] Fix | Delete
*
[4601] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[4602] Fix | Delete
*
[4603] Fix | Delete
* @param int $term_id Term ID.
[4604] Fix | Delete
* @return bool Returns false if a term is not shared between multiple taxonomies or
[4605] Fix | Delete
* if splitting shared taxonomy terms is finished.
[4606] Fix | Delete
*/
[4607] Fix | Delete
function wp_term_is_shared( $term_id ) {
[4608] Fix | Delete
global $wpdb;
[4609] Fix | Delete
[4610] Fix | Delete
if ( get_option( 'finished_splitting_shared_terms' ) ) {
[4611] Fix | Delete
return false;
[4612] Fix | Delete
}
[4613] Fix | Delete
[4614] Fix | Delete
$tt_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id ) );
[4615] Fix | Delete
[4616] Fix | Delete
return $tt_count > 1;
[4617] Fix | Delete
}
[4618] Fix | Delete
[4619] Fix | Delete
/**
[4620] Fix | Delete
* Generates a permalink for a taxonomy term archive.
[4621] Fix | Delete
*
[4622] Fix | Delete
* @since 2.5.0
[4623] Fix | Delete
*
[4624] Fix | Delete
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
[4625] Fix | Delete
*
[4626] Fix | Delete
* @param WP_Term|int|string $term The term object, ID, or slug whose link will be retrieved.
[4627] Fix | Delete
* @param string $taxonomy Optional. Taxonomy. Default empty.
[4628] Fix | Delete
* @return string|WP_Error URL of the taxonomy term archive on success, WP_Error if term does not exist.
[4629] Fix | Delete
*/
[4630] Fix | Delete
function get_term_link( $term, $taxonomy = '' ) {
[4631] Fix | Delete
global $wp_rewrite;
[4632] Fix | Delete
[4633] Fix | Delete
if ( ! is_object( $term ) ) {
[4634] Fix | Delete
if ( is_int( $term ) ) {
[4635] Fix | Delete
$term = get_term( $term, $taxonomy );
[4636] Fix | Delete
} else {
[4637] Fix | Delete
$term = get_term_by( 'slug', $term, $taxonomy );
[4638] Fix | Delete
}
[4639] Fix | Delete
}
[4640] Fix | Delete
[4641] Fix | Delete
if ( ! is_object( $term ) ) {
[4642] Fix | Delete
$term = new WP_Error( 'invalid_term', __( 'Empty Term.' ) );
[4643] Fix | Delete
}
[4644] Fix | Delete
[4645] Fix | Delete
if ( is_wp_error( $term ) ) {
[4646] Fix | Delete
return $term;
[4647] Fix | Delete
}
[4648] Fix | Delete
[4649] Fix | Delete
$taxonomy = $term->taxonomy;
[4650] Fix | Delete
[4651] Fix | Delete
$termlink = $wp_rewrite->get_extra_permastruct( $taxonomy );
[4652] Fix | Delete
[4653] Fix | Delete
/**
[4654] Fix | Delete
* Filters the permalink structure for a term before token replacement occurs.
[4655] Fix | Delete
*
[4656] Fix | Delete
* @since 4.9.0
[4657] Fix | Delete
*
[4658] Fix | Delete
* @param string $termlink The permalink structure for the term's taxonomy.
[4659] Fix | Delete
* @param WP_Term $term The term object.
[4660] Fix | Delete
*/
[4661] Fix | Delete
$termlink = apply_filters( 'pre_term_link', $termlink, $term );
[4662] Fix | Delete
[4663] Fix | Delete
$slug = $term->slug;
[4664] Fix | Delete
$t = get_taxonomy( $taxonomy );
[4665] Fix | Delete
[4666] Fix | Delete
if ( empty( $termlink ) ) {
[4667] Fix | Delete
if ( 'category' === $taxonomy ) {
[4668] Fix | Delete
$termlink = '?cat=' . $term->term_id;
[4669] Fix | Delete
} elseif ( $t->query_var ) {
[4670] Fix | Delete
$termlink = "?$t->query_var=$slug";
[4671] Fix | Delete
} else {
[4672] Fix | Delete
$termlink = "?taxonomy=$taxonomy&term=$slug";
[4673] Fix | Delete
}
[4674] Fix | Delete
$termlink = home_url( $termlink );
[4675] Fix | Delete
} else {
[4676] Fix | Delete
if ( ! empty( $t->rewrite['hierarchical'] ) ) {
[4677] Fix | Delete
$hierarchical_slugs = array();
[4678] Fix | Delete
$ancestors = get_ancestors( $term->term_id, $taxonomy, 'taxonomy' );
[4679] Fix | Delete
foreach ( (array) $ancestors as $ancestor ) {
[4680] Fix | Delete
$ancestor_term = get_term( $ancestor, $taxonomy );
[4681] Fix | Delete
$hierarchical_slugs[] = $ancestor_term->slug;
[4682] Fix | Delete
}
[4683] Fix | Delete
$hierarchical_slugs = array_reverse( $hierarchical_slugs );
[4684] Fix | Delete
$hierarchical_slugs[] = $slug;
[4685] Fix | Delete
$termlink = str_replace( "%$taxonomy%", implode( '/', $hierarchical_slugs ), $termlink );
[4686] Fix | Delete
} else {
[4687] Fix | Delete
$termlink = str_replace( "%$taxonomy%", $slug, $termlink );
[4688] Fix | Delete
}
[4689] Fix | Delete
$termlink = home_url( user_trailingslashit( $termlink, 'category' ) );
[4690] Fix | Delete
}
[4691] Fix | Delete
[4692] Fix | Delete
// Back compat filters.
[4693] Fix | Delete
if ( 'post_tag' === $taxonomy ) {
[4694] Fix | Delete
[4695] Fix | Delete
/**
[4696] Fix | Delete
* Filters the tag link.
[4697] Fix | Delete
*
[4698] Fix | Delete
* @since 2.3.0
[4699] Fix | Delete
* @since 2.5.0 Deprecated in favor of {@see 'term_link'} filter.
[4700] Fix | Delete
* @since 5.4.1 Restored (un-deprecated).
[4701] Fix | Delete
*
[4702] Fix | Delete
* @param string $termlink Tag link URL.
[4703] Fix | Delete
* @param int $term_id Term ID.
[4704] Fix | Delete
*/
[4705] Fix | Delete
$termlink = apply_filters( 'tag_link', $termlink, $term->term_id );
[4706] Fix | Delete
} elseif ( 'category' === $taxonomy ) {
[4707] Fix | Delete
[4708] Fix | Delete
/**
[4709] Fix | Delete
* Filters the category link.
[4710] Fix | Delete
*
[4711] Fix | Delete
* @since 1.5.0
[4712] Fix | Delete
* @since 2.5.0 Deprecated in favor of {@see 'term_link'} filter.
[4713] Fix | Delete
* @since 5.4.1 Restored (un-deprecated).
[4714] Fix | Delete
*
[4715] Fix | Delete
* @param string $termlink Category link URL.
[4716] Fix | Delete
* @param int $term_id Term ID.
[4717] Fix | Delete
*/
[4718] Fix | Delete
$termlink = apply_filters( 'category_link', $termlink, $term->term_id );
[4719] Fix | Delete
}
[4720] Fix | Delete
[4721] Fix | Delete
/**
[4722] Fix | Delete
* Filters the term link.
[4723] Fix | Delete
*
[4724] Fix | Delete
* @since 2.5.0
[4725] Fix | Delete
*
[4726] Fix | Delete
* @param string $termlink Term link URL.
[4727] Fix | Delete
* @param WP_Term $term Term object.
[4728] Fix | Delete
* @param string $taxonomy Taxonomy slug.
[4729] Fix | Delete
*/
[4730] Fix | Delete
return apply_filters( 'term_link', $termlink, $term, $taxonomy );
[4731] Fix | Delete
}
[4732] Fix | Delete
[4733] Fix | Delete
/**
[4734] Fix | Delete
* Displays the taxonomies of a post with available options.
[4735] Fix | Delete
*
[4736] Fix | Delete
* This function can be used within the loop to display the taxonomies for a
[4737] Fix | Delete
* post without specifying the Post ID. You can also use it outside the Loop to
[4738] Fix | Delete
* display the taxonomies for a specific post.
[4739] Fix | Delete
*
[4740] Fix | Delete
* @since 2.5.0
[4741] Fix | Delete
*
[4742] Fix | Delete
* @param array $args {
[4743] Fix | Delete
* Arguments about which post to use and how to format the output. Shares all of the arguments
[4744] Fix | Delete
* supported by get_the_taxonomies(), in addition to the following.
[4745] Fix | Delete
*
[4746] Fix | Delete
* @type int|WP_Post $post Post ID or object to get taxonomies of. Default current post.
[4747] Fix | Delete
* @type string $before Displays before the taxonomies. Default empty string.
[4748] Fix | Delete
* @type string $sep Separates each taxonomy. Default is a space.
[4749] Fix | Delete
* @type string $after Displays after the taxonomies. Default empty string.
[4750] Fix | Delete
* }
[4751] Fix | Delete
*/
[4752] Fix | Delete
function the_taxonomies( $args = array() ) {
[4753] Fix | Delete
$defaults = array(
[4754] Fix | Delete
'post' => 0,
[4755] Fix | Delete
'before' => '',
[4756] Fix | Delete
'sep' => ' ',
[4757] Fix | Delete
'after' => '',
[4758] Fix | Delete
);
[4759] Fix | Delete
[4760] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[4761] Fix | Delete
[4762] Fix | Delete
echo $parsed_args['before'] . implode( $parsed_args['sep'], get_the_taxonomies( $parsed_args['post'], $parsed_args ) ) . $parsed_args['after'];
[4763] Fix | Delete
}
[4764] Fix | Delete
[4765] Fix | Delete
/**
[4766] Fix | Delete
* Retrieves all taxonomies associated with a post.
[4767] Fix | Delete
*
[4768] Fix | Delete
* This function can be used within the loop. It will also return an array of
[4769] Fix | Delete
* the taxonomies with links to the taxonomy and name.
[4770] Fix | Delete
*
[4771] Fix | Delete
* @since 2.5.0
[4772] Fix | Delete
*
[4773] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
[4774] Fix | Delete
* @param array $args {
[4775] Fix | Delete
* Optional. Arguments about how to format the list of taxonomies. Default empty array.
[4776] Fix | Delete
*
[4777] Fix | Delete
* @type string $template Template for displaying a taxonomy label and list of terms.
[4778] Fix | Delete
* Default is "Label: Terms."
[4779] Fix | Delete
* @type string $term_template Template for displaying a single term in the list. Default is the term name
[4780] Fix | Delete
* linked to its archive.
[4781] Fix | Delete
* }
[4782] Fix | Delete
* @return string[] List of taxonomies.
[4783] Fix | Delete
*/
[4784] Fix | Delete
function get_the_taxonomies( $post = 0, $args = array() ) {
[4785] Fix | Delete
$post = get_post( $post );
[4786] Fix | Delete
[4787] Fix | Delete
$args = wp_parse_args(
[4788] Fix | Delete
$args,
[4789] Fix | Delete
array(
[4790] Fix | Delete
/* translators: %s: Taxonomy label, %l: List of terms formatted as per $term_template. */
[4791] Fix | Delete
'template' => __( '%s: %l.' ),
[4792] Fix | Delete
'term_template' => '<a href="%1$s">%2$s</a>',
[4793] Fix | Delete
)
[4794] Fix | Delete
);
[4795] Fix | Delete
[4796] Fix | Delete
$taxonomies = array();
[4797] Fix | Delete
[4798] Fix | Delete
if ( ! $post ) {
[4799] Fix | Delete
return $taxonomies;
[4800] Fix | Delete
}
[4801] Fix | Delete
[4802] Fix | Delete
foreach ( get_object_taxonomies( $post ) as $taxonomy ) {
[4803] Fix | Delete
$t = (array) get_taxonomy( $taxonomy );
[4804] Fix | Delete
if ( empty( $t['label'] ) ) {
[4805] Fix | Delete
$t['label'] = $taxonomy;
[4806] Fix | Delete
}
[4807] Fix | Delete
if ( empty( $t['args'] ) ) {
[4808] Fix | Delete
$t['args'] = array();
[4809] Fix | Delete
}
[4810] Fix | Delete
if ( empty( $t['template'] ) ) {
[4811] Fix | Delete
$t['template'] = $args['template'];
[4812] Fix | Delete
}
[4813] Fix | Delete
if ( empty( $t['term_template'] ) ) {
[4814] Fix | Delete
$t['term_template'] = $args['term_template'];
[4815] Fix | Delete
}
[4816] Fix | Delete
[4817] Fix | Delete
$terms = get_object_term_cache( $post->ID, $taxonomy );
[4818] Fix | Delete
if ( false === $terms ) {
[4819] Fix | Delete
$terms = wp_get_object_terms( $post->ID, $taxonomy, $t['args'] );
[4820] Fix | Delete
}
[4821] Fix | Delete
$links = array();
[4822] Fix | Delete
[4823] Fix | Delete
foreach ( $terms as $term ) {
[4824] Fix | Delete
$links[] = wp_sprintf( $t['term_template'], esc_attr( get_term_link( $term ) ), $term->name );
[4825] Fix | Delete
}
[4826] Fix | Delete
if ( $links ) {
[4827] Fix | Delete
$taxonomies[ $taxonomy ] = wp_sprintf( $t['template'], $t['label'], $links, $terms );
[4828] Fix | Delete
}
[4829] Fix | Delete
}
[4830] Fix | Delete
return $taxonomies;
[4831] Fix | Delete
}
[4832] Fix | Delete
[4833] Fix | Delete
/**
[4834] Fix | Delete
* Retrieves all taxonomy names for the given post.
[4835] Fix | Delete
*
[4836] Fix | Delete
* @since 2.5.0
[4837] Fix | Delete
*
[4838] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
[4839] Fix | Delete
* @return string[] An array of all taxonomy names for the given post.
[4840] Fix | Delete
*/
[4841] Fix | Delete
function get_post_taxonomies( $post = 0 ) {
[4842] Fix | Delete
$post = get_post( $post );
[4843] Fix | Delete
[4844] Fix | Delete
return get_object_taxonomies( $post );
[4845] Fix | Delete
}
[4846] Fix | Delete
[4847] Fix | Delete
/**
[4848] Fix | Delete
* Determines if the given object is associated with any of the given terms.
[4849] Fix | Delete
*
[4850] Fix | Delete
* The given terms are checked against the object's terms' term_ids, names and slugs.
[4851] Fix | Delete
* Terms given as integers will only be checked against the object's terms' term_ids.
[4852] Fix | Delete
* If no terms are given, determines if object is associated with any terms in the given taxonomy.
[4853] Fix | Delete
*
[4854] Fix | Delete
* @since 2.7.0
[4855] Fix | Delete
*
[4856] Fix | Delete
* @param int $object_id ID of the object (post ID, link ID, ...).
[4857] Fix | Delete
* @param string $taxonomy Single taxonomy name.
[4858] Fix | Delete
* @param int|string|int[]|string[] $terms Optional. Term ID, name, slug, or array of such
[4859] Fix | Delete
* to check against. Default null.
[4860] Fix | Delete
* @return bool|WP_Error WP_Error on input error.
[4861] Fix | Delete
*/
[4862] Fix | Delete
function is_object_in_term( $object_id, $taxonomy, $terms = null ) {
[4863] Fix | Delete
$object_id = (int) $object_id;
[4864] Fix | Delete
if ( ! $object_id ) {
[4865] Fix | Delete
return new WP_Error( 'invalid_object', __( 'Invalid object ID.' ) );
[4866] Fix | Delete
}
[4867] Fix | Delete
[4868] Fix | Delete
$object_terms = get_object_term_cache( $object_id, $taxonomy );
[4869] Fix | Delete
if ( false === $object_terms ) {
[4870] Fix | Delete
$object_terms = wp_get_object_terms( $object_id, $taxonomy, array( 'update_term_meta_cache' => false ) );
[4871] Fix | Delete
if ( is_wp_error( $object_terms ) ) {
[4872] Fix | Delete
return $object_terms;
[4873] Fix | Delete
}
[4874] Fix | Delete
[4875] Fix | Delete
wp_cache_set( $object_id, wp_list_pluck( $object_terms, 'term_id' ), "{$taxonomy}_relationships" );
[4876] Fix | Delete
}
[4877] Fix | Delete
[4878] Fix | Delete
if ( is_wp_error( $object_terms ) ) {
[4879] Fix | Delete
return $object_terms;
[4880] Fix | Delete
}
[4881] Fix | Delete
if ( empty( $object_terms ) ) {
[4882] Fix | Delete
return false;
[4883] Fix | Delete
}
[4884] Fix | Delete
if ( empty( $terms ) ) {
[4885] Fix | Delete
return ( ! empty( $object_terms ) );
[4886] Fix | Delete
}
[4887] Fix | Delete
[4888] Fix | Delete
$terms = (array) $terms;
[4889] Fix | Delete
[4890] Fix | Delete
$ints = array_filter( $terms, 'is_int' );
[4891] Fix | Delete
if ( $ints ) {
[4892] Fix | Delete
$strs = array_diff( $terms, $ints );
[4893] Fix | Delete
} else {
[4894] Fix | Delete
$strs =& $terms;
[4895] Fix | Delete
}
[4896] Fix | Delete
[4897] Fix | Delete
foreach ( $object_terms as $object_term ) {
[4898] Fix | Delete
// If term is an int, check against term_ids only.
[4899] Fix | Delete
if ( $ints && in_array( $object_term->term_id, $ints, true ) ) {
[4900] Fix | Delete
return true;
[4901] Fix | Delete
}
[4902] Fix | Delete
[4903] Fix | Delete
if ( $strs ) {
[4904] Fix | Delete
// Only check numeric strings against term_id, to avoid false matches due to type juggling.
[4905] Fix | Delete
$numeric_strs = array_map( 'intval', array_filter( $strs, 'is_numeric' ) );
[4906] Fix | Delete
if ( in_array( $object_term->term_id, $numeric_strs, true ) ) {
[4907] Fix | Delete
return true;
[4908] Fix | Delete
}
[4909] Fix | Delete
[4910] Fix | Delete
if ( in_array( $object_term->name, $strs, true ) ) {
[4911] Fix | Delete
return true;
[4912] Fix | Delete
}
[4913] Fix | Delete
if ( in_array( $object_term->slug, $strs, true ) ) {
[4914] Fix | Delete
return true;
[4915] Fix | Delete
}
[4916] Fix | Delete
}
[4917] Fix | Delete
}
[4918] Fix | Delete
[4919] Fix | Delete
return false;
[4920] Fix | Delete
}
[4921] Fix | Delete
[4922] Fix | Delete
/**
[4923] Fix | Delete
* Determines if the given object type is associated with the given taxonomy.
[4924] Fix | Delete
*
[4925] Fix | Delete
* @since 3.0.0
[4926] Fix | Delete
*
[4927] Fix | Delete
* @param string $object_type Object type string.
[4928] Fix | Delete
* @param string $taxonomy Single taxonomy name.
[4929] Fix | Delete
* @return bool True if object is associated with the taxonomy, otherwise false.
[4930] Fix | Delete
*/
[4931] Fix | Delete
function is_object_in_taxonomy( $object_type, $taxonomy ) {
[4932] Fix | Delete
$taxonomies = get_object_taxonomies( $object_type );
[4933] Fix | Delete
if ( empty( $taxonomies ) ) {
[4934] Fix | Delete
return false;
[4935] Fix | Delete
}
[4936] Fix | Delete
return in_array( $taxonomy, $taxonomies, true );
[4937] Fix | Delete
}
[4938] Fix | Delete
[4939] Fix | Delete
/**
[4940] Fix | Delete
* Gets an array of ancestor IDs for a given object.
[4941] Fix | Delete
*
[4942] Fix | Delete
* @since 3.1.0
[4943] Fix | Delete
* @since 4.1.0 Introduced the `$resource_type` argument.
[4944] Fix | Delete
*
[4945] Fix | Delete
* @param int $object_id Optional. The ID of the object. Default 0.
[4946] Fix | Delete
* @param string $object_type Optional. The type of object for which we'll be retrieving
[4947] Fix | Delete
* ancestors. Accepts a post type or a taxonomy name. Default empty.
[4948] Fix | Delete
* @param string $resource_type Optional. Type of resource $object_type is. Accepts 'post_type'
[4949] Fix | Delete
* or 'taxonomy'. Default empty.
[4950] Fix | Delete
* @return int[] An array of IDs of ancestors from lowest to highest in the hierarchy.
[4951] Fix | Delete
*/
[4952] Fix | Delete
function get_ancestors( $object_id = 0, $object_type = '', $resource_type = '' ) {
[4953] Fix | Delete
$object_id = (int) $object_id;
[4954] Fix | Delete
[4955] Fix | Delete
$ancestors = array();
[4956] Fix | Delete
[4957] Fix | Delete
if ( empty( $object_id ) ) {
[4958] Fix | Delete
[4959] Fix | Delete
/** This filter is documented in wp-includes/taxonomy.php */
[4960] Fix | Delete
return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );
[4961] Fix | Delete
}
[4962] Fix | Delete
[4963] Fix | Delete
if ( ! $resource_type ) {
[4964] Fix | Delete
if ( is_taxonomy_hierarchical( $object_type ) ) {
[4965] Fix | Delete
$resource_type = 'taxonomy';
[4966] Fix | Delete
} elseif ( post_type_exists( $object_type ) ) {
[4967] Fix | Delete
$resource_type = 'post_type';
[4968] Fix | Delete
}
[4969] Fix | Delete
}
[4970] Fix | Delete
[4971] Fix | Delete
if ( 'taxonomy' === $resource_type ) {
[4972] Fix | Delete
$term = get_term( $object_id, $object_type );
[4973] Fix | Delete
while ( ! is_wp_error( $term ) && ! empty( $term->parent ) && ! in_array( $term->parent, $ancestors, true ) ) {
[4974] Fix | Delete
$ancestors[] = (int) $term->parent;
[4975] Fix | Delete
$term = get_term( $term->parent, $object_type );
[4976] Fix | Delete
}
[4977] Fix | Delete
} elseif ( 'post_type' === $resource_type ) {
[4978] Fix | Delete
$ancestors = get_post_ancestors( $object_id );
[4979] Fix | Delete
}
[4980] Fix | Delete
[4981] Fix | Delete
/**
[4982] Fix | Delete
* Filters a given object's ancestors.
[4983] Fix | Delete
*
[4984] Fix | Delete
* @since 3.1.0
[4985] Fix | Delete
* @since 4.1.1 Introduced the `$resource_type` parameter.
[4986] Fix | Delete
*
[4987] Fix | Delete
* @param int[] $ancestors An array of IDs of object ancestors.
[4988] Fix | Delete
* @param int $object_id Object ID.
[4989] Fix | Delete
* @param string $object_type Type of object.
[4990] Fix | Delete
* @param string $resource_type Type of resource $object_type is.
[4991] Fix | Delete
*/
[4992] Fix | Delete
return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );
[4993] Fix | Delete
}
[4994] Fix | Delete
[4995] Fix | Delete
/**
[4996] Fix | Delete
* Returns the term's parent's term ID.
[4997] Fix | Delete
*
[4998] Fix | Delete
* @since 3.1.0
[4999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function