I am not an expert Wordpress PHP developer but I am not understanding this situation. I am passing a variable through a static function into the $GLOBALS variable that contains an array. That variable when in the static function is always NULL, but before it goes into it, it is a valid type and prints fine.
functions.php
$badge_Id = get_comment_meta($comment->comment_ID,"badge_id", true);
if(strlen($badge_Id) > 0) {
Cisco_Rewards::add_badge_id($badge_id);
echo $badge_id; // PRINTS PERFECTLY
}
rewards.php
class Cisco_Rewards {
static function add_badge_id($badge_id) {
if(count($GLOBALS['badge_ids']) == 0) {
$GLOBALS['badge_ids'] = array();
}
echo $badge_id; // WONT PRINT, IS NULL
array_push($GLOBALS['badge_ids'], $badge_Id);
print_r($GLOBALS['badge_ids']); // ALWAYS HAS NULL VALUES
}
$badge_Idor$badge_id? You've made this error in a couple of places. Perhaps consider using a clearer font in your text editor.