-
Notifications
You must be signed in to change notification settings - Fork 3
/
googleanalytics.php
132 lines (115 loc) · 4.62 KB
/
googleanalytics.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/**
* @package GoogleAnalytics
* @subpackage Main
*/
/**
* Plugin Name: Google Analytics by MonsterInsights
* Plugin URI: https://www.monsterinsights.com/pricing/#utm_source=wordpress&utm_medium=plugin&utm_campaign=wpgaplugin&utm_content=v504
* Description: This plugin makes it simple to add Google Analytics to your WordPress site, adding lots of features, e.g. error page, search result and automatic outgoing links and download tracking.
* Author: MonsterInsights
* Version: 5.5.3
* Requires at least: 3.9
* Author URI: https://www.monsterinsights.com/
* License: GPL v3
* Text Domain: google-analytics-for-wordpress
* Domain Path: /languages
*
* Google Analytics for WordPress
* Copyright (C) 2008-2016, MonsterInsights, [email protected]
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// This plugin was originally based on Rich Boakes' Analytics plugin: http://boakes.org/analytics, but has since been rewritten and refactored multiple times.
define( 'GAWP_VERSION', '5.5.3' );
define( 'GAWP_FILE', __FILE__ );
define( 'GAWP_PATH', plugin_basename( __FILE__ ) );
define( 'GAWP_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
function monsterinsights_needs_manual_update_check(){
require_once 'includes/ecommerce-addon-license-fix.php';
}
add_action( 'plugins_loaded', 'monsterinsights_needs_manual_update_check');
function monsterinsights_lite_60_admin_notice() {
if ( ! current_user_can('manage_options' ) ) {
return;
}
if ( ! get_option( 'monsterinsights_60_beta' , false ) ) { ?>
<div class="updated notice is-dismissible">
<p><?php echo sprintf(__( 'MonsterInsights 6.0 is Coming Soon — %sCheck out the sneak peak%s — It’s going to be awesome', 'google-analytics-for-wordpress'), '<a href="https://www.monsterinsights.com/whats-coming-monsterinsights-6-0-sneak-peak/">', '</a>' ); ?></p>
</div>
<?php
update_option( 'monsterinsights_60_beta', true );
}
}
add_action( 'admin_notices', 'monsterinsights_lite_60_admin_notice' );
if ( file_exists( dirname( GAWP_FILE ) . '/vendor/autoload_52.php' ) ) {
require dirname( GAWP_FILE ) . '/vendor/autoload_52.php';
}
// Only require the needed classes
if ( is_admin() ) {
global $yoast_ga_admin;
$yoast_ga_admin = new Yoast_GA_Admin;
}
else {
global $yoast_ga_frontend;
$yoast_ga_frontend = new Yoast_GA_Frontend;
}
/* ***************************** BOOTSTRAP / HOOK INTO WP *************************** */
$spl_autoload_exists = function_exists( 'spl_autoload_register' );
$filter_input_exists = function_exists( 'filter_input' );
if ( ! $spl_autoload_exists ) {
add_action( 'admin_init', 'yoast_wpseo_self_deactivate_spl', 1 );
}
if ( ! $filter_input_exists ) {
add_action( 'admin_init', 'yoast_wpseo_self_deactivate_filter_input', 1 );
}
/**
* Throw an error if the PHP SPL extension is disabled (prevent white screens) and self-deactivate plugin
*
* @since 5.3.3
*/
function yoast_ga_self_deactivate_spl() {
if ( is_admin() ) {
yoast_ga_extenstion_notice(
esc_html__( 'The Standard PHP Library (SPL) extension seem to be unavailable. Please ask your web host to enable it.', 'google-analytics-for-wordpress' )
);
}
}
/**
* Throw an error if the filter extension is disabled (prevent white screens) and self-deactivate plugin
*
* @since 5.3.3
*/
function yoast_ga_self_deactivate_filter_input() {
if ( is_admin() ) {
yoast_ga_extenstion_notice(
esc_html__( 'The (standard) PHP filter extension seem to be unavailable. Please ask your web host to enable it.', 'google-analytics-for-wordpress' )
);
}
}
/**
* Show a notice in the admin
*
* @param string $message
*
* @since 5.3.3
*/
function yoast_ga_extenstion_notice( $message ) {
add_action( 'admin_notices', create_function( $message, 'echo \'<div class="error"><p>\' . __( \'Activation failed:\', \'google-analytics-for-wordpress\' ) . \' \' . $message . \'</p></div>\';' ) );
deactivate_plugins( plugin_basename( GAWP_FILE ) );
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
}
register_deactivation_hook( __FILE__, array( 'Yoast_GA_Admin', 'ga_deactivation_hook' ) );