Example #1
0
        public static function show_admin_single_analytics()
        {
            global $post;
            $back_exclude_posts = explode(',', get_option('post_analytics_exclude_posts_back'));
            if (is_array($back_exclude_posts)) {
                if (in_array($post->ID, $back_exclude_posts)) {
                    _e('This post is excluded and will not show Analytics.');
                    return;
                }
            }
            $urlPost = '';
            $wp_analytify = new WP_Analytify();
            $urlPost = parse_url(get_permalink($post->ID));
            $start_date = '';
            $end_date = '';
            $urlpost = '';
            $is_access_level = get_option('post_analytics_access_back');
            if ($wp_analytify->pa_check_roles($is_access_level)) {
                ?>

			<div class="pa-filter">
				<table cellspacing="0" cellpadding="0" width="400">
					<tbody>
						<tr>
							<td width="0">
								<input type="text" id="start_date" name="start_date">
							</td>
							<td width="0">
								<input type="text" id="end_date" name="end_date">
							</td>
								<input type="hidden" name="urlpost" id="urlpost" value="<?php 
                echo $urlPost['path'];
                ?>
">
							<td width="0">
								<input type="button" id="view_analytics" name="view_analytics" value="View Analytics" class="button-primary btn-green">
							</td>
					   </tr>
					</tbody>
				</table>
			</div>
			<div class="loading" style="display:none">
				<img src="<?php 
                echo plugins_url('images/loading.gif', __FILE__);
                ?>
">
			</div>
			<div class="show-hide">
					<?php 
                $wp_analytify->get_single_admin_analytics($start_date, $end_date, $post->ID, 0);
                ?>
			</div>
			<?php 
            } else {
                echo _e('You are not allowed to see stats', 'wp-analytify');
            }
        }
        public static function show_admin_single_analytics()
        {
            global $post;
            // // Don't show statistics on posts which are not published.
            // if ( get_post_status ( $post->ID ) != 'publish' ) {
            // esc_html_e( 'Statistics will be loaded after you publish this content.', 'wp-analytify' );
            // return false;
            // }
            $back_exclude_posts = explode(',', get_option('post_analytics_exclude_posts_back'));
            if (is_array($back_exclude_posts)) {
                if (in_array($post->ID, $back_exclude_posts)) {
                    _e('This post is excluded and will not show Analytics.');
                    return;
                }
            }
            $urlPost = '';
            $start_date = '';
            $end_date = '';
            $wp_analytify = new WP_Analytify();
            $urlPost = parse_url(get_permalink($post->ID));
            if (get_the_time('Y', $post->ID) < 2005) {
                $start_date = '2005-01-01';
            } else {
                $start_date = get_the_time('Y-m-d', $post->ID);
            }
            $end_date = date('Y-m-d');
            $is_access_level = get_option('post_analytics_access_back');
            if ($wp_analytify->pa_check_roles($is_access_level)) {
                ?>

			<div class="pa-filter">
				<table cellspacing="0" cellpadding="0" width="400">
					<tbody>
						<tr>
							<td width="0">
								<input type="text" id="start_date" name="start_date" value="<?php 
                echo $start_date;
                ?>
">
							</td>
							<td width="0">
								<input type="text" id="end_date" name="end_date" value="<?php 
                echo $end_date;
                ?>
">
							</td>
							<input type="hidden" name="urlpost" id="urlpost" value="<?php 
                echo $urlPost['path'];
                ?>
">
							<td width="0">
								<input type="button" id="view_analytics" name="view_analytics" value="View Analytics" class="button-primary btn-green">
							</td>
						</tr>
					</tbody>
				</table>
			</div>
			<div class="loading" style="display:none">
				<img src="<?php 
                echo plugins_url('images/loading.gif', __FILE__);
                ?>
">
			</div>
			<div class="show-hide">
				<?php 
                $wp_analytify->get_single_admin_analytics($start_date, $end_date, $post->ID, 0);
                ?>
			</div>
			<?php 
            } else {
                echo _e('You are not allowed to see stats', 'wp-analytify');
            }
        }