PluginProbe ʕ •ᴥ•ʔ
ShareThis Dashboard for Google Analytics / 3.2.0
ShareThis Dashboard for Google Analytics v3.2.0
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 / class-ga-frontend.php
googleanalytics / class Last commit date
controller 4 years ago core 4 years ago class-ga-admin.php 2 years ago class-ga-autoloader.php 4 years ago class-ga-frontend.php 3 years ago class-ga-helper.php 2 years ago class-ga-hook.php 4 years ago class-ga-notice.php 4 years ago class-ga-sharethis.php 4 years ago class-ga-stats.php 2 years ago class-ga-template.php 4 years ago
class-ga-frontend.php
78 lines
1 <?php
2 /**
3 * GoogleAnalytics Frontend.
4 *
5 * @package GoogleAnalytics
6 */
7
8 /**
9 * Frontend.
10 */
11 class Ga_Frontend {
12
13 const GA_SHARETHIS_PLATFORM_URL = '//platform-api.sharethis.com/js/sharethis.js#source=googleanalytics-wordpress';
14
15 /**
16 * Platform ShareThis.
17 *
18 * @return void
19 */
20 public static function platform_sharethis() {
21 $url = self::GA_SHARETHIS_PLATFORM_URL . '#product=ga';
22 if ( get_option( Ga_Admin::GA_SHARETHIS_PROPERTY_ID ) ) {
23 $url = $url . '&property=' . get_option( Ga_Admin::GA_SHARETHIS_PROPERTY_ID );
24 }
25
26 wp_register_script( GA_NAME . '-platform-sharethis', $url, null, null, false ); // phpcs:ignore
27 wp_enqueue_script( GA_NAME . '-platform-sharethis' );
28 }
29
30 /**
31 * Adds frontend actions hooks.
32 */
33 public static function add_actions() {
34 if ( Ga_Helper::are_features_enabled() ) {
35 add_action( 'wp_enqueue_scripts', 'Ga_Frontend::platform_sharethis' );
36 }
37 add_action( 'wp_head', 'Ga_Frontend::insert_ga_script' );
38 }
39
40 /**
41 * Insert GoogleAnalytics script.
42 *
43 * @return void
44 */
45 public static function insert_ga_script() {
46 if ( true === Ga_Helper::can_add_ga_code() || true === Ga_Helper::is_all_feature_disabled() ) {
47 $web_property_id = self::get_web_property_id();
48 $optimize = get_option( 'googleanalytics_optimize_code' );
49 $anonymization = get_option( 'googleanalytics_ip_anonymization' );
50 $debug_mode_on = 'on' === get_option( 'googleanalytics_enable_debug_mode', 'off' );
51
52 if ( Ga_Helper::should_load_ga_javascript( $web_property_id ) ) {
53 $data = array(
54 Ga_Admin::GA_WEB_PROPERTY_ID_OPTION_NAME => $web_property_id,
55 'optimize' => $optimize,
56 'anonymization' => $anonymization,
57 );
58
59 include plugin_dir_path( __FILE__ ) . '../view/ga-code.php';
60 }
61 }
62 }
63
64 /**
65 * Gets and returns Web Property Id.
66 *
67 * @return string Web Property Id
68 */
69 public static function get_web_property_id() {
70 $web_property_id = get_option( Ga_Admin::GA_WEB_PROPERTY_ID_OPTION_NAME );
71 if ( true === Ga_Helper::is_code_manually_enabled() || true === Ga_Helper::is_all_feature_disabled() ) {
72 $web_property_id = get_option( Ga_Admin::GA_WEB_PROPERTY_ID_MANUALLY_VALUE_OPTION_NAME );
73 }
74
75 return $web_property_id;
76 }
77 }
78