Ticket #36666: 36666.4.diff
File 36666.4.diff, 3.4 KB (added by , 9 years ago) |
---|
-
src/wp-includes/theme.php
1536 1536 1537 1537 switch ( $feature ) { 1538 1538 case 'post-thumbnails': 1539 // All post types are already supported. 1540 if ( true === get_theme_support( 'post-thumbnails' ) ) { 1541 return; 1539 // All post types are already supported or no arguments were passed. 1540 if ( $args === get_theme_support( 'post-thumbnails' ) || true === $args ) { 1541 $args = array( get_post_types_by_support( 'thumbnail' ) ); 1542 break; 1542 1543 } 1543 1544 1544 1545 /* … … 1832 1833 * @since 3.0.0 1833 1834 * @see add_theme_support() 1834 1835 * @param string $feature the feature being added 1836 * @param array $args Optional arguments 1835 1837 * @return bool|void Whether feature was removed. 1836 1838 */ 1837 function remove_theme_support( $feature ) {1839 function remove_theme_support( $feature, $args = array() ) { 1838 1840 // Blacklist: for internal registrations not used directly by themes. 1839 1841 if ( in_array( $feature, array( 'editor-style', 'widgets', 'menus' ) ) ) 1840 1842 return false; 1841 1843 1842 return _remove_theme_support( $feature );1844 return _remove_theme_support( $feature, $args ); 1843 1845 } 1844 1845 1846 /** 1846 1847 * Do not use. Removes theme support internally, ignorant of the blacklist. 1847 1848 * … … 1853 1854 * @global Custom_Background $custom_background 1854 1855 * 1855 1856 * @param string $feature 1857 * @param array $args Optional arguments 1858 * @return bool|void 1856 1859 */ 1857 function _remove_theme_support( $feature ) {1860 function _remove_theme_support( $feature, $args = array() ) { 1858 1861 global $_wp_theme_features; 1859 1862 1863 // Theme support was never added for this feature. 1864 if ( ! isset( $_wp_theme_features[ $feature ] ) ) { 1865 return false; 1866 } 1867 1868 // Full removal of theme support. 1860 1869 switch ( $feature ) { 1861 1870 case 'custom-header-uploads' : 1862 if ( ! isset( $_wp_theme_features['custom-header'] ) ) 1871 if ( ! isset( $_wp_theme_features['custom-header'] ) ) { 1863 1872 return false; 1873 } 1864 1874 add_theme_support( 'custom-header', array( 'uploads' => false ) ); 1875 1865 1876 return; // Do not continue - custom-header-uploads no longer exists. 1866 }1867 1877 1868 if ( ! isset( $_wp_theme_features[ $feature ] ) )1869 return false;1870 1871 switch ( $feature ) {1872 1878 case 'custom-header' : 1873 if ( ! did_action( 'wp_loaded' ) ) 1879 if ( ! did_action( 'wp_loaded' ) ) { 1874 1880 break; 1881 } 1875 1882 $support = get_theme_support( 'custom-header' ); 1876 if ( $support[0]['wp-head-callback'] ) 1883 if ( $support[0]['wp-head-callback'] ) { 1877 1884 remove_action( 'wp_head', $support[0]['wp-head-callback'] ); 1885 } 1878 1886 remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) ); 1879 1887 unset( $GLOBALS['custom_image_header'] ); 1880 1888 break; 1881 1889 1882 1890 case 'custom-background' : 1883 if ( ! did_action( 'wp_loaded' ) ) 1891 if ( ! did_action( 'wp_loaded' ) ) { 1884 1892 break; 1893 } 1885 1894 $support = get_theme_support( 'custom-background' ); 1886 1895 remove_action( 'wp_head', $support[0]['wp-head-callback'] ); 1887 1896 remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) ); 1888 1897 unset( $GLOBALS['custom_background'] ); 1889 1898 break; 1899 1900 case 'html5' : 1901 case 'post-formats' : 1902 case 'post-thumbnails' : 1903 if ( $args ) { 1904 $kept_args = array_diff( $_wp_theme_features[ $feature ][0], $args ); 1905 1906 if ( ! empty( $kept_args ) ) { 1907 $_wp_theme_features[ $feature ][0] = $kept_args; 1908 return true; 1909 } 1910 } 1911 1912 break; 1890 1913 } 1891 1914 1892 1915 unset( $_wp_theme_features[ $feature ] );