remove_theme_mod

函数


remove_theme_mod ( $name )
参数
  • (string)
    $name
    Theme modification name.
    Required:
定义位置
  • wp-includes/theme.php
    , line 1079
引入
2.1.0
弃用

从活动主题列表中删除主题修改名称。

如果删除名称的同时也删除了所有元素,那么整个选项将被删除。

function remove_theme_mod( $name ) {
	$mods = get_theme_mods();

	if ( ! isset( $mods[ $name ] ) ) {
		return;
	}

	unset( $mods[ $name ] );

	if ( empty( $mods ) ) {
		remove_theme_mods();
		return;
	}

	$theme = get_option( 'stylesheet' );

	update_option( "theme_mods_$theme", $mods );
}