I'm searching for a way to pass a variable from a custom Wordpress page template to my child theme functions.php file. I have the wrong scope and I'm completely lost. I'm trying to generate a google map with user submitted data here: http://cheryllynch.com/homevalue/
Do I need to write to the mySQL database to do this? Should I brake the rules and use a global variable?
<!--HomeValue.php Template-->
$latitude = $xml[$i]->response->results->result->address->latitude;
$_POST['latitude'];
<!--functions.php-->
wp_enqueue_script( //From jqueryui.com copy CDN (or download)
'jqueryui',
'//code.jquery.com/ui/1.10.3/jquery-ui.js',
array('jquery')
); //End of enqueue jQuery UI
wp_enqueue_script( 'extra js', get_stylesheet_directory_uri() . '/js/extra.js' );
$datatoBePassed = array(
'hvuri' => get_stylesheet_directory_uri() . '/page-homevalue.php',
'latitude' => __(latitude),
'longitude' => __(longitude)
);
wp_localize_script( 'extra js', 'gmap_php_vars', $datatoBePassed );
}
}
add_action( 'wp_enqueue_scripts', 'cheryllynch_sheeva_child_scripts' );