Ticket #26516: 26516.diff
File 26516.diff, 5.3 KB (added by , 11 years ago) |
---|
-
wp-includes/theme.php
1568 1568 if ( ! isset( $_wp_theme_features[ $feature ] ) ) 1569 1569 return false; 1570 1570 1571 if ( func_num_args() <= 1 )1572 return $_wp_theme_features[ $feature ];1573 1574 1571 $args = array_slice( func_get_args(), 1 ); 1575 switch ( $feature ) { 1576 case 'custom-header' : 1577 case 'custom-background' : 1578 if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) ) 1579 return $_wp_theme_features[ $feature ][0][ $args[0] ]; 1580 return false; 1581 break; 1582 default : 1583 return $_wp_theme_features[ $feature ]; 1584 break; 1572 if ( ! empty( $args ) ) { 1573 switch ( $feature ) { 1574 case 'custom-header' : 1575 case 'custom-background' : 1576 if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) ) 1577 return $_wp_theme_features[ $feature ][0][ $args[0] ]; 1578 return false; 1579 break; 1580 } 1581 } 1582 1583 $feature_args = $_wp_theme_features[ $feature ]; 1584 if ( is_array( $feature_args ) ) { 1585 $feature_args = array_merge( $feature_args, $_wp_theme_features[ $feature ][0] ); 1585 1586 } 1587 1588 /** 1589 * Filter whether the theme support for a specific feature. 1590 * 1591 * The dynamic portion of the hook name, $feature, refers to 1592 * the specific theme feature. Possible values include 'post-formats', 1593 * 'post-thumbnails', 'menus', 'automatic-feed-links', and 'html5'. 1594 * 1595 * @since 3.9.0 1596 * 1597 * @param array|bool $feature_args The array of extra arguments, or true if there are none. 1598 * @param array $args Array of arguments for the feature. 1599 */ 1600 return apply_filters( "get_theme_support-{$feature}", $feature_args, $args ); 1586 1601 } 1587 1602 1588 1603 /** … … 1611 1626 * @since 3.1.0 1612 1627 */ 1613 1628 function _remove_theme_support( $feature ) { 1614 global $_wp_theme_features;1615 1616 1629 switch ( $feature ) { 1617 1630 case 'custom-header-uploads' : 1618 if ( ! isset( $_wp_theme_features['custom-header']) )1631 if ( ! current_theme_supports( 'custom-header' ) ) 1619 1632 return false; 1620 1633 add_theme_support( 'custom-header', array( 'uploads' => false ) ); 1621 1634 return; // Do not continue - custom-header-uploads no longer exists. 1622 1635 } 1623 1636 1624 if ( ! isset( $_wp_theme_features[ $feature ]) )1637 if ( ! current_theme_supports( $feature ) ) 1625 1638 return false; 1626 1639 1627 1640 switch ( $feature ) { 1628 1641 case 'custom-header' : 1629 1642 if ( ! did_action( 'wp_loaded' ) ) 1630 1643 break; 1631 $support = get_theme_support( 'custom-header' ); 1632 if ( $support[0]['wp-head-callback'] ) 1633 remove_action( 'wp_head', $support[0]['wp-head-callback'] ); 1644 remove_action( 'wp_head', get_theme_support( 'custom-header', 'wp-head-callback' ) ); 1634 1645 remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) ); 1635 1646 unset( $GLOBALS['custom_image_header'] ); 1636 1647 break; … … 1638 1649 case 'custom-background' : 1639 1650 if ( ! did_action( 'wp_loaded' ) ) 1640 1651 break; 1641 $support = get_theme_support( 'custom-background' ); 1642 remove_action( 'wp_head', $support[0]['wp-head-callback'] ); 1652 remove_action( 'wp_head', get_theme_support( 'custom-background', 'wp-head-callback' ) ); 1643 1653 remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) ); 1644 1654 unset( $GLOBALS['custom_background'] ); 1645 1655 break; 1646 1656 } 1647 1657 1648 unset( $ _wp_theme_features[ $feature ] );1658 unset( $GLOBALS['_wp_theme_features'][ $feature ] ); 1649 1659 return true; 1650 1660 } 1651 1661 … … 1657 1667 * @return boolean 1658 1668 */ 1659 1669 function current_theme_supports( $feature ) { 1660 global $_wp_theme_features;1661 1662 1670 if ( 'custom-header-uploads' == $feature ) 1663 1671 return current_theme_supports( 'custom-header', 'uploads' ); 1664 1672 1665 if ( ! isset( $_wp_theme_features[$feature]) )1673 if ( ! get_theme_support( $feature ) ) 1666 1674 return false; 1667 1675 1668 1676 // If no args passed then no extra checks need be performed … … 1676 1684 // post-thumbnails can be registered for only certain content/post types by passing 1677 1685 // an array of types to add_theme_support(). If no array was passed, then 1678 1686 // any type is accepted 1679 if ( true === $_wp_theme_features[$feature]) // Registered for all types1687 if ( true === get_theme_support( $feature ) ) // Registered for all types 1680 1688 return true; 1681 1689 $content_type = $args[0]; 1682 return in_array( $content_type, $_wp_theme_features[$feature][0]);1690 return in_array( $content_type, get_theme_support( $feature ) ); 1683 1691 break; 1684 1692 1685 1693 case 'html5': … … 1690 1698 // Specific areas of HTML5 support *must* be passed via an array to add_theme_support() 1691 1699 1692 1700 $type = $args[0]; 1693 return in_array( $type, $_wp_theme_features[$feature][0]);1701 return in_array( $type, get_theme_support( $feature ) ); 1694 1702 break; 1695 1703 1696 1704 case 'custom-header': … … 1698 1706 // specific custom header and background capabilities can be registered by passing 1699 1707 // an array to add_theme_support() 1700 1708 $header_support = $args[0]; 1701 return ( isset( $_wp_theme_features[$feature][0][$header_support] ) && $_wp_theme_features[$feature][0][$header_support]);1709 return get_theme_support( $feature, $header_support ); 1702 1710 break; 1703 1711 } 1704 1712 … … 1716 1724 * @param array $args Array of arguments for the feature. 1717 1725 * @param string $feature The theme feature. 1718 1726 */ 1719 return apply_filters( "current_theme_supports-{$feature}", true, $args, $_wp_theme_features[$feature]);1727 return apply_filters( "current_theme_supports-{$feature}", true, $args, get_theme_support( $feature ) ); 1720 1728 } 1721 1729 1722 1730 /**