diff --git src/wp-includes/theme.php src/wp-includes/theme.php
index 76aa955..47a1552 100644
|
|
|
function remove_editor_styles() { |
| 1366 | 1366 | * The init hook may be too late for some features. |
| 1367 | 1367 | * |
| 1368 | 1368 | * @since 2.9.0 |
| 1369 | | * @param string $feature the feature being added |
| | 1369 | * @global array $_wp_theme_features All supported features. |
| | 1370 | * @param string $feature The feature being added. |
| | 1371 | * @return bool|void |
| 1370 | 1372 | */ |
| 1371 | 1373 | function add_theme_support( $feature ) { |
| 1372 | 1374 | global $_wp_theme_features; |
| … |
… |
add_action( 'wp_loaded', '_custom_header_background_just_in_time' ); |
| 1561 | 1563 | * |
| 1562 | 1564 | * @since 3.1.0 |
| 1563 | 1565 | * |
| 1564 | | * @param string $feature the feature to check |
| 1565 | | * @return array The array of extra arguments |
| | 1566 | * @global array $_wp_theme_features All supported features. |
| | 1567 | * @param string $feature The feature to check. |
| | 1568 | * @return array|bool The array of extra arguments, or true if there are none. |
| 1566 | 1569 | */ |
| 1567 | 1570 | function get_theme_support( $feature ) { |
| 1568 | 1571 | global $_wp_theme_features; |
| 1569 | 1572 | if ( ! isset( $_wp_theme_features[ $feature ] ) ) |
| 1570 | 1573 | return false; |
| 1571 | 1574 | |
| 1572 | | if ( func_num_args() <= 1 ) |
| 1573 | | return $_wp_theme_features[ $feature ]; |
| 1574 | | |
| 1575 | 1575 | $args = array_slice( func_get_args(), 1 ); |
| 1576 | | switch ( $feature ) { |
| 1577 | | case 'custom-header' : |
| 1578 | | case 'custom-background' : |
| 1579 | | if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) ) |
| 1580 | | return $_wp_theme_features[ $feature ][0][ $args[0] ]; |
| 1581 | | return false; |
| 1582 | | break; |
| 1583 | | default : |
| 1584 | | return $_wp_theme_features[ $feature ]; |
| 1585 | | break; |
| | 1576 | if ( ! empty( $args ) ) { |
| | 1577 | switch ( $feature ) { |
| | 1578 | case 'custom-header' : |
| | 1579 | case 'custom-background' : |
| | 1580 | if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) ) |
| | 1581 | return $_wp_theme_features[ $feature ][0][ $args[0] ]; |
| | 1582 | return false; |
| | 1583 | break; |
| | 1584 | } |
| 1586 | 1585 | } |
| | 1586 | |
| | 1587 | $feature_args = $_wp_theme_features[ $feature ]; |
| | 1588 | if ( is_array( $feature_args ) ) { |
| | 1589 | $feature_args = array_merge( $feature_args, $_wp_theme_features[ $feature ][0] ); |
| | 1590 | } |
| | 1591 | |
| | 1592 | /** |
| | 1593 | * Filter whether the theme support for a specific feature. |
| | 1594 | * |
| | 1595 | * The dynamic portion of the hook name, $feature, refers to |
| | 1596 | * the specific theme feature. Possible values include 'post-formats', |
| | 1597 | * 'post-thumbnails', 'menus', 'automatic-feed-links', and 'html5'. |
| | 1598 | * |
| | 1599 | * @since 3.9.0 |
| | 1600 | * |
| | 1601 | * @param array|bool $feature_args The array of extra arguments, or true if there are none. |
| | 1602 | * @param array $args Array of arguments for the feature. |
| | 1603 | */ |
| | 1604 | return apply_filters( "get_theme_support-{$feature}", $feature_args, $args ); |
| 1587 | 1605 | } |
| 1588 | 1606 | |
| 1589 | 1607 | /** |
| … |
… |
function get_theme_support( $feature ) { |
| 1594 | 1612 | * |
| 1595 | 1613 | * @since 3.0.0 |
| 1596 | 1614 | * @see add_theme_support() |
| 1597 | | * @param string $feature the feature being added |
| | 1615 | * @param string $feature The feature being removed. |
| 1598 | 1616 | * @return bool Whether feature was removed. |
| 1599 | 1617 | */ |
| 1600 | 1618 | function remove_theme_support( $feature ) { |
| … |
… |
function remove_theme_support( $feature ) { |
| 1610 | 1628 | * |
| 1611 | 1629 | * @access private |
| 1612 | 1630 | * @since 3.1.0 |
| | 1631 | * @param string $feature The feature being removed. |
| | 1632 | * @return bool Whether feature was removed. |
| 1613 | 1633 | */ |
| 1614 | 1634 | function _remove_theme_support( $feature ) { |
| 1615 | | global $_wp_theme_features; |
| 1616 | | |
| 1617 | 1635 | switch ( $feature ) { |
| 1618 | 1636 | case 'custom-header-uploads' : |
| 1619 | | if ( ! isset( $_wp_theme_features['custom-header'] ) ) |
| | 1637 | if ( ! current_theme_supports( 'custom-header' ) ) |
| 1620 | 1638 | return false; |
| 1621 | 1639 | add_theme_support( 'custom-header', array( 'uploads' => false ) ); |
| 1622 | 1640 | return; // Do not continue - custom-header-uploads no longer exists. |
| 1623 | 1641 | } |
| 1624 | 1642 | |
| 1625 | | if ( ! isset( $_wp_theme_features[ $feature ] ) ) |
| | 1643 | if ( ! current_theme_supports( $feature ) ) |
| 1626 | 1644 | return false; |
| 1627 | 1645 | |
| 1628 | 1646 | switch ( $feature ) { |
| 1629 | 1647 | case 'custom-header' : |
| 1630 | 1648 | if ( ! did_action( 'wp_loaded' ) ) |
| 1631 | 1649 | break; |
| 1632 | | $support = get_theme_support( 'custom-header' ); |
| 1633 | | if ( $support[0]['wp-head-callback'] ) |
| 1634 | | remove_action( 'wp_head', $support[0]['wp-head-callback'] ); |
| | 1650 | remove_action( 'wp_head', get_theme_support( 'custom-header', 'wp-head-callback' ) ); |
| 1635 | 1651 | remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) ); |
| 1636 | 1652 | unset( $GLOBALS['custom_image_header'] ); |
| 1637 | 1653 | break; |
| … |
… |
function _remove_theme_support( $feature ) { |
| 1639 | 1655 | case 'custom-background' : |
| 1640 | 1656 | if ( ! did_action( 'wp_loaded' ) ) |
| 1641 | 1657 | break; |
| 1642 | | $support = get_theme_support( 'custom-background' ); |
| 1643 | | remove_action( 'wp_head', $support[0]['wp-head-callback'] ); |
| | 1658 | remove_action( 'wp_head', get_theme_support( 'custom-background', 'wp-head-callback' ) ); |
| 1644 | 1659 | remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) ); |
| 1645 | 1660 | unset( $GLOBALS['custom_background'] ); |
| 1646 | 1661 | break; |
| 1647 | 1662 | } |
| 1648 | 1663 | |
| 1649 | | unset( $_wp_theme_features[ $feature ] ); |
| | 1664 | unset( $GLOBALS['_wp_theme_features'][ $feature ] ); |
| 1650 | 1665 | return true; |
| 1651 | 1666 | } |
| 1652 | 1667 | |
| … |
… |
function _remove_theme_support( $feature ) { |
| 1654 | 1669 | * Checks a theme's support for a given feature |
| 1655 | 1670 | * |
| 1656 | 1671 | * @since 2.9.0 |
| 1657 | | * @param string $feature the feature being checked |
| 1658 | | * @return boolean |
| | 1672 | * @param string $feature The feature being checked. |
| | 1673 | * @return boolean Whether the current theme supports the given feature. |
| 1659 | 1674 | */ |
| 1660 | 1675 | function current_theme_supports( $feature ) { |
| 1661 | | global $_wp_theme_features; |
| 1662 | | |
| 1663 | 1676 | if ( 'custom-header-uploads' == $feature ) |
| 1664 | 1677 | return current_theme_supports( 'custom-header', 'uploads' ); |
| 1665 | 1678 | |
| 1666 | | if ( !isset( $_wp_theme_features[$feature] ) ) |
| | 1679 | if ( ! get_theme_support( $feature ) ) |
| 1667 | 1680 | return false; |
| 1668 | 1681 | |
| 1669 | 1682 | // If no args passed then no extra checks need be performed |
| … |
… |
function current_theme_supports( $feature ) { |
| 1677 | 1690 | // post-thumbnails can be registered for only certain content/post types by passing |
| 1678 | 1691 | // an array of types to add_theme_support(). If no array was passed, then |
| 1679 | 1692 | // any type is accepted |
| 1680 | | if ( true === $_wp_theme_features[$feature] ) // Registered for all types |
| | 1693 | if ( true === get_theme_support( $feature ) ) // Registered for all types |
| 1681 | 1694 | return true; |
| 1682 | 1695 | $content_type = $args[0]; |
| 1683 | | return in_array( $content_type, $_wp_theme_features[$feature][0] ); |
| | 1696 | return in_array( $content_type, get_theme_support( $feature ) ); |
| 1684 | 1697 | break; |
| 1685 | 1698 | |
| 1686 | 1699 | case 'html5': |
| … |
… |
function current_theme_supports( $feature ) { |
| 1691 | 1704 | // Specific areas of HTML5 support *must* be passed via an array to add_theme_support() |
| 1692 | 1705 | |
| 1693 | 1706 | $type = $args[0]; |
| 1694 | | return in_array( $type, $_wp_theme_features[$feature][0] ); |
| | 1707 | return in_array( $type, get_theme_support( $feature ) ); |
| 1695 | 1708 | break; |
| 1696 | 1709 | |
| 1697 | 1710 | case 'custom-header': |
| 1698 | 1711 | case 'custom-background' : |
| 1699 | 1712 | // specific custom header and background capabilities can be registered by passing |
| 1700 | 1713 | // an array to add_theme_support() |
| 1701 | | $header_support = $args[0]; |
| 1702 | | return ( isset( $_wp_theme_features[$feature][0][$header_support] ) && $_wp_theme_features[$feature][0][$header_support] ); |
| | 1714 | $capability = $args[0]; |
| | 1715 | return (bool) get_theme_support( $feature, $capability ); |
| 1703 | 1716 | break; |
| 1704 | 1717 | } |
| 1705 | 1718 | |
| … |
… |
function current_theme_supports( $feature ) { |
| 1713 | 1726 | * |
| 1714 | 1727 | * @since 3.4.0 |
| 1715 | 1728 | * |
| 1716 | | * @param bool true Whether the current theme supports the given feature. Default true. |
| 1717 | | * @param array $args Array of arguments for the feature. |
| 1718 | | * @param string $feature The theme feature. |
| | 1729 | * @param bool true Whether the current theme supports the given feature. Default true. |
| | 1730 | * @param array $args Array of arguments for the feature. |
| | 1731 | * @param array $support Specific theme support for the feature. |
| 1719 | 1732 | */ |
| 1720 | | return apply_filters( "current_theme_supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); |
| | 1733 | return apply_filters( "current_theme_supports-{$feature}", true, $args, get_theme_support( $feature ) ); |
| 1721 | 1734 | } |
| 1722 | 1735 | |
| 1723 | 1736 | /** |