_remove_theme_support

函式
_remove_theme_support ( $feature )
Access
Private
引數
  • (string) $feature The feature being removed. See add_theme_support() for the list of possible values.
    Required:
返回值
  • (bool) True if support was removed, false if the feature was not registered.
定義位置
相關方法
remove_theme_supportget_theme_supportremove_post_type_supportremove_theme_modremove_theme_mods
引入
3.1.0
棄用
-

_remove_theme_support: 這個函式用來移除對某一特定主題功能的支援。

請勿使用。在不知道那些不被主題直接使用的情況下,在內部刪除主題支援。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function _remove_theme_support( $feature ) {
global $_wp_theme_features;
switch ( $feature ) {
case 'custom-header-uploads':
if ( ! isset( $_wp_theme_features['custom-header'] ) ) {
return false;
}
add_theme_support( 'custom-header', array( 'uploads' => false ) );
return; // Do not continue - custom-header-uploads no longer exists.
}
if ( ! isset( $_wp_theme_features[ $feature ] ) ) {
return false;
}
switch ( $feature ) {
case 'custom-header':
if ( ! did_action( 'wp_loaded' ) ) {
break;
}
$support = get_theme_support( 'custom-header' );
if ( isset( $support[0]['wp-head-callback'] ) ) {
remove_action( 'wp_head', $support[0]['wp-head-callback'] );
}
if ( isset( $GLOBALS['custom_image_header'] ) ) {
remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) );
unset( $GLOBALS['custom_image_header'] );
}
break;
case 'custom-background':
if ( ! did_action( 'wp_loaded' ) ) {
break;
}
$support = get_theme_support( 'custom-background' );
if ( isset( $support[0]['wp-head-callback'] ) ) {
remove_action( 'wp_head', $support[0]['wp-head-callback'] );
}
remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) );
unset( $GLOBALS['custom_background'] );
break;
}
unset( $_wp_theme_features[ $feature ] );
return true;
}
function _remove_theme_support( $feature ) { global $_wp_theme_features; switch ( $feature ) { case 'custom-header-uploads': if ( ! isset( $_wp_theme_features['custom-header'] ) ) { return false; } add_theme_support( 'custom-header', array( 'uploads' => false ) ); return; // Do not continue - custom-header-uploads no longer exists. } if ( ! isset( $_wp_theme_features[ $feature ] ) ) { return false; } switch ( $feature ) { case 'custom-header': if ( ! did_action( 'wp_loaded' ) ) { break; } $support = get_theme_support( 'custom-header' ); if ( isset( $support[0]['wp-head-callback'] ) ) { remove_action( 'wp_head', $support[0]['wp-head-callback'] ); } if ( isset( $GLOBALS['custom_image_header'] ) ) { remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) ); unset( $GLOBALS['custom_image_header'] ); } break; case 'custom-background': if ( ! did_action( 'wp_loaded' ) ) { break; } $support = get_theme_support( 'custom-background' ); if ( isset( $support[0]['wp-head-callback'] ) ) { remove_action( 'wp_head', $support[0]['wp-head-callback'] ); } remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) ); unset( $GLOBALS['custom_background'] ); break; } unset( $_wp_theme_features[ $feature ] ); return true; }
function _remove_theme_support( $feature ) {
	global $_wp_theme_features;

	switch ( $feature ) {
		case 'custom-header-uploads':
			if ( ! isset( $_wp_theme_features['custom-header'] ) ) {
				return false;
			}
			add_theme_support( 'custom-header', array( 'uploads' => false ) );
			return; // Do not continue - custom-header-uploads no longer exists.
	}

	if ( ! isset( $_wp_theme_features[ $feature ] ) ) {
		return false;
	}

	switch ( $feature ) {
		case 'custom-header':
			if ( ! did_action( 'wp_loaded' ) ) {
				break;
			}
			$support = get_theme_support( 'custom-header' );
			if ( isset( $support[0]['wp-head-callback'] ) ) {
				remove_action( 'wp_head', $support[0]['wp-head-callback'] );
			}
			if ( isset( $GLOBALS['custom_image_header'] ) ) {
				remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) );
				unset( $GLOBALS['custom_image_header'] );
			}
			break;

		case 'custom-background':
			if ( ! did_action( 'wp_loaded' ) ) {
				break;
			}
			$support = get_theme_support( 'custom-background' );
			if ( isset( $support[0]['wp-head-callback'] ) ) {
				remove_action( 'wp_head', $support[0]['wp-head-callback'] );
			}
			remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) );
			unset( $GLOBALS['custom_background'] );
			break;
	}

	unset( $_wp_theme_features[ $feature ] );

	return true;
}

常見問題

FAQs
檢視更多 >