动态样式表与Redux框架


Dynamic Stylesheet with Redux framework

我遇到了一个问题,通过redux使样式表动态。在我的config.php中,我写了下面的代码:

array(
    'id'        => 'scheme',
    'type'      => 'select',
    'title'     => __('Theme Stylesheet', 'redux-framework-demo'),
    'subtitle'  => __('Select a predefined color scheme. They`re located in `/css/color-schemes/` theme folder', 'redux-framework-demo'),
    'options'   => array('orange.css' => 'orange.css', 'red.css' => 'red.css', 'blue.css' => 'blue.css'),
    'default'   => 'orange.css',
),

和我试图通过在functions.php上编写下面的代码来排队样式表

if(!isset($redux_demo['scheme'])) {
    wp_enqueue_style( 'pm-color-scheme', get_stylesheet_directory_uri() . '/css/color-schemes/orange.css' );
}
else {
    wp_enqueue_style( 'pm-color-scheme', get_stylesheet_directory_uri() . '/css/color-schemes/'.$redux_demo['scheme'] );
}

但是当我从主题选项中选择blue。css时,就像这样http://prntscr.com/3s5td0

每次我得到的默认值是orange.css http://prntscr.com/3s5ucm.

我现在能做什么?

$redux_demo在您的Redux配置运行之前不会工作。