<?php

/**
 * Analytify Dashboard file.
 * @package WP_Analytify
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly.
}
$wp_analytify = new WP_Analytify();
$start_date_val = strtotime('- 30 days');
$end_date_val = strtotime('now');
$start_date = date('Y-m-d', $start_date_val);
$end_date = date('Y-m-d', $end_date_val);
if (filter_input(INPUT_POST, 'view_data') && wp_verify_nonce(filter_input(INPUT_POST, 'analytify_dashboard_nonce'), 'analytify_dashboard_action')) {
    $s_date = filter_input(INPUT_POST, 'st_date');
    $ed_date = filter_input(INPUT_POST, 'ed_date');
}
if (isset($s_date)) {
    $start_date = $s_date;
}
if (isset($ed_date)) {
    $end_date = $ed_date;
}
// Fetch Dashboard Profile ID.
$dashboard_profile_id = get_option('pt_webprofile_dashboard');
?>
<div class="wrap">
	<h2 class='opt-title'><span id='icon-options-general' class='analytics-options'><img src="<?php 
echo esc_url(plugins_url('images/wp-analytics-logo.png', dirname(__FILE__)));
示例#2
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');
            }
        }
<?php

$wp_analytify = new WP_Analytify();
if (!function_exists('curl_init')) {
    esc_html_e('This plugin requires the CURL PHP extension');
    return false;
}
if (!function_exists('json_decode')) {
    esc_html_e('This plugin requires the JSON PHP extension');
    return false;
}
if (!function_exists('http_build_query')) {
    esc_html_e('This plugin requires http_build_query()');
    return false;
}
/* Save user specific Keys, ID's and Redirect URI */
if (isset($_POST['save_code'])) {
    if (isset($_POST['auth_step']) and $_POST['auth_step'] == 'Yes') {
        update_option('ANALYTIFY_USER_KEYS', sanitize_text_field($_POST['auth_step']));
        update_option('ANALYTIFY_CLIENTID', sanitize_text_field($_POST['analytify_clientid']));
        update_option('ANALYTIFY_CLIENTSECRET', sanitize_text_field($_POST['analytify_clientsecret']));
        update_option('ANALYTIFY_DEV_KEY', sanitize_text_field($_POST['analytify_apikey']));
        update_option('ANALYTIFY_REDIRECT_URI', sanitize_text_field($_POST['analytify_redirect_uri']));
    }
    if (!isset($_POST['auth_step'])) {
        update_option('ANALYTIFY_USER_KEYS', 'No');
    }
    /*	if( isset($_POST['auth_step']) and $_POST['auth_step'] == 'user_access_code' ) {
    
    		$key_google_token = $_POST[ 'key_google_token' ];
    
示例#5
0
<?php

$wp_analytify = new WP_Analytify();
if (!function_exists('curl_init')) {
    esc_html_e('This plugin requires the CURL PHP extension');
    return false;
}
if (!function_exists('json_decode')) {
    esc_html_e('This plugin requires the JSON PHP extension');
    return false;
}
if (!function_exists('http_build_query')) {
    esc_html_e('This plugin requires http_build_query()');
    return false;
}
// Save access code
if (isset($_POST['save_code'])) {
    if (isset($_POST['auth_step']) and $_POST['auth_step'] == 'user_keys') {
        update_option('ANALYTIFY_CLIENTID', $_POST['analytify_clientid']);
        update_option('ANALYTIFY_CLIENTSECRET', $_POST['analytify_clientsecret']);
        update_option('ANALYTIFY_DEV_KEY', $_POST['analytify_apikey']);
    }
    if (isset($_POST['auth_step']) and $_POST['auth_step'] == 'user_access_code') {
        $key_google_token = $_POST['key_google_token'];
        if ($wp_analytify->pt_save_data($key_google_token)) {
            $update_message = '<div id="setting-error-settings_updated" class="updated settings-error below-h2"><p><strong>Access code saved.</strong></p></div>';
        }
    }
}
$url = http_build_query(array('next' => $wp_analytify->pa_setting_url(), 'scope' => ANALYTIFY_SCOPE, 'response_type' => 'code', 'redirect_uri' => ANALYTIFY_REDIRECT, 'client_id' => get_option('ANALYTIFY_CLIENTID'), 'access_type' => 'offline', 'approval_prompt' => 'auto'));
// Saving settings for back end Analytics for Posts and Pages.