功能-发动机罩下is_user_logged_in()
可用于确定来宾和已登录(因此已注册)用户之间的差异,switch_theme( $stylesheet )
更改中的实际数据库条目{$wpdb->options}
表格:
update_option( \'template\', $template );
update_option( \'stylesheet\', $stylesheet );
update_option( \'current_theme\', $new_name );
if ( count( $wp_theme_directories ) > 1 ) {
update_option( \'template_root\', get_raw_theme_root( $template, true ) );
update_option( \'stylesheet_root\', get_raw_theme_root( $stylesheet, true ) );
} else {
delete_option( \'template_root\' );
delete_option( \'stylesheet_root\' );
}
update_option( \'theme_switched\', $old_theme->get_stylesheet() );
简单的解决方案:两个样式表因此,我不建议这样做。只需在用户/来宾的基础上切换“主题”,即:加载的样式表
$stylesheet = plugins_dir_url( __FILE__ ).\'assets/\';
$stylesheet .= is_user_logged_in()
? \'style-user.css\'
: \'style-guest.css;
wp_enqueue_style(
\'main-stylesheet\',
$stylesheet
array( \'commons.css\' )
1.0
);
如您所见,我添加了
commons.css
到样式表。这将是另一个以前注册/排队的样式表,其中包含双方共享的所有定义。