PluginProbe ʕ •ᴥ•ʔ
ShareThis Dashboard for Google Analytics / 2.0.5
ShareThis Dashboard for Google Analytics v2.0.5
3.3.2 trunk 1.0.7 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.5 2.3.5 2.3.6 2.3.7 2.3.8 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.0.0 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.3.0 3.3.1
googleanalytics / class / Ga_Frontend.php
googleanalytics / class Last commit date
Ga_Admin.php 9 years ago Ga_Autoloader.php 9 years ago Ga_Frontend.php 9 years ago Ga_Helper.php 9 years ago Ga_Hook.php 9 years ago Ga_Stats.php 9 years ago Ga_View.php 9 years ago
Ga_Frontend.php
68 lines
1 <?php
2
3 class Ga_Frontend {
4
5 public static function insights_googleanalytics() {
6 if ( is_ssl() ) {
7 $url = 'https://ws.sharethis.com/button/st_insights.js';
8 } else {
9 $url = 'http://w.sharethis.com/button/st_insights.js';
10 }
11 $url = add_query_arg( array(
12
13 'publisher' => '75560ae7-5c5f-483e-936f-e426496af114',
14 'product' => 'GA'
15 ), $url );
16 wp_register_script( GA_NAME . '-sharethis', $url, null, null, false );
17 wp_enqueue_script( GA_NAME . '-sharethis' );
18 }
19
20 public static function loader_tag_googleanalytics( $tag, $handle ) {
21 if ( GA_NAME . '-sharethis' === $handle ) {
22 $tag = str_replace( '<script', '<script id=\'st_insights_js\'', $tag );
23 }
24
25 return $tag;
26 }
27
28 /**
29 * Adds frontend actions hooks.
30 */
31 public static function add_actions() {
32 if ( Ga_Helper::can_add_ga_code() ) {
33 add_action( 'wp_head', 'Ga_Frontend::googleanalytics' );
34 if ( get_option( Ga_Admin::GA_SHARETHIS_TERMS_OPTION_NAME ) && Ga_Helper::is_sharethis_included() ) {
35 add_action( 'wp_enqueue_scripts', 'Ga_Frontend::insights_googleanalytics' );
36 add_filter( 'script_loader_tag', 'Ga_Frontend::loader_tag_googleanalytics', 10, 2 );
37 }
38 }
39 }
40
41 /**
42 * Displays Google Analytics Tracking code.
43 */
44 public static function googleanalytics() {
45 $web_property_id = self::get_web_property_id();
46 if ( Ga_Helper::is_configured( $web_property_id ) ) {
47 Ga_View::load( 'ga_code', array(
48 'data' => array(
49 Ga_Admin::GA_WEB_PROPERTY_ID_OPTION_NAME => $web_property_id
50 )
51 ) );
52 }
53 }
54
55 /**
56 * Gets and returns Web Property Id.
57 *
58 * @return string Web Property Id
59 */
60 private static function get_web_property_id() {
61 $web_property_id = get_option( Ga_Admin::GA_WEB_PROPERTY_ID_OPTION_NAME );
62 if ( Ga_Helper::is_code_manually_enabled() ) {
63 $web_property_id = get_option( Ga_Admin::GA_WEB_PROPERTY_ID_MANUALLY_VALUE_OPTION_NAME );
64 }
65
66 return $web_property_id;
67 }
68 }