函数原型
get_theme_mods(): array
函数描述
Retrieves all theme modifications.
是否弃用
未弃用
函数参数
无
函数返回值
array Theme modifications.
函数位置
File: wp-includes/theme.php.
函数源码
function get_theme_mods() {
$theme_slug = get_option( 'stylesheet' );
$mods = get_option( "theme_mods_$theme_slug" );
if ( false === $mods ) {
$theme_name = get_option( 'current_theme' );
if ( false === $theme_name ) {
$theme_name = wp_get_theme()->get( 'Name' );
}
$mods = get_option( "mods_$theme_name" ); // Deprecated location.
if ( is_admin() && false !== $mods ) {
update_option( "theme_mods_$theme_slug", $mods );
delete_option( "mods_$theme_name" );
}
}
if ( ! is_array( $mods ) ) {
$mods = array();
}
return $mods;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 5.9.0 | The return value is always an array. |
| 3.1.0 | Introduced. |

