Variable from a plugin into a theme

Your webhost has disabled register_globals in the php.ini, so you have to “register” your variables manually everytime you want to use it. For example:

<?php
global $xavi;
echo $xavi;
?>

Another approach is using the $GLOBALS array:

<?php
echo $GLOBALS['xavi'];
?>

But in my opinion, you should avoid using globals. Instead use a simple registry-class, which you can add/get your values.

EDIT

This isn’t a WordPress specific solution and could be a bit of an overkill for this simple question. The registry pattern is an official programming design-pattern. Same goes for the singleton-pattern which I’ve used here too.

What we do here is to store our content in a registry-object. It’s singleton, so only one instance is created.

I know, the problem isn’t solved really. Instead of using the $GLOBALS array, we are using a registry class which is indeed also “global” as we call the instance everytime we need it. You don’t have control, where you call it. Also the testing of a singleton class could be problematic. If you want more control, just look at the factory-pattern with dependancy injection.

class Webeo_Registry {
    /**
     * Array to store items
     * 
     * @var array
     */
    private $_objects = array();

    /**
     * Stores the registry object
     * 
     * @var Webeo_Registry
     */
    private static $_instance = null;

    /**
     * Get the instance
     * 
     * @return void
     */
    public static function getInstance() {
        if (is_null(self::$_instance)) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }

    /**
     * Constructor
     * 
     * @access private
     * @return void
     */
    private function __construct() {}

    /**
     * Set an item by given key and value
     * 
     * @param string $key
     * @param void $value
     * @return void
     */
    public function __set($key, $value) {
        // maybe you want to check if the value already exists
        $this->_objects[$key] = $value;
    }

    /**
     * Get an item by key
     * 
     * @param string $key Identifier for the registry item
     * @return void
     */
    public function __get($key) {
        if(isset($this->_objects[$key])) {
            $result = $this->_objects[$key];
        } else {
            $result = null;
        }

        return $result;
    }

    /**
     * Check if an item with the given key exists
     * 
     * @param string $key
     * @return void
     */
    public function __isset($key) {
        return isset($this->_objects[$key]);
    }

    /**
     * Delete an item with the given key
     * 
     * @param string $key
     * @return void
     */
    public function __unset($key) {
        unset($this->_objects[$key]);
    }

    /**
     * Make clone private, so nobody can clone the instance
     * 
     * @return void
     */
    private function __clone() {}
}

In your plugin/theme, you only have to return the instance and you’re ready to use it:

$registry = Webeo_Registry::getInstance();

// Define some options (just add it after the "->". The magic method __set will do the rest)
$registry->optionA = 'awdawd';
$registry->optionB = array(1,2,3);

// Check the content
print_r($registry);

// Remove an item
unset($registry->optionA);

// Check if option exists
if(isset($registry->optionA)) {
    echo 'option exist';
} else {
    echo 'option does not exist';
}