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
} elseif ( ! $_term ) {
[1000] Fix | Delete
return null;
[1001] Fix | Delete
}
[1002] Fix | Delete
[1003] Fix | Delete
// Ensure for filters that this is not empty.
[1004] Fix | Delete
$taxonomy = $_term->taxonomy;
[1005] Fix | Delete
[1006] Fix | Delete
$old_term = $_term;
[1007] Fix | Delete
/**
[1008] Fix | Delete
* Filters a taxonomy term object.
[1009] Fix | Delete
*
[1010] Fix | Delete
* The {@see 'get_$taxonomy'} hook is also available for targeting a specific
[1011] Fix | Delete
* taxonomy.
[1012] Fix | Delete
*
[1013] Fix | Delete
* @since 2.3.0
[1014] Fix | Delete
* @since 4.4.0 `$_term` is now a `WP_Term` object.
[1015] Fix | Delete
*
[1016] Fix | Delete
* @param WP_Term $_term Term object.
[1017] Fix | Delete
* @param string $taxonomy The taxonomy slug.
[1018] Fix | Delete
*/
[1019] Fix | Delete
$_term = apply_filters( 'get_term', $_term, $taxonomy );
[1020] Fix | Delete
[1021] Fix | Delete
/**
[1022] Fix | Delete
* Filters a taxonomy term object.
[1023] Fix | Delete
*
[1024] Fix | Delete
* The dynamic portion of the hook name, `$taxonomy`, refers
[1025] Fix | Delete
* to the slug of the term's taxonomy.
[1026] Fix | Delete
*
[1027] Fix | Delete
* Possible hook names include:
[1028] Fix | Delete
*
[1029] Fix | Delete
* - `get_category`
[1030] Fix | Delete
* - `get_post_tag`
[1031] Fix | Delete
*
[1032] Fix | Delete
* @since 2.3.0
[1033] Fix | Delete
* @since 4.4.0 `$_term` is now a `WP_Term` object.
[1034] Fix | Delete
*
[1035] Fix | Delete
* @param WP_Term $_term Term object.
[1036] Fix | Delete
* @param string $taxonomy The taxonomy slug.
[1037] Fix | Delete
*/
[1038] Fix | Delete
$_term = apply_filters( "get_{$taxonomy}", $_term, $taxonomy );
[1039] Fix | Delete
[1040] Fix | Delete
// Bail if a filter callback has changed the type of the `$_term` object.
[1041] Fix | Delete
if ( ! ( $_term instanceof WP_Term ) ) {
[1042] Fix | Delete
return $_term;
[1043] Fix | Delete
}
[1044] Fix | Delete
[1045] Fix | Delete
// Sanitize term, according to the specified filter.
[1046] Fix | Delete
if ( $_term !== $old_term || $_term->filter !== $filter ) {
[1047] Fix | Delete
$_term->filter( $filter );
[1048] Fix | Delete
}
[1049] Fix | Delete
[1050] Fix | Delete
if ( ARRAY_A === $output ) {
[1051] Fix | Delete
return $_term->to_array();
[1052] Fix | Delete
} elseif ( ARRAY_N === $output ) {
[1053] Fix | Delete
return array_values( $_term->to_array() );
[1054] Fix | Delete
}
[1055] Fix | Delete
[1056] Fix | Delete
return $_term;
[1057] Fix | Delete
}
[1058] Fix | Delete
[1059] Fix | Delete
/**
[1060] Fix | Delete
* Gets all term data from database by term field and data.
[1061] Fix | Delete
*
[1062] Fix | Delete
* Warning: $value is not escaped for 'name' $field. You must do it yourself, if
[1063] Fix | Delete
* required.
[1064] Fix | Delete
*
[1065] Fix | Delete
* The default $field is 'id', therefore it is possible to also use null for
[1066] Fix | Delete
* field, but not recommended that you do so.
[1067] Fix | Delete
*
[1068] Fix | Delete
* If $value does not exist, the return value will be false. If $taxonomy exists
[1069] Fix | Delete
* and $field and $value combinations exist, the term will be returned.
[1070] Fix | Delete
*
[1071] Fix | Delete
* This function will always return the first term that matches the `$field`-
[1072] Fix | Delete
* `$value`-`$taxonomy` combination specified in the parameters. If your query
[1073] Fix | Delete
* is likely to match more than one term (as is likely to be the case when
[1074] Fix | Delete
* `$field` is 'name', for example), consider using get_terms() instead; that
[1075] Fix | Delete
* way, you will get all matching terms, and can provide your own logic for
[1076] Fix | Delete
* deciding which one was intended.
[1077] Fix | Delete
*
[1078] Fix | Delete
* @todo Better formatting for DocBlock.
[1079] Fix | Delete
*
[1080] Fix | Delete
* @since 2.3.0
[1081] Fix | Delete
* @since 4.4.0 `$taxonomy` is optional if `$field` is 'term_taxonomy_id'. Converted to return
[1082] Fix | Delete
* a WP_Term object if `$output` is `OBJECT`.
[1083] Fix | Delete
* @since 5.5.0 Added 'ID' as an alias of 'id' for the `$field` parameter.
[1084] Fix | Delete
*
[1085] Fix | Delete
* @see sanitize_term_field() The $context param lists the available values for get_term_by() $filter param.
[1086] Fix | Delete
*
[1087] Fix | Delete
* @param string $field Either 'slug', 'name', 'term_id' (or 'id', 'ID'), or 'term_taxonomy_id'.
[1088] Fix | Delete
* @param string|int $value Search for this term value.
[1089] Fix | Delete
* @param string $taxonomy Taxonomy name. Optional, if `$field` is 'term_taxonomy_id'.
[1090] Fix | Delete
* @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
[1091] Fix | Delete
* correspond to a WP_Term object, an associative array, or a numeric array,
[1092] Fix | Delete
* respectively. Default OBJECT.
[1093] Fix | Delete
* @param string $filter Optional. How to sanitize term fields. Default 'raw'.
[1094] Fix | Delete
* @return WP_Term|array|false WP_Term instance (or array) on success, depending on the `$output` value.
[1095] Fix | Delete
* False if `$taxonomy` does not exist or `$term` was not found.
[1096] Fix | Delete
*/
[1097] Fix | Delete
function get_term_by( $field, $value, $taxonomy = '', $output = OBJECT, $filter = 'raw' ) {
[1098] Fix | Delete
[1099] Fix | Delete
// 'term_taxonomy_id' lookups don't require taxonomy checks.
[1100] Fix | Delete
if ( 'term_taxonomy_id' !== $field && ! taxonomy_exists( $taxonomy ) ) {
[1101] Fix | Delete
return false;
[1102] Fix | Delete
}
[1103] Fix | Delete
[1104] Fix | Delete
// No need to perform a query for empty 'slug' or 'name'.
[1105] Fix | Delete
if ( 'slug' === $field || 'name' === $field ) {
[1106] Fix | Delete
$value = (string) $value;
[1107] Fix | Delete
[1108] Fix | Delete
if ( 0 === strlen( $value ) ) {
[1109] Fix | Delete
return false;
[1110] Fix | Delete
}
[1111] Fix | Delete
}
[1112] Fix | Delete
[1113] Fix | Delete
if ( 'id' === $field || 'ID' === $field || 'term_id' === $field ) {
[1114] Fix | Delete
$term = get_term( (int) $value, $taxonomy, $output, $filter );
[1115] Fix | Delete
if ( is_wp_error( $term ) || null === $term ) {
[1116] Fix | Delete
$term = false;
[1117] Fix | Delete
}
[1118] Fix | Delete
return $term;
[1119] Fix | Delete
}
[1120] Fix | Delete
[1121] Fix | Delete
$args = array(
[1122] Fix | Delete
'get' => 'all',
[1123] Fix | Delete
'number' => 1,
[1124] Fix | Delete
'taxonomy' => $taxonomy,
[1125] Fix | Delete
'update_term_meta_cache' => false,
[1126] Fix | Delete
'orderby' => 'none',
[1127] Fix | Delete
'suppress_filter' => true,
[1128] Fix | Delete
);
[1129] Fix | Delete
[1130] Fix | Delete
switch ( $field ) {
[1131] Fix | Delete
case 'slug':
[1132] Fix | Delete
$args['slug'] = $value;
[1133] Fix | Delete
break;
[1134] Fix | Delete
case 'name':
[1135] Fix | Delete
$args['name'] = $value;
[1136] Fix | Delete
break;
[1137] Fix | Delete
case 'term_taxonomy_id':
[1138] Fix | Delete
$args['term_taxonomy_id'] = $value;
[1139] Fix | Delete
unset( $args['taxonomy'] );
[1140] Fix | Delete
break;
[1141] Fix | Delete
default:
[1142] Fix | Delete
return false;
[1143] Fix | Delete
}
[1144] Fix | Delete
[1145] Fix | Delete
$terms = get_terms( $args );
[1146] Fix | Delete
if ( is_wp_error( $terms ) || empty( $terms ) ) {
[1147] Fix | Delete
return false;
[1148] Fix | Delete
}
[1149] Fix | Delete
[1150] Fix | Delete
$term = array_shift( $terms );
[1151] Fix | Delete
[1152] Fix | Delete
// In the case of 'term_taxonomy_id', override the provided `$taxonomy` with whatever we find in the DB.
[1153] Fix | Delete
if ( 'term_taxonomy_id' === $field ) {
[1154] Fix | Delete
$taxonomy = $term->taxonomy;
[1155] Fix | Delete
}
[1156] Fix | Delete
[1157] Fix | Delete
return get_term( $term, $taxonomy, $output, $filter );
[1158] Fix | Delete
}
[1159] Fix | Delete
[1160] Fix | Delete
/**
[1161] Fix | Delete
* Merges all term children into a single array of their IDs.
[1162] Fix | Delete
*
[1163] Fix | Delete
* This recursive function will merge all of the children of $term into the same
[1164] Fix | Delete
* array of term IDs. Only useful for taxonomies which are hierarchical.
[1165] Fix | Delete
*
[1166] Fix | Delete
* Will return an empty array if $term does not exist in $taxonomy.
[1167] Fix | Delete
*
[1168] Fix | Delete
* @since 2.3.0
[1169] Fix | Delete
*
[1170] Fix | Delete
* @param int $term_id ID of term to get children.
[1171] Fix | Delete
* @param string $taxonomy Taxonomy name.
[1172] Fix | Delete
* @return array|WP_Error List of term IDs. WP_Error returned if `$taxonomy` does not exist.
[1173] Fix | Delete
*/
[1174] Fix | Delete
function get_term_children( $term_id, $taxonomy ) {
[1175] Fix | Delete
if ( ! taxonomy_exists( $taxonomy ) ) {
[1176] Fix | Delete
return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
[1177] Fix | Delete
}
[1178] Fix | Delete
[1179] Fix | Delete
$term_id = (int) $term_id;
[1180] Fix | Delete
[1181] Fix | Delete
$terms = _get_term_hierarchy( $taxonomy );
[1182] Fix | Delete
[1183] Fix | Delete
if ( ! isset( $terms[ $term_id ] ) ) {
[1184] Fix | Delete
return array();
[1185] Fix | Delete
}
[1186] Fix | Delete
[1187] Fix | Delete
$children = $terms[ $term_id ];
[1188] Fix | Delete
[1189] Fix | Delete
foreach ( (array) $terms[ $term_id ] as $child ) {
[1190] Fix | Delete
if ( $term_id === $child ) {
[1191] Fix | Delete
continue;
[1192] Fix | Delete
}
[1193] Fix | Delete
[1194] Fix | Delete
if ( isset( $terms[ $child ] ) ) {
[1195] Fix | Delete
$children = array_merge( $children, get_term_children( $child, $taxonomy ) );
[1196] Fix | Delete
}
[1197] Fix | Delete
}
[1198] Fix | Delete
[1199] Fix | Delete
return $children;
[1200] Fix | Delete
}
[1201] Fix | Delete
[1202] Fix | Delete
/**
[1203] Fix | Delete
* Gets sanitized term field.
[1204] Fix | Delete
*
[1205] Fix | Delete
* The function is for contextual reasons and for simplicity of usage.
[1206] Fix | Delete
*
[1207] Fix | Delete
* @since 2.3.0
[1208] Fix | Delete
* @since 4.4.0 The `$taxonomy` parameter was made optional. `$term` can also now accept a WP_Term object.
[1209] Fix | Delete
*
[1210] Fix | Delete
* @see sanitize_term_field()
[1211] Fix | Delete
*
[1212] Fix | Delete
* @param string $field Term field to fetch.
[1213] Fix | Delete
* @param int|WP_Term $term Term ID or object.
[1214] Fix | Delete
* @param string $taxonomy Optional. Taxonomy name. Default empty.
[1215] Fix | Delete
* @param string $context Optional. How to sanitize term fields. Look at sanitize_term_field() for available options.
[1216] Fix | Delete
* Default 'display'.
[1217] Fix | Delete
* @return string|int|null|WP_Error Will return an empty string if $term is not an object or if $field is not set in $term.
[1218] Fix | Delete
*/
[1219] Fix | Delete
function get_term_field( $field, $term, $taxonomy = '', $context = 'display' ) {
[1220] Fix | Delete
$term = get_term( $term, $taxonomy );
[1221] Fix | Delete
if ( is_wp_error( $term ) ) {
[1222] Fix | Delete
return $term;
[1223] Fix | Delete
}
[1224] Fix | Delete
[1225] Fix | Delete
if ( ! is_object( $term ) ) {
[1226] Fix | Delete
return '';
[1227] Fix | Delete
}
[1228] Fix | Delete
[1229] Fix | Delete
if ( ! isset( $term->$field ) ) {
[1230] Fix | Delete
return '';
[1231] Fix | Delete
}
[1232] Fix | Delete
[1233] Fix | Delete
return sanitize_term_field( $field, $term->$field, $term->term_id, $term->taxonomy, $context );
[1234] Fix | Delete
}
[1235] Fix | Delete
[1236] Fix | Delete
/**
[1237] Fix | Delete
* Sanitizes term for editing.
[1238] Fix | Delete
*
[1239] Fix | Delete
* Return value is sanitize_term() and usage is for sanitizing the term for
[1240] Fix | Delete
* editing. Function is for contextual and simplicity.
[1241] Fix | Delete
*
[1242] Fix | Delete
* @since 2.3.0
[1243] Fix | Delete
*
[1244] Fix | Delete
* @param int|object $id Term ID or object.
[1245] Fix | Delete
* @param string $taxonomy Taxonomy name.
[1246] Fix | Delete
* @return string|int|null|WP_Error Will return empty string if $term is not an object.
[1247] Fix | Delete
*/
[1248] Fix | Delete
function get_term_to_edit( $id, $taxonomy ) {
[1249] Fix | Delete
$term = get_term( $id, $taxonomy );
[1250] Fix | Delete
[1251] Fix | Delete
if ( is_wp_error( $term ) ) {
[1252] Fix | Delete
return $term;
[1253] Fix | Delete
}
[1254] Fix | Delete
[1255] Fix | Delete
if ( ! is_object( $term ) ) {
[1256] Fix | Delete
return '';
[1257] Fix | Delete
}
[1258] Fix | Delete
[1259] Fix | Delete
return sanitize_term( $term, $taxonomy, 'edit' );
[1260] Fix | Delete
}
[1261] Fix | Delete
[1262] Fix | Delete
/**
[1263] Fix | Delete
* Retrieves the terms in a given taxonomy or list of taxonomies.
[1264] Fix | Delete
*
[1265] Fix | Delete
* You can fully inject any customizations to the query before it is sent, as
[1266] Fix | Delete
* well as control the output with a filter.
[1267] Fix | Delete
*
[1268] Fix | Delete
* The return type varies depending on the value passed to `$args['fields']`. See
[1269] Fix | Delete
* WP_Term_Query::get_terms() for details. In all cases, a `WP_Error` object will
[1270] Fix | Delete
* be returned if an invalid taxonomy is requested.
[1271] Fix | Delete
*
[1272] Fix | Delete
* The {@see 'get_terms'} filter will be called when the cache has the term and will
[1273] Fix | Delete
* pass the found term along with the array of $taxonomies and array of $args.
[1274] Fix | Delete
* This filter is also called before the array of terms is passed and will pass
[1275] Fix | Delete
* the array of terms, along with the $taxonomies and $args.
[1276] Fix | Delete
*
[1277] Fix | Delete
* The {@see 'list_terms_exclusions'} filter passes the compiled exclusions along with
[1278] Fix | Delete
* the $args.
[1279] Fix | Delete
*
[1280] Fix | Delete
* The {@see 'get_terms_orderby'} filter passes the `ORDER BY` clause for the query
[1281] Fix | Delete
* along with the $args array.
[1282] Fix | Delete
*
[1283] Fix | Delete
* Taxonomy or an array of taxonomies should be passed via the 'taxonomy' argument
[1284] Fix | Delete
* in the `$args` array:
[1285] Fix | Delete
*
[1286] Fix | Delete
* $terms = get_terms( array(
[1287] Fix | Delete
* 'taxonomy' => 'post_tag',
[1288] Fix | Delete
* 'hide_empty' => false,
[1289] Fix | Delete
* ) );
[1290] Fix | Delete
*
[1291] Fix | Delete
* Prior to 4.5.0, taxonomy was passed as the first parameter of `get_terms()`.
[1292] Fix | Delete
*
[1293] Fix | Delete
* @since 2.3.0
[1294] Fix | Delete
* @since 4.2.0 Introduced 'name' and 'childless' parameters.
[1295] Fix | Delete
* @since 4.4.0 Introduced the ability to pass 'term_id' as an alias of 'id' for the `orderby` parameter.
[1296] Fix | Delete
* Introduced the 'meta_query' and 'update_term_meta_cache' parameters. Converted to return
[1297] Fix | Delete
* a list of WP_Term objects.
[1298] Fix | Delete
* @since 4.5.0 Changed the function signature so that the `$args` array can be provided as the first parameter.
[1299] Fix | Delete
* Introduced 'meta_key' and 'meta_value' parameters. Introduced the ability to order results by metadata.
[1300] Fix | Delete
* @since 4.8.0 Introduced 'suppress_filter' parameter.
[1301] Fix | Delete
*
[1302] Fix | Delete
* @internal The `$deprecated` parameter is parsed for backward compatibility only.
[1303] Fix | Delete
*
[1304] Fix | Delete
* @param array|string $args Optional. Array or string of arguments. See WP_Term_Query::__construct()
[1305] Fix | Delete
* for information on accepted arguments. Default empty array.
[1306] Fix | Delete
* @param array|string $deprecated Optional. Argument array, when using the legacy function parameter format.
[1307] Fix | Delete
* If present, this parameter will be interpreted as `$args`, and the first
[1308] Fix | Delete
* function parameter will be parsed as a taxonomy or array of taxonomies.
[1309] Fix | Delete
* Default empty.
[1310] Fix | Delete
* @return WP_Term[]|int[]|string[]|string|WP_Error Array of terms, a count thereof as a numeric string,
[1311] Fix | Delete
* or WP_Error if any of the taxonomies do not exist.
[1312] Fix | Delete
* See the function description for more information.
[1313] Fix | Delete
*/
[1314] Fix | Delete
function get_terms( $args = array(), $deprecated = '' ) {
[1315] Fix | Delete
$term_query = new WP_Term_Query();
[1316] Fix | Delete
[1317] Fix | Delete
$defaults = array(
[1318] Fix | Delete
'suppress_filter' => false,
[1319] Fix | Delete
);
[1320] Fix | Delete
[1321] Fix | Delete
/*
[1322] Fix | Delete
* Legacy argument format ($taxonomy, $args) takes precedence.
[1323] Fix | Delete
*
[1324] Fix | Delete
* We detect legacy argument format by checking if
[1325] Fix | Delete
* (a) a second non-empty parameter is passed, or
[1326] Fix | Delete
* (b) the first parameter shares no keys with the default array (ie, it's a list of taxonomies)
[1327] Fix | Delete
*/
[1328] Fix | Delete
$_args = wp_parse_args( $args );
[1329] Fix | Delete
$key_intersect = array_intersect_key( $term_query->query_var_defaults, (array) $_args );
[1330] Fix | Delete
$do_legacy_args = $deprecated || empty( $key_intersect );
[1331] Fix | Delete
[1332] Fix | Delete
if ( $do_legacy_args ) {
[1333] Fix | Delete
$taxonomies = (array) $args;
[1334] Fix | Delete
$args = wp_parse_args( $deprecated, $defaults );
[1335] Fix | Delete
$args['taxonomy'] = $taxonomies;
[1336] Fix | Delete
} else {
[1337] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[1338] Fix | Delete
if ( isset( $args['taxonomy'] ) && null !== $args['taxonomy'] ) {
[1339] Fix | Delete
$args['taxonomy'] = (array) $args['taxonomy'];
[1340] Fix | Delete
}
[1341] Fix | Delete
}
[1342] Fix | Delete
[1343] Fix | Delete
if ( ! empty( $args['taxonomy'] ) ) {
[1344] Fix | Delete
foreach ( $args['taxonomy'] as $taxonomy ) {
[1345] Fix | Delete
if ( ! taxonomy_exists( $taxonomy ) ) {
[1346] Fix | Delete
return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
[1347] Fix | Delete
}
[1348] Fix | Delete
}
[1349] Fix | Delete
}
[1350] Fix | Delete
[1351] Fix | Delete
// Don't pass suppress_filter to WP_Term_Query.
[1352] Fix | Delete
$suppress_filter = $args['suppress_filter'];
[1353] Fix | Delete
unset( $args['suppress_filter'] );
[1354] Fix | Delete
[1355] Fix | Delete
$terms = $term_query->query( $args );
[1356] Fix | Delete
[1357] Fix | Delete
// Count queries are not filtered, for legacy reasons.
[1358] Fix | Delete
if ( ! is_array( $terms ) ) {
[1359] Fix | Delete
return $terms;
[1360] Fix | Delete
}
[1361] Fix | Delete
[1362] Fix | Delete
if ( $suppress_filter ) {
[1363] Fix | Delete
return $terms;
[1364] Fix | Delete
}
[1365] Fix | Delete
[1366] Fix | Delete
/**
[1367] Fix | Delete
* Filters the found terms.
[1368] Fix | Delete
*
[1369] Fix | Delete
* @since 2.3.0
[1370] Fix | Delete
* @since 4.6.0 Added the `$term_query` parameter.
[1371] Fix | Delete
*
[1372] Fix | Delete
* @param array $terms Array of found terms.
[1373] Fix | Delete
* @param array|null $taxonomies An array of taxonomies if known.
[1374] Fix | Delete
* @param array $args An array of get_terms() arguments.
[1375] Fix | Delete
* @param WP_Term_Query $term_query The WP_Term_Query object.
[1376] Fix | Delete
*/
[1377] Fix | Delete
return apply_filters( 'get_terms', $terms, $term_query->query_vars['taxonomy'], $term_query->query_vars, $term_query );
[1378] Fix | Delete
}
[1379] Fix | Delete
[1380] Fix | Delete
/**
[1381] Fix | Delete
* Adds metadata to a term.
[1382] Fix | Delete
*
[1383] Fix | Delete
* @since 4.4.0
[1384] Fix | Delete
*
[1385] Fix | Delete
* @param int $term_id Term ID.
[1386] Fix | Delete
* @param string $meta_key Metadata name.
[1387] Fix | Delete
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
[1388] Fix | Delete
* @param bool $unique Optional. Whether the same key should not be added.
[1389] Fix | Delete
* Default false.
[1390] Fix | Delete
* @return int|false|WP_Error Meta ID on success, false on failure.
[1391] Fix | Delete
* WP_Error when term_id is ambiguous between taxonomies.
[1392] Fix | Delete
*/
[1393] Fix | Delete
function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) {
[1394] Fix | Delete
if ( wp_term_is_shared( $term_id ) ) {
[1395] Fix | Delete
return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.' ), $term_id );
[1396] Fix | Delete
}
[1397] Fix | Delete
[1398] Fix | Delete
return add_metadata( 'term', $term_id, $meta_key, $meta_value, $unique );
[1399] Fix | Delete
}
[1400] Fix | Delete
[1401] Fix | Delete
/**
[1402] Fix | Delete
* Removes metadata matching criteria from a term.
[1403] Fix | Delete
*
[1404] Fix | Delete
* @since 4.4.0
[1405] Fix | Delete
*
[1406] Fix | Delete
* @param int $term_id Term ID.
[1407] Fix | Delete
* @param string $meta_key Metadata name.
[1408] Fix | Delete
* @param mixed $meta_value Optional. Metadata value. If provided,
[1409] Fix | Delete
* rows will only be removed that match the value.
[1410] Fix | Delete
* Must be serializable if non-scalar. Default empty.
[1411] Fix | Delete
* @return bool True on success, false on failure.
[1412] Fix | Delete
*/
[1413] Fix | Delete
function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) {
[1414] Fix | Delete
return delete_metadata( 'term', $term_id, $meta_key, $meta_value );
[1415] Fix | Delete
}
[1416] Fix | Delete
[1417] Fix | Delete
/**
[1418] Fix | Delete
* Retrieves metadata for a term.
[1419] Fix | Delete
*
[1420] Fix | Delete
* @since 4.4.0
[1421] Fix | Delete
*
[1422] Fix | Delete
* @param int $term_id Term ID.
[1423] Fix | Delete
* @param string $key Optional. The meta key to retrieve. By default,
[1424] Fix | Delete
* returns data for all keys. Default empty.
[1425] Fix | Delete
* @param bool $single Optional. Whether to return a single value.
[1426] Fix | Delete
* This parameter has no effect if `$key` is not specified.
[1427] Fix | Delete
* Default false.
[1428] Fix | Delete
* @return mixed An array of values if `$single` is false.
[1429] Fix | Delete
* The value of the meta field if `$single` is true.
[1430] Fix | Delete
* False for an invalid `$term_id` (non-numeric, zero, or negative value).
[1431] Fix | Delete
* An empty string if a valid but non-existing term ID is passed.
[1432] Fix | Delete
*/
[1433] Fix | Delete
function get_term_meta( $term_id, $key = '', $single = false ) {
[1434] Fix | Delete
return get_metadata( 'term', $term_id, $key, $single );
[1435] Fix | Delete
}
[1436] Fix | Delete
[1437] Fix | Delete
/**
[1438] Fix | Delete
* Updates term metadata.
[1439] Fix | Delete
*
[1440] Fix | Delete
* Use the `$prev_value` parameter to differentiate between meta fields with the same key and term ID.
[1441] Fix | Delete
*
[1442] Fix | Delete
* If the meta field for the term does not exist, it will be added.
[1443] Fix | Delete
*
[1444] Fix | Delete
* @since 4.4.0
[1445] Fix | Delete
*
[1446] Fix | Delete
* @param int $term_id Term ID.
[1447] Fix | Delete
* @param string $meta_key Metadata key.
[1448] Fix | Delete
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
[1449] Fix | Delete
* @param mixed $prev_value Optional. Previous value to check before updating.
[1450] Fix | Delete
* If specified, only update existing metadata entries with
[1451] Fix | Delete
* this value. Otherwise, update all entries. Default empty.
[1452] Fix | Delete
* @return int|bool|WP_Error Meta ID if the key didn't exist. true on successful update,
[1453] Fix | Delete
* false on failure or if the value passed to the function
[1454] Fix | Delete
* is the same as the one that is already in the database.
[1455] Fix | Delete
* WP_Error when term_id is ambiguous between taxonomies.
[1456] Fix | Delete
*/
[1457] Fix | Delete
function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) {
[1458] Fix | Delete
if ( wp_term_is_shared( $term_id ) ) {
[1459] Fix | Delete
return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.' ), $term_id );
[1460] Fix | Delete
}
[1461] Fix | Delete
[1462] Fix | Delete
return update_metadata( 'term', $term_id, $meta_key, $meta_value, $prev_value );
[1463] Fix | Delete
}
[1464] Fix | Delete
[1465] Fix | Delete
/**
[1466] Fix | Delete
* Updates metadata cache for list of term IDs.
[1467] Fix | Delete
*
[1468] Fix | Delete
* Performs SQL query to retrieve all metadata for the terms matching `$term_ids` and stores them in the cache.
[1469] Fix | Delete
* Subsequent calls to `get_term_meta()` will not need to query the database.
[1470] Fix | Delete
*
[1471] Fix | Delete
* @since 4.4.0
[1472] Fix | Delete
*
[1473] Fix | Delete
* @param array $term_ids List of term IDs.
[1474] Fix | Delete
* @return array|false An array of metadata on success, false if there is nothing to update.
[1475] Fix | Delete
*/
[1476] Fix | Delete
function update_termmeta_cache( $term_ids ) {
[1477] Fix | Delete
return update_meta_cache( 'term', $term_ids );
[1478] Fix | Delete
}
[1479] Fix | Delete
[1480] Fix | Delete
[1481] Fix | Delete
/**
[1482] Fix | Delete
* Queue term meta for lazy-loading.
[1483] Fix | Delete
*
[1484] Fix | Delete
* @since 6.3.0
[1485] Fix | Delete
*
[1486] Fix | Delete
* @param array $term_ids List of term IDs.
[1487] Fix | Delete
*/
[1488] Fix | Delete
function wp_lazyload_term_meta( array $term_ids ) {
[1489] Fix | Delete
if ( empty( $term_ids ) ) {
[1490] Fix | Delete
return;
[1491] Fix | Delete
}
[1492] Fix | Delete
$lazyloader = wp_metadata_lazyloader();
[1493] Fix | Delete
$lazyloader->queue_objects( 'term', $term_ids );
[1494] Fix | Delete
}
[1495] Fix | Delete
[1496] Fix | Delete
/**
[1497] Fix | Delete
* Gets all meta data, including meta IDs, for the given term ID.
[1498] Fix | Delete
*
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function