"; echo $aimtell_tracking_code; } /***************Plugin Functions****************/ /****** Admin Functions *********/ function aimtellWP_footer_info() { //load only on plugin page if(isset($_GET['page']) && $_GET['page'] == "aimtell-web-push"){ echo phpversion(); } } function aimtellWP_admin_scripts($hook) { //load only on plugin page if(strpos($hook, "aimtell-web-push") > -1 ){ //load css wp_enqueue_style( 'aimtell-css', AIMTELL_URL. 'assets/css/stylesheet.css' ); //load the aimtell core js file, dependency on jQuery wp_enqueue_script( 'aimtell-js', AIMTELL_URL . 'assets/js/aimtell.js', array( 'jquery' ) ); } } function aimtellWP_admin_menu() { add_menu_page( 'Aimtell Push', 'Aimtell Push', 'manage_options', 'aimtell-web-push', 'aimtellWP_admin_load', AIMTELL_URL . 'assets/images/aimtell_icon.png' ); } function aimtellWP_admin_load() { //make sure user has proper permissions if ( !current_user_can( 'manage_options' ) ) { wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); } //grab the option vars $aimtell_domain = get_option( 'aimtell_domain' ); $aimtell_uid = get_option( 'aimtell_uid' ); $aimtell_idSite = get_option( 'aimtell_idSite' ); $aimtell_webpushid = get_option( 'aimtell_webpushid' ); //grab page $aimtell_show_page = (isset($_POST['page'])) ? $_POST['page'] : null; //load specific page switch ($aimtell_show_page) { case 'login': include __FOLDERDIR__."/templates/login.php"; break; case 'register': include __FOLDERDIR__."/templates/register.php"; break; case 'addSite': include __FOLDERDIR__."/templates/addSite.php"; break; case 'viewSite': //if posting idSite for update if(!empty($_POST['idSite'])){ update_option( 'aimtell_idSite', $_POST['idSite'], 'yes' ); } //if posting domain for update if(!empty($_POST['domain'])){ update_option( 'aimtell_domain', $_POST['domain'], 'yes' ); } //if posting webPushID for update if(!empty($_POST['webPushID'])){ update_option( 'aimtell_webpushid', $_POST['webPushID'], 'yes' ); } //if posting webPushID for update if(!empty($_POST['uid'])){ update_option( 'aimtell_uid', $_POST['uid'], 'yes' ); } //grab the token, we need to pass it $aimtell_auth_token = $_COOKIE['aimtell_auth_token']; include __FOLDERDIR__."/templates/viewSite.php"; break; default: //if auth token is set and we already have all required site variables, go ahead show viewSite if(!empty($_COOKIE['aimtell_auth_token']) && !empty($aimtell_domain) && !empty($aimtell_uid) && !empty($aimtell_idSite) && !empty($aimtell_webpushid) ){ $aimtell_auth_token = $_COOKIE['aimtell_auth_token']; include __FOLDERDIR__."/templates/viewSite.php"; } //if the domain is set in DB, they have an account, show login else if(!empty($aimtell_uid)){ include __FOLDERDIR__."/templates/login.php"; } else{ include __FOLDERDIR__."/templates/login.php"; //removing register, we are forcing them to register on our website now } break; } } /************End Admin Functions**************/ add_action( 'admin_menu', 'aimtellWP_admin_menu' ); add_action( 'wp_footer', 'aimtellWP_footer', 100 ); add_action( 'admin_enqueue_scripts', 'aimtellWP_admin_scripts' ); add_filter('admin_footer_text', 'aimtellWP_footer_info');