例如,这是可行的:
\'default\' => \'#ffffff\'
但这并不是:
$white = \'#ffffff\';
\'default\' => $white
如何将变量传递给键/值对?
以下是一些上下文的更完整示例:
$white = \'#ffffff\';
$transport = \'refresh\';
$wp_customize->add_setting(\'mytheme_text_color\', array(
\'default\' => $white,
\'transport\' => $transport
));
回复jgraup:
此代码适用于:
$wp_customize->add_setting(\'themeone_primary_nav_background_color\', array(
\'default\' => \'#181818\',
\'transport\' => \'refresh\'
));
此代码不:
$args = array(\'default\' => \'#181818\', \'transport\' => \'refresh\');
$wp_customize->add_setting(\'themeone_primary_nav_background_color\', $args);
当我在管理部分自定义页面颜色时,我应该会看到一个“默认”颜色按钮。在前面的代码中,我看到了这个按钮。在后一段代码中,我没有。
如果有人想查看,我已将文件上传到我的google drive:https://drive.google.com/open?id=0B01XHUEqiziEcW14WE5NN0VYYlE
下面是示例输出问题的图片:https://drive.google.com/file/d/0B01XHUEqiziEUDVyZWFRWGZ0SkE/view?usp=sharing