Ticket #12739: remove_theme_support-ugly.diff
File remove_theme_support-ugly.diff, 2.0 KB (added by , 15 years ago) |
---|
-
theme.php
1531 1531 /** 1532 1532 * Allows a theme to register its support of a certain feature 1533 1533 * 1534 * Must be called in the themes functions.php file to work. 1534 * Must be called in the theme's functions.php file to work. 1535 * If attached to a hook, it must be after_setup_theme. 1536 * The init hook may be too late for some features. 1535 1537 * 1536 1538 * @since 2.9.0 1537 1539 * @param string $feature the feature being added … … 1548 1550 /** 1549 1551 * Allows a theme to de-register its support of a certain feature 1550 1552 * 1551 * Must be called in the themes functions.php file to work. 1553 * Should be called in the theme's functions.php file. Generally would 1554 * be used for child themes to override support from the parent theme. 1552 1555 * 1553 1556 * @since 3.0.0 1557 * @see add_theme_support() 1554 1558 * @param string $feature the feature being added 1555 1559 */ 1556 1560 function remove_theme_support( $feature ) { 1561 // Blacklist: for internal registrations not used directly by themes. 1562 if ( in_array( $feature, array( 'custom-background', 'custom-header', 'editor-style', 'widgets' ) ) ) 1563 return false; 1564 1557 1565 global $_wp_theme_features; 1558 1566 1559 unset($_wp_theme_features[$feature]); 1567 if ( ! isset( $_wp_theme_features[$feature] ) ) 1568 return false; 1569 1570 if ( func_num_args() == 1 ) { 1571 unset( $_wp_theme_features[$feature] ); 1572 return true; 1573 } 1574 1575 // @todo pluggable arg checking. see current_theme_supports() 1576 $args = array_slice( func_get_args(), 1 ); 1577 switch( $feature ) { 1578 case 'post-thumbnails' : 1579 if ( true === $_wp_theme_features[$feature] ) { 1580 global $_wp_post_type_features; 1581 $post_types = array(); 1582 1583 foreach ( (array) $_wp_post_type_features as $post_type => $features ) { 1584 if ( ! isset( $features['thumbnail'] ) ) 1585 continue; 1586 $post_types[] = $post_type; 1587 } 1588 } else { 1589 $post_types = $_wp_theme_features[$feature][0]; 1590 } 1591 $_wp_theme_features[$feature] = array_diff( $post_types, $args[0] ); 1592 return true; 1593 break; 1594 } 1560 1595 } 1561 1596 1562 1597 /**