I created the functions.php for my theme-child:
<?php
add_action('wp_enqueue_scripts', 'child_enqueue_styles',
99);
function child_enqueue_styles(){
$parent_style = 'parent-style';
wp_enqueue_style($parent_style,
get_template_directory_uri() . '/style.css');
wp_enqueue_style('child-style',
get_stylesheet_directory_uri() . '/style.css',
array($parent_style)); }
if(get_stylesheet() !== get_template()){
add_filter('pre_update_option_theme_mods_' .
get_stylesheet(),
function($value, $old_value){
update_option('theme_mods_' . get_template(),
$value);
return $old_value;}, 10, 2);
add_filter('pre_option_theme_mods_' . get_stylesheet(),
function($default){return get_option('theme_mods_' .
get_template(), $default);});}
/*---Initialize globald data ---*/ add_action('after_setup_theme', function(){
$value1 = $GLOBALS['bbl_var1'];
$value2 = $GLOBALS['bbl_var2'];
$value3 = $GLOBALS['bbl_var3'];});
$GLOBALS['bbl_var1'] = 'JdV111';
$GLOBALS['bbl_var2'] = 'JdV222';
$GLOBALS['bbl_var3'] = 'JdV333';
?>
And my PHP-snippet:
<?php
echo '<br>' . $GLOBALS['bbl_var1'];
echo '<br>' . $GLOBALS['bbl_var2'];
echo '<br>' . $GLOBALS['bbl_var3'];
I got the PHP message:
Warning: Undefined array key "bbl_var1" in /......./wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(100) : eval()'d code on line 2
What should I have done wrong?