Ticket #36666: 36666.2.diff
File 36666.2.diff, 3.5 KB (added by , 9 years ago) |
---|
-
theme.php
1832 1832 * @since 3.0.0 1833 1833 * @see add_theme_support() 1834 1834 * @param string $feature the feature being added 1835 * @param array $args Optional arguments 1835 1836 * @return bool|void Whether feature was removed. 1836 1837 */ 1837 function remove_theme_support( $feature ) {1838 function remove_theme_support( $feature, $args = array() ) { 1838 1839 // Blacklist: for internal registrations not used directly by themes. 1839 1840 if ( in_array( $feature, array( 'editor-style', 'widgets', 'menus' ) ) ) 1840 1841 return false; 1841 1842 1842 return _remove_theme_support( $feature );1843 return _remove_theme_support( $feature, $args ); 1843 1844 } 1844 1845 1845 /** 1846 1846 * Do not use. Removes theme support internally, ignorant of the blacklist. 1847 1847 * … … 1853 1853 * @global Custom_Background $custom_background 1854 1854 * 1855 1855 * @param string $feature 1856 * @param array $args Optional arguments 1857 * @return bool|void 1856 1858 */ 1857 function _remove_theme_support( $feature ) {1859 function _remove_theme_support( $feature, $args = array() ) { 1858 1860 global $_wp_theme_features; 1859 1861 1862 // Theme support was never added for this feature. 1863 if ( ! isset( $_wp_theme_features[ $feature ] ) ) { 1864 return false; 1865 } 1866 1867 // Partial removal of theme support, such as a particular post format or thumbnails on a specific post type. 1868 if ( $args ) { 1869 switch ( $feature ) { 1870 // Remove the passed arguments from this feature, reassigning those that remain. 1871 case 'html5' : 1872 case 'post-formats' : 1873 $kept_args = array_diff( $_wp_theme_features[ $feature ][0], $args ); 1874 1875 if ( ! empty( $kept_args ) ) { 1876 $_wp_theme_features[ $feature ][0] = $kept_args; 1877 return true; 1878 } 1879 1880 return false; 1881 1882 case 'post-thumbnails' : 1883 if ( is_bool( $_wp_theme_features['post-thumbnails'] ) ) { 1884 $_wp_theme_features['post-thumbnails'] = array(); 1885 $_wp_theme_features['post-thumbnails'][] = get_post_types_by_support( 'thumbnail' ); 1886 } 1887 1888 $kept_args = array_diff( $_wp_theme_features[ $feature ][0], $args ); 1889 1890 if ( ! empty( $kept_args ) ) { 1891 $_wp_theme_features[ $feature ][0] = $kept_args; 1892 return true; 1893 } 1894 1895 return false; 1896 1897 default : 1898 return false; 1899 } 1900 } 1901 1902 // Full removal of theme support. 1860 1903 switch ( $feature ) { 1861 1904 case 'custom-header-uploads' : 1862 if ( ! isset( $_wp_theme_features['custom-header'] ) ) 1905 if ( ! isset( $_wp_theme_features['custom-header'] ) ) { 1863 1906 return false; 1907 } 1864 1908 add_theme_support( 'custom-header', array( 'uploads' => false ) ); 1909 1865 1910 return; // Do not continue - custom-header-uploads no longer exists. 1866 }1867 1911 1868 if ( ! isset( $_wp_theme_features[ $feature ] ) )1869 return false;1870 1871 switch ( $feature ) {1872 1912 case 'custom-header' : 1873 if ( ! did_action( 'wp_loaded' ) ) 1913 if ( ! did_action( 'wp_loaded' ) ) { 1874 1914 break; 1915 } 1875 1916 $support = get_theme_support( 'custom-header' ); 1876 if ( $support[0]['wp-head-callback'] ) 1917 if ( $support[0]['wp-head-callback'] ) { 1877 1918 remove_action( 'wp_head', $support[0]['wp-head-callback'] ); 1919 } 1878 1920 remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) ); 1879 1921 unset( $GLOBALS['custom_image_header'] ); 1880 1922 break; 1881 1923 1924 1882 1925 case 'custom-background' : 1883 if ( ! did_action( 'wp_loaded' ) ) 1926 if ( ! did_action( 'wp_loaded' ) ) { 1884 1927 break; 1928 } 1885 1929 $support = get_theme_support( 'custom-background' ); 1886 1930 remove_action( 'wp_head', $support[0]['wp-head-callback'] ); 1887 1931 remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) );