3

我遇到了通过 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

我每次都像这样http://prntscr.com/3s5ucm得到默认值是 orange.css 。

我现在能做什么?

4

1 回答 1

1

$redux_demo 在你的 Redux Config 运行之后才会起作用。确保你先运行它。

于 2014-09-26T22:16:41.347 回答