Ticket #36666: 36666.diff
File 36666.diff, 3.1 KB (added by , 9 years ago) |
---|
-
theme.php
1816 1816 * @since 3.0.0 1817 1817 * @see add_theme_support() 1818 1818 * @param string $feature the feature being added 1819 * @param array $args Optional arguments 1819 1820 * @return bool|void Whether feature was removed. 1820 1821 */ 1821 function remove_theme_support( $feature ) {1822 function remove_theme_support( $feature, $args = array() ) { 1822 1823 // Blacklist: for internal registrations not used directly by themes. 1823 1824 if ( in_array( $feature, array( 'editor-style', 'widgets', 'menus' ) ) ) 1824 1825 return false; 1825 1826 1826 return _remove_theme_support( $feature );1827 return _remove_theme_support( $feature, $args ); 1827 1828 } 1828 1829 1829 /** 1830 1830 * Do not use. Removes theme support internally, ignorant of the blacklist. 1831 1831 * … … 1837 1837 * @global Custom_Background $custom_background 1838 1838 * 1839 1839 * @param string $feature 1840 * @param array $args Optional arguments 1841 * @return bool|void 1840 1842 */ 1841 function _remove_theme_support( $feature ) {1843 function _remove_theme_support( $feature, $args = array() ) { 1842 1844 global $_wp_theme_features; 1843 1845 1846 // Theme support was never added for this feature. 1847 if ( ! isset( $_wp_theme_features[ $feature ] ) ) { 1848 return false; 1849 } 1850 1851 // Partial removal of theme support, such as a particular post format or thumbnails on a specific post type. 1852 if ( $args ) { 1853 switch ( $feature ) { 1854 // Remove the passed arguments from this feature, reassigning those that remain. 1855 case 'html5' : 1856 case 'post-formats' : 1857 case 'post-thumbnails' : 1858 $kept_args = array_diff( $_wp_theme_features[ $feature ][0], $args ); 1859 1860 if ( ! empty( $kept_args ) ) { 1861 $_wp_theme_features[ $feature ][0] = $kept_args; 1862 return true; 1863 } 1864 1865 return false; 1866 1867 case 'custom-logo' : 1868 case 'widgets' : 1869 break; 1870 1871 default : 1872 return false; 1873 } 1874 } 1875 1876 // Full removal of theme support. 1844 1877 switch ( $feature ) { 1845 1878 case 'custom-header-uploads' : 1846 if ( ! isset( $_wp_theme_features['custom-header'] ) ) 1879 if ( ! isset( $_wp_theme_features['custom-header'] ) ) { 1847 1880 return false; 1881 } 1848 1882 add_theme_support( 'custom-header', array( 'uploads' => false ) ); 1883 1849 1884 return; // Do not continue - custom-header-uploads no longer exists. 1850 }1851 1885 1852 if ( ! isset( $_wp_theme_features[ $feature ] ) )1853 return false;1854 1855 switch ( $feature ) {1856 1886 case 'custom-header' : 1857 if ( ! did_action( 'wp_loaded' ) ) 1887 if ( ! did_action( 'wp_loaded' ) ) { 1858 1888 break; 1889 } 1859 1890 $support = get_theme_support( 'custom-header' ); 1860 if ( $support[0]['wp-head-callback'] ) 1891 if ( $support[0]['wp-head-callback'] ) { 1861 1892 remove_action( 'wp_head', $support[0]['wp-head-callback'] ); 1893 } 1862 1894 remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) ); 1863 1895 unset( $GLOBALS['custom_image_header'] ); 1864 1896 break; 1865 1897 1898 1866 1899 case 'custom-background' : 1867 if ( ! did_action( 'wp_loaded' ) ) 1900 if ( ! did_action( 'wp_loaded' ) ) { 1868 1901 break; 1902 } 1869 1903 $support = get_theme_support( 'custom-background' ); 1870 1904 remove_action( 'wp_head', $support[0]['wp-head-callback'] ); 1871 1905 remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) );