array( 'title' => 'Overview', 'template' => 'overview' ),
'aimtell-campaigns' => array( 'title' => 'Campaigns', 'template' => 'campaigns' ),
'aimtell-blog-posts' => array( 'title' => 'Blog posts', 'template' => 'rss' ),
'aimtell-segments' => array( 'title' => 'Segments', 'template' => 'segments' ),
'aimtell-web-push-settings' => array( 'title' => 'Settings', 'template' => 'settings' ),
);
}
/**
* The site is connected once all four values the tracking script needs are stored.
*/
function aimtell_is_connected() {
return get_option( 'aimtell_uid' ) && get_option( 'aimtell_idSite' ) && get_option( 'aimtell_domain' ) && get_option( 'aimtell_webpushid' );
}
function aimtell_admin_url( $slug = 'aimtell-web-push', $args = array() ) {
return add_query_arg( array_merge( array( 'page' => $slug ), $args ), admin_url( 'admin.php' ) );
}
function aimtellWP_admin_menu() {
$pages = aimtell_admin_pages();
add_menu_page(
'Aimtell',
'Aimtell',
'manage_options',
'aimtell-web-push',
'aimtell_admin_render',
AIMTELL_URL . 'assets/images/aimtell_icon.png'
);
foreach ( $pages as $slug => $page ) {
add_submenu_page( 'aimtell-web-push', $page['title'] . ' ‹ Aimtell', $page['title'], 'manage_options', $slug, 'aimtell_admin_render' );
}
}
add_action( 'admin_menu', 'aimtellWP_admin_menu' );
/**
* Which screen to show. Account screens show sample data until the site is connected,
* and the sign-in screen when the site is connected but this browser has no token.
*/
function aimtell_current_view() {
$page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : 'aimtell-web-push';
$view = isset( $_GET['view'] ) ? sanitize_key( $_GET['view'] ) : '';
$pages = aimtell_admin_pages();
if ( ! isset( $pages[ $page ] ) ) {
$page = 'aimtell-web-push';
}
if ( 'settings' === $pages[ $page ]['template'] ) {
return array( 'page' => $page, 'template' => 'settings', 'demo' => false );
}
if ( 'signin' === $view || 'connect' === $view ) {
return array( 'page' => $page, 'template' => $view, 'demo' => false );
}
if ( ! aimtell_is_connected() ) {
return array( 'page' => $page, 'template' => $pages[ $page ]['template'], 'demo' => true );
}
if ( empty( $_COOKIE['aimtell_auth_token'] ) ) {
return array( 'page' => $page, 'template' => 'signin', 'demo' => false );
}
return array( 'page' => $page, 'template' => $pages[ $page ]['template'], 'demo' => false );
}
function aimtell_admin_render() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) );
}
$aimtell_view = aimtell_current_view();
$aimtell_demo = $aimtell_view['demo'];
echo '
';
// WordPress moves admin notices to just after the first h1/h2 in .wrap; this empty one keeps them at the top
echo '';
include __FOLDERDIR__ . '/templates/' . $aimtell_view['template'] . '.php';
echo '
';
}
/**
* The sample-data banner shown above account screens until the site is connected.
*/
function aimtell_demo_banner() {
?>
You're exploring with sample dataClick around. Nothing here is sent. Create a free account to see your own subscribers and campaigns.