function https_stats_footer()
{
    $protocol = !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? "https://" : "http://";
    global $wp_the_query, $current_user;
    $options = stats_get_options();
    if (!empty($current_user->ID) || empty($options['blog_id'])) {
        return;
    }
    $a['blog'] = $options['blog_id'];
    $a['v'] = 'ext';
    if ($wp_the_query->is_single || $wp_the_query->is_page) {
        $a['post'] = $wp_the_query->get_queried_object_id();
    } else {
        $a['post'] = '0';
    }
    ?>
<script src="<?php 
    echo $protocol;
    ?>
stats.wordpress.com/e-<?php 
    echo gmdate('YW');
    ?>
.js" type="text/javascript"></script>
<script type="text/javascript">
st_go({<?php 
    echo stats_array($a);
    ?>
});
var load_cmc = function(){linktracker_init(<?php 
    echo "{$a['blog']},{$a['post']},2";
    ?>
);};
if ( typeof addLoadEvent != 'undefined' ) addLoadEvent(load_cmc);
else load_cmc();
</script>
<?php 
}
function stats_template_redirect()
{
    global $wp_the_query, $current_user, $stats_footer;
    if (is_feed() || is_robots() || is_trackback()) {
        return;
    }
    $options = stats_get_options();
    // Ensure this is always setup for the check below
    $options['reg_users'] = empty($options['reg_users']) ? false : true;
    if (!$options['reg_users'] && !empty($current_user->ID)) {
        return;
    }
    add_action('wp_footer', 'stats_footer', 101);
    add_action('wp_head', 'stats_add_shutdown_action');
    $blog = get_option('jetpack_id');
    $v = 'ext';
    $j = JETPACK__API_VERSION;
    if ($wp_the_query->is_single || $wp_the_query->is_page || $wp_the_query->is_posts_page) {
        $post = $wp_the_query->get_queried_object_id();
    } else {
        $post = '0';
    }
    $http = is_ssl() ? 'https' : 'http';
    $week = gmdate('YW');
    $data = stats_array(compact('v', 'j', 'blog', 'post'));
    $stats_footer = <<<END

\t<script src="{$http}://stats.wordpress.com/e-{$week}.js" type="text/javascript"></script>
\t<script type="text/javascript">
\tst_go({{$data}});
\tvar load_cmc = function(){linktracker_init({$blog},{$post},2);};
\tif ( typeof addLoadEvent != 'undefined' ) addLoadEvent(load_cmc);
\telse load_cmc();
\t</script>
END;
}
Exemple #3
0
function stats_template_redirect()
{
    global $current_user, $stats_footer;
    if (is_feed() || is_robots() || is_trackback() || is_preview()) {
        return;
    }
    // Should we be counting this user's views?
    if (!empty($current_user->ID)) {
        $count_roles = stats_get_option('count_roles');
        if (!array_intersect($current_user->roles, $count_roles)) {
            return;
        }
    }
    add_action('wp_footer', 'stats_footer', 101);
    add_action('wp_head', 'stats_add_shutdown_action');
    $script = set_url_scheme('//stats.wp.com/e-' . gmdate('YW') . '.js');
    $data = stats_build_view_data();
    $data_stats_array = stats_array($data);
    $stats_footer = <<<END
<script type='text/javascript' src='{$script}' async defer></script>
<script type='text/javascript'>
\t_stq = window._stq || [];
\t_stq.push([ 'view', {{$data_stats_array}} ]);
\t_stq.push([ 'clickTrackerInit', '{$data['blog']}', '{$data['post']}' ]);
</script>

END;
}
Exemple #4
0
function stats_template_redirect()
{
    global $wp_the_query, $current_user, $stats_footer;
    if (is_feed() || is_robots() || is_trackback()) {
        return;
    }
    $options = stats_get_options();
    // Should we be counting this user's views?
    if (!empty($current_user->ID)) {
        $count_roles = stats_get_option('count_roles');
        if (!array_intersect($current_user->roles, $count_roles)) {
            return;
        }
    }
    add_action('wp_footer', 'stats_footer', 101);
    add_action('wp_head', 'stats_add_shutdown_action');
    $blog = Jetpack_Options::get_option('id');
    $tz = get_option('gmt_offset');
    $v = 'ext';
    $j = sprintf('%s:%s', JETPACK__API_VERSION, JETPACK__VERSION);
    if ($wp_the_query->is_single || $wp_the_query->is_page || $wp_the_query->is_posts_page) {
        // Store and reset the queried_object and queried_object_id
        // Otherwise, redirect_canonical() will redirect to home_url( '/' ) for show_on_front = page sites where home_url() is not all lowercase.
        // Repro:
        // 1. Set home_url = http://ExamPle.com/
        // 2. Set show_on_front = page
        // 3. Set page_on_front = something
        // 4. Visit http://example.com/
        $queried_object = isset($wp_the_query->queried_object) ? $wp_the_query->queried_object : null;
        $queried_object_id = isset($wp_the_query->queried_object_id) ? $wp_the_query->queried_object_id : null;
        $post = $wp_the_query->get_queried_object_id();
        $wp_the_query->queried_object = $queried_object;
        $wp_the_query->queried_object_id = $queried_object_id;
    } else {
        $post = '0';
    }
    $http = is_ssl() ? 'https' : 'http';
    $week = gmdate('YW');
    $data = stats_array(compact('v', 'j', 'blog', 'post', 'tz'));
    $stats_footer = <<<END

\t<script src="{$http}://stats.wordpress.com/e-{$week}.js" type="text/javascript"></script>
\t<script type="text/javascript">
\tst_go({{$data}});
\tvar load_cmc = function(){linktracker_init({$blog},{$post},2);};
\tif ( typeof addLoadEvent != 'undefined' ) addLoadEvent(load_cmc);
\telse load_cmc();
\t</script>
END;
}
Exemple #5
0
function stats_footer()
{
    global $wp_the_query, $current_user;
    $options = stats_get_options();
    echo "<!--stats_footer_test-->";
    if (!$options['footer']) {
        stats_set_option('footer', true);
    }
    if (empty($options['blog_id'])) {
        return;
    }
    if (!$options['reg_users'] && !empty($current_user->ID)) {
        return;
    }
    $a['blog'] = $options['blog_id'];
    $a['v'] = 'ext';
    if ($wp_the_query->is_single || $wp_the_query->is_page) {
        $a['post'] = $wp_the_query->get_queried_object_id();
    } else {
        $a['post'] = '0';
    }
    $http = is_ssl() ? 'https' : 'http';
    ?>
<script src="<?php 
    echo $http;
    ?>
://stats.wordpress.com/e-<?php 
    echo gmdate('YW');
    ?>
.js" type="text/javascript"></script>
<script type="text/javascript">
st_go({<?php 
    echo stats_array($a);
    ?>
});
var load_cmc = function(){linktracker_init(<?php 
    echo "{$a['blog']},{$a['post']},2";
    ?>
);};
if ( typeof addLoadEvent != 'undefined' ) addLoadEvent(load_cmc);
else load_cmc();
</script>
<?php 
}
function stats_template_redirect()
{
    global $wp_the_query, $current_user, $stats_footer;
    if (is_feed() || is_robots() || is_trackback() || is_preview()) {
        return;
    }
    $options = stats_get_options();
    // Should we be counting this user's views?
    if (!empty($current_user->ID)) {
        $count_roles = stats_get_option('count_roles');
        if (!array_intersect($current_user->roles, $count_roles)) {
            return;
        }
    }
    add_action('wp_footer', 'stats_footer', 101);
    add_action('wp_head', 'stats_add_shutdown_action');
    $blog = Jetpack_Options::get_option('id');
    $tz = get_option('gmt_offset');
    $v = 'ext';
    $blog_url = parse_url(site_url());
    $srv = $blog_url['host'];
    $j = sprintf('%s:%s', JETPACK__API_VERSION, JETPACK__VERSION);
    if ($wp_the_query->is_single || $wp_the_query->is_page || $wp_the_query->is_posts_page) {
        // Store and reset the queried_object and queried_object_id
        // Otherwise, redirect_canonical() will redirect to home_url( '/' ) for show_on_front = page sites where home_url() is not all lowercase.
        // Repro:
        // 1. Set home_url = http://ExamPle.com/
        // 2. Set show_on_front = page
        // 3. Set page_on_front = something
        // 4. Visit http://example.com/
        $queried_object = isset($wp_the_query->queried_object) ? $wp_the_query->queried_object : null;
        $queried_object_id = isset($wp_the_query->queried_object_id) ? $wp_the_query->queried_object_id : null;
        $post = $wp_the_query->get_queried_object_id();
        $wp_the_query->queried_object = $queried_object;
        $wp_the_query->queried_object_id = $queried_object_id;
    } else {
        $post = '0';
    }
    $script = set_url_scheme('//stats.wp.com/e-' . gmdate('YW') . '.js');
    $data = stats_array(compact('v', 'j', 'blog', 'post', 'tz', 'srv'));
    $stats_footer = <<<END
<script type='text/javascript' src='{$script}' async defer></script>
<script type='text/javascript'>
\t_stq = window._stq || [];
\t_stq.push([ 'view', {{$data}} ]);
\t_stq.push([ 'clickTrackerInit', '{$blog}', '{$post}' ]);
</script>

END;
}
function stats_template_redirect()
{
    global $wp_the_query, $current_user, $stats_footer;
    if (is_feed() || is_robots() || is_trackback()) {
        return;
    }
    $options = stats_get_options();
    // Ensure this is always setup for the check below
    $options['reg_users'] = empty($options['reg_users']) ? false : true;
    if (!$options['reg_users'] && !empty($current_user->ID)) {
        return;
    }
    add_action('wp_footer', 'stats_footer', 101);
    add_action('wp_head', 'stats_add_shutdown_action');
    $blog = Jetpack::get_option('id');
    $v = 'ext';
    $j = sprintf('%s:%s', JETPACK__API_VERSION, JETPACK__VERSION);
    if ($wp_the_query->is_single || $wp_the_query->is_page || $wp_the_query->is_posts_page) {
        // Store and reset the queried_object and queried_object_id
        // Otherwise, redirect_canonical() will redirect to home_url( '/' ) for show_on_front = page sites where home_url() is not all lowercase.
        // Repro:
        // 1. Set home_url = http://ExamPle.com/
        // 2. Set show_on_front = page
        // 3. Set page_on_front = something
        // 4. Visit http://example.com/
        $queried_object = isset($wp_the_query->queried_object) ? $wp_the_query->queried_object : null;
        $queried_object_id = isset($wp_the_query->queried_object_id) ? $wp_the_query->queried_object_id : null;
        $post = $wp_the_query->get_queried_object_id();
        $wp_the_query->queried_object = $queried_object;
        $wp_the_query->queried_object_id = $queried_object_id;
    } else {
        $post = '0';
    }
    $http = is_ssl() ? 'https' : 'http';
    $week = gmdate('YW');
    $data = stats_array(compact('v', 'j', 'blog', 'post'));
    $stats_footer = <<<END

\t<script src="{$http}://stats.wordpress.com/e-{$week}.js" type="text/javascript"></script>
\t<script type="text/javascript">
\tst_go({{$data}});
\tvar load_cmc = function(){linktracker_init({$blog},{$post},2);};
\tif ( typeof addLoadEvent != 'undefined' ) addLoadEvent(load_cmc);
\telse load_cmc();
\t</script>
END;
    if (isset($options['hide_smile']) && $options['hide_smile']) {
        $stats_footer .= "\n<style type='text/css'>img#wpstats{display:none}</style>";
    }
}