[ACCEPTED]-Global Variables in a WordPress Plugin-wordpress-admin

Accepted answer
Score: 10

It turns out if you want a global variable 4 for your install function, you must declare 3 it to be global.

global $version = '1.0a';
register_activation_hook( __FILE__, 'install' );
function install() {
  global $version;
  add_option( 'test_version', $version );

More information can be 2 found at the link below under the "A 1 Note on Variable Scoping" section: http://codex.wordpress.org/Function_Reference/register_activation_hook

More Related questions