I'm working on my first plugin and i have made a nice settings page which saves and works. But i have splitted it to few files and now i can't detemine if field is checked.. I have also tried declaring a global variable but i can't get it to work :\
This is how my plugin starts-
global $if_autoload;
add_action('init', 'additional_menus_admin');
function additional_menus_admin() {
require_once(dirname(__FILE__) . '/admin.php');
require_once(dirname(__FILE__) . '/hooks.php');
}
I try to see if the "autoload" checkbox is checked on my hooks.php-
add_action('wp_head','hook_additional_menu', 20);
function hook_additional_menu() {
global $if_autoload;
echo '<test>'.$if_autoload.'</test>';
}
I have also tried using the get_option function but nothing.. All the fields are being save on my admin.php file and i tried pushing the global variable from there too-
function menu_autoload_callback() {
$if_autoload = get_option( 'autoload-or-shortcode' );
echo '<input type="checkbox" name="autoload-or-shortcode" value="1"'. checked( 1, get_option( 'autoload-or-shortcode' ), false ) .' /><br />';
}
What am i doing wrong? any help is appriciated! Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire