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
* @since 4.9.0
[1500] Fix | Delete
*
[1501] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[1502] Fix | Delete
*
[1503] Fix | Delete
* @param int $term_id Term ID.
[1504] Fix | Delete
* @return array|false Array with meta data, or false when the meta table is not installed.
[1505] Fix | Delete
*/
[1506] Fix | Delete
function has_term_meta( $term_id ) {
[1507] Fix | Delete
$check = wp_check_term_meta_support_prefilter( null );
[1508] Fix | Delete
if ( null !== $check ) {
[1509] Fix | Delete
return $check;
[1510] Fix | Delete
}
[1511] Fix | Delete
[1512] Fix | Delete
global $wpdb;
[1513] Fix | Delete
[1514] Fix | Delete
return $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value, meta_id, term_id FROM $wpdb->termmeta WHERE term_id = %d ORDER BY meta_key,meta_id", $term_id ), ARRAY_A );
[1515] Fix | Delete
}
[1516] Fix | Delete
[1517] Fix | Delete
/**
[1518] Fix | Delete
* Registers a meta key for terms.
[1519] Fix | Delete
*
[1520] Fix | Delete
* @since 4.9.8
[1521] Fix | Delete
*
[1522] Fix | Delete
* @param string $taxonomy Taxonomy to register a meta key for. Pass an empty string
[1523] Fix | Delete
* to register the meta key across all existing taxonomies.
[1524] Fix | Delete
* @param string $meta_key The meta key to register.
[1525] Fix | Delete
* @param array $args Data used to describe the meta key when registered. See
[1526] Fix | Delete
* {@see register_meta()} for a list of supported arguments.
[1527] Fix | Delete
* @return bool True if the meta key was successfully registered, false if not.
[1528] Fix | Delete
*/
[1529] Fix | Delete
function register_term_meta( $taxonomy, $meta_key, array $args ) {
[1530] Fix | Delete
$args['object_subtype'] = $taxonomy;
[1531] Fix | Delete
[1532] Fix | Delete
return register_meta( 'term', $meta_key, $args );
[1533] Fix | Delete
}
[1534] Fix | Delete
[1535] Fix | Delete
/**
[1536] Fix | Delete
* Unregisters a meta key for terms.
[1537] Fix | Delete
*
[1538] Fix | Delete
* @since 4.9.8
[1539] Fix | Delete
*
[1540] Fix | Delete
* @param string $taxonomy Taxonomy the meta key is currently registered for. Pass
[1541] Fix | Delete
* an empty string if the meta key is registered across all
[1542] Fix | Delete
* existing taxonomies.
[1543] Fix | Delete
* @param string $meta_key The meta key to unregister.
[1544] Fix | Delete
* @return bool True on success, false if the meta key was not previously registered.
[1545] Fix | Delete
*/
[1546] Fix | Delete
function unregister_term_meta( $taxonomy, $meta_key ) {
[1547] Fix | Delete
return unregister_meta_key( 'term', $meta_key, $taxonomy );
[1548] Fix | Delete
}
[1549] Fix | Delete
[1550] Fix | Delete
/**
[1551] Fix | Delete
* Determines whether a taxonomy term exists.
[1552] Fix | Delete
*
[1553] Fix | Delete
* Formerly is_term(), introduced in 2.3.0.
[1554] Fix | Delete
*
[1555] Fix | Delete
* For more information on this and similar theme functions, check out
[1556] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[1557] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[1558] Fix | Delete
*
[1559] Fix | Delete
* @since 3.0.0
[1560] Fix | Delete
* @since 6.0.0 Converted to use `get_terms()`.
[1561] Fix | Delete
*
[1562] Fix | Delete
* @global bool $_wp_suspend_cache_invalidation
[1563] Fix | Delete
*
[1564] Fix | Delete
* @param int|string $term The term to check. Accepts term ID, slug, or name.
[1565] Fix | Delete
* @param string $taxonomy Optional. The taxonomy name to use.
[1566] Fix | Delete
* @param int $parent_term Optional. ID of parent term under which to confine the exists search.
[1567] Fix | Delete
* @return mixed Returns null if the term does not exist.
[1568] Fix | Delete
* Returns the term ID if no taxonomy is specified and the term ID exists.
[1569] Fix | Delete
* Returns an array of the term ID and the term taxonomy ID if the taxonomy is specified and the pairing exists.
[1570] Fix | Delete
* Returns 0 if term ID 0 is passed to the function.
[1571] Fix | Delete
*/
[1572] Fix | Delete
function term_exists( $term, $taxonomy = '', $parent_term = null ) {
[1573] Fix | Delete
global $_wp_suspend_cache_invalidation;
[1574] Fix | Delete
[1575] Fix | Delete
if ( null === $term ) {
[1576] Fix | Delete
return null;
[1577] Fix | Delete
}
[1578] Fix | Delete
[1579] Fix | Delete
$defaults = array(
[1580] Fix | Delete
'get' => 'all',
[1581] Fix | Delete
'fields' => 'ids',
[1582] Fix | Delete
'number' => 1,
[1583] Fix | Delete
'update_term_meta_cache' => false,
[1584] Fix | Delete
'order' => 'ASC',
[1585] Fix | Delete
'orderby' => 'term_id',
[1586] Fix | Delete
'suppress_filter' => true,
[1587] Fix | Delete
);
[1588] Fix | Delete
[1589] Fix | Delete
// Ensure that while importing, queries are not cached.
[1590] Fix | Delete
if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
[1591] Fix | Delete
$defaults['cache_results'] = false;
[1592] Fix | Delete
}
[1593] Fix | Delete
[1594] Fix | Delete
if ( ! empty( $taxonomy ) ) {
[1595] Fix | Delete
$defaults['taxonomy'] = $taxonomy;
[1596] Fix | Delete
$defaults['fields'] = 'all';
[1597] Fix | Delete
}
[1598] Fix | Delete
[1599] Fix | Delete
/**
[1600] Fix | Delete
* Filters default query arguments for checking if a term exists.
[1601] Fix | Delete
*
[1602] Fix | Delete
* @since 6.0.0
[1603] Fix | Delete
*
[1604] Fix | Delete
* @param array $defaults An array of arguments passed to get_terms().
[1605] Fix | Delete
* @param int|string $term The term to check. Accepts term ID, slug, or name.
[1606] Fix | Delete
* @param string $taxonomy The taxonomy name to use. An empty string indicates
[1607] Fix | Delete
* the search is against all taxonomies.
[1608] Fix | Delete
* @param int|null $parent_term ID of parent term under which to confine the exists search.
[1609] Fix | Delete
* Null indicates the search is unconfined.
[1610] Fix | Delete
*/
[1611] Fix | Delete
$defaults = apply_filters( 'term_exists_default_query_args', $defaults, $term, $taxonomy, $parent_term );
[1612] Fix | Delete
[1613] Fix | Delete
if ( is_int( $term ) ) {
[1614] Fix | Delete
if ( 0 === $term ) {
[1615] Fix | Delete
return 0;
[1616] Fix | Delete
}
[1617] Fix | Delete
$args = wp_parse_args( array( 'include' => array( $term ) ), $defaults );
[1618] Fix | Delete
$terms = get_terms( $args );
[1619] Fix | Delete
} else {
[1620] Fix | Delete
$term = trim( wp_unslash( $term ) );
[1621] Fix | Delete
if ( '' === $term ) {
[1622] Fix | Delete
return null;
[1623] Fix | Delete
}
[1624] Fix | Delete
[1625] Fix | Delete
if ( ! empty( $taxonomy ) && is_numeric( $parent_term ) ) {
[1626] Fix | Delete
$defaults['parent'] = (int) $parent_term;
[1627] Fix | Delete
}
[1628] Fix | Delete
[1629] Fix | Delete
$args = wp_parse_args( array( 'slug' => sanitize_title( $term ) ), $defaults );
[1630] Fix | Delete
$terms = get_terms( $args );
[1631] Fix | Delete
if ( empty( $terms ) || is_wp_error( $terms ) ) {
[1632] Fix | Delete
$args = wp_parse_args( array( 'name' => $term ), $defaults );
[1633] Fix | Delete
$terms = get_terms( $args );
[1634] Fix | Delete
}
[1635] Fix | Delete
}
[1636] Fix | Delete
[1637] Fix | Delete
if ( empty( $terms ) || is_wp_error( $terms ) ) {
[1638] Fix | Delete
return null;
[1639] Fix | Delete
}
[1640] Fix | Delete
[1641] Fix | Delete
$_term = array_shift( $terms );
[1642] Fix | Delete
[1643] Fix | Delete
if ( ! empty( $taxonomy ) ) {
[1644] Fix | Delete
return array(
[1645] Fix | Delete
'term_id' => (string) $_term->term_id,
[1646] Fix | Delete
'term_taxonomy_id' => (string) $_term->term_taxonomy_id,
[1647] Fix | Delete
);
[1648] Fix | Delete
}
[1649] Fix | Delete
[1650] Fix | Delete
return (string) $_term;
[1651] Fix | Delete
}
[1652] Fix | Delete
[1653] Fix | Delete
/**
[1654] Fix | Delete
* Checks if a term is an ancestor of another term.
[1655] Fix | Delete
*
[1656] Fix | Delete
* You can use either an ID or the term object for both parameters.
[1657] Fix | Delete
*
[1658] Fix | Delete
* @since 3.4.0
[1659] Fix | Delete
*
[1660] Fix | Delete
* @param int|object $term1 ID or object to check if this is the parent term.
[1661] Fix | Delete
* @param int|object $term2 The child term.
[1662] Fix | Delete
* @param string $taxonomy Taxonomy name that $term1 and `$term2` belong to.
[1663] Fix | Delete
* @return bool Whether `$term2` is a child of `$term1`.
[1664] Fix | Delete
*/
[1665] Fix | Delete
function term_is_ancestor_of( $term1, $term2, $taxonomy ) {
[1666] Fix | Delete
if ( ! isset( $term1->term_id ) ) {
[1667] Fix | Delete
$term1 = get_term( $term1, $taxonomy );
[1668] Fix | Delete
}
[1669] Fix | Delete
if ( ! isset( $term2->parent ) ) {
[1670] Fix | Delete
$term2 = get_term( $term2, $taxonomy );
[1671] Fix | Delete
}
[1672] Fix | Delete
[1673] Fix | Delete
if ( empty( $term1->term_id ) || empty( $term2->parent ) ) {
[1674] Fix | Delete
return false;
[1675] Fix | Delete
}
[1676] Fix | Delete
if ( $term2->parent === $term1->term_id ) {
[1677] Fix | Delete
return true;
[1678] Fix | Delete
}
[1679] Fix | Delete
[1680] Fix | Delete
return term_is_ancestor_of( $term1, get_term( $term2->parent, $taxonomy ), $taxonomy );
[1681] Fix | Delete
}
[1682] Fix | Delete
[1683] Fix | Delete
/**
[1684] Fix | Delete
* Sanitizes all term fields.
[1685] Fix | Delete
*
[1686] Fix | Delete
* Relies on sanitize_term_field() to sanitize the term. The difference is that
[1687] Fix | Delete
* this function will sanitize **all** fields. The context is based
[1688] Fix | Delete
* on sanitize_term_field().
[1689] Fix | Delete
*
[1690] Fix | Delete
* The `$term` is expected to be either an array or an object.
[1691] Fix | Delete
*
[1692] Fix | Delete
* @since 2.3.0
[1693] Fix | Delete
*
[1694] Fix | Delete
* @param array|object $term The term to check.
[1695] Fix | Delete
* @param string $taxonomy The taxonomy name to use.
[1696] Fix | Delete
* @param string $context Optional. Context in which to sanitize the term.
[1697] Fix | Delete
* Accepts 'raw', 'edit', 'db', 'display', 'rss',
[1698] Fix | Delete
* 'attribute', or 'js'. Default 'display'.
[1699] Fix | Delete
* @return array|object Term with all fields sanitized.
[1700] Fix | Delete
*/
[1701] Fix | Delete
function sanitize_term( $term, $taxonomy, $context = 'display' ) {
[1702] Fix | Delete
$fields = array( 'term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group', 'term_taxonomy_id', 'object_id' );
[1703] Fix | Delete
[1704] Fix | Delete
$do_object = is_object( $term );
[1705] Fix | Delete
[1706] Fix | Delete
$term_id = $do_object ? $term->term_id : ( isset( $term['term_id'] ) ? $term['term_id'] : 0 );
[1707] Fix | Delete
[1708] Fix | Delete
foreach ( (array) $fields as $field ) {
[1709] Fix | Delete
if ( $do_object ) {
[1710] Fix | Delete
if ( isset( $term->$field ) ) {
[1711] Fix | Delete
$term->$field = sanitize_term_field( $field, $term->$field, $term_id, $taxonomy, $context );
[1712] Fix | Delete
}
[1713] Fix | Delete
} else {
[1714] Fix | Delete
if ( isset( $term[ $field ] ) ) {
[1715] Fix | Delete
$term[ $field ] = sanitize_term_field( $field, $term[ $field ], $term_id, $taxonomy, $context );
[1716] Fix | Delete
}
[1717] Fix | Delete
}
[1718] Fix | Delete
}
[1719] Fix | Delete
[1720] Fix | Delete
if ( $do_object ) {
[1721] Fix | Delete
$term->filter = $context;
[1722] Fix | Delete
} else {
[1723] Fix | Delete
$term['filter'] = $context;
[1724] Fix | Delete
}
[1725] Fix | Delete
[1726] Fix | Delete
return $term;
[1727] Fix | Delete
}
[1728] Fix | Delete
[1729] Fix | Delete
/**
[1730] Fix | Delete
* Sanitizes the field value in the term based on the context.
[1731] Fix | Delete
*
[1732] Fix | Delete
* Passing a term field value through the function should be assumed to have
[1733] Fix | Delete
* cleansed the value for whatever context the term field is going to be used.
[1734] Fix | Delete
*
[1735] Fix | Delete
* If no context or an unsupported context is given, then default filters will
[1736] Fix | Delete
* be applied.
[1737] Fix | Delete
*
[1738] Fix | Delete
* There are enough filters for each context to support a custom filtering
[1739] Fix | Delete
* without creating your own filter function. Simply create a function that
[1740] Fix | Delete
* hooks into the filter you need.
[1741] Fix | Delete
*
[1742] Fix | Delete
* @since 2.3.0
[1743] Fix | Delete
*
[1744] Fix | Delete
* @param string $field Term field to sanitize.
[1745] Fix | Delete
* @param string $value Search for this term value.
[1746] Fix | Delete
* @param int $term_id Term ID.
[1747] Fix | Delete
* @param string $taxonomy Taxonomy name.
[1748] Fix | Delete
* @param string $context Context in which to sanitize the term field.
[1749] Fix | Delete
* Accepts 'raw', 'edit', 'db', 'display', 'rss',
[1750] Fix | Delete
* 'attribute', or 'js'. Default 'display'.
[1751] Fix | Delete
* @return mixed Sanitized field.
[1752] Fix | Delete
*/
[1753] Fix | Delete
function sanitize_term_field( $field, $value, $term_id, $taxonomy, $context ) {
[1754] Fix | Delete
$int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' );
[1755] Fix | Delete
if ( in_array( $field, $int_fields, true ) ) {
[1756] Fix | Delete
$value = (int) $value;
[1757] Fix | Delete
if ( $value < 0 ) {
[1758] Fix | Delete
$value = 0;
[1759] Fix | Delete
}
[1760] Fix | Delete
}
[1761] Fix | Delete
[1762] Fix | Delete
$context = strtolower( $context );
[1763] Fix | Delete
[1764] Fix | Delete
if ( 'raw' === $context ) {
[1765] Fix | Delete
return $value;
[1766] Fix | Delete
}
[1767] Fix | Delete
[1768] Fix | Delete
if ( 'edit' === $context ) {
[1769] Fix | Delete
[1770] Fix | Delete
/**
[1771] Fix | Delete
* Filters a term field to edit before it is sanitized.
[1772] Fix | Delete
*
[1773] Fix | Delete
* The dynamic portion of the hook name, `$field`, refers to the term field.
[1774] Fix | Delete
*
[1775] Fix | Delete
* @since 2.3.0
[1776] Fix | Delete
*
[1777] Fix | Delete
* @param mixed $value Value of the term field.
[1778] Fix | Delete
* @param int $term_id Term ID.
[1779] Fix | Delete
* @param string $taxonomy Taxonomy slug.
[1780] Fix | Delete
*/
[1781] Fix | Delete
$value = apply_filters( "edit_term_{$field}", $value, $term_id, $taxonomy );
[1782] Fix | Delete
[1783] Fix | Delete
/**
[1784] Fix | Delete
* Filters the taxonomy field to edit before it is sanitized.
[1785] Fix | Delete
*
[1786] Fix | Delete
* The dynamic portions of the filter name, `$taxonomy` and `$field`, refer
[1787] Fix | Delete
* to the taxonomy slug and taxonomy field, respectively.
[1788] Fix | Delete
*
[1789] Fix | Delete
* @since 2.3.0
[1790] Fix | Delete
*
[1791] Fix | Delete
* @param mixed $value Value of the taxonomy field to edit.
[1792] Fix | Delete
* @param int $term_id Term ID.
[1793] Fix | Delete
*/
[1794] Fix | Delete
$value = apply_filters( "edit_{$taxonomy}_{$field}", $value, $term_id );
[1795] Fix | Delete
[1796] Fix | Delete
if ( 'description' === $field ) {
[1797] Fix | Delete
$value = esc_html( $value ); // textarea_escaped
[1798] Fix | Delete
} else {
[1799] Fix | Delete
$value = esc_attr( $value );
[1800] Fix | Delete
}
[1801] Fix | Delete
} elseif ( 'db' === $context ) {
[1802] Fix | Delete
[1803] Fix | Delete
/**
[1804] Fix | Delete
* Filters a term field value before it is sanitized.
[1805] Fix | Delete
*
[1806] Fix | Delete
* The dynamic portion of the hook name, `$field`, refers to the term field.
[1807] Fix | Delete
*
[1808] Fix | Delete
* @since 2.3.0
[1809] Fix | Delete
*
[1810] Fix | Delete
* @param mixed $value Value of the term field.
[1811] Fix | Delete
* @param string $taxonomy Taxonomy slug.
[1812] Fix | Delete
*/
[1813] Fix | Delete
$value = apply_filters( "pre_term_{$field}", $value, $taxonomy );
[1814] Fix | Delete
[1815] Fix | Delete
/**
[1816] Fix | Delete
* Filters a taxonomy field before it is sanitized.
[1817] Fix | Delete
*
[1818] Fix | Delete
* The dynamic portions of the filter name, `$taxonomy` and `$field`, refer
[1819] Fix | Delete
* to the taxonomy slug and field name, respectively.
[1820] Fix | Delete
*
[1821] Fix | Delete
* @since 2.3.0
[1822] Fix | Delete
*
[1823] Fix | Delete
* @param mixed $value Value of the taxonomy field.
[1824] Fix | Delete
*/
[1825] Fix | Delete
$value = apply_filters( "pre_{$taxonomy}_{$field}", $value );
[1826] Fix | Delete
[1827] Fix | Delete
// Back compat filters.
[1828] Fix | Delete
if ( 'slug' === $field ) {
[1829] Fix | Delete
/**
[1830] Fix | Delete
* Filters the category nicename before it is sanitized.
[1831] Fix | Delete
*
[1832] Fix | Delete
* Use the {@see 'pre_$taxonomy_$field'} hook instead.
[1833] Fix | Delete
*
[1834] Fix | Delete
* @since 2.0.3
[1835] Fix | Delete
*
[1836] Fix | Delete
* @param string $value The category nicename.
[1837] Fix | Delete
*/
[1838] Fix | Delete
$value = apply_filters( 'pre_category_nicename', $value );
[1839] Fix | Delete
}
[1840] Fix | Delete
} elseif ( 'rss' === $context ) {
[1841] Fix | Delete
[1842] Fix | Delete
/**
[1843] Fix | Delete
* Filters the term field for use in RSS.
[1844] Fix | Delete
*
[1845] Fix | Delete
* The dynamic portion of the hook name, `$field`, refers to the term field.
[1846] Fix | Delete
*
[1847] Fix | Delete
* @since 2.3.0
[1848] Fix | Delete
*
[1849] Fix | Delete
* @param mixed $value Value of the term field.
[1850] Fix | Delete
* @param string $taxonomy Taxonomy slug.
[1851] Fix | Delete
*/
[1852] Fix | Delete
$value = apply_filters( "term_{$field}_rss", $value, $taxonomy );
[1853] Fix | Delete
[1854] Fix | Delete
/**
[1855] Fix | Delete
* Filters the taxonomy field for use in RSS.
[1856] Fix | Delete
*
[1857] Fix | Delete
* The dynamic portions of the hook name, `$taxonomy`, and `$field`, refer
[1858] Fix | Delete
* to the taxonomy slug and field name, respectively.
[1859] Fix | Delete
*
[1860] Fix | Delete
* @since 2.3.0
[1861] Fix | Delete
*
[1862] Fix | Delete
* @param mixed $value Value of the taxonomy field.
[1863] Fix | Delete
*/
[1864] Fix | Delete
$value = apply_filters( "{$taxonomy}_{$field}_rss", $value );
[1865] Fix | Delete
} else {
[1866] Fix | Delete
// Use display filters by default.
[1867] Fix | Delete
[1868] Fix | Delete
/**
[1869] Fix | Delete
* Filters the term field sanitized for display.
[1870] Fix | Delete
*
[1871] Fix | Delete
* The dynamic portion of the hook name, `$field`, refers to the term field name.
[1872] Fix | Delete
*
[1873] Fix | Delete
* @since 2.3.0
[1874] Fix | Delete
*
[1875] Fix | Delete
* @param mixed $value Value of the term field.
[1876] Fix | Delete
* @param int $term_id Term ID.
[1877] Fix | Delete
* @param string $taxonomy Taxonomy slug.
[1878] Fix | Delete
* @param string $context Context to retrieve the term field value.
[1879] Fix | Delete
*/
[1880] Fix | Delete
$value = apply_filters( "term_{$field}", $value, $term_id, $taxonomy, $context );
[1881] Fix | Delete
[1882] Fix | Delete
/**
[1883] Fix | Delete
* Filters the taxonomy field sanitized for display.
[1884] Fix | Delete
*
[1885] Fix | Delete
* The dynamic portions of the filter name, `$taxonomy`, and `$field`, refer
[1886] Fix | Delete
* to the taxonomy slug and taxonomy field, respectively.
[1887] Fix | Delete
*
[1888] Fix | Delete
* @since 2.3.0
[1889] Fix | Delete
*
[1890] Fix | Delete
* @param mixed $value Value of the taxonomy field.
[1891] Fix | Delete
* @param int $term_id Term ID.
[1892] Fix | Delete
* @param string $context Context to retrieve the taxonomy field value.
[1893] Fix | Delete
*/
[1894] Fix | Delete
$value = apply_filters( "{$taxonomy}_{$field}", $value, $term_id, $context );
[1895] Fix | Delete
}
[1896] Fix | Delete
[1897] Fix | Delete
if ( 'attribute' === $context ) {
[1898] Fix | Delete
$value = esc_attr( $value );
[1899] Fix | Delete
} elseif ( 'js' === $context ) {
[1900] Fix | Delete
$value = esc_js( $value );
[1901] Fix | Delete
}
[1902] Fix | Delete
[1903] Fix | Delete
// Restore the type for integer fields after esc_attr().
[1904] Fix | Delete
if ( in_array( $field, $int_fields, true ) ) {
[1905] Fix | Delete
$value = (int) $value;
[1906] Fix | Delete
}
[1907] Fix | Delete
[1908] Fix | Delete
return $value;
[1909] Fix | Delete
}
[1910] Fix | Delete
[1911] Fix | Delete
/**
[1912] Fix | Delete
* Counts how many terms are in taxonomy.
[1913] Fix | Delete
*
[1914] Fix | Delete
* Default $args is 'hide_empty' which can be 'hide_empty=true' or array('hide_empty' => true).
[1915] Fix | Delete
*
[1916] Fix | Delete
* @since 2.3.0
[1917] Fix | Delete
* @since 5.6.0 Changed the function signature so that the `$args` array can be provided as the first parameter.
[1918] Fix | Delete
*
[1919] Fix | Delete
* @internal The `$deprecated` parameter is parsed for backward compatibility only.
[1920] Fix | Delete
*
[1921] Fix | Delete
* @param array|string $args Optional. Array or string of arguments. See WP_Term_Query::__construct()
[1922] Fix | Delete
* for information on accepted arguments. Default empty array.
[1923] Fix | Delete
* @param array|string $deprecated Optional. Argument array, when using the legacy function parameter format.
[1924] Fix | Delete
* If present, this parameter will be interpreted as `$args`, and the first
[1925] Fix | Delete
* function parameter will be parsed as a taxonomy or array of taxonomies.
[1926] Fix | Delete
* Default empty.
[1927] Fix | Delete
* @return string|WP_Error Numeric string containing the number of terms in that
[1928] Fix | Delete
* taxonomy or WP_Error if the taxonomy does not exist.
[1929] Fix | Delete
*/
[1930] Fix | Delete
function wp_count_terms( $args = array(), $deprecated = '' ) {
[1931] Fix | Delete
$use_legacy_args = false;
[1932] Fix | Delete
[1933] Fix | Delete
// Check whether function is used with legacy signature: `$taxonomy` and `$args`.
[1934] Fix | Delete
if ( $args
[1935] Fix | Delete
&& ( is_string( $args ) && taxonomy_exists( $args )
[1936] Fix | Delete
|| is_array( $args ) && wp_is_numeric_array( $args ) )
[1937] Fix | Delete
) {
[1938] Fix | Delete
$use_legacy_args = true;
[1939] Fix | Delete
}
[1940] Fix | Delete
[1941] Fix | Delete
$defaults = array( 'hide_empty' => false );
[1942] Fix | Delete
[1943] Fix | Delete
if ( $use_legacy_args ) {
[1944] Fix | Delete
$defaults['taxonomy'] = $args;
[1945] Fix | Delete
$args = $deprecated;
[1946] Fix | Delete
}
[1947] Fix | Delete
[1948] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[1949] Fix | Delete
[1950] Fix | Delete
// Backward compatibility.
[1951] Fix | Delete
if ( isset( $args['ignore_empty'] ) ) {
[1952] Fix | Delete
$args['hide_empty'] = $args['ignore_empty'];
[1953] Fix | Delete
unset( $args['ignore_empty'] );
[1954] Fix | Delete
}
[1955] Fix | Delete
[1956] Fix | Delete
$args['fields'] = 'count';
[1957] Fix | Delete
[1958] Fix | Delete
return get_terms( $args );
[1959] Fix | Delete
}
[1960] Fix | Delete
[1961] Fix | Delete
/**
[1962] Fix | Delete
* Unlinks the object from the taxonomy or taxonomies.
[1963] Fix | Delete
*
[1964] Fix | Delete
* Will remove all relationships between the object and any terms in
[1965] Fix | Delete
* a particular taxonomy or taxonomies. Does not remove the term or
[1966] Fix | Delete
* taxonomy itself.
[1967] Fix | Delete
*
[1968] Fix | Delete
* @since 2.3.0
[1969] Fix | Delete
*
[1970] Fix | Delete
* @param int $object_id The term object ID that refers to the term.
[1971] Fix | Delete
* @param string|array $taxonomies List of taxonomy names or single taxonomy name.
[1972] Fix | Delete
*/
[1973] Fix | Delete
function wp_delete_object_term_relationships( $object_id, $taxonomies ) {
[1974] Fix | Delete
$object_id = (int) $object_id;
[1975] Fix | Delete
[1976] Fix | Delete
if ( ! is_array( $taxonomies ) ) {
[1977] Fix | Delete
$taxonomies = array( $taxonomies );
[1978] Fix | Delete
}
[1979] Fix | Delete
[1980] Fix | Delete
foreach ( (array) $taxonomies as $taxonomy ) {
[1981] Fix | Delete
$term_ids = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids' ) );
[1982] Fix | Delete
$term_ids = array_map( 'intval', $term_ids );
[1983] Fix | Delete
wp_remove_object_terms( $object_id, $term_ids, $taxonomy );
[1984] Fix | Delete
}
[1985] Fix | Delete
}
[1986] Fix | Delete
[1987] Fix | Delete
/**
[1988] Fix | Delete
* Removes a term from the database.
[1989] Fix | Delete
*
[1990] Fix | Delete
* If the term is a parent of other terms, then the children will be updated to
[1991] Fix | Delete
* that term's parent.
[1992] Fix | Delete
*
[1993] Fix | Delete
* Metadata associated with the term will be deleted.
[1994] Fix | Delete
*
[1995] Fix | Delete
* @since 2.3.0
[1996] Fix | Delete
*
[1997] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[1998] Fix | Delete
*
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function