Can\'t get options with $data[\'variable\'].
(我正在使用SMOF-略微修改的选项框架)例如,在标题中。php(index.php、footer.php等):
global $data;
$logo_type = stripslashes( $data[\'type_logo\'] );
什么都没发生,变数$logo_type
不包含任何内容。但是如果我在css样式中使用相同的代码。php-一切正常。来自\\css\\style的代码。php:
<?php
/* Background Body */
$bg_color = stripslashes ( $data[\'ct_bg_color\'] );
?>
/* Body BG Color */
body, .body-class { background-color: <?php echo $bg_color; ?>
}
作为框架一部分的功能:/*-----------------------------------------------------------------------------------*/
/* Generate a static css file from the defined options
/*-----------------------------------------------------------------------------------*/
// This function will generate a static css file which you can use in your theme.
// Some examples of the dynamically generated options has been defined in css/styles.php
function generate_options_css($newdata) {
$data = $newdata;
$css_dir = get_stylesheet_directory() . \'/css/\'; // Shorten code, save 1 call
ob_start(); // Capture all output (output buffering)
require($css_dir . \'styles.php\'); // Generate CSS
$css = ob_get_clean(); // Get generated CSS (output buffering)
file_put_contents($css_dir . \'options.css\', $css, LOCK_EX); // Save it
}
链接到框架文件:https://github.com/sy4mil/Options-Framework/tree/master/admin/functions第一次遇到此问题。。。无法理解问题所在(php、web托管等)
还有其他人遇到此问题吗?