@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -66,39 +66,39 @@ discard block |
||
66 | 66 | // Get object |
67 | 67 | $this->base = MonsterInsights(); |
68 | 68 | $this->client = $this->base->ga; |
69 | - $this->dashboard_disabled = monsterinsights_get_option( 'dashboards_disabled', false ); |
|
70 | - $this->dashboard_report = monsterinsights_get_option( 'dashboard_report', 'overview' ); |
|
69 | + $this->dashboard_disabled = monsterinsights_get_option('dashboards_disabled', false); |
|
70 | + $this->dashboard_report = monsterinsights_get_option('dashboard_report', 'overview'); |
|
71 | 71 | |
72 | - if ( isset( $this->client->status ) && $this->client->status === 'valid' ) { |
|
72 | + if (isset($this->client->status) && $this->client->status === 'valid') { |
|
73 | 73 | // Cron actions |
74 | 74 | // Add cron if its not there |
75 | - add_action( 'wp', array( $this, 'schedule_cron' ) ); |
|
75 | + add_action('wp', array($this, 'schedule_cron')); |
|
76 | 76 | |
77 | 77 | // Collect analytics data on cron event |
78 | - add_action( 'monsterinsights_daily_cron', array( $this, 'run_cron' ) ); |
|
78 | + add_action('monsterinsights_daily_cron', array($this, 'run_cron')); |
|
79 | 79 | |
80 | 80 | // If cron did not run for some reason (no users visited site), run it now |
81 | - if ( filter_input( INPUT_GET, 'page' ) === 'monsterinsights_dashboard' || filter_input( INPUT_GET, 'page' ) === 'monsterinsights_reports' ) { |
|
82 | - add_action( 'admin_init', array( $this, 'maybe_get_data' ) ); |
|
81 | + if (filter_input(INPUT_GET, 'page') === 'monsterinsights_dashboard' || filter_input(INPUT_GET, 'page') === 'monsterinsights_reports') { |
|
82 | + add_action('admin_init', array($this, 'maybe_get_data')); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | 87 | // Dashboard disabled setting |
88 | - add_action( 'monsterinsights_settings_save_general', array( $this, 'dashboard_disabled' ), 9 ); |
|
88 | + add_action('monsterinsights_settings_save_general', array($this, 'dashboard_disabled'), 9); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | public function dashboard_disabled( ) { |
92 | - $dashboards_disabled = isset( $_POST['dashboards_disabled'] ) ? 1 : 0; |
|
93 | - $dashboards_disabled_old = monsterinsights_get_option( 'dashboards_disabled', false ); |
|
92 | + $dashboards_disabled = isset($_POST['dashboards_disabled']) ? 1 : 0; |
|
93 | + $dashboards_disabled_old = monsterinsights_get_option('dashboards_disabled', false); |
|
94 | 94 | |
95 | 95 | // We only care if the switch is going on or off |
96 | - if ( $dashboards_disabled && ! $dashboards_disabled_old ) { |
|
96 | + if ($dashboards_disabled && ! $dashboards_disabled_old) { |
|
97 | 97 | // The dashboards are now being disabled |
98 | 98 | // Clear data + last run + failed |
99 | 99 | $this->delete_aggregate_data(); |
100 | 100 | |
101 | - } else if ( ! $dashboards_disabled && $dashboards_disabled_old ){ |
|
101 | + } else if ( ! $dashboards_disabled && $dashboards_disabled_old) { |
|
102 | 102 | // The dashboards are now being enabled |
103 | 103 | // Refresh data + schedule cron |
104 | 104 | $this->refresh_aggregate_data(); |
@@ -107,38 +107,38 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | public function schedule_cron() { |
110 | - if ( ! wp_next_scheduled( 'monsterinsights_daily_cron' ) ) { |
|
110 | + if ( ! wp_next_scheduled('monsterinsights_daily_cron')) { |
|
111 | 111 | // Set the next event of fetching data |
112 | - wp_schedule_event( strtotime( date( 'Y-m-d', strtotime( 'tomorrow' ) ) . ' 00:01:00 ' ), 'daily', 'monsterinsights_daily_cron' ); |
|
112 | + wp_schedule_event(strtotime(date('Y-m-d', strtotime('tomorrow')) . ' 00:01:00 '), 'daily', 'monsterinsights_daily_cron'); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | 116 | public function maybe_get_data() { |
117 | - if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
117 | + if ( ! current_user_can('monsterinsights_view_dashboard')) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | - $last_run = monsterinsights_get_option( 'cron_last_run', false ); |
|
121 | + $last_run = monsterinsights_get_option('cron_last_run', false); |
|
122 | 122 | |
123 | 123 | // See if issue connecting or expired |
124 | - if ( $last_run === false || monsterinsights_hours_between( $last_run ) >= 24 || date( 'Ymd', $last_run ) !== date('Ymd', time() ) ) { |
|
124 | + if ($last_run === false || monsterinsights_hours_between($last_run) >= 24 || date('Ymd', $last_run) !== date('Ymd', time())) { |
|
125 | 125 | $this->run_cron(); |
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | 129 | public function run_cron() { |
130 | - if ( $this->dashboard_disabled ) { |
|
130 | + if ($this->dashboard_disabled) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
134 | - if ( is_numeric( (int) $this->client->profile ) && $this->client->status === 'valid' ) { |
|
134 | + if (is_numeric((int) $this->client->profile) && $this->client->status === 'valid') { |
|
135 | 135 | // Profile is set |
136 | 136 | $this->add_aggregate_data(); |
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | 140 | public function refresh_aggregate_data() { |
141 | - if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
141 | + if ( ! current_user_can('monsterinsights_view_dashboard')) { |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | private function add_aggregate_data() { |
150 | - if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
150 | + if ( ! current_user_can('monsterinsights_view_dashboard')) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | /** |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | * not be used by other developers. This hook's behavior may be modified |
158 | 158 | * or the hook may be removed at any time, without warning. |
159 | 159 | */ |
160 | - do_action( 'monsterinsights_add_aggregate_data', $this->client, $this->client->profile ); |
|
161 | - monsterinsights_update_option( 'cron_last_run', time() ); |
|
162 | - monsterinsights_delete_option( 'cron_failed' ); |
|
160 | + do_action('monsterinsights_add_aggregate_data', $this->client, $this->client->profile); |
|
161 | + monsterinsights_update_option('cron_last_run', time()); |
|
162 | + monsterinsights_delete_option('cron_failed'); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | public function delete_aggregate_data() { |
166 | - if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
166 | + if ( ! current_user_can('monsterinsights_view_dashboard')) { |
|
167 | 167 | return false; |
168 | 168 | } |
169 | 169 | /** |
@@ -173,13 +173,13 @@ discard block |
||
173 | 173 | * not be used by other developers. This hook's behavior may be modified |
174 | 174 | * or the hook may be removed at any time, without warning. |
175 | 175 | */ |
176 | - if ( ! empty( $this->client ) && ! empty( $this->client->profile ) ) { |
|
177 | - do_action( 'monsterinsights_delete_aggregate_data', $this->client, $this->client->profile ); |
|
176 | + if ( ! empty($this->client) && ! empty($this->client->profile)) { |
|
177 | + do_action('monsterinsights_delete_aggregate_data', $this->client, $this->client->profile); |
|
178 | 178 | } |
179 | 179 | $options = array( |
180 | 180 | 'cron_failed', |
181 | 181 | 'cron_last_run', |
182 | 182 | ); |
183 | - monsterinsights_delete_options( $options ); |
|
183 | + monsterinsights_delete_options($options); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | \ No newline at end of file |
@@ -14,172 +14,172 @@ |
||
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | 16 | if ( ! defined( 'ABSPATH' ) ) { |
17 | - exit; |
|
17 | + exit; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | final class MonsterInsights_Reporting { |
21 | 21 | |
22 | - /** |
|
23 | - * Holds the base object. |
|
24 | - * |
|
25 | - * @access public |
|
26 | - * @since 6.0.0 |
|
27 | - * @var MonsterInsights $base MonsterInsights Base object. |
|
28 | - */ |
|
29 | - public $base; |
|
30 | - |
|
31 | - /** |
|
32 | - * Holds the GA client object if using oAuth. |
|
33 | - * |
|
34 | - * @access public |
|
35 | - * @since 6.0.0 |
|
36 | - * @var MonsterInsights_GA_Client $client GA client object. |
|
37 | - */ |
|
38 | - public $client; |
|
39 | - |
|
40 | - /** |
|
41 | - * Is the dashboard/reporting pages disabled? |
|
42 | - * |
|
43 | - * @access public |
|
44 | - * @since 6.0.0 |
|
45 | - * @var bool $dashboard_disabled If the dashboard is disabled. |
|
46 | - */ |
|
47 | - public $dashboard_disabled; |
|
48 | - |
|
49 | - /** |
|
50 | - * Dashboard report |
|
51 | - * |
|
52 | - * @access public |
|
53 | - * @since 6.0.0 |
|
54 | - * @var string $dashboard_report Report hook name of dashboard report. |
|
55 | - */ |
|
56 | - public $dashboard_report; |
|
57 | - |
|
58 | - /** |
|
59 | - * Primary class constructor. |
|
60 | - * |
|
61 | - * @access public |
|
62 | - * @since 6.0.0 |
|
63 | - */ |
|
64 | - public function __construct( ) { |
|
65 | - |
|
66 | - // Get object |
|
67 | - $this->base = MonsterInsights(); |
|
68 | - $this->client = $this->base->ga; |
|
69 | - $this->dashboard_disabled = monsterinsights_get_option( 'dashboards_disabled', false ); |
|
70 | - $this->dashboard_report = monsterinsights_get_option( 'dashboard_report', 'overview' ); |
|
71 | - |
|
72 | - if ( isset( $this->client->status ) && $this->client->status === 'valid' ) { |
|
73 | - // Cron actions |
|
74 | - // Add cron if its not there |
|
75 | - add_action( 'wp', array( $this, 'schedule_cron' ) ); |
|
22 | + /** |
|
23 | + * Holds the base object. |
|
24 | + * |
|
25 | + * @access public |
|
26 | + * @since 6.0.0 |
|
27 | + * @var MonsterInsights $base MonsterInsights Base object. |
|
28 | + */ |
|
29 | + public $base; |
|
30 | + |
|
31 | + /** |
|
32 | + * Holds the GA client object if using oAuth. |
|
33 | + * |
|
34 | + * @access public |
|
35 | + * @since 6.0.0 |
|
36 | + * @var MonsterInsights_GA_Client $client GA client object. |
|
37 | + */ |
|
38 | + public $client; |
|
39 | + |
|
40 | + /** |
|
41 | + * Is the dashboard/reporting pages disabled? |
|
42 | + * |
|
43 | + * @access public |
|
44 | + * @since 6.0.0 |
|
45 | + * @var bool $dashboard_disabled If the dashboard is disabled. |
|
46 | + */ |
|
47 | + public $dashboard_disabled; |
|
48 | + |
|
49 | + /** |
|
50 | + * Dashboard report |
|
51 | + * |
|
52 | + * @access public |
|
53 | + * @since 6.0.0 |
|
54 | + * @var string $dashboard_report Report hook name of dashboard report. |
|
55 | + */ |
|
56 | + public $dashboard_report; |
|
57 | + |
|
58 | + /** |
|
59 | + * Primary class constructor. |
|
60 | + * |
|
61 | + * @access public |
|
62 | + * @since 6.0.0 |
|
63 | + */ |
|
64 | + public function __construct( ) { |
|
65 | + |
|
66 | + // Get object |
|
67 | + $this->base = MonsterInsights(); |
|
68 | + $this->client = $this->base->ga; |
|
69 | + $this->dashboard_disabled = monsterinsights_get_option( 'dashboards_disabled', false ); |
|
70 | + $this->dashboard_report = monsterinsights_get_option( 'dashboard_report', 'overview' ); |
|
71 | + |
|
72 | + if ( isset( $this->client->status ) && $this->client->status === 'valid' ) { |
|
73 | + // Cron actions |
|
74 | + // Add cron if its not there |
|
75 | + add_action( 'wp', array( $this, 'schedule_cron' ) ); |
|
76 | 76 | |
77 | - // Collect analytics data on cron event |
|
78 | - add_action( 'monsterinsights_daily_cron', array( $this, 'run_cron' ) ); |
|
79 | - |
|
80 | - // If cron did not run for some reason (no users visited site), run it now |
|
81 | - if ( filter_input( INPUT_GET, 'page' ) === 'monsterinsights_dashboard' || filter_input( INPUT_GET, 'page' ) === 'monsterinsights_reports' ) { |
|
82 | - add_action( 'admin_init', array( $this, 'maybe_get_data' ) ); |
|
83 | - } |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - // Dashboard disabled setting |
|
88 | - add_action( 'monsterinsights_settings_save_general', array( $this, 'dashboard_disabled' ), 9 ); |
|
89 | - } |
|
90 | - |
|
91 | - public function dashboard_disabled( ) { |
|
92 | - $dashboards_disabled = isset( $_POST['dashboards_disabled'] ) ? 1 : 0; |
|
93 | - $dashboards_disabled_old = monsterinsights_get_option( 'dashboards_disabled', false ); |
|
94 | - |
|
95 | - // We only care if the switch is going on or off |
|
96 | - if ( $dashboards_disabled && ! $dashboards_disabled_old ) { |
|
97 | - // The dashboards are now being disabled |
|
98 | - // Clear data + last run + failed |
|
99 | - $this->delete_aggregate_data(); |
|
100 | - |
|
101 | - } else if ( ! $dashboards_disabled && $dashboards_disabled_old ){ |
|
102 | - // The dashboards are now being enabled |
|
103 | - // Refresh data + schedule cron |
|
104 | - $this->refresh_aggregate_data(); |
|
105 | - $this->schedule_cron(); |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - public function schedule_cron() { |
|
110 | - if ( ! wp_next_scheduled( 'monsterinsights_daily_cron' ) ) { |
|
111 | - // Set the next event of fetching data |
|
112 | - wp_schedule_event( strtotime( date( 'Y-m-d', strtotime( 'tomorrow' ) ) . ' 00:01:00 ' ), 'daily', 'monsterinsights_daily_cron' ); |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - public function maybe_get_data() { |
|
117 | - if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
118 | - return false; |
|
119 | - } |
|
120 | - |
|
121 | - $last_run = monsterinsights_get_option( 'cron_last_run', false ); |
|
122 | - |
|
123 | - // See if issue connecting or expired |
|
124 | - if ( $last_run === false || monsterinsights_hours_between( $last_run ) >= 24 || date( 'Ymd', $last_run ) !== date('Ymd', time() ) ) { |
|
125 | - $this->run_cron(); |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - public function run_cron() { |
|
130 | - if ( $this->dashboard_disabled ) { |
|
131 | - return; |
|
132 | - } |
|
133 | - |
|
134 | - if ( is_numeric( (int) $this->client->profile ) && $this->client->status === 'valid' ) { |
|
135 | - // Profile is set |
|
136 | - $this->add_aggregate_data(); |
|
137 | - } |
|
138 | - } |
|
139 | - |
|
140 | - public function refresh_aggregate_data() { |
|
141 | - if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
142 | - return false; |
|
143 | - } |
|
144 | - |
|
145 | - $this->delete_aggregate_data(); |
|
146 | - $this->add_aggregate_data(); |
|
147 | - } |
|
148 | - |
|
149 | - private function add_aggregate_data() { |
|
150 | - if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
151 | - return false; |
|
152 | - } |
|
153 | - /** |
|
154 | - * Developer Alert: |
|
155 | - * |
|
156 | - * Per the README, this is considered an internal hook and should |
|
157 | - * not be used by other developers. This hook's behavior may be modified |
|
158 | - * or the hook may be removed at any time, without warning. |
|
159 | - */ |
|
160 | - do_action( 'monsterinsights_add_aggregate_data', $this->client, $this->client->profile ); |
|
161 | - monsterinsights_update_option( 'cron_last_run', time() ); |
|
162 | - monsterinsights_delete_option( 'cron_failed' ); |
|
163 | - } |
|
164 | - |
|
165 | - public function delete_aggregate_data() { |
|
166 | - if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
167 | - return false; |
|
168 | - } |
|
169 | - /** |
|
170 | - * Developer Alert: |
|
171 | - * |
|
172 | - * Per the README, this is considered an internal hook and should |
|
173 | - * not be used by other developers. This hook's behavior may be modified |
|
174 | - * or the hook may be removed at any time, without warning. |
|
175 | - */ |
|
176 | - if ( ! empty( $this->client ) && ! empty( $this->client->profile ) ) { |
|
177 | - do_action( 'monsterinsights_delete_aggregate_data', $this->client, $this->client->profile ); |
|
178 | - } |
|
179 | - $options = array( |
|
180 | - 'cron_failed', |
|
181 | - 'cron_last_run', |
|
182 | - ); |
|
183 | - monsterinsights_delete_options( $options ); |
|
184 | - } |
|
77 | + // Collect analytics data on cron event |
|
78 | + add_action( 'monsterinsights_daily_cron', array( $this, 'run_cron' ) ); |
|
79 | + |
|
80 | + // If cron did not run for some reason (no users visited site), run it now |
|
81 | + if ( filter_input( INPUT_GET, 'page' ) === 'monsterinsights_dashboard' || filter_input( INPUT_GET, 'page' ) === 'monsterinsights_reports' ) { |
|
82 | + add_action( 'admin_init', array( $this, 'maybe_get_data' ) ); |
|
83 | + } |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + // Dashboard disabled setting |
|
88 | + add_action( 'monsterinsights_settings_save_general', array( $this, 'dashboard_disabled' ), 9 ); |
|
89 | + } |
|
90 | + |
|
91 | + public function dashboard_disabled( ) { |
|
92 | + $dashboards_disabled = isset( $_POST['dashboards_disabled'] ) ? 1 : 0; |
|
93 | + $dashboards_disabled_old = monsterinsights_get_option( 'dashboards_disabled', false ); |
|
94 | + |
|
95 | + // We only care if the switch is going on or off |
|
96 | + if ( $dashboards_disabled && ! $dashboards_disabled_old ) { |
|
97 | + // The dashboards are now being disabled |
|
98 | + // Clear data + last run + failed |
|
99 | + $this->delete_aggregate_data(); |
|
100 | + |
|
101 | + } else if ( ! $dashboards_disabled && $dashboards_disabled_old ){ |
|
102 | + // The dashboards are now being enabled |
|
103 | + // Refresh data + schedule cron |
|
104 | + $this->refresh_aggregate_data(); |
|
105 | + $this->schedule_cron(); |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + public function schedule_cron() { |
|
110 | + if ( ! wp_next_scheduled( 'monsterinsights_daily_cron' ) ) { |
|
111 | + // Set the next event of fetching data |
|
112 | + wp_schedule_event( strtotime( date( 'Y-m-d', strtotime( 'tomorrow' ) ) . ' 00:01:00 ' ), 'daily', 'monsterinsights_daily_cron' ); |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + public function maybe_get_data() { |
|
117 | + if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
118 | + return false; |
|
119 | + } |
|
120 | + |
|
121 | + $last_run = monsterinsights_get_option( 'cron_last_run', false ); |
|
122 | + |
|
123 | + // See if issue connecting or expired |
|
124 | + if ( $last_run === false || monsterinsights_hours_between( $last_run ) >= 24 || date( 'Ymd', $last_run ) !== date('Ymd', time() ) ) { |
|
125 | + $this->run_cron(); |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + public function run_cron() { |
|
130 | + if ( $this->dashboard_disabled ) { |
|
131 | + return; |
|
132 | + } |
|
133 | + |
|
134 | + if ( is_numeric( (int) $this->client->profile ) && $this->client->status === 'valid' ) { |
|
135 | + // Profile is set |
|
136 | + $this->add_aggregate_data(); |
|
137 | + } |
|
138 | + } |
|
139 | + |
|
140 | + public function refresh_aggregate_data() { |
|
141 | + if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
142 | + return false; |
|
143 | + } |
|
144 | + |
|
145 | + $this->delete_aggregate_data(); |
|
146 | + $this->add_aggregate_data(); |
|
147 | + } |
|
148 | + |
|
149 | + private function add_aggregate_data() { |
|
150 | + if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
151 | + return false; |
|
152 | + } |
|
153 | + /** |
|
154 | + * Developer Alert: |
|
155 | + * |
|
156 | + * Per the README, this is considered an internal hook and should |
|
157 | + * not be used by other developers. This hook's behavior may be modified |
|
158 | + * or the hook may be removed at any time, without warning. |
|
159 | + */ |
|
160 | + do_action( 'monsterinsights_add_aggregate_data', $this->client, $this->client->profile ); |
|
161 | + monsterinsights_update_option( 'cron_last_run', time() ); |
|
162 | + monsterinsights_delete_option( 'cron_failed' ); |
|
163 | + } |
|
164 | + |
|
165 | + public function delete_aggregate_data() { |
|
166 | + if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
167 | + return false; |
|
168 | + } |
|
169 | + /** |
|
170 | + * Developer Alert: |
|
171 | + * |
|
172 | + * Per the README, this is considered an internal hook and should |
|
173 | + * not be used by other developers. This hook's behavior may be modified |
|
174 | + * or the hook may be removed at any time, without warning. |
|
175 | + */ |
|
176 | + if ( ! empty( $this->client ) && ! empty( $this->client->profile ) ) { |
|
177 | + do_action( 'monsterinsights_delete_aggregate_data', $this->client, $this->client->profile ); |
|
178 | + } |
|
179 | + $options = array( |
|
180 | + 'cron_failed', |
|
181 | + 'cron_last_run', |
|
182 | + ); |
|
183 | + monsterinsights_delete_options( $options ); |
|
184 | + } |
|
185 | 185 | } |
186 | 186 | \ No newline at end of file |
@@ -10,47 +10,47 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | -function monsterinsights_google_auth_start_view( $reauth = false ) { |
|
18 | - $class = ( $reauth ) ? 'monsterinsights_google_auth_reauth_start_view' : 'monsterinsights_google_auth_start_view' ; |
|
17 | +function monsterinsights_google_auth_start_view($reauth = false) { |
|
18 | + $class = ($reauth) ? 'monsterinsights_google_auth_reauth_start_view' : 'monsterinsights_google_auth_start_view'; |
|
19 | 19 | ob_start(); |
20 | 20 | ?> |
21 | 21 | <div class="<?php echo $class; ?>"> |
22 | - <?php if ( $reauth ) { ?> |
|
22 | + <?php if ($reauth) { ?> |
|
23 | 23 | <div id="monsterinsights_google_auth_box_header"> |
24 | 24 | <div class="monsterinsights_google_auth_box_header_reauth"> |
25 | - <?php esc_html_e( 'This process will replace your current Google Analytics connection.', 'google-analytics-for-wordpress' ); ?> |
|
26 | - <a href="" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e( 'Cancel', 'google-analytics-for-wordpress' ); ?>" > |
|
27 | - <?php esc_html_e( 'Cancel', 'google-analytics-for-wordpress' ); ?> |
|
25 | + <?php esc_html_e('This process will replace your current Google Analytics connection.', 'google-analytics-for-wordpress'); ?> |
|
26 | + <a href="" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e('Cancel', 'google-analytics-for-wordpress'); ?>" > |
|
27 | + <?php esc_html_e('Cancel', 'google-analytics-for-wordpress'); ?> |
|
28 | 28 | </a> |
29 | 29 | </div> |
30 | 30 | </div> |
31 | 31 | <?php } ?> |
32 | - <div id="monsterinsights_google_auth_box_contents" <?php if ( $reauth ) { echo 'class="monsterinsights_google_auth_reauth"'; } ?> > |
|
33 | - <?php if ( $reauth ) { ?> |
|
34 | - <div class="monsterinsights_google_auth_view_title monsterinsights_google_auth_start_view_title"><?php esc_html_e( 'RE-AUTHENTICATE', 'google-analytics-for-wordpress' ); ?> </div> |
|
35 | - <div class="monsterinsights_google_auth_view_description monsterinsights_google_auth_start_view_description"><?php esc_html_e( 'Re-authenticate your Google Analytics account with MonsterInsights', 'google-analytics-for-wordpress' ); ?> </div> |
|
32 | + <div id="monsterinsights_google_auth_box_contents" <?php if ($reauth) { echo 'class="monsterinsights_google_auth_reauth"'; } ?> > |
|
33 | + <?php if ($reauth) { ?> |
|
34 | + <div class="monsterinsights_google_auth_view_title monsterinsights_google_auth_start_view_title"><?php esc_html_e('RE-AUTHENTICATE', 'google-analytics-for-wordpress'); ?> </div> |
|
35 | + <div class="monsterinsights_google_auth_view_description monsterinsights_google_auth_start_view_description"><?php esc_html_e('Re-authenticate your Google Analytics account with MonsterInsights', 'google-analytics-for-wordpress'); ?> </div> |
|
36 | 36 | <?php } else { ?> |
37 | - <div class="monsterinsights_google_auth_view_title monsterinsights_google_auth_view_title monsterinsights_google_auth_start_view_title"><?php esc_html_e( 'AUTHENTICATION', 'google-analytics-for-wordpress' ); ?> </div> |
|
38 | - <div class="monsterinsights_google_auth_view_description monsterinsights_google_auth_start_view_description"><?php esc_html_e( 'Authenticate your Google Analytics account with MonsterInsights', 'google-analytics-for-wordpress' ); ?> </div> |
|
37 | + <div class="monsterinsights_google_auth_view_title monsterinsights_google_auth_view_title monsterinsights_google_auth_start_view_title"><?php esc_html_e('AUTHENTICATION', 'google-analytics-for-wordpress'); ?> </div> |
|
38 | + <div class="monsterinsights_google_auth_view_description monsterinsights_google_auth_start_view_description"><?php esc_html_e('Authenticate your Google Analytics account with MonsterInsights', 'google-analytics-for-wordpress'); ?> </div> |
|
39 | 39 | <?php } ?> |
40 | - <input type="hidden" id="monsterinsightsreauth" name="monsterinsightsreauth" value="<?php echo ( $reauth ) ? 'true' : 'false';?>"> |
|
41 | - <input type="hidden" id="monsterinsightsview" name="monsterinsightsview" value="<?php echo 'start';?>"> |
|
40 | + <input type="hidden" id="monsterinsightsreauth" name="monsterinsightsreauth" value="<?php echo ($reauth) ? 'true' : 'false'; ?>"> |
|
41 | + <input type="hidden" id="monsterinsightsview" name="monsterinsightsview" value="<?php echo 'start'; ?>"> |
|
42 | 42 | </div> |
43 | 43 | <div id="monsterinsights_google_auth_box_footer"> |
44 | 44 | <div id="monsterinsights_google_auth_box_footer_left"> |
45 | - <a href="#" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e( 'Cancel', 'google-analytics-for-wordpress' ); ?>" > <?php esc_html_e( 'CANCEL', 'google-analytics-for-wordpress' ); ?></a> |
|
45 | + <a href="#" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e('Cancel', 'google-analytics-for-wordpress'); ?>" > <?php esc_html_e('CANCEL', 'google-analytics-for-wordpress'); ?></a> |
|
46 | 46 | </div> |
47 | 47 | <div id="monsterinsights_google_auth_box_footer_center"> |
48 | 48 | |
49 | 49 | </div> |
50 | 50 | <div id="monsterinsights_google_auth_box_footer_right"> |
51 | - <a href="#" id="monsterinsights_google_auth_box_next" class="monsterinsights_google_auth_box_next" title="<?php esc_attr_e( 'Next', 'google-analytics-for-wordpress' ); ?>" > |
|
51 | + <a href="#" id="monsterinsights_google_auth_box_next" class="monsterinsights_google_auth_box_next" title="<?php esc_attr_e('Next', 'google-analytics-for-wordpress'); ?>" > |
|
52 | 52 | <div id="monsterinsights_google_auth_box_footer_right_next"> |
53 | - <?php esc_html_e( 'NEXT', 'google-analytics-for-wordpress' ); ?> |
|
53 | + <?php esc_html_e('NEXT', 'google-analytics-for-wordpress'); ?> |
|
54 | 54 | </div> |
55 | 55 | </a> |
56 | 56 | </div> |
@@ -61,44 +61,44 @@ discard block |
||
61 | 61 | ob_end_clean(); |
62 | 62 | return $contents; |
63 | 63 | } |
64 | -function monsterinsights_google_auth_enterkey_view( $reauth = false, $auth_url = '', $error = '' ) { |
|
65 | - $class = ( $reauth ) ? 'monsterinsights_google_auth_reauth_enterkey_view' : 'monsterinsights_google_auth_enterkey_view' ; |
|
66 | - $auth_url = esc_js( esc_url( $auth_url ) ); |
|
64 | +function monsterinsights_google_auth_enterkey_view($reauth = false, $auth_url = '', $error = '') { |
|
65 | + $class = ($reauth) ? 'monsterinsights_google_auth_reauth_enterkey_view' : 'monsterinsights_google_auth_enterkey_view'; |
|
66 | + $auth_url = esc_js(esc_url($auth_url)); |
|
67 | 67 | ob_start(); |
68 | 68 | ?> |
69 | 69 | <div class="<?php echo $class; ?>"> |
70 | - <?php if ( $reauth ) { ?> |
|
70 | + <?php if ($reauth) { ?> |
|
71 | 71 | <div id="monsterinsights_google_auth_box_header"> |
72 | 72 | <div class="monsterinsights_google_auth_box_header_reauth"> |
73 | - <?php esc_html_e( 'This process will replace your current Google Analytics connection.', 'google-analytics-for-wordpress' ); ?> |
|
74 | - <a href="" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e( 'Cancel', 'google-analytics-for-wordpress' ); ?>" > |
|
75 | - <?php esc_html_e( 'Cancel', 'google-analytics-for-wordpress' ); ?> |
|
73 | + <?php esc_html_e('This process will replace your current Google Analytics connection.', 'google-analytics-for-wordpress'); ?> |
|
74 | + <a href="" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e('Cancel', 'google-analytics-for-wordpress'); ?>" > |
|
75 | + <?php esc_html_e('Cancel', 'google-analytics-for-wordpress'); ?> |
|
76 | 76 | </a> |
77 | 77 | </div> |
78 | 78 | </div> |
79 | 79 | <?php } ?> |
80 | - <div id="monsterinsights_google_auth_box_contents" <?php if ( $reauth ) { echo 'class="monsterinsights_google_auth_reauth"'; } ?> > |
|
81 | - <div class="monsterinsights_google_auth_view_title monsterinsights_google_auth_enterkey_view_title"><?php esc_html_e( 'ENTER GOOGLE CODE', 'google-analytics-for-wordpress' ); ?> </div> |
|
82 | - <a id="monsterinsights-google-oauth-window" class="button" onclick="monsterinsights_popupwindow('<?php echo esc_js( esc_attr( esc_url( $auth_url ) ) ); ?>',500,500);"><?php esc_html_e( 'Click To Get Google Code', 'google-analytics-for-wordpress' ); ?> </a> |
|
83 | - <label for="monsterinsights_step_data" class="monsterinsights_google_auth_step_data_label_enterkey_view"><?php esc_html_e( 'Copy the Google code into the box below and click next', 'google-analytics-for-wordpress' ); ?> </label> |
|
84 | - <input type="text" id="monsterinsights_step_data" class="monsterinsights_google_auth_step_data_enterkey_view" name="monsterinsights_step_data" placeholder="<?php esc_html_e( 'Paste Google Code here', 'google-analytics-for-wordpress'); ?>"> |
|
85 | - <input type="hidden" id="monsterinsightsreauth" name="monsterinsightsreauth" value="<?php echo ($reauth) ? 'true' : 'false';?>"> |
|
86 | - <input type="hidden" id="monsterinsightsview" name="monsterinsightsview" value="<?php echo 'enterkey';?>"> |
|
87 | - <?php if ( ! empty( $error ) ) { ?> |
|
88 | - <div class="monsterinsights_google_auth_enterkey_error notice notice-warning" style="margin:0px;padding:0px;"><p><?php esc_html_e( $error ); ?><p></div> |
|
80 | + <div id="monsterinsights_google_auth_box_contents" <?php if ($reauth) { echo 'class="monsterinsights_google_auth_reauth"'; } ?> > |
|
81 | + <div class="monsterinsights_google_auth_view_title monsterinsights_google_auth_enterkey_view_title"><?php esc_html_e('ENTER GOOGLE CODE', 'google-analytics-for-wordpress'); ?> </div> |
|
82 | + <a id="monsterinsights-google-oauth-window" class="button" onclick="monsterinsights_popupwindow('<?php echo esc_js(esc_attr(esc_url($auth_url))); ?>',500,500);"><?php esc_html_e('Click To Get Google Code', 'google-analytics-for-wordpress'); ?> </a> |
|
83 | + <label for="monsterinsights_step_data" class="monsterinsights_google_auth_step_data_label_enterkey_view"><?php esc_html_e('Copy the Google code into the box below and click next', 'google-analytics-for-wordpress'); ?> </label> |
|
84 | + <input type="text" id="monsterinsights_step_data" class="monsterinsights_google_auth_step_data_enterkey_view" name="monsterinsights_step_data" placeholder="<?php esc_html_e('Paste Google Code here', 'google-analytics-for-wordpress'); ?>"> |
|
85 | + <input type="hidden" id="monsterinsightsreauth" name="monsterinsightsreauth" value="<?php echo ($reauth) ? 'true' : 'false'; ?>"> |
|
86 | + <input type="hidden" id="monsterinsightsview" name="monsterinsightsview" value="<?php echo 'enterkey'; ?>"> |
|
87 | + <?php if ( ! empty($error)) { ?> |
|
88 | + <div class="monsterinsights_google_auth_enterkey_error notice notice-warning" style="margin:0px;padding:0px;"><p><?php esc_html_e($error); ?><p></div> |
|
89 | 89 | <?php } ?> |
90 | 90 | </div> |
91 | 91 | <div id="monsterinsights_google_auth_box_footer"> |
92 | 92 | <div id="monsterinsights_google_auth_box_footer_left"> |
93 | - <a href="#" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e( 'Cancel', 'google-analytics-for-wordpress' ); ?>" > <?php esc_html_e( 'CANCEL', 'google-analytics-for-wordpress' ); ?></a> |
|
93 | + <a href="#" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e('Cancel', 'google-analytics-for-wordpress'); ?>" > <?php esc_html_e('CANCEL', 'google-analytics-for-wordpress'); ?></a> |
|
94 | 94 | </div> |
95 | 95 | <div id="monsterinsights_google_auth_box_footer_center"> |
96 | 96 | |
97 | 97 | </div> |
98 | 98 | <div id="monsterinsights_google_auth_box_footer_right"> |
99 | - <a href="#" id="monsterinsights_google_auth_box_next" class="monsterinsights_google_auth_box_next" title="<?php esc_attr_e( 'Next', 'google-analytics-for-wordpress' ); ?>" > |
|
99 | + <a href="#" id="monsterinsights_google_auth_box_next" class="monsterinsights_google_auth_box_next" title="<?php esc_attr_e('Next', 'google-analytics-for-wordpress'); ?>" > |
|
100 | 100 | <div id="monsterinsights_google_auth_box_footer_right_next"> |
101 | - <?php esc_html_e( 'NEXT', 'google-analytics-for-wordpress' ); ?> |
|
101 | + <?php esc_html_e('NEXT', 'google-analytics-for-wordpress'); ?> |
|
102 | 102 | </div> |
103 | 103 | </a> |
104 | 104 | </div> |
@@ -109,43 +109,43 @@ discard block |
||
109 | 109 | ob_end_clean(); |
110 | 110 | return $contents; |
111 | 111 | } |
112 | -function monsterinsights_google_auth_selectprofile_view( $reauth = false, $selectprofile = '', $error = '' ) { |
|
113 | - $class = ( $reauth ) ? 'monsterinsights_google_auth_reauth_selectprofile_view' : 'monsterinsights_google_auth_selectprofile_view' ; |
|
112 | +function monsterinsights_google_auth_selectprofile_view($reauth = false, $selectprofile = '', $error = '') { |
|
113 | + $class = ($reauth) ? 'monsterinsights_google_auth_reauth_selectprofile_view' : 'monsterinsights_google_auth_selectprofile_view'; |
|
114 | 114 | ob_start(); |
115 | 115 | ?> |
116 | 116 | <div class="<?php echo $class; ?>"> |
117 | - <?php if ( $reauth ) { ?> |
|
117 | + <?php if ($reauth) { ?> |
|
118 | 118 | <div id="monsterinsights_google_auth_box_header"> |
119 | 119 | <div class="monsterinsights_google_auth_box_header_reauth"> |
120 | - <?php esc_html_e( 'This process will replace your current Google Analytics connection.', 'google-analytics-for-wordpress' ); ?> |
|
121 | - <a href="" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e( 'Cancel', 'google-analytics-for-wordpress' ); ?>" > |
|
122 | - <?php esc_html_e( 'Cancel', 'google-analytics-for-wordpress' ); ?> |
|
120 | + <?php esc_html_e('This process will replace your current Google Analytics connection.', 'google-analytics-for-wordpress'); ?> |
|
121 | + <a href="" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e('Cancel', 'google-analytics-for-wordpress'); ?>" > |
|
122 | + <?php esc_html_e('Cancel', 'google-analytics-for-wordpress'); ?> |
|
123 | 123 | </a> |
124 | 124 | </div> |
125 | 125 | </div> |
126 | 126 | <?php } ?> |
127 | - <div id="monsterinsights_google_auth_box_contents" <?php if ( $reauth ) { echo 'class="monsterinsights_google_auth_reauth"'; } ?> > |
|
127 | + <div id="monsterinsights_google_auth_box_contents" <?php if ($reauth) { echo 'class="monsterinsights_google_auth_reauth"'; } ?> > |
|
128 | 128 | |
129 | - <div class="monsterinsights_google_auth_view_title monsterinsights_google_auth_start_view_title"><?php esc_html_e( 'SELECT PROFILE', 'google-analytics-for-wordpress' ); ?> </div> |
|
130 | - <div class="monsterinsights_google_auth_view_description monsterinsights_google_auth_start_view_description"><?php esc_html_e( 'Select the Google Analytics Profile to Use', 'google-analytics-for-wordpress' ); ?> </div> |
|
129 | + <div class="monsterinsights_google_auth_view_title monsterinsights_google_auth_start_view_title"><?php esc_html_e('SELECT PROFILE', 'google-analytics-for-wordpress'); ?> </div> |
|
130 | + <div class="monsterinsights_google_auth_view_description monsterinsights_google_auth_start_view_description"><?php esc_html_e('Select the Google Analytics Profile to Use', 'google-analytics-for-wordpress'); ?> </div> |
|
131 | 131 | <?php echo $selectprofile; ?> |
132 | - <input type="hidden" id="monsterinsightsreauth" name="monsterinsightsreauth" value="<?php echo ( $reauth) ? 'true' : 'false';?>"> |
|
133 | - <input type="hidden" id="monsterinsightsview" name="monsterinsightsview" value="<?php echo 'selectprofile';?>"> |
|
134 | - <?php if ( ! empty( $error ) ) { ?> |
|
135 | - <div class="monsterinsights_google_auth_selectprofile_error notice notice-warning" style="margin:0px;padding:0px;"><p><?php esc_html_e( $error ); ?><p></div> |
|
132 | + <input type="hidden" id="monsterinsightsreauth" name="monsterinsightsreauth" value="<?php echo ($reauth) ? 'true' : 'false'; ?>"> |
|
133 | + <input type="hidden" id="monsterinsightsview" name="monsterinsightsview" value="<?php echo 'selectprofile'; ?>"> |
|
134 | + <?php if ( ! empty($error)) { ?> |
|
135 | + <div class="monsterinsights_google_auth_selectprofile_error notice notice-warning" style="margin:0px;padding:0px;"><p><?php esc_html_e($error); ?><p></div> |
|
136 | 136 | <?php } ?> |
137 | 137 | </div> |
138 | 138 | <div id="monsterinsights_google_auth_box_footer"> |
139 | 139 | <div id="monsterinsights_google_auth_box_footer_left"> |
140 | - <a href="#" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e( 'Cancel', 'google-analytics-for-wordpress' ); ?>" > <?php esc_html_e( 'CANCEL', 'google-analytics-for-wordpress' ); ?></a> |
|
140 | + <a href="#" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e('Cancel', 'google-analytics-for-wordpress'); ?>" > <?php esc_html_e('CANCEL', 'google-analytics-for-wordpress'); ?></a> |
|
141 | 141 | </div> |
142 | 142 | <div id="monsterinsights_google_auth_box_footer_center"> |
143 | 143 | |
144 | 144 | </div> |
145 | 145 | <div id="monsterinsights_google_auth_box_footer_right"> |
146 | - <a href="#" id="monsterinsights_google_auth_box_next" class="monsterinsights_google_auth_box_next" title="<?php esc_attr_e( 'Next', 'google-analytics-for-wordpress' ); ?>" > |
|
146 | + <a href="#" id="monsterinsights_google_auth_box_next" class="monsterinsights_google_auth_box_next" title="<?php esc_attr_e('Next', 'google-analytics-for-wordpress'); ?>" > |
|
147 | 147 | <div id="monsterinsights_google_auth_box_footer_right_next"> |
148 | - <?php esc_html_e( 'NEXT', 'google-analytics-for-wordpress' ); ?> |
|
148 | + <?php esc_html_e('NEXT', 'google-analytics-for-wordpress'); ?> |
|
149 | 149 | </div> |
150 | 150 | </a> |
151 | 151 | </div> |
@@ -156,23 +156,23 @@ discard block |
||
156 | 156 | ob_end_clean(); |
157 | 157 | return $contents; |
158 | 158 | } |
159 | -function monsterinsights_google_auth_done_view( $reauth = false ) { |
|
160 | - $class = ( $reauth ) ? 'monsterinsights_google_auth_reauth_done_view' : 'monsterinsights_google_auth_done_view' ; |
|
159 | +function monsterinsights_google_auth_done_view($reauth = false) { |
|
160 | + $class = ($reauth) ? 'monsterinsights_google_auth_reauth_done_view' : 'monsterinsights_google_auth_done_view'; |
|
161 | 161 | ob_start(); |
162 | 162 | ?> |
163 | 163 | <div class="<?php echo $class; ?>"> |
164 | - <?php if ( $reauth ) { ?> |
|
164 | + <?php if ($reauth) { ?> |
|
165 | 165 | <div id="monsterinsights_google_auth_box_header"> |
166 | 166 | <div class="monsterinsights_google_auth_box_header_reauth"> |
167 | - <?php esc_html_e( 'Your Google connection has been replaced.', 'google-analytics-for-wordpress' ); ?> |
|
167 | + <?php esc_html_e('Your Google connection has been replaced.', 'google-analytics-for-wordpress'); ?> |
|
168 | 168 | </div> |
169 | 169 | </div> |
170 | 170 | <?php } ?> |
171 | - <div id="monsterinsights_google_auth_box_contents" <?php if ( $reauth ) { echo 'class="monsterinsights_google_auth_reauth"'; } ?> > |
|
172 | - <div class="monsterinsights_google_auth_view_title monsterinsights_google_auth_start_view_title"><?php esc_html_e( 'DONE', 'google-analytics-for-wordpress' ); ?> </div> |
|
173 | - <div class="monsterinsights_google_auth_view_description monsterinsights_google_auth_start_view_description"><?php esc_html_e( 'You\'re all set!', 'google-analytics-for-wordpress' ); ?> </div> |
|
174 | - <input type="hidden" id="monsterinsightsreauth" name="monsterinsightsreauth" value="<?php echo ( $reauth) ? 'true' : 'false';?>"> |
|
175 | - <input type="hidden" id="monsterinsightsview" name="monsterinsightsview" value="<?php echo 'done';?>"> |
|
171 | + <div id="monsterinsights_google_auth_box_contents" <?php if ($reauth) { echo 'class="monsterinsights_google_auth_reauth"'; } ?> > |
|
172 | + <div class="monsterinsights_google_auth_view_title monsterinsights_google_auth_start_view_title"><?php esc_html_e('DONE', 'google-analytics-for-wordpress'); ?> </div> |
|
173 | + <div class="monsterinsights_google_auth_view_description monsterinsights_google_auth_start_view_description"><?php esc_html_e('You\'re all set!', 'google-analytics-for-wordpress'); ?> </div> |
|
174 | + <input type="hidden" id="monsterinsightsreauth" name="monsterinsightsreauth" value="<?php echo ($reauth) ? 'true' : 'false'; ?>"> |
|
175 | + <input type="hidden" id="monsterinsightsview" name="monsterinsightsview" value="<?php echo 'done'; ?>"> |
|
176 | 176 | </div> |
177 | 177 | <div id="monsterinsights_google_auth_box_footer"> |
178 | 178 | <div id="monsterinsights_google_auth_box_footer_left"> |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | |
183 | 183 | </div> |
184 | 184 | <div id="monsterinsights_google_auth_box_footer_right"> |
185 | - <a href="#" id="monsterinsights_google_auth_box_done" class="monsterinsights_google_auth_box_done" title="<?php esc_attr_e( 'Save and close', 'google-analytics-for-wordpress' ); ?>" > |
|
185 | + <a href="#" id="monsterinsights_google_auth_box_done" class="monsterinsights_google_auth_box_done" title="<?php esc_attr_e('Save and close', 'google-analytics-for-wordpress'); ?>" > |
|
186 | 186 | <div id="monsterinsights_google_auth_box_footer_right_next"> |
187 | - <?php esc_html_e( 'CLOSE', 'google-analytics-for-wordpress' ); ?> |
|
187 | + <?php esc_html_e('CLOSE', 'google-analytics-for-wordpress'); ?> |
|
188 | 188 | </div> |
189 | 189 | </a> |
190 | 190 | </div> |
@@ -196,26 +196,26 @@ discard block |
||
196 | 196 | return $contents; |
197 | 197 | } |
198 | 198 | |
199 | -function monsterinsights_google_auth_error_view( $reauth = false, $error = '' ) { |
|
200 | - $class = ( $reauth ) ? 'monsterinsights_google_auth_reauth_exit_view' : 'monsterinsights_google_auth_exit_view' ; |
|
199 | +function monsterinsights_google_auth_error_view($reauth = false, $error = '') { |
|
200 | + $class = ($reauth) ? 'monsterinsights_google_auth_reauth_exit_view' : 'monsterinsights_google_auth_exit_view'; |
|
201 | 201 | ob_start(); |
202 | 202 | ?> |
203 | 203 | <div class="<?php echo $class; ?>"> |
204 | - <?php if ( $reauth ) { ?> |
|
204 | + <?php if ($reauth) { ?> |
|
205 | 205 | <div id="monsterinsights_google_auth_box_header"> |
206 | 206 | <div class="monsterinsights_google_auth_box_header_reauth"> |
207 | - <?php esc_html_e( 'An error has occured.', 'google-analytics-for-wordpress' ); ?> |
|
208 | - <a href="" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e( 'Exit', 'google-analytics-for-wordpress' ); ?>" > |
|
209 | - <?php esc_html_e( 'Exit', 'google-analytics-for-wordpress' ); ?> |
|
207 | + <?php esc_html_e('An error has occured.', 'google-analytics-for-wordpress'); ?> |
|
208 | + <a href="" class="monsterinsights_google_auth_box_cancel" title="<?php esc_attr_e('Exit', 'google-analytics-for-wordpress'); ?>" > |
|
209 | + <?php esc_html_e('Exit', 'google-analytics-for-wordpress'); ?> |
|
210 | 210 | </a> |
211 | 211 | </div> |
212 | 212 | </div> |
213 | 213 | <?php } ?> |
214 | - <div id="monsterinsights_google_auth_box_contents" <?php if ( $reauth ) { echo 'class="monsterinsights_google_auth_reauth"'; } ?> > |
|
215 | - <div class="monsterinsights_google_auth_view_title monsterinsights_google_auth_exit_view_title"><?php esc_html_e( 'ERROR', 'google-analytics-for-wordpress' ); ?> </div> |
|
214 | + <div id="monsterinsights_google_auth_box_contents" <?php if ($reauth) { echo 'class="monsterinsights_google_auth_reauth"'; } ?> > |
|
215 | + <div class="monsterinsights_google_auth_view_title monsterinsights_google_auth_exit_view_title"><?php esc_html_e('ERROR', 'google-analytics-for-wordpress'); ?> </div> |
|
216 | 216 | <div class="monsterinsights_google_auth_view_description monsterinsights_google_auth_exit_view_description"><?php echo $error; ?> </div> |
217 | - <input type="hidden" id="monsterinsightsreauth" name="monsterinsightsreauth" value="<?php echo ( $reauth) ? 'true' : 'false';?>"> |
|
218 | - <input type="hidden" id="monsterinsightsview" name="monsterinsightsview" value="<?php echo 'done';?>"> |
|
217 | + <input type="hidden" id="monsterinsightsreauth" name="monsterinsightsreauth" value="<?php echo ($reauth) ? 'true' : 'false'; ?>"> |
|
218 | + <input type="hidden" id="monsterinsightsview" name="monsterinsightsview" value="<?php echo 'done'; ?>"> |
|
219 | 219 | </div> |
220 | 220 | <div id="monsterinsights_google_auth_box_footer"> |
221 | 221 | <div id="monsterinsights_google_auth_box_footer_left"> |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | |
226 | 226 | </div> |
227 | 227 | <div id="monsterinsights_google_auth_box_footer_right"> |
228 | - <a href="#" id="monsterinsights_google_auth_box_cancel_error" class="monsterinsights_google_auth_box_cancel_error" title="<?php esc_attr_e( 'Exit', 'google-analytics-for-wordpress' ); ?>" > |
|
228 | + <a href="#" id="monsterinsights_google_auth_box_cancel_error" class="monsterinsights_google_auth_box_cancel_error" title="<?php esc_attr_e('Exit', 'google-analytics-for-wordpress'); ?>" > |
|
229 | 229 | <div id="monsterinsights_google_auth_box_footer_right_next"> |
230 | - <?php esc_html_e( 'EXIT', 'google-analytics-for-wordpress' ); ?> |
|
230 | + <?php esc_html_e('EXIT', 'google-analytics-for-wordpress'); ?> |
|
231 | 231 | </div> |
232 | 232 | </a> |
233 | 233 | </div> |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | public function __construct() { |
38 | 38 | |
39 | 39 | // Populate $notices |
40 | - $this->notices = get_option( 'monsterinsights_notices' ); |
|
41 | - if ( ! is_array( $this->notices ) ) { |
|
40 | + $this->notices = get_option('monsterinsights_notices'); |
|
41 | + if ( ! is_array($this->notices)) { |
|
42 | 42 | $this->notices = array(); |
43 | 43 | } |
44 | 44 | |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * @return bool Notice Dismissed |
55 | 55 | */ |
56 | 56 | |
57 | - public function is_dismissed( $notice ) { |
|
58 | - if ( ! isset( $this->notices[ $notice ] ) ) { |
|
57 | + public function is_dismissed($notice) { |
|
58 | + if ( ! isset($this->notices[$notice])) { |
|
59 | 59 | return false; |
60 | 60 | } |
61 | 61 | return true; |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * @param string $notice Programmatic Notice Name |
72 | 72 | * @return null |
73 | 73 | */ |
74 | - public function dismiss( $notice ) { |
|
75 | - $this->notices[ $notice ] = true; |
|
76 | - update_option( 'monsterinsights_notices', $this->notices ); |
|
74 | + public function dismiss($notice) { |
|
75 | + $this->notices[$notice] = true; |
|
76 | + update_option('monsterinsights_notices', $this->notices); |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @param string $notice Programmatic Notice Name |
88 | 88 | * @return null |
89 | 89 | */ |
90 | - public function undismiss( $notice ) { |
|
91 | - unset( $this->notices[ $notice ] ); |
|
92 | - update_option( 'monsterinsights_notices', $this->notices ); |
|
90 | + public function undismiss($notice) { |
|
91 | + unset($this->notices[$notice]); |
|
92 | + update_option('monsterinsights_notices', $this->notices); |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @param string $button_url Button URL (optional) |
108 | 108 | * @param bool $is_dismissible User can Dismiss Message (default: false) |
109 | 109 | */ |
110 | - public function display_inline_notice( $name, $title, $message, $type = 'success', $is_dismissible = false, $args = array() ) { |
|
110 | + public function display_inline_notice($name, $title, $message, $type = 'success', $is_dismissible = false, $args = array()) { |
|
111 | 111 | /* Available/Planned $args options |
112 | 112 | * $args = array( |
113 | 113 | * 'primary' => array( |
@@ -128,33 +128,33 @@ discard block |
||
128 | 128 | |
129 | 129 | |
130 | 130 | // Check if the notice is dismissible, and if so has been dismissed. |
131 | - if ( $is_dismissible && $this->is_dismissed( $name ) ) { |
|
131 | + if ($is_dismissible && $this->is_dismissed($name)) { |
|
132 | 132 | // Nothing to show here, return! |
133 | 133 | return ''; |
134 | 134 | } |
135 | 135 | |
136 | - $dismissible = ( $is_dismissible ) ? ' is-dismissible': ''; |
|
136 | + $dismissible = ($is_dismissible) ? ' is-dismissible' : ''; |
|
137 | 137 | |
138 | 138 | // Display inline notice |
139 | 139 | ob_start(); |
140 | 140 | ?> |
141 | - <div class="monsterinsights-notice <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice' . $dismissible; ?>" data-notice="<?php echo esc_attr( $name ); ?>"> |
|
142 | - <div class="monsterinsights-notice-icon <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-icon'?>"> |
|
141 | + <div class="monsterinsights-notice <?php echo 'monsterinsights-' . esc_attr($type) . '-notice' . $dismissible; ?>" data-notice="<?php echo esc_attr($name); ?>"> |
|
142 | + <div class="monsterinsights-notice-icon <?php echo 'monsterinsights-' . esc_attr($type) . '-notice-icon'?>"> |
|
143 | 143 | </div> |
144 | - <div class="monsterinsights-notice-text <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-text'?>"> |
|
144 | + <div class="monsterinsights-notice-text <?php echo 'monsterinsights-' . esc_attr($type) . '-notice-text'?>"> |
|
145 | 145 | <?php |
146 | 146 | // Title |
147 | - if ( ! empty ( $title ) ) { |
|
147 | + if ( ! empty ($title)) { |
|
148 | 148 | ?> |
149 | - <p class="monsterinsights-notice-title"><?php echo esc_html( $title ); ?></p> |
|
149 | + <p class="monsterinsights-notice-title"><?php echo esc_html($title); ?></p> |
|
150 | 150 | <?php |
151 | 151 | } |
152 | 152 | |
153 | 153 | // Message |
154 | - if ( ! empty( $message ) ) { |
|
155 | - if ( empty( $args['skip_message_escape'] ) ) { |
|
154 | + if ( ! empty($message)) { |
|
155 | + if (empty($args['skip_message_escape'])) { |
|
156 | 156 | ?> |
157 | - <p class="monsterinsights-notice-message"><?php echo esc_html( $message ); ?></p> |
|
157 | + <p class="monsterinsights-notice-message"><?php echo esc_html($message); ?></p> |
|
158 | 158 | <?php |
159 | 159 | } else { |
160 | 160 | ?> |
@@ -164,65 +164,65 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | // Primary Button |
167 | - if ( ! empty( $args['primary']['text'] ) ) { |
|
167 | + if ( ! empty($args['primary']['text'])) { |
|
168 | 168 | |
169 | 169 | $text = ''; |
170 | - if ( ! empty( $args['primary']['text'] ) ) { |
|
170 | + if ( ! empty($args['primary']['text'])) { |
|
171 | 171 | $text = $args['primary']['text']; |
172 | 172 | } |
173 | 173 | |
174 | 174 | $url = '#'; |
175 | - if ( ! empty( $args['primary']['url'] ) ) { |
|
175 | + if ( ! empty($args['primary']['url'])) { |
|
176 | 176 | $url = $args['primary']['url']; |
177 | 177 | } |
178 | 178 | |
179 | 179 | $target = ''; |
180 | - if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank') { |
|
180 | + if ( ! empty($args['primary']['target']) && $args['primary']['target'] === 'blank') { |
|
181 | 181 | $target = ' target="_blank" rel="noopener noreferrer"'; |
182 | 182 | } |
183 | 183 | |
184 | 184 | $class = 'button button-primary'; |
185 | - if ( ! empty( $args['primary']['class'] ) ) { |
|
186 | - $class = ' class="'. $args['primary']['class'] . '"'; |
|
185 | + if ( ! empty($args['primary']['class'])) { |
|
186 | + $class = ' class="' . $args['primary']['class'] . '"'; |
|
187 | 187 | } |
188 | 188 | ?> |
189 | - <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a> |
|
189 | + <a href="<?php echo esc_attr($url); ?>"<?php echo $target; ?><?php echo $class; ?>><?php echo esc_html($text); ?></a> |
|
190 | 190 | <?php |
191 | 191 | } |
192 | 192 | |
193 | 193 | // Secondary Button |
194 | - if ( ! empty( $args['secondary']['text'] ) ) { |
|
194 | + if ( ! empty($args['secondary']['text'])) { |
|
195 | 195 | |
196 | 196 | $text = ''; |
197 | - if ( ! empty( $args['secondary']['text'] ) ) { |
|
197 | + if ( ! empty($args['secondary']['text'])) { |
|
198 | 198 | $text = $args['secondary']['text']; |
199 | 199 | } |
200 | 200 | |
201 | 201 | $url = '#'; |
202 | - if ( ! empty( $args['secondary']['url'] ) ) { |
|
202 | + if ( ! empty($args['secondary']['url'])) { |
|
203 | 203 | $url = $args['secondary']['url']; |
204 | 204 | } |
205 | 205 | |
206 | 206 | $target = ''; |
207 | - if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank') { |
|
207 | + if ( ! empty($args['secondary']['target']) && $args['secondary']['target'] === 'blank') { |
|
208 | 208 | $target = ' target="_blank" rel="noopener noreferrer"'; |
209 | 209 | } |
210 | 210 | |
211 | 211 | $class = 'button button-secondary'; |
212 | - if ( ! empty( $args['secondary']['class'] ) ) { |
|
213 | - $class = ' class="'. $args['secondary']['class'] . '"'; |
|
212 | + if ( ! empty($args['secondary']['class'])) { |
|
213 | + $class = ' class="' . $args['secondary']['class'] . '"'; |
|
214 | 214 | } |
215 | 215 | ?> |
216 | - <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a> |
|
216 | + <a href="<?php echo esc_attr($url); ?>"<?php echo $target; ?><?php echo $class; ?>><?php echo esc_html($text); ?></a> |
|
217 | 217 | <?php |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Dismiss Button |
221 | - if ( $is_dismissible ) { |
|
221 | + if ($is_dismissible) { |
|
222 | 222 | ?> |
223 | 223 | <button type="button" class="notice-dismiss<?php echo $dismissible; ?>"> |
224 | 224 | <span class="screen-reader-text"> |
225 | - <?php esc_html_e( 'Dismiss this notice', 'google-analytics-for-wordpress' ); ?> |
|
225 | + <?php esc_html_e('Dismiss this notice', 'google-analytics-for-wordpress'); ?> |
|
226 | 226 | </span> |
227 | 227 | </button> |
228 | 228 | <?php |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -17,20 +17,20 @@ discard block |
||
17 | 17 | $current_screen = get_current_screen(); |
18 | 18 | global $admin_page_hooks; |
19 | 19 | |
20 | - if ( ! is_object( $current_screen ) || empty( $current_screen->id ) || empty( $admin_page_hooks ) ) { |
|
20 | + if ( ! is_object($current_screen) || empty($current_screen->id) || empty($admin_page_hooks)) { |
|
21 | 21 | return false; |
22 | 22 | } |
23 | 23 | |
24 | 24 | $settings_page = false; |
25 | - if ( ! empty( $admin_page_hooks['monsterinsights_dashboard'] ) && $current_screen->id === $admin_page_hooks['monsterinsights_dashboard'] . '_page_monsterinsights_addons' ) { |
|
25 | + if ( ! empty($admin_page_hooks['monsterinsights_dashboard']) && $current_screen->id === $admin_page_hooks['monsterinsights_dashboard'] . '_page_monsterinsights_addons') { |
|
26 | 26 | $settings_page = true; |
27 | 27 | } |
28 | 28 | |
29 | - if ( ! empty( $admin_page_hooks['monsterinsights_settings'] ) && $current_screen->id === $admin_page_hooks['monsterinsights_settings'] . '_page_monsterinsights_addons' ) { |
|
29 | + if ( ! empty($admin_page_hooks['monsterinsights_settings']) && $current_screen->id === $admin_page_hooks['monsterinsights_settings'] . '_page_monsterinsights_addons') { |
|
30 | 30 | $settings_page = true; |
31 | 31 | } |
32 | 32 | |
33 | - if ( ! empty( $admin_page_hooks['monsterinsights_network'] ) && $current_screen->id === $admin_page_hooks['monsterinsights_network'] . '_page_monsterinsights_addons-network' ) { |
|
33 | + if ( ! empty($admin_page_hooks['monsterinsights_network']) && $current_screen->id === $admin_page_hooks['monsterinsights_network'] . '_page_monsterinsights_addons-network') { |
|
34 | 34 | $settings_page = true; |
35 | 35 | } |
36 | 36 | |
@@ -45,23 +45,23 @@ discard block |
||
45 | 45 | * @return null Return early if not refreshing the addons. |
46 | 46 | */ |
47 | 47 | function monsterinsights_maybe_refresh_addons() { |
48 | - if ( ! monsterinsights_is_addons_page() ) { |
|
48 | + if ( ! monsterinsights_is_addons_page()) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | - if ( ! monsterinsights_is_refreshing_addons() ) { |
|
53 | + if ( ! monsterinsights_is_refreshing_addons()) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | - if ( ! monsterinsights_refresh_addons_action() ) { |
|
57 | + if ( ! monsterinsights_refresh_addons_action()) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | - monsterinsights_get_addons_data( monsterinsights_get_license_key() ); |
|
61 | + monsterinsights_get_addons_data(monsterinsights_get_license_key()); |
|
62 | 62 | |
63 | 63 | } |
64 | -add_action( 'current_screen', 'monsterinsights_maybe_refresh_addons' ); |
|
64 | +add_action('current_screen', 'monsterinsights_maybe_refresh_addons'); |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Callback to output the MonsterInsights addons page. |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | ?> |
81 | 81 | <?php echo monsterinsights_ublock_notice(); ?> |
82 | 82 | <div id="monsterinsights-addon-heading" class="monsterinsights-addons-subheading monsterinsights-clearfix-after"> |
83 | - <h1><?php esc_html_e( 'MonsterInsights Addons', 'google-analytics-for-wordpress' ); ?></h1> |
|
83 | + <h1><?php esc_html_e('MonsterInsights Addons', 'google-analytics-for-wordpress'); ?></h1> |
|
84 | 84 | <form id="add-on-search"> |
85 | 85 | <span class="spinner"></span> |
86 | - <input id="add-on-searchbox" name="monsterinsights-addon-search" value="" placeholder="<?php esc_attr_e( 'Search MI Addons', 'google-analytics-for-wordpress' ); ?>" /> |
|
86 | + <input id="add-on-searchbox" name="monsterinsights-addon-search" value="" placeholder="<?php esc_attr_e('Search MI Addons', 'google-analytics-for-wordpress'); ?>" /> |
|
87 | 87 | <select id="monsterinsights-filter-select"> |
88 | - <option value="asc"><?php esc_html_e( 'Sort Ascending (A-Z)', 'google-analytics-for-wordpress' ); ?></option> |
|
89 | - <option value="desc"><?php esc_html_e( 'Sort Descending (Z-A)', 'google-analytics-for-wordpress' ); ?></option> |
|
88 | + <option value="asc"><?php esc_html_e('Sort Ascending (A-Z)', 'google-analytics-for-wordpress'); ?></option> |
|
89 | + <option value="desc"><?php esc_html_e('Sort Descending (Z-A)', 'google-analytics-for-wordpress'); ?></option> |
|
90 | 90 | </select> |
91 | 91 | </form> |
92 | 92 | </div> |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * or the hook may be removed at any time, without warning. |
102 | 102 | */ |
103 | 103 | ?> |
104 | - <?php do_action( 'monsterinsights_addons_section' ); ?> |
|
104 | + <?php do_action('monsterinsights_addons_section'); ?> |
|
105 | 105 | </div> |
106 | 106 | </div> |
107 | 107 | <?php |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | function monsterinsights_addons_content() { |
117 | 117 | |
118 | 118 | // If error(s) occured during license key verification, display them and exit now. |
119 | - if ( false !== monsterinsights_get_license_key_errors() ) { |
|
119 | + if (false !== monsterinsights_get_license_key_errors()) { |
|
120 | 120 | ?> |
121 | 121 | <div class="error below-h2"> |
122 | 122 | <p> |
123 | - <?php esc_html_e( 'In order to get access to Addons, you need to resolve your license key errors.', 'google-analytics-for-wordpress' ); ?> |
|
123 | + <?php esc_html_e('In order to get access to Addons, you need to resolve your license key errors.', 'google-analytics-for-wordpress'); ?> |
|
124 | 124 | </p> |
125 | 125 | </div> |
126 | 126 | <?php |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | |
133 | 133 | // If no Addon(s) were returned, our API call returned an error. |
134 | 134 | // Show an error message with a button to reload the page, which will trigger another API call. |
135 | - if ( ! $addons ) { |
|
135 | + if ( ! $addons) { |
|
136 | 136 | ?> |
137 | 137 | <form id="monsterinsights-addons-refresh-addons-form" method="post"> |
138 | 138 | <p> |
139 | - <?php esc_html_e( 'There was an issue retrieving the addons for this site. Please click on the button below the refresh the addons data.', 'google-analytics-for-wordpress' ); ?> |
|
139 | + <?php esc_html_e('There was an issue retrieving the addons for this site. Please click on the button below the refresh the addons data.', 'google-analytics-for-wordpress'); ?> |
|
140 | 140 | </p> |
141 | 141 | <p> |
142 | - <a href="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" class="button button-primary"><?php esc_html_e( 'Refresh Addons', 'google-analytics-for-wordpress' ); ?></a> |
|
142 | + <a href="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" class="button button-primary"><?php esc_html_e('Refresh Addons', 'google-analytics-for-wordpress'); ?></a> |
|
143 | 143 | </p> |
144 | 144 | </form> |
145 | 145 | <?php |
@@ -154,17 +154,17 @@ discard block |
||
154 | 154 | <div id="monsterinsights-addons"> |
155 | 155 | <?php |
156 | 156 | // Output Addons the User is licensed to use. |
157 | - if ( count( $addons['licensed'] )> 0 ) { |
|
157 | + if (count($addons['licensed']) > 0) { |
|
158 | 158 | ?> |
159 | 159 | <div class="monsterinsights-addons-area licensed" class="monsterinsights-clear"> |
160 | - <h3><?php esc_html_e( 'Available Addons:', 'google-analytics-for-wordpress' ); ?></h3> |
|
160 | + <h3><?php esc_html_e('Available Addons:', 'google-analytics-for-wordpress'); ?></h3> |
|
161 | 161 | |
162 | 162 | <div id="monsterinsights-addons-licensed" class="monsterinsights-addons"> |
163 | 163 | <!-- list container class required for list.js --> |
164 | 164 | <div class="list"> |
165 | 165 | <?php |
166 | - foreach ( (array) $addons['licensed'] as $i => $addon ) { |
|
167 | - monsterinsights_get_addon_card( $addon, $i, true, $installed_plugins ); |
|
166 | + foreach ((array) $addons['licensed'] as $i => $addon) { |
|
167 | + monsterinsights_get_addon_card($addon, $i, true, $installed_plugins); |
|
168 | 168 | } |
169 | 169 | ?> |
170 | 170 | </div> |
@@ -174,18 +174,18 @@ discard block |
||
174 | 174 | } // Close licensed addons |
175 | 175 | |
176 | 176 | // Output Addons the User isn't licensed to use. |
177 | - if ( count( $addons['unlicensed'] ) > 0 ) { |
|
177 | + if (count($addons['unlicensed']) > 0) { |
|
178 | 178 | ?> |
179 | 179 | <div class="monsterinsights-addons-area unlicensed" class="monsterinsights-clear"> |
180 | - <h3><?php esc_html_e( 'Unlock More Addons', 'google-analytics-for-wordpress' ); ?></h3> |
|
181 | - <p><?php echo sprintf( esc_html__( '%1$sWant even more addons?%2$sUpgrade your MonsterInsights account%3$s and unlock the following addons:', 'google-analytics-for-wordpress' ), '<strong>', '</strong> <a href="' . $upgrade_url. '">', '</a>' ); ?></p> |
|
180 | + <h3><?php esc_html_e('Unlock More Addons', 'google-analytics-for-wordpress'); ?></h3> |
|
181 | + <p><?php echo sprintf(esc_html__('%1$sWant even more addons?%2$sUpgrade your MonsterInsights account%3$s and unlock the following addons:', 'google-analytics-for-wordpress'), '<strong>', '</strong> <a href="' . $upgrade_url . '">', '</a>'); ?></p> |
|
182 | 182 | |
183 | 183 | <div id="monsterinsights-addons-unlicensed" class="monsterinsights-addons"> |
184 | 184 | <!-- list container class required for list.js --> |
185 | 185 | <div class="list"> |
186 | 186 | <?php |
187 | - foreach ( (array) $addons['unlicensed'] as $i => $addon ) { |
|
188 | - monsterinsights_get_addon_card( $addon, $i, false, $installed_plugins ); |
|
187 | + foreach ((array) $addons['unlicensed'] as $i => $addon) { |
|
188 | + monsterinsights_get_addon_card($addon, $i, false, $installed_plugins); |
|
189 | 189 | } |
190 | 190 | ?> |
191 | 191 | </div> |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | <?php |
199 | 199 | |
200 | 200 | } |
201 | -add_action( 'monsterinsights_addons_section', 'monsterinsights_addons_content' ); |
|
201 | +add_action('monsterinsights_addons_section', 'monsterinsights_addons_content'); |
|
202 | 202 | |
203 | 203 | /** |
204 | 204 | * Retrieves addons from the stored transient or remote server. |
@@ -214,12 +214,12 @@ discard block |
||
214 | 214 | $type = monsterinsights_get_license_key_type(); |
215 | 215 | |
216 | 216 | // Get addons data from transient or perform API query if no transient. |
217 | - if ( false === ( $addons = get_transient( '_monsterinsights_addons' ) ) ) { |
|
218 | - $addons = monsterinsights_get_addons_data( $key ); |
|
217 | + if (false === ($addons = get_transient('_monsterinsights_addons'))) { |
|
218 | + $addons = monsterinsights_get_addons_data($key); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | // If no Addons exist, return false |
222 | - if ( ! $addons ) { |
|
222 | + if ( ! $addons) { |
|
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | |
@@ -230,14 +230,14 @@ discard block |
||
230 | 230 | 'licensed' => array(), |
231 | 231 | 'unlicensed'=> array(), |
232 | 232 | ); |
233 | - foreach ( (array) $addons as $i => $addon ) { |
|
233 | + foreach ((array) $addons as $i => $addon) { |
|
234 | 234 | |
235 | 235 | // Determine whether the user is licensed to use this Addon or not. |
236 | 236 | if ( |
237 | - empty( $type ) || |
|
238 | - ( in_array( 'Pro', $addon->categories ) && ( $type != 'pro' && $type != 'master' ) ) || |
|
239 | - ( in_array( 'Plus', $addon->categories ) && $type != 'plus' && $type != 'pro' && $type != 'master' ) || |
|
240 | - ( in_array( 'Basic', $addon->categories ) && ( $type != 'basic' && $type != 'plus' && $type != 'pro' && $type != 'master' ) ) |
|
237 | + empty($type) || |
|
238 | + (in_array('Pro', $addon->categories) && ($type != 'pro' && $type != 'master')) || |
|
239 | + (in_array('Plus', $addon->categories) && $type != 'plus' && $type != 'pro' && $type != 'master') || |
|
240 | + (in_array('Basic', $addon->categories) && ($type != 'basic' && $type != 'plus' && $type != 'pro' && $type != 'master')) |
|
241 | 241 | ) { |
242 | 242 | // Unlicensed |
243 | 243 | $results['unlicensed'][] = $addon; |
@@ -262,33 +262,33 @@ discard block |
||
262 | 262 | * @param string $key The user license key. |
263 | 263 | * @return array Array of addon data otherwise. |
264 | 264 | */ |
265 | -function monsterinsights_get_addons_data( $key ) { |
|
265 | +function monsterinsights_get_addons_data($key) { |
|
266 | 266 | // Get the base class object. |
267 | 267 | $base = MonsterInsights(); |
268 | 268 | $type = monsterinsights_get_license_key_type(); |
269 | 269 | |
270 | 270 | // Get Addons |
271 | 271 | // If the key is valid, we'll get personalised upgrade URLs for each Addon (if necessary) and plugin update information. |
272 | - if ( $key ) { |
|
273 | - $addons = $base->license->perform_remote_request( 'get-addons-data-v600', array( 'tgm-updater-key' => $key ) ); |
|
272 | + if ($key) { |
|
273 | + $addons = $base->license->perform_remote_request('get-addons-data-v600', array('tgm-updater-key' => $key)); |
|
274 | 274 | } else { |
275 | - $addons = $base->license->perform_remote_request( 'get-all-addons-data', array() ); |
|
275 | + $addons = $base->license->perform_remote_request('get-all-addons-data', array()); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | // If there was an API error, set transient for only 10 minutes. |
279 | - if ( ! $addons ) { |
|
280 | - set_transient( '_monsterinsights_addons', false, 10 * MINUTE_IN_SECONDS ); |
|
279 | + if ( ! $addons) { |
|
280 | + set_transient('_monsterinsights_addons', false, 10 * MINUTE_IN_SECONDS); |
|
281 | 281 | return false; |
282 | 282 | } |
283 | 283 | |
284 | 284 | // If there was an error retrieving the addons, set the error. |
285 | - if ( isset( $addons->error ) ) { |
|
286 | - set_transient( '_monsterinsights_addons', false, 10 * MINUTE_IN_SECONDS ); |
|
285 | + if (isset($addons->error)) { |
|
286 | + set_transient('_monsterinsights_addons', false, 10 * MINUTE_IN_SECONDS); |
|
287 | 287 | return false; |
288 | 288 | } |
289 | 289 | |
290 | 290 | // Otherwise, our request worked. Save the data and return it. |
291 | - set_transient( '_monsterinsights_addons', $addons, 4 * HOUR_IN_SECONDS ); |
|
291 | + set_transient('_monsterinsights_addons', $addons, 4 * HOUR_IN_SECONDS); |
|
292 | 292 | return $addons; |
293 | 293 | |
294 | 294 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @return bool True if being refreshed, false otherwise. |
302 | 302 | */ |
303 | 303 | function monsterinsights_is_refreshing_addons() { |
304 | - return isset( $_POST['google-analytics-for-wordpress-refresh-addons-submit'] ); |
|
304 | + return isset($_POST['google-analytics-for-wordpress-refresh-addons-submit']); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @return bool True if nonces check out, false otherwise. |
313 | 313 | */ |
314 | 314 | function monsterinsights_refresh_addons_action() { |
315 | - return isset( $_POST['google-analytics-for-wordpress-refresh-addons-submit'] ) && wp_verify_nonce( $_POST['google-analytics-for-wordpress-refresh-addons'], 'google-analytics-for-wordpress-refresh-addons' ); |
|
315 | + return isset($_POST['google-analytics-for-wordpress-refresh-addons-submit']) && wp_verify_nonce($_POST['google-analytics-for-wordpress-refresh-addons'], 'google-analytics-for-wordpress-refresh-addons'); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -323,11 +323,11 @@ discard block |
||
323 | 323 | * @param string $slug The plugin slug. |
324 | 324 | * @return string The plugin basename if found, else the plugin slug. |
325 | 325 | */ |
326 | -function monsterinsights_get_plugin_basename_from_slug( $slug ) { |
|
327 | - $keys = array_keys( get_plugins() ); |
|
326 | +function monsterinsights_get_plugin_basename_from_slug($slug) { |
|
327 | + $keys = array_keys(get_plugins()); |
|
328 | 328 | |
329 | - foreach ( $keys as $key ) { |
|
330 | - if ( preg_match( '|^' . $slug . '|', $key ) ) { |
|
329 | + foreach ($keys as $key) { |
|
330 | + if (preg_match('|^' . $slug . '|', $key)) { |
|
331 | 331 | return $key; |
332 | 332 | } |
333 | 333 | } |
@@ -346,55 +346,55 @@ discard block |
||
346 | 346 | * @param bool $is_licensed Whether the Addon is licensed for use |
347 | 347 | * @param array $installed_plugins Installed WordPress Plugins |
348 | 348 | */ |
349 | -function monsterinsights_get_addon_card( $addon, $counter = 0, $is_licensed = false, $installed_plugins = false ) { |
|
349 | +function monsterinsights_get_addon_card($addon, $counter = 0, $is_licensed = false, $installed_plugins = false) { |
|
350 | 350 | |
351 | 351 | // Setup some vars |
352 | - $slug = str_replace( 'monsterinsights-', '', $addon->slug ); |
|
352 | + $slug = str_replace('monsterinsights-', '', $addon->slug); |
|
353 | 353 | $slug = 'monsterinsights-' . $addon->slug; |
354 | - if ( $slug === 'monsterinsights-ecommerce' ) { |
|
354 | + if ($slug === 'monsterinsights-ecommerce') { |
|
355 | 355 | $slug = 'ga-ecommerce'; |
356 | 356 | } |
357 | 357 | |
358 | - $plugin_basename = monsterinsights_get_plugin_basename_from_slug( $slug ); |
|
359 | - $categories = implode( ',', $addon->categories ); |
|
360 | - if ( ! $installed_plugins ) { |
|
358 | + $plugin_basename = monsterinsights_get_plugin_basename_from_slug($slug); |
|
359 | + $categories = implode(',', $addon->categories); |
|
360 | + if ( ! $installed_plugins) { |
|
361 | 361 | $installed_plugins = get_plugins(); |
362 | 362 | } |
363 | 363 | |
364 | 364 | // If the Addon doesn't supply an upgrade_url key, it's because the user hasn't provided a license |
365 | 365 | // get_upgrade_link() will return the Lite or Pro link as necessary for us. |
366 | - if ( ! isset( $addon->upgrade_url ) ) { |
|
366 | + if ( ! isset($addon->upgrade_url)) { |
|
367 | 367 | $addon->upgrade_url = monsterinsights_get_upgrade_link(); |
368 | 368 | } |
369 | 369 | |
370 | 370 | // Link user to doc to install MI pro to install addons |
371 | - if ( ! monsterinsights_is_pro_version() && $is_licensed && ! isset( $installed_plugins[ $plugin_basename ] ) ) { |
|
371 | + if ( ! monsterinsights_is_pro_version() && $is_licensed && ! isset($installed_plugins[$plugin_basename])) { |
|
372 | 372 | $addon->url = 'https://www.monsterinsights.com/docs/install-monsterinsights-pro-to-use-addons'; |
373 | 373 | } |
374 | 374 | |
375 | 375 | // Output the card |
376 | 376 | ?> |
377 | 377 | <div class="monsterinsights-addon"> |
378 | - <h3 class="monsterinsights-addon-title"><?php echo esc_html( $addon->title ); ?></h3> |
|
378 | + <h3 class="monsterinsights-addon-title"><?php echo esc_html($addon->title); ?></h3> |
|
379 | 379 | <?php |
380 | - if ( ! empty( $addon->image ) ) { |
|
380 | + if ( ! empty($addon->image)) { |
|
381 | 381 | ?> |
382 | - <img class="monsterinsights-addon-thumb" src="<?php echo esc_attr( esc_url( $addon->image ) ); ?>" alt="<?php echo esc_attr( $addon->title ); ?>" /> |
|
382 | + <img class="monsterinsights-addon-thumb" src="<?php echo esc_attr(esc_url($addon->image)); ?>" alt="<?php echo esc_attr($addon->title); ?>" /> |
|
383 | 383 | <?php |
384 | 384 | } |
385 | 385 | ?> |
386 | 386 | |
387 | - <p class="monsterinsights-addon-excerpt"><?php echo esc_html( $addon->excerpt ); ?></p> |
|
387 | + <p class="monsterinsights-addon-excerpt"><?php echo esc_html($addon->excerpt); ?></p> |
|
388 | 388 | |
389 | 389 | <?php |
390 | 390 | // If the Addon is unlicensed, show the upgrade button |
391 | - if ( ! $is_licensed ) { |
|
391 | + if ( ! $is_licensed) { |
|
392 | 392 | ?> |
393 | 393 | <div class="monsterinsights-addon-active monsterinsights-addon-message"> |
394 | 394 | <div class="interior"> |
395 | 395 | <div class="monsterinsights-addon-upgrade"> |
396 | - <a href="<?php echo esc_attr( esc_url( $addon->upgrade_url ) ); ?>" target="_blank" rel="noopener noreferrer" referrer="no-referrer" class="button button-primary monsterinsights-addon-upgrade-button" rel="<?php echo esc_attr( $plugin_basename ); ?>"> |
|
397 | - <?php esc_html_e( 'Upgrade Now', 'google-analytics-for-wordpress' ); ?> |
|
396 | + <a href="<?php echo esc_attr(esc_url($addon->upgrade_url)); ?>" target="_blank" rel="noopener noreferrer" referrer="no-referrer" class="button button-primary monsterinsights-addon-upgrade-button" rel="<?php echo esc_attr($plugin_basename); ?>"> |
|
397 | + <?php esc_html_e('Upgrade Now', 'google-analytics-for-wordpress'); ?> |
|
398 | 398 | </a> |
399 | 399 | <span class="spinner monsterinsights-spinner"></span> |
400 | 400 | </div> |
@@ -405,26 +405,26 @@ discard block |
||
405 | 405 | // Addon is licensed |
406 | 406 | |
407 | 407 | // If the plugin is not installed, display an install message and button. |
408 | - if ( ! isset( $installed_plugins[ $plugin_basename ] ) ) { |
|
409 | - if ( empty( $addon->url ) ) { |
|
408 | + if ( ! isset($installed_plugins[$plugin_basename])) { |
|
409 | + if (empty($addon->url)) { |
|
410 | 410 | $addon->url = ''; |
411 | 411 | } |
412 | 412 | ?> |
413 | 413 | <div class="monsterinsights-addon-not-installed monsterinsights-addon-message"> |
414 | 414 | <div class="interior"> |
415 | - <?php if ( monsterinsights_is_pro_version() ) { ?> |
|
416 | - <span class="addon-status"><?php echo sprintf( esc_html__( 'Status: %1$sNot Installed%2$s', 'google-analytics-for-wordpress' ), '<span>', '</span>' ); ?></span> |
|
415 | + <?php if (monsterinsights_is_pro_version()) { ?> |
|
416 | + <span class="addon-status"><?php echo sprintf(esc_html__('Status: %1$sNot Installed%2$s', 'google-analytics-for-wordpress'), '<span>', '</span>'); ?></span> |
|
417 | 417 | <?php } ?> |
418 | 418 | <div class="monsterinsights-addon-action"> |
419 | - <?php if ( monsterinsights_is_pro_version() ) { ?> |
|
420 | - <a class="button button-primary monsterinsights-addon-action-button monsterinsights-install-addon" href="#" rel="<?php echo esc_attr( esc_url( $addon->url ) ); ?>"> |
|
419 | + <?php if (monsterinsights_is_pro_version()) { ?> |
|
420 | + <a class="button button-primary monsterinsights-addon-action-button monsterinsights-install-addon" href="#" rel="<?php echo esc_attr(esc_url($addon->url)); ?>"> |
|
421 | 421 | <i class="monsterinsights-cloud-download"></i> |
422 | - <?php esc_html_e( 'Install', 'google-analytics-for-wordpress' ); ?> |
|
422 | + <?php esc_html_e('Install', 'google-analytics-for-wordpress'); ?> |
|
423 | 423 | </a> |
424 | 424 | <?php } else { ?> |
425 | - <a class="button button-primary monsterinsights-addon-action-button" href="<?php echo esc_url( $addon->url ); ?>" rel="noopener noreferrer" referrer="no-referrer" target="_blank"> |
|
425 | + <a class="button button-primary monsterinsights-addon-action-button" href="<?php echo esc_url($addon->url); ?>" rel="noopener noreferrer" referrer="no-referrer" target="_blank"> |
|
426 | 426 | <i class="monsterinsights-cloud-download"></i> |
427 | - <?php esc_html_e( "Why can't I install addons?", 'google-analytics-for-wordpress' ); ?> |
|
427 | + <?php esc_html_e("Why can't I install addons?", 'google-analytics-for-wordpress'); ?> |
|
428 | 428 | </a> |
429 | 429 | <?php } ?> |
430 | 430 | <span class="spinner monsterinsights-spinner"></span> |
@@ -436,35 +436,35 @@ discard block |
||
436 | 436 | // Plugin is installed. |
437 | 437 | |
438 | 438 | $active = false; |
439 | - $ms_active = is_plugin_active_for_network( $plugin_basename ); |
|
440 | - $ss_active = is_plugin_active( $plugin_basename ); |
|
439 | + $ms_active = is_plugin_active_for_network($plugin_basename); |
|
440 | + $ss_active = is_plugin_active($plugin_basename); |
|
441 | 441 | |
442 | - if ( is_multisite() && is_network_admin() ) { |
|
443 | - $active = is_plugin_active_for_network( $plugin_basename ); |
|
442 | + if (is_multisite() && is_network_admin()) { |
|
443 | + $active = is_plugin_active_for_network($plugin_basename); |
|
444 | 444 | } else { |
445 | - $active = is_plugin_active( $plugin_basename ); |
|
445 | + $active = is_plugin_active($plugin_basename); |
|
446 | 446 | } |
447 | 447 | |
448 | - if ( $active ) { |
|
448 | + if ($active) { |
|
449 | 449 | // Plugin is active. Display the active message and deactivate button. |
450 | 450 | ?> |
451 | 451 | <div class="monsterinsights-addon-active monsterinsights-addon-message"> |
452 | 452 | <div class="interior"> |
453 | - <?php if ( $ms_active ) { ?> |
|
454 | - <span class="addon-status"><?php echo sprintf( esc_html__( 'Status: %1$sNetwork Active%2$s', 'google-analytics-for-wordpress'), '<span>', '</span>' ); ?></span> |
|
453 | + <?php if ($ms_active) { ?> |
|
454 | + <span class="addon-status"><?php echo sprintf(esc_html__('Status: %1$sNetwork Active%2$s', 'google-analytics-for-wordpress'), '<span>', '</span>'); ?></span> |
|
455 | 455 | <?php } else { ?> |
456 | - <span class="addon-status"><?php echo sprintf( esc_html__( 'Status: %1$sActive%2$s', 'google-analytics-for-wordpress'), '<span>', '</span>' ); ?></span> |
|
456 | + <span class="addon-status"><?php echo sprintf(esc_html__('Status: %1$sActive%2$s', 'google-analytics-for-wordpress'), '<span>', '</span>'); ?></span> |
|
457 | 457 | <?php } ?> |
458 | - <?php if ( ( is_multisite() && is_network_admin() && $ms_active ) || ! is_multisite() || ( is_multisite() && !is_network_admin() && !$ms_active && $ss_active ) ) { ?> |
|
458 | + <?php if ((is_multisite() && is_network_admin() && $ms_active) || ! is_multisite() || (is_multisite() && ! is_network_admin() && ! $ms_active && $ss_active)) { ?> |
|
459 | 459 | <div class="monsterinsights-addon-action"> |
460 | - <a class="button button-primary monsterinsights-addon-action-button monsterinsights-deactivate-addon" href="#" rel="<?php echo esc_attr( $plugin_basename ); ?>"> |
|
460 | + <a class="button button-primary monsterinsights-addon-action-button monsterinsights-deactivate-addon" href="#" rel="<?php echo esc_attr($plugin_basename); ?>"> |
|
461 | 461 | <i class="monsterinsights-toggle-on"></i> |
462 | - <?php if ( is_multisite() && is_network_admin() && $ms_active ) { ?> |
|
463 | - <?php esc_html_e( 'Network deactivate', 'google-analytics-for-wordpress' ); ?> |
|
464 | - <?php } else if ( is_multisite() && !is_network_admin() && !$ms_active && $ss_active ) { ?> |
|
465 | - <?php esc_html_e( 'Deactivate', 'google-analytics-for-wordpress' ); ?> |
|
462 | + <?php if (is_multisite() && is_network_admin() && $ms_active) { ?> |
|
463 | + <?php esc_html_e('Network deactivate', 'google-analytics-for-wordpress'); ?> |
|
464 | + <?php } else if (is_multisite() && ! is_network_admin() && ! $ms_active && $ss_active) { ?> |
|
465 | + <?php esc_html_e('Deactivate', 'google-analytics-for-wordpress'); ?> |
|
466 | 466 | <?php } else { ?> |
467 | - <?php esc_html_e( 'Deactivate', 'google-analytics-for-wordpress' ); ?> |
|
467 | + <?php esc_html_e('Deactivate', 'google-analytics-for-wordpress'); ?> |
|
468 | 468 | <?php } ?> |
469 | 469 | </a> |
470 | 470 | <span class="spinner google-analytics-for-wordpress-spinner"></span> |
@@ -478,18 +478,18 @@ discard block |
||
478 | 478 | ?> |
479 | 479 | <div class="monsterinsights-addon-inactive monsterinsights-addon-message"> |
480 | 480 | <div class="interior"> |
481 | - <?php if ( $ms_active ) { ?> |
|
482 | - <span class="addon-status"><?php echo sprintf( esc_html__( 'Status: %1$sNetwork Inactive%2$s', 'google-analytics-for-wordpress'), '<span>', '</span>' ); ?></span> |
|
481 | + <?php if ($ms_active) { ?> |
|
482 | + <span class="addon-status"><?php echo sprintf(esc_html__('Status: %1$sNetwork Inactive%2$s', 'google-analytics-for-wordpress'), '<span>', '</span>'); ?></span> |
|
483 | 483 | <?php } else { ?> |
484 | - <span class="addon-status"><?php echo sprintf( esc_html__( 'Status: %1$sInactive%2$s', 'google-analytics-for-wordpress'), '<span>', '</span>' ); ?></span> |
|
484 | + <span class="addon-status"><?php echo sprintf(esc_html__('Status: %1$sInactive%2$s', 'google-analytics-for-wordpress'), '<span>', '</span>'); ?></span> |
|
485 | 485 | <?php } ?> |
486 | 486 | <div class="monsterinsights-addon-action"> |
487 | - <a class="button button-primary monsterinsights-addon-action-button monsterinsights-activate-addon" href="#" rel="<?php echo esc_attr( $plugin_basename ); ?>"> |
|
487 | + <a class="button button-primary monsterinsights-addon-action-button monsterinsights-activate-addon" href="#" rel="<?php echo esc_attr($plugin_basename); ?>"> |
|
488 | 488 | <i class="monsterinsights-toggle-on"></i> |
489 | - <?php if ( is_multisite() && is_network_admin() && ! $ms_active ) { ?> |
|
490 | - <?php esc_html_e( 'Network activate', 'google-analytics-for-wordpress' ); ?> |
|
489 | + <?php if (is_multisite() && is_network_admin() && ! $ms_active) { ?> |
|
490 | + <?php esc_html_e('Network activate', 'google-analytics-for-wordpress'); ?> |
|
491 | 491 | <?php } else { ?> |
492 | - <?php esc_html_e( 'Activate', 'google-analytics-for-wordpress' ); ?> |
|
492 | + <?php esc_html_e('Activate', 'google-analytics-for-wordpress'); ?> |
|
493 | 493 | <?php } ?> |
494 | 494 | </a> |
495 | 495 | <span class="spinner monsterinsights-spinner"></span> |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -18,16 +18,16 @@ discard block |
||
18 | 18 | $current_screen = get_current_screen(); |
19 | 19 | global $admin_page_hooks; |
20 | 20 | |
21 | - if ( ! is_object( $current_screen ) || empty( $current_screen->id ) || empty( $admin_page_hooks ) ) { |
|
21 | + if ( ! is_object($current_screen) || empty($current_screen->id) || empty($admin_page_hooks)) { |
|
22 | 22 | return false; |
23 | 23 | } |
24 | 24 | |
25 | 25 | $settings_page = false; |
26 | - if ( ! empty( $admin_page_hooks['monsterinsights_dashboard'] ) && $current_screen->id === $admin_page_hooks['monsterinsights_dashboard'] . '_page_monsterinsights_settings' ) { |
|
26 | + if ( ! empty($admin_page_hooks['monsterinsights_dashboard']) && $current_screen->id === $admin_page_hooks['monsterinsights_dashboard'] . '_page_monsterinsights_settings') { |
|
27 | 27 | $settings_page = true; |
28 | 28 | } |
29 | 29 | |
30 | - if ( $current_screen->id === 'toplevel_page_monsterinsights_settings' ) { |
|
30 | + if ($current_screen->id === 'toplevel_page_monsterinsights_settings') { |
|
31 | 31 | $settings_page = true; |
32 | 32 | } |
33 | 33 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * not be used by other developers. This hook's behavior may be modified |
52 | 52 | * or the hook may be removed at any time, without warning. |
53 | 53 | */ |
54 | - do_action( 'monsterinsights_head' ); |
|
54 | + do_action('monsterinsights_head'); |
|
55 | 55 | ?> |
56 | 56 | <?php echo monsterinsights_ublock_notice(); ?> |
57 | 57 | |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | <h1 id="monsterinsights-settings-page-main-nav" class="monsterinsights-main-nav-container monsterinsights-nav-container" data-container="#monsterinsights-settings-pages"> |
60 | 60 | <a class="monsterinsights-main-nav-item monsterinsights-nav-item monsterinsights-spacing-item" href="#"> </a> |
61 | 61 | |
62 | - <a class="monsterinsights-main-nav-item monsterinsights-nav-item monsterinsights-active" href="#monsterinsights-main-tab-general" title="<?php echo esc_attr( __( 'General', 'google-analytics-for-wordpress' ) ); ?>"> |
|
63 | - <?php echo esc_html__( 'General', 'google-analytics-for-wordpress' ); ?> |
|
62 | + <a class="monsterinsights-main-nav-item monsterinsights-nav-item monsterinsights-active" href="#monsterinsights-main-tab-general" title="<?php echo esc_attr(__('General', 'google-analytics-for-wordpress')); ?>"> |
|
63 | + <?php echo esc_html__('General', 'google-analytics-for-wordpress'); ?> |
|
64 | 64 | </a> |
65 | 65 | |
66 | - <a class="monsterinsights-main-nav-item monsterinsights-nav-item" href="#monsterinsights-main-tab-tracking" title="<?php echo esc_attr( __( 'Tracking', 'google-analytics-for-wordpress' ) ); ?>"> |
|
67 | - <?php echo esc_html__( 'Tracking', 'google-analytics-for-wordpress' ); ?> |
|
66 | + <a class="monsterinsights-main-nav-item monsterinsights-nav-item" href="#monsterinsights-main-tab-tracking" title="<?php echo esc_attr(__('Tracking', 'google-analytics-for-wordpress')); ?>"> |
|
67 | + <?php echo esc_html__('Tracking', 'google-analytics-for-wordpress'); ?> |
|
68 | 68 | </a> |
69 | 69 | <!-- |
70 | 70 | <a class="monsterinsights-main-nav-item monsterinsights-nav-item" href="#monsterinsights-main-tab-status" title="<?php //echo esc_attr( __( 'Status', 'google-analytics-for-wordpress' ) ); ?>"> |
@@ -109,24 +109,24 @@ discard block |
||
109 | 109 | */ |
110 | 110 | function monsterinsights_save_general_settings_page() { |
111 | 111 | |
112 | - if ( ! monsterinsights_is_settings_page() ) { |
|
112 | + if ( ! monsterinsights_is_settings_page()) { |
|
113 | 113 | return; |
114 | 114 | } |
115 | 115 | |
116 | 116 | // Check if user pressed the 'Update' button and nonce is valid |
117 | - if ( ! isset( $_POST['monsterinsights-settings-submit'] ) ) { |
|
117 | + if ( ! isset($_POST['monsterinsights-settings-submit'])) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
121 | - if ( ! wp_verify_nonce( $_POST['monsterinsights-settings-nonce'], 'monsterinsights-settings-nonce' ) ) { |
|
121 | + if ( ! wp_verify_nonce($_POST['monsterinsights-settings-nonce'], 'monsterinsights-settings-nonce')) { |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
125 | - if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
125 | + if ( ! current_user_can('monsterinsights_save_settings')) { |
|
126 | 126 | return; |
127 | 127 | } |
128 | 128 | |
129 | - if ( ! empty( $_POST['monsterinsights_settings_tab'] ) && $_POST['monsterinsights_settings_tab'] === 'general' ) { |
|
129 | + if ( ! empty($_POST['monsterinsights_settings_tab']) && $_POST['monsterinsights_settings_tab'] === 'general') { |
|
130 | 130 | /** |
131 | 131 | * Developer Alert: |
132 | 132 | * |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | * not be used by other developers. This hook's behavior may be modified |
135 | 135 | * or the hook may be removed at any time, without warning. |
136 | 136 | */ |
137 | - do_action( 'monsterinsights_settings_save_general' ); |
|
137 | + do_action('monsterinsights_settings_save_general'); |
|
138 | 138 | } |
139 | 139 | } |
140 | -add_action( 'current_screen', 'monsterinsights_save_general_settings_page' ); |
|
140 | +add_action('current_screen', 'monsterinsights_save_general_settings_page'); |
|
141 | 141 | |
142 | 142 | /** |
143 | 143 | * Outputs a WordPress style notification to tell the user settings were saved |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @return void |
149 | 149 | */ |
150 | 150 | function monsterinsights_updated_settings() { |
151 | - echo monsterinsights_get_message( 'success', esc_html__( 'Settings saved successfully.', 'google-analytics-for-wordpress' ) ); |
|
151 | + echo monsterinsights_get_message('success', esc_html__('Settings saved successfully.', 'google-analytics-for-wordpress')); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return void |
161 | 161 | */ |
162 | 162 | function monsterinsights_invalid_ua_code() { |
163 | - echo monsterinsights_get_message( 'error', esc_html__( 'Invalid UA code.', 'google-analytics-for-wordpress' ) ); |
|
163 | + echo monsterinsights_get_message('error', esc_html__('Invalid UA code.', 'google-analytics-for-wordpress')); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -176,20 +176,20 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return void |
178 | 178 | */ |
179 | -function monsterinsights_make_checkbox( $option_id, $title = '', $description = '' ) { |
|
180 | - $option_value = monsterinsights_get_option( $option_id, 0 ); |
|
181 | - $option_class = str_replace( '_', '-', $option_id ); |
|
179 | +function monsterinsights_make_checkbox($option_id, $title = '', $description = '') { |
|
180 | + $option_value = monsterinsights_get_option($option_id, 0); |
|
181 | + $option_class = str_replace('_', '-', $option_id); |
|
182 | 182 | ob_start(); |
183 | 183 | ?> |
184 | - <tr id="monsterinsights-input-<?php echo esc_attr( $option_class ); ?>"> |
|
185 | - <?php if ( !empty ( $title ) ) { ?> |
|
184 | + <tr id="monsterinsights-input-<?php echo esc_attr($option_class); ?>"> |
|
185 | + <?php if ( ! empty ($title)) { ?> |
|
186 | 186 | <th scope="row"> |
187 | - <label for="monsterinsights-<?php echo esc_attr( $option_class ); ?>"><?php echo $title; ?></label> |
|
187 | + <label for="monsterinsights-<?php echo esc_attr($option_class); ?>"><?php echo $title; ?></label> |
|
188 | 188 | </th> |
189 | 189 | <?php } ?> |
190 | 190 | <td> |
191 | - <input type="checkbox" id="monsterinsights-<?php echo esc_attr( $option_class ); ?>" name="<?php echo esc_attr( $option_id ); ?>" <?php checked( $option_value, 1 ); ?> /> |
|
192 | - <?php if ( ! empty ( $description ) ) { ?> |
|
191 | + <input type="checkbox" id="monsterinsights-<?php echo esc_attr($option_class); ?>" name="<?php echo esc_attr($option_id); ?>" <?php checked($option_value, 1); ?> /> |
|
192 | + <?php if ( ! empty ($description)) { ?> |
|
193 | 193 | <p class="description"> |
194 | 194 | <?php echo $description; ?> |
195 | 195 | </p> |
@@ -204,109 +204,109 @@ discard block |
||
204 | 204 | |
205 | 205 | function monsterinsights_switch_to_analyticsjs() { |
206 | 206 | $nonce = ''; |
207 | - if ( ! empty( $_REQUEST['monsterinsights-switch-to-analyticsjs-nonce'] ) ) { |
|
207 | + if ( ! empty($_REQUEST['monsterinsights-switch-to-analyticsjs-nonce'])) { |
|
208 | 208 | $nonce = 'monsterinsights-switch-to-analyticsjs-nonce'; |
209 | - } else if ( ! empty( $_REQUEST['_wpnonce'] ) ) { |
|
209 | + } else if ( ! empty($_REQUEST['_wpnonce'])) { |
|
210 | 210 | $nonce = '_wpnonce'; |
211 | 211 | } |
212 | 212 | |
213 | - if ( empty( $nonce ) ) { |
|
213 | + if (empty($nonce)) { |
|
214 | 214 | return; |
215 | 215 | } |
216 | 216 | |
217 | - if ( ! wp_verify_nonce( $_REQUEST[$nonce], 'monsterinsights-switch-to-analyticsjs-nonce' ) ) { |
|
217 | + if ( ! wp_verify_nonce($_REQUEST[$nonce], 'monsterinsights-switch-to-analyticsjs-nonce')) { |
|
218 | 218 | return; |
219 | 219 | } |
220 | 220 | |
221 | - if ( empty( $_REQUEST['monsterinsights-action'] ) || $_REQUEST['monsterinsights-action'] !== 'switch_to_analyticsjs' ) { |
|
221 | + if (empty($_REQUEST['monsterinsights-action']) || $_REQUEST['monsterinsights-action'] !== 'switch_to_analyticsjs') { |
|
222 | 222 | return; |
223 | 223 | } |
224 | 224 | |
225 | - if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
226 | - wp_die( esc_html__( 'You do not have permission to manage MonsterInsights settings', 'google-analytics-for-wordpress' ), esc_html__( 'Error', 'google-analytics-for-wordpress' ), array( 'response' => 403 ) ); |
|
225 | + if ( ! current_user_can('monsterinsights_save_settings')) { |
|
226 | + wp_die(esc_html__('You do not have permission to manage MonsterInsights settings', 'google-analytics-for-wordpress'), esc_html__('Error', 'google-analytics-for-wordpress'), array('response' => 403)); |
|
227 | 227 | } |
228 | 228 | |
229 | - $return = ''; |
|
230 | - if ( ! empty( $_REQUEST['return'] ) && monsterinsights_is_settings_tab( $_REQUEST['return'] ) ) { |
|
231 | - $return = admin_url( 'admin.php?page=monsterinsights_settings&monsterinsights-message=tracking_mode_switched#monsterinsights-main-tab-tracking?monsterinsights-sub-tab-') . $_REQUEST['return']; |
|
232 | - $return = add_query_arg( 'return', $_REQUEST['return'], $return ); |
|
229 | + $return = ''; |
|
230 | + if ( ! empty($_REQUEST['return']) && monsterinsights_is_settings_tab($_REQUEST['return'])) { |
|
231 | + $return = admin_url('admin.php?page=monsterinsights_settings&monsterinsights-message=tracking_mode_switched#monsterinsights-main-tab-tracking?monsterinsights-sub-tab-') . $_REQUEST['return']; |
|
232 | + $return = add_query_arg('return', $_REQUEST['return'], $return); |
|
233 | 233 | } else { |
234 | - $return = admin_url( 'admin.php?page=monsterinsights_settings&monsterinsights-message=tracking_mode_switched'); |
|
234 | + $return = admin_url('admin.php?page=monsterinsights_settings&monsterinsights-message=tracking_mode_switched'); |
|
235 | 235 | } |
236 | - monsterinsights_update_option( 'tracking_mode', 'analytics' ); |
|
237 | - wp_safe_redirect( $return );exit; |
|
236 | + monsterinsights_update_option('tracking_mode', 'analytics'); |
|
237 | + wp_safe_redirect($return); exit; |
|
238 | 238 | } |
239 | -add_action( 'admin_init', 'monsterinsights_switch_to_analyticsjs',9 ); |
|
239 | +add_action('admin_init', 'monsterinsights_switch_to_analyticsjs', 9); |
|
240 | 240 | |
241 | 241 | function monsterinsights_switched_to_analyticsjs() { |
242 | - echo monsterinsights_get_message( 'success', esc_html__( 'Successfully migrated to Universal Analytics (analytics.js)!', 'google-analytics-for-wordpress' ) ); |
|
242 | + echo monsterinsights_get_message('success', esc_html__('Successfully migrated to Universal Analytics (analytics.js)!', 'google-analytics-for-wordpress')); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | function monsterinsights_switch_to_analyticsjs_show_notice() { |
246 | - if ( empty( $_REQUEST['monsterinsights-message'] ) || $_REQUEST['monsterinsights-message'] !== 'tracking_mode_switched' ) { |
|
246 | + if (empty($_REQUEST['monsterinsights-message']) || $_REQUEST['monsterinsights-message'] !== 'tracking_mode_switched') { |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | |
250 | - if ( ! empty( $_REQUEST['return'] ) && monsterinsights_is_settings_tab( $_REQUEST['return'] ) ) { |
|
251 | - add_action( 'monsterinsights_tracking_' . $_REQUEST['return'] . '_tab_notice', 'monsterinsights_switched_to_analyticsjs' ); |
|
250 | + if ( ! empty($_REQUEST['return']) && monsterinsights_is_settings_tab($_REQUEST['return'])) { |
|
251 | + add_action('monsterinsights_tracking_' . $_REQUEST['return'] . '_tab_notice', 'monsterinsights_switched_to_analyticsjs'); |
|
252 | 252 | } else { |
253 | - add_action( 'monsterinsights_settings_general_tab_notice', 'monsterinsights_switched_to_analyticsjs' ); |
|
253 | + add_action('monsterinsights_settings_general_tab_notice', 'monsterinsights_switched_to_analyticsjs'); |
|
254 | 254 | } |
255 | 255 | } |
256 | -add_action( 'admin_init', 'monsterinsights_switch_to_analyticsjs_show_notice', 11 ); |
|
256 | +add_action('admin_init', 'monsterinsights_switch_to_analyticsjs_show_notice', 11); |
|
257 | 257 | |
258 | 258 | |
259 | 259 | |
260 | 260 | function monsterinsights_switch_to_jsevents() { |
261 | 261 | $nonce = ''; |
262 | - if ( ! empty( $_REQUEST['monsterinsights-switch-to-jsevents-nonce'] ) ) { |
|
262 | + if ( ! empty($_REQUEST['monsterinsights-switch-to-jsevents-nonce'])) { |
|
263 | 263 | $nonce = 'monsterinsights-switch-to-jsevents-nonce'; |
264 | - } else if ( ! empty( $_REQUEST['_wpnonce'] ) ) { |
|
264 | + } else if ( ! empty($_REQUEST['_wpnonce'])) { |
|
265 | 265 | $nonce = '_wpnonce'; |
266 | 266 | } |
267 | 267 | |
268 | - if ( empty( $nonce ) ) { |
|
268 | + if (empty($nonce)) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | |
272 | - if ( ! wp_verify_nonce( $_REQUEST[$nonce], 'monsterinsights-switch-to-jsevents-nonce' ) ) { |
|
272 | + if ( ! wp_verify_nonce($_REQUEST[$nonce], 'monsterinsights-switch-to-jsevents-nonce')) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | - if ( empty( $_REQUEST['monsterinsights-action'] ) || $_REQUEST['monsterinsights-action'] !== 'switch_to_jsevents' ) { |
|
276 | + if (empty($_REQUEST['monsterinsights-action']) || $_REQUEST['monsterinsights-action'] !== 'switch_to_jsevents') { |
|
277 | 277 | return; |
278 | 278 | } |
279 | 279 | |
280 | - if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
281 | - wp_die( esc_html__( 'You do not have permission to manage MonsterInsights settings', 'google-analytics-for-wordpress' ), esc_html__( 'Error', 'google-analytics-for-wordpress' ), array( 'response' => 403 ) ); |
|
280 | + if ( ! current_user_can('monsterinsights_save_settings')) { |
|
281 | + wp_die(esc_html__('You do not have permission to manage MonsterInsights settings', 'google-analytics-for-wordpress'), esc_html__('Error', 'google-analytics-for-wordpress'), array('response' => 403)); |
|
282 | 282 | } |
283 | 283 | |
284 | - $return = ''; |
|
285 | - if ( ! empty( $_REQUEST['return'] ) && monsterinsights_is_settings_tab( $_REQUEST['return'] ) ) { |
|
286 | - $return = admin_url( 'admin.php?page=monsterinsights_settings&monsterinsights-message=jsvents_mode_switched#monsterinsights-main-tab-tracking?monsterinsights-sub-tab-') . $_REQUEST['return']; |
|
287 | - $return = add_query_arg( 'return', $_REQUEST['return'], $return ); |
|
284 | + $return = ''; |
|
285 | + if ( ! empty($_REQUEST['return']) && monsterinsights_is_settings_tab($_REQUEST['return'])) { |
|
286 | + $return = admin_url('admin.php?page=monsterinsights_settings&monsterinsights-message=jsvents_mode_switched#monsterinsights-main-tab-tracking?monsterinsights-sub-tab-') . $_REQUEST['return']; |
|
287 | + $return = add_query_arg('return', $_REQUEST['return'], $return); |
|
288 | 288 | } else { |
289 | - $return = admin_url( 'admin.php?page=monsterinsights_settings&monsterinsights-message=jsvents_mode_switched'); |
|
289 | + $return = admin_url('admin.php?page=monsterinsights_settings&monsterinsights-message=jsvents_mode_switched'); |
|
290 | 290 | } |
291 | - monsterinsights_update_option( 'events_mode', 'js' ); |
|
292 | - wp_safe_redirect( $return );exit; |
|
291 | + monsterinsights_update_option('events_mode', 'js'); |
|
292 | + wp_safe_redirect($return); exit; |
|
293 | 293 | } |
294 | -add_action( 'admin_init', 'monsterinsights_switch_to_jsevents',9 ); |
|
294 | +add_action('admin_init', 'monsterinsights_switch_to_jsevents', 9); |
|
295 | 295 | |
296 | 296 | function monsterinsights_switched_to_jsevents() { |
297 | - echo monsterinsights_get_message( 'success', esc_html__( 'Successfully migrated to JS events tracking!', 'google-analytics-for-wordpress' ) ); |
|
297 | + echo monsterinsights_get_message('success', esc_html__('Successfully migrated to JS events tracking!', 'google-analytics-for-wordpress')); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | function monsterinsights_switch_to_jsevents_show_notice() { |
301 | - if ( empty( $_REQUEST['monsterinsights-message'] ) || $_REQUEST['monsterinsights-message'] !== 'jsvents_mode_switched' ) { |
|
301 | + if (empty($_REQUEST['monsterinsights-message']) || $_REQUEST['monsterinsights-message'] !== 'jsvents_mode_switched') { |
|
302 | 302 | return; |
303 | 303 | } |
304 | 304 | |
305 | - $allowed_tabs = array( 'engagement', 'performance', 'ecommerce', 'demographics', 'dimensions', 'goptimize' ); |
|
306 | - if ( ! empty( $_REQUEST['return'] ) && in_array( $_REQUEST['return'], $allowed_tabs ) ) { |
|
307 | - add_action( 'monsterinsights_tracking_' . $_REQUEST['return'] . '_tab_notice', 'monsterinsights_switched_to_jsevents' ); |
|
305 | + $allowed_tabs = array('engagement', 'performance', 'ecommerce', 'demographics', 'dimensions', 'goptimize'); |
|
306 | + if ( ! empty($_REQUEST['return']) && in_array($_REQUEST['return'], $allowed_tabs)) { |
|
307 | + add_action('monsterinsights_tracking_' . $_REQUEST['return'] . '_tab_notice', 'monsterinsights_switched_to_jsevents'); |
|
308 | 308 | } else { |
309 | - add_action( 'monsterinsights_settings_general_tab_notice', 'monsterinsights_switched_to_jsevents' ); |
|
309 | + add_action('monsterinsights_settings_general_tab_notice', 'monsterinsights_switched_to_jsevents'); |
|
310 | 310 | } |
311 | 311 | } |
312 | -add_action( 'admin_init', 'monsterinsights_switch_to_jsevents_show_notice', 11 ); |
|
313 | 312 | \ No newline at end of file |
313 | +add_action('admin_init', 'monsterinsights_switch_to_jsevents_show_notice', 11); |
|
314 | 314 | \ No newline at end of file |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | } |
212 | 212 | |
213 | 213 | if ( empty( $nonce ) ) { |
214 | - return; |
|
214 | + return; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | if ( ! wp_verify_nonce( $_REQUEST[$nonce], 'monsterinsights-switch-to-analyticsjs-nonce' ) ) { |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | } |
267 | 267 | |
268 | 268 | if ( empty( $nonce ) ) { |
269 | - return; |
|
269 | + return; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | if ( ! wp_verify_nonce( $_REQUEST[$nonce], 'monsterinsights-switch-to-jsevents-nonce' ) ) { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if ( ! defined('ABSPATH')) { |
|
4 | 4 | exit; |
5 | 5 | } |
6 | 6 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * not be used by other developers. This hook's behavior may be modified |
21 | 21 | * or the hook may be removed at any time, without warning. |
22 | 22 | */ |
23 | - do_action( 'monsterinsights_head' ); |
|
23 | + do_action('monsterinsights_head'); |
|
24 | 24 | ?> |
25 | 25 | <?php echo monsterinsights_ublock_notice(); ?> |
26 | 26 | |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | <h1 id="monsterinsights-tools-page-main-nav" class="monsterinsights-main-nav-container monsterinsights-nav-container" data-container="#monsterinsights-tools-pages"> |
29 | 29 | <a class="monsterinsights-main-nav-item monsterinsights-nav-item monsterinsights-spacing-item" href="#"> </a> |
30 | 30 | |
31 | - <a class="monsterinsights-main-nav-item monsterinsights-nav-item monsterinsights-active" href="#monsterinsights-main-tab-settings" title="<?php echo esc_attr( __( 'Import/Export', 'google-analytics-for-wordpress' ) ); ?>"> |
|
32 | - <?php echo esc_html__( 'Import/Export', 'google-analytics-for-wordpress' ); ?> |
|
31 | + <a class="monsterinsights-main-nav-item monsterinsights-nav-item monsterinsights-active" href="#monsterinsights-main-tab-settings" title="<?php echo esc_attr(__('Import/Export', 'google-analytics-for-wordpress')); ?>"> |
|
32 | + <?php echo esc_html__('Import/Export', 'google-analytics-for-wordpress'); ?> |
|
33 | 33 | </a> |
34 | 34 | |
35 | - <a class="monsterinsights-main-nav-item monsterinsights-nav-item" href="#monsterinsights-main-tab-url-builder" title="<?php echo esc_attr( __( 'Campaign URL Builder', 'google-analytics-for-wordpress' ) ); ?>"> |
|
36 | - <?php echo esc_html__( 'URL Builder', 'google-analytics-for-wordpress' ); ?> |
|
35 | + <a class="monsterinsights-main-nav-item monsterinsights-nav-item" href="#monsterinsights-main-tab-url-builder" title="<?php echo esc_attr(__('Campaign URL Builder', 'google-analytics-for-wordpress')); ?>"> |
|
36 | + <?php echo esc_html__('URL Builder', 'google-analytics-for-wordpress'); ?> |
|
37 | 37 | </a> |
38 | 38 | </h1> |
39 | 39 | |
@@ -51,27 +51,27 @@ discard block |
||
51 | 51 | <?php |
52 | 52 | } |
53 | 53 | |
54 | -function monsterinsights_tools_url_builder_tab(){ |
|
55 | - do_action( 'monsterinsights_tools_url_builder_tab' ); |
|
54 | +function monsterinsights_tools_url_builder_tab() { |
|
55 | + do_action('monsterinsights_tools_url_builder_tab'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | function monsterinsights_tools_settings_tab() { |
59 | - ob_start();?> |
|
60 | - <h2><?php echo esc_html__( 'Setting Tools', 'google-analytics-for-wordpress' );?></h2> |
|
61 | - <p><?php echo esc_html__( 'You can use the below tools to import settings from other MonsterInsights websites or export settings to import into another MonsterInsights install.', 'google-analytics-for-wordpress' ); ?> </p> |
|
59 | + ob_start(); ?> |
|
60 | + <h2><?php echo esc_html__('Setting Tools', 'google-analytics-for-wordpress'); ?></h2> |
|
61 | + <p><?php echo esc_html__('You can use the below tools to import settings from other MonsterInsights websites or export settings to import into another MonsterInsights install.', 'google-analytics-for-wordpress'); ?> </p> |
|
62 | 62 | <br /> |
63 | 63 | <table class="form-table"> |
64 | 64 | <tbody> |
65 | 65 | <tr> |
66 | 66 | <th scope="row"> |
67 | 67 | <label for="monsterinsights-import-settings"> |
68 | - <?php echo esc_html__( 'Import Settings', 'google-analytics-for-wordpress' );?> |
|
68 | + <?php echo esc_html__('Import Settings', 'google-analytics-for-wordpress'); ?> |
|
69 | 69 | </label> |
70 | 70 | </th> |
71 | 71 | <td> |
72 | 72 | <?php |
73 | - if ( ! empty( $_REQUEST['action'] ) && ! empty( $_REQUEST['result'] ) && $_REQUEST['action'] === 'import' && $_REQUEST['result'] === 'success' ){ |
|
74 | - echo MonsterInsights()->notices->display_inline_notice( 'monsterinsights_standard_notice', '', __( 'Successfully imported settings!','google-analytics-for-wordpress'), 'success', false, array() ); |
|
73 | + if ( ! empty($_REQUEST['action']) && ! empty($_REQUEST['result']) && $_REQUEST['action'] === 'import' && $_REQUEST['result'] === 'success') { |
|
74 | + echo MonsterInsights()->notices->display_inline_notice('monsterinsights_standard_notice', '', __('Successfully imported settings!', 'google-analytics-for-wordpress'), 'success', false, array()); |
|
75 | 75 | } |
76 | 76 | ?> |
77 | 77 | <form method="post" enctype="multipart/form-data"> |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | <input type="file" name="import_file"/> |
80 | 80 | <input type="hidden" name="monsterinsights_action" value="monsterinsights_import_settings" /> |
81 | 81 | </p> |
82 | - <p class="description"><?php echo esc_html__( 'Paste the import field content from another MonsterInsights site in above.', 'google-analytics-for-wordpress' );?></p> |
|
82 | + <p class="description"><?php echo esc_html__('Paste the import field content from another MonsterInsights site in above.', 'google-analytics-for-wordpress'); ?></p> |
|
83 | 83 | <p> |
84 | - <?php wp_nonce_field( 'monsterinsights_import_settings', 'monsterinsights_import_settings' ); ?> |
|
84 | + <?php wp_nonce_field('monsterinsights_import_settings', 'monsterinsights_import_settings'); ?> |
|
85 | 85 | </p> |
86 | 86 | <p> |
87 | - <?php submit_button( __( 'Import', 'google-analytics-for-wordpress' ), 'monsterinsights-action-button button button-action', 'submit', false ); ?> |
|
87 | + <?php submit_button(__('Import', 'google-analytics-for-wordpress'), 'monsterinsights-action-button button button-action', 'submit', false); ?> |
|
88 | 88 | </p> |
89 | 89 | </form> |
90 | 90 | </td> |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | <tr> |
93 | 93 | <th scope="row"> |
94 | 94 | <label for="monsterinsights-export-settings"> |
95 | - <?php echo esc_html__( 'Export Settings:', 'google-analytics-for-wordpress' );?> |
|
95 | + <?php echo esc_html__('Export Settings:', 'google-analytics-for-wordpress'); ?> |
|
96 | 96 | </label> |
97 | 97 | </th> |
98 | 98 | <td> |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | <input type="hidden" name="monsterinsights_action" value="monsterinsights_export_settings" /> |
102 | 102 | </p> |
103 | 103 | <p> |
104 | - <?php wp_nonce_field( 'monsterinsights_export_settings', 'monsterinsights_export_settings' ); ?> |
|
104 | + <?php wp_nonce_field('monsterinsights_export_settings', 'monsterinsights_export_settings'); ?> |
|
105 | 105 | </p> |
106 | 106 | <p> |
107 | - <?php submit_button( __( 'Export', 'google-analytics-for-wordpress' ), 'monsterinsights-settings-export monsterinsights-action-button button button-action', 'submit', false ); ?> |
|
107 | + <?php submit_button(__('Export', 'google-analytics-for-wordpress'), 'monsterinsights-settings-export monsterinsights-action-button button button-action', 'submit', false); ?> |
|
108 | 108 | </p> |
109 | 109 | </form> |
110 | 110 | </td> |
@@ -125,73 +125,73 @@ discard block |
||
125 | 125 | * @return void |
126 | 126 | */ |
127 | 127 | function monsterinsights_process_export_settings() { |
128 | - if ( !isset( $_POST['monsterinsights_action'] ) || empty( $_POST['monsterinsights_action'] ) ) { |
|
128 | + if ( ! isset($_POST['monsterinsights_action']) || empty($_POST['monsterinsights_action'])) { |
|
129 | 129 | return; |
130 | 130 | } |
131 | 131 | |
132 | - if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
132 | + if ( ! current_user_can('monsterinsights_save_settings')) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | - if ( $_POST['monsterinsights_action'] !== 'monsterinsights_export_settings' ){ |
|
136 | + if ($_POST['monsterinsights_action'] !== 'monsterinsights_export_settings') { |
|
137 | 137 | return; |
138 | 138 | } |
139 | 139 | |
140 | - if ( empty( $_POST['monsterinsights_export_settings'] ) || ! wp_verify_nonce( $_POST['monsterinsights_export_settings'], 'monsterinsights_export_settings' ) ) { |
|
140 | + if (empty($_POST['monsterinsights_export_settings']) || ! wp_verify_nonce($_POST['monsterinsights_export_settings'], 'monsterinsights_export_settings')) { |
|
141 | 141 | return; |
142 | 142 | } |
143 | 143 | |
144 | 144 | $settings = monsterinsights_export_settings(); |
145 | - ignore_user_abort( true ); |
|
145 | + ignore_user_abort(true); |
|
146 | 146 | |
147 | 147 | nocache_headers(); |
148 | - header( 'Content-Type: application/json; charset=utf-8' ); |
|
149 | - header( 'Content-Disposition: attachment; filename=monsterinsights-settings-export-' . date( 'm-d-Y' ) . '.json' ); |
|
150 | - header( "Expires: 0" ); |
|
148 | + header('Content-Type: application/json; charset=utf-8'); |
|
149 | + header('Content-Disposition: attachment; filename=monsterinsights-settings-export-' . date('m-d-Y') . '.json'); |
|
150 | + header("Expires: 0"); |
|
151 | 151 | |
152 | 152 | echo $settings; |
153 | 153 | exit; |
154 | 154 | } |
155 | -add_action( 'admin_init', 'monsterinsights_process_export_settings' ); |
|
155 | +add_action('admin_init', 'monsterinsights_process_export_settings'); |
|
156 | 156 | |
157 | 157 | function monsterinsights_import_settings() { |
158 | 158 | |
159 | - if ( !isset( $_POST['monsterinsights_action'] ) || empty( $_POST['monsterinsights_action'] ) ) { |
|
159 | + if ( ! isset($_POST['monsterinsights_action']) || empty($_POST['monsterinsights_action'])) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | - if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
163 | + if ( ! current_user_can('monsterinsights_save_settings')) { |
|
164 | 164 | return; |
165 | 165 | } |
166 | 166 | |
167 | - if ( $_POST['monsterinsights_action'] !== 'monsterinsights_import_settings' ){ |
|
167 | + if ($_POST['monsterinsights_action'] !== 'monsterinsights_import_settings') { |
|
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | - if ( !wp_verify_nonce( $_POST['monsterinsights_import_settings'], 'monsterinsights_import_settings' ) ) { |
|
171 | + if ( ! wp_verify_nonce($_POST['monsterinsights_import_settings'], 'monsterinsights_import_settings')) { |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | |
175 | - $extension = explode( '.', $_FILES['import_file']['name'] ); |
|
176 | - $extension = end( $extension ); |
|
175 | + $extension = explode('.', $_FILES['import_file']['name']); |
|
176 | + $extension = end($extension); |
|
177 | 177 | |
178 | - if ( $extension != 'json' ) { |
|
179 | - wp_die( __( 'Please upload a valid .json file', 'google-analytics-for-wordpress' ) ); |
|
178 | + if ($extension != 'json') { |
|
179 | + wp_die(__('Please upload a valid .json file', 'google-analytics-for-wordpress')); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | $import_file = $_FILES['import_file']['tmp_name']; |
183 | 183 | |
184 | - if ( empty( $import_file ) ) { |
|
185 | - wp_die( __( 'Please upload a file to import', 'google-analytics-for-wordpress' ) ); |
|
184 | + if (empty($import_file)) { |
|
185 | + wp_die(__('Please upload a file to import', 'google-analytics-for-wordpress')); |
|
186 | 186 | } |
187 | 187 | |
188 | - $file = file_get_contents( $import_file ); |
|
189 | - if ( empty( $file ) ) { |
|
190 | - wp_die( __( 'Please upload a real settings export file to import', 'google-analytics-for-wordpress' ) ); |
|
188 | + $file = file_get_contents($import_file); |
|
189 | + if (empty($file)) { |
|
190 | + wp_die(__('Please upload a real settings export file to import', 'google-analytics-for-wordpress')); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | // Retrieve the settings from the file and convert the json object to an array. |
194 | - $new_settings = json_decode( wp_json_encode( json_decode( $file ) ), true ); |
|
194 | + $new_settings = json_decode(wp_json_encode(json_decode($file)), true); |
|
195 | 195 | $settings = monsterinsights_get_options(); |
196 | 196 | $exclude = array( |
197 | 197 | 'analytics_profile', |
@@ -202,28 +202,28 @@ discard block |
||
202 | 202 | 'monsterinsights_oauth_status', |
203 | 203 | ); |
204 | 204 | |
205 | - foreach ( $exclude as $e ) { |
|
206 | - if ( ! empty( $new_settings[ $e ] ) ) { |
|
207 | - unset( $new_settings[ $e ] ); |
|
205 | + foreach ($exclude as $e) { |
|
206 | + if ( ! empty($new_settings[$e])) { |
|
207 | + unset($new_settings[$e]); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | - if ( ! is_super_admin() ) { |
|
212 | - if ( ! empty( $new_settings[ 'custom_code' ] ) ) { |
|
213 | - unset( $new_settings[ 'custom_code' ] ); |
|
211 | + if ( ! is_super_admin()) { |
|
212 | + if ( ! empty($new_settings['custom_code'])) { |
|
213 | + unset($new_settings['custom_code']); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | - foreach ( $exclude as $e ) { |
|
218 | - if ( ! empty( $settings[ $e ] ) ) { |
|
219 | - $new_settings = $settings[ $e ]; |
|
217 | + foreach ($exclude as $e) { |
|
218 | + if ( ! empty($settings[$e])) { |
|
219 | + $new_settings = $settings[$e]; |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | 223 | global $monsterinsights_settings; |
224 | 224 | $monsterinsights_settings = $new_settings; |
225 | 225 | |
226 | - update_option( monsterinsights_get_option_name(), $new_settings ); |
|
227 | - wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_tools&action=import&result=success#monsterinsights-main-tab-settings' ) ); exit; |
|
226 | + update_option(monsterinsights_get_option_name(), $new_settings); |
|
227 | + wp_safe_redirect(admin_url('admin.php?page=monsterinsights_tools&action=import&result=success#monsterinsights-main-tab-settings')); exit; |
|
228 | 228 | } |
229 | -add_action( 'admin_init', 'monsterinsights_import_settings' ); |
|
230 | 229 | \ No newline at end of file |
230 | +add_action('admin_init', 'monsterinsights_import_settings'); |
|
231 | 231 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; |
|
4 | + exit; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -13,15 +13,15 @@ discard block |
||
13 | 13 | * @return void |
14 | 14 | */ |
15 | 15 | function monsterinsights_tools_page() { |
16 | - /** |
|
17 | - * Developer Alert: |
|
18 | - * |
|
19 | - * Per the README, this is considered an internal hook and should |
|
20 | - * not be used by other developers. This hook's behavior may be modified |
|
21 | - * or the hook may be removed at any time, without warning. |
|
22 | - */ |
|
23 | - do_action( 'monsterinsights_head' ); |
|
24 | - ?> |
|
16 | + /** |
|
17 | + * Developer Alert: |
|
18 | + * |
|
19 | + * Per the README, this is considered an internal hook and should |
|
20 | + * not be used by other developers. This hook's behavior may be modified |
|
21 | + * or the hook may be removed at any time, without warning. |
|
22 | + */ |
|
23 | + do_action( 'monsterinsights_head' ); |
|
24 | + ?> |
|
25 | 25 | <?php echo monsterinsights_ublock_notice(); ?> |
26 | 26 | |
27 | 27 | <!-- Tabs --> |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | function monsterinsights_tools_url_builder_tab(){ |
55 | - do_action( 'monsterinsights_tools_url_builder_tab' ); |
|
55 | + do_action( 'monsterinsights_tools_url_builder_tab' ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | function monsterinsights_tools_settings_tab() { |
59 | - ob_start();?> |
|
59 | + ob_start();?> |
|
60 | 60 | <h2><?php echo esc_html__( 'Setting Tools', 'google-analytics-for-wordpress' );?></h2> |
61 | 61 | <p><?php echo esc_html__( 'You can use the below tools to import settings from other MonsterInsights websites or export settings to import into another MonsterInsights install.', 'google-analytics-for-wordpress' ); ?> </p> |
62 | 62 | <br /> |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | </th> |
71 | 71 | <td> |
72 | 72 | <?php |
73 | - if ( ! empty( $_REQUEST['action'] ) && ! empty( $_REQUEST['result'] ) && $_REQUEST['action'] === 'import' && $_REQUEST['result'] === 'success' ){ |
|
74 | - echo MonsterInsights()->notices->display_inline_notice( 'monsterinsights_standard_notice', '', __( 'Successfully imported settings!','google-analytics-for-wordpress'), 'success', false, array() ); |
|
75 | - } |
|
76 | - ?> |
|
73 | + if ( ! empty( $_REQUEST['action'] ) && ! empty( $_REQUEST['result'] ) && $_REQUEST['action'] === 'import' && $_REQUEST['result'] === 'success' ){ |
|
74 | + echo MonsterInsights()->notices->display_inline_notice( 'monsterinsights_standard_notice', '', __( 'Successfully imported settings!','google-analytics-for-wordpress'), 'success', false, array() ); |
|
75 | + } |
|
76 | + ?> |
|
77 | 77 | <form method="post" enctype="multipart/form-data"> |
78 | 78 | <p> |
79 | 79 | <input type="file" name="import_file"/> |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | </tbody> |
114 | 114 | </table> |
115 | 115 | <?php |
116 | - echo ob_get_clean(); |
|
116 | + echo ob_get_clean(); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -125,105 +125,105 @@ discard block |
||
125 | 125 | * @return void |
126 | 126 | */ |
127 | 127 | function monsterinsights_process_export_settings() { |
128 | - if ( !isset( $_POST['monsterinsights_action'] ) || empty( $_POST['monsterinsights_action'] ) ) { |
|
129 | - return; |
|
130 | - } |
|
128 | + if ( !isset( $_POST['monsterinsights_action'] ) || empty( $_POST['monsterinsights_action'] ) ) { |
|
129 | + return; |
|
130 | + } |
|
131 | 131 | |
132 | - if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
133 | - return; |
|
134 | - } |
|
132 | + if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
133 | + return; |
|
134 | + } |
|
135 | 135 | |
136 | - if ( $_POST['monsterinsights_action'] !== 'monsterinsights_export_settings' ){ |
|
137 | - return; |
|
138 | - } |
|
136 | + if ( $_POST['monsterinsights_action'] !== 'monsterinsights_export_settings' ){ |
|
137 | + return; |
|
138 | + } |
|
139 | 139 | |
140 | - if ( empty( $_POST['monsterinsights_export_settings'] ) || ! wp_verify_nonce( $_POST['monsterinsights_export_settings'], 'monsterinsights_export_settings' ) ) { |
|
141 | - return; |
|
142 | - } |
|
140 | + if ( empty( $_POST['monsterinsights_export_settings'] ) || ! wp_verify_nonce( $_POST['monsterinsights_export_settings'], 'monsterinsights_export_settings' ) ) { |
|
141 | + return; |
|
142 | + } |
|
143 | 143 | |
144 | - $settings = monsterinsights_export_settings(); |
|
145 | - ignore_user_abort( true ); |
|
144 | + $settings = monsterinsights_export_settings(); |
|
145 | + ignore_user_abort( true ); |
|
146 | 146 | |
147 | - nocache_headers(); |
|
148 | - header( 'Content-Type: application/json; charset=utf-8' ); |
|
149 | - header( 'Content-Disposition: attachment; filename=monsterinsights-settings-export-' . date( 'm-d-Y' ) . '.json' ); |
|
150 | - header( "Expires: 0" ); |
|
147 | + nocache_headers(); |
|
148 | + header( 'Content-Type: application/json; charset=utf-8' ); |
|
149 | + header( 'Content-Disposition: attachment; filename=monsterinsights-settings-export-' . date( 'm-d-Y' ) . '.json' ); |
|
150 | + header( "Expires: 0" ); |
|
151 | 151 | |
152 | - echo $settings; |
|
153 | - exit; |
|
152 | + echo $settings; |
|
153 | + exit; |
|
154 | 154 | } |
155 | 155 | add_action( 'admin_init', 'monsterinsights_process_export_settings' ); |
156 | 156 | |
157 | 157 | function monsterinsights_import_settings() { |
158 | 158 | |
159 | - if ( !isset( $_POST['monsterinsights_action'] ) || empty( $_POST['monsterinsights_action'] ) ) { |
|
160 | - return; |
|
161 | - } |
|
162 | - |
|
163 | - if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
164 | - return; |
|
165 | - } |
|
166 | - |
|
167 | - if ( $_POST['monsterinsights_action'] !== 'monsterinsights_import_settings' ){ |
|
168 | - return; |
|
169 | - } |
|
170 | - |
|
171 | - if ( !wp_verify_nonce( $_POST['monsterinsights_import_settings'], 'monsterinsights_import_settings' ) ) { |
|
172 | - return; |
|
173 | - } |
|
174 | - |
|
175 | - $extension = explode( '.', $_FILES['import_file']['name'] ); |
|
176 | - $extension = end( $extension ); |
|
177 | - |
|
178 | - if ( $extension != 'json' ) { |
|
179 | - wp_die( __( 'Please upload a valid .json file', 'google-analytics-for-wordpress' ) ); |
|
180 | - } |
|
181 | - |
|
182 | - $import_file = $_FILES['import_file']['tmp_name']; |
|
183 | - |
|
184 | - if ( empty( $import_file ) ) { |
|
185 | - wp_die( __( 'Please upload a file to import', 'google-analytics-for-wordpress' ) ); |
|
186 | - } |
|
187 | - |
|
188 | - $file = file_get_contents( $import_file ); |
|
189 | - if ( empty( $file ) ) { |
|
190 | - wp_die( __( 'Please upload a real settings export file to import', 'google-analytics-for-wordpress' ) ); |
|
191 | - } |
|
192 | - |
|
193 | - // Retrieve the settings from the file and convert the json object to an array. |
|
194 | - $new_settings = json_decode( wp_json_encode( json_decode( $file ) ), true ); |
|
195 | - $settings = monsterinsights_get_options(); |
|
196 | - $exclude = array( |
|
197 | - 'analytics_profile', |
|
198 | - 'analytics_profile_code', |
|
199 | - 'analytics_profile_name', |
|
200 | - 'oauth_version', |
|
201 | - 'cron_last_run', |
|
202 | - 'monsterinsights_oauth_status', |
|
203 | - ); |
|
204 | - |
|
205 | - foreach ( $exclude as $e ) { |
|
206 | - if ( ! empty( $new_settings[ $e ] ) ) { |
|
207 | - unset( $new_settings[ $e ] ); |
|
208 | - } |
|
209 | - } |
|
210 | - |
|
211 | - if ( ! is_super_admin() ) { |
|
212 | - if ( ! empty( $new_settings[ 'custom_code' ] ) ) { |
|
213 | - unset( $new_settings[ 'custom_code' ] ); |
|
214 | - } |
|
215 | - } |
|
216 | - |
|
217 | - foreach ( $exclude as $e ) { |
|
218 | - if ( ! empty( $settings[ $e ] ) ) { |
|
219 | - $new_settings = $settings[ $e ]; |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - global $monsterinsights_settings; |
|
224 | - $monsterinsights_settings = $new_settings; |
|
225 | - |
|
226 | - update_option( monsterinsights_get_option_name(), $new_settings ); |
|
227 | - wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_tools&action=import&result=success#monsterinsights-main-tab-settings' ) ); exit; |
|
159 | + if ( !isset( $_POST['monsterinsights_action'] ) || empty( $_POST['monsterinsights_action'] ) ) { |
|
160 | + return; |
|
161 | + } |
|
162 | + |
|
163 | + if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
164 | + return; |
|
165 | + } |
|
166 | + |
|
167 | + if ( $_POST['monsterinsights_action'] !== 'monsterinsights_import_settings' ){ |
|
168 | + return; |
|
169 | + } |
|
170 | + |
|
171 | + if ( !wp_verify_nonce( $_POST['monsterinsights_import_settings'], 'monsterinsights_import_settings' ) ) { |
|
172 | + return; |
|
173 | + } |
|
174 | + |
|
175 | + $extension = explode( '.', $_FILES['import_file']['name'] ); |
|
176 | + $extension = end( $extension ); |
|
177 | + |
|
178 | + if ( $extension != 'json' ) { |
|
179 | + wp_die( __( 'Please upload a valid .json file', 'google-analytics-for-wordpress' ) ); |
|
180 | + } |
|
181 | + |
|
182 | + $import_file = $_FILES['import_file']['tmp_name']; |
|
183 | + |
|
184 | + if ( empty( $import_file ) ) { |
|
185 | + wp_die( __( 'Please upload a file to import', 'google-analytics-for-wordpress' ) ); |
|
186 | + } |
|
187 | + |
|
188 | + $file = file_get_contents( $import_file ); |
|
189 | + if ( empty( $file ) ) { |
|
190 | + wp_die( __( 'Please upload a real settings export file to import', 'google-analytics-for-wordpress' ) ); |
|
191 | + } |
|
192 | + |
|
193 | + // Retrieve the settings from the file and convert the json object to an array. |
|
194 | + $new_settings = json_decode( wp_json_encode( json_decode( $file ) ), true ); |
|
195 | + $settings = monsterinsights_get_options(); |
|
196 | + $exclude = array( |
|
197 | + 'analytics_profile', |
|
198 | + 'analytics_profile_code', |
|
199 | + 'analytics_profile_name', |
|
200 | + 'oauth_version', |
|
201 | + 'cron_last_run', |
|
202 | + 'monsterinsights_oauth_status', |
|
203 | + ); |
|
204 | + |
|
205 | + foreach ( $exclude as $e ) { |
|
206 | + if ( ! empty( $new_settings[ $e ] ) ) { |
|
207 | + unset( $new_settings[ $e ] ); |
|
208 | + } |
|
209 | + } |
|
210 | + |
|
211 | + if ( ! is_super_admin() ) { |
|
212 | + if ( ! empty( $new_settings[ 'custom_code' ] ) ) { |
|
213 | + unset( $new_settings[ 'custom_code' ] ); |
|
214 | + } |
|
215 | + } |
|
216 | + |
|
217 | + foreach ( $exclude as $e ) { |
|
218 | + if ( ! empty( $settings[ $e ] ) ) { |
|
219 | + $new_settings = $settings[ $e ]; |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + global $monsterinsights_settings; |
|
224 | + $monsterinsights_settings = $new_settings; |
|
225 | + |
|
226 | + update_option( monsterinsights_get_option_name(), $new_settings ); |
|
227 | + wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_tools&action=import&result=success#monsterinsights-main-tab-settings' ) ); exit; |
|
228 | 228 | } |
229 | 229 | add_action( 'admin_init', 'monsterinsights_import_settings' ); |
230 | 230 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * not be used by other developers. This hook's behavior may be modified |
31 | 31 | * or the hook may be removed at any time, without warning. |
32 | 32 | */ |
33 | - $reports = apply_filters( 'monsterinsights_get_reports', array() ); |
|
33 | + $reports = apply_filters('monsterinsights_get_reports', array()); |
|
34 | 34 | return $reports; |
35 | 35 | } |
36 | 36 | |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | * not be used by other developers. This hook's behavior may be modified |
51 | 51 | * or the hook may be removed at any time, without warning. |
52 | 52 | */ |
53 | - do_action( 'monsterinsights_head' ); |
|
53 | + do_action('monsterinsights_head'); |
|
54 | 54 | |
55 | - if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
56 | - wp_die( esc_html__( 'Access denied' , 'google-analytics-for-wordpress' ) ); |
|
55 | + if ( ! current_user_can('monsterinsights_view_dashboard')) { |
|
56 | + wp_die(esc_html__('Access denied', 'google-analytics-for-wordpress')); |
|
57 | 57 | } |
58 | 58 | |
59 | - $dashboard_disabled = monsterinsights_get_option( 'dashboard_disabled', false ); |
|
60 | - $profile_enabled = monsterinsights_get_option( 'analytics_profile', false ); // not using profile |
|
61 | - $oauth_version = monsterinsights_get_option( 'oauth_version', '1.0' ); |
|
62 | - $last_run = monsterinsights_get_option( 'cron_last_run', false ); |
|
63 | - $failed = monsterinsights_get_option( 'cron_failed', false ); |
|
64 | - $pro_access_key = get_option( 'monsterinsights_pro_access_token', false ); |
|
65 | - $lite_access_key = get_option( 'monsterinsights_lite_access_token', false ); |
|
66 | - $needs_re_auth = ( ( $failed && ( $last_run === false || monsterinsights_hours_between( $last_run ) >= 48 ) ) || ( empty( $pro_access_key ) && empty( $lite_access_key ) ) || ( version_compare( $oauth_version, '1.0', '<' ) ) ) ? true : false; |
|
59 | + $dashboard_disabled = monsterinsights_get_option('dashboard_disabled', false); |
|
60 | + $profile_enabled = monsterinsights_get_option('analytics_profile', false); // not using profile |
|
61 | + $oauth_version = monsterinsights_get_option('oauth_version', '1.0'); |
|
62 | + $last_run = monsterinsights_get_option('cron_last_run', false); |
|
63 | + $failed = monsterinsights_get_option('cron_failed', false); |
|
64 | + $pro_access_key = get_option('monsterinsights_pro_access_token', false); |
|
65 | + $lite_access_key = get_option('monsterinsights_lite_access_token', false); |
|
66 | + $needs_re_auth = (($failed && ($last_run === false || monsterinsights_hours_between($last_run) >= 48)) || (empty($pro_access_key) && empty($lite_access_key)) || (version_compare($oauth_version, '1.0', '<'))) ? true : false; |
|
67 | 67 | ?> |
68 | 68 | <?php echo monsterinsights_ublock_notice(); ?> |
69 | 69 | |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | ?> |
75 | 75 | <a class="monsterinsights-main-nav-item monsterinsights-nav-item monsterinsights-spacing-item" href="#"> </a> |
76 | 76 | <?php |
77 | - foreach ( (array) monsterinsights_get_reports() as $id => $title ) { |
|
78 | - $class = ( 0 === $i ? 'monsterinsights-active' : '' ); |
|
77 | + foreach ((array) monsterinsights_get_reports() as $id => $title) { |
|
78 | + $class = (0 === $i ? 'monsterinsights-active' : ''); |
|
79 | 79 | ?> |
80 | - <a class="monsterinsights-main-nav-item monsterinsights-nav-item <?php echo $class; ?>" href="#monsterinsights-main-tab-<?php echo esc_attr( $id ); ?>" title="<?php echo esc_attr( $title ); ?>"> |
|
81 | - <?php echo esc_html( $title ); ?> |
|
80 | + <a class="monsterinsights-main-nav-item monsterinsights-nav-item <?php echo $class; ?>" href="#monsterinsights-main-tab-<?php echo esc_attr($id); ?>" title="<?php echo esc_attr($title); ?>"> |
|
81 | + <?php echo esc_html($title); ?> |
|
82 | 82 | </a> |
83 | 83 | <?php |
84 | 84 | $i++; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | <div class="monsterinsights-clear"> |
91 | 91 | <div class="monsterinsights-reports-action-bar"> |
92 | 92 | <div class="monsterinsights-reports-action-bar-title"> |
93 | - <?php esc_html_e( 'Reports', 'google-analytics-for-wordpress' );?> |
|
93 | + <?php esc_html_e('Reports', 'google-analytics-for-wordpress'); ?> |
|
94 | 94 | </div> |
95 | 95 | <div class="monsterinsights-reports-action-bar-actions"><?php |
96 | 96 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * not be used by other developers. This hook's behavior may be modified |
101 | 101 | * or the hook may be removed at any time, without warning. |
102 | 102 | */ |
103 | - do_action( 'monsterinsights_tab_reports_actions' ); |
|
103 | + do_action('monsterinsights_tab_reports_actions'); |
|
104 | 104 | ?> |
105 | 105 | </div> |
106 | 106 | </div> |
@@ -110,64 +110,64 @@ discard block |
||
110 | 110 | <h1 class="monsterinsights-hideme"></h1><!-- so wp notices are below the nav bar --> |
111 | 111 | <?php |
112 | 112 | $i = 0; |
113 | - foreach ( (array) monsterinsights_get_reports() as $id => $title ) { |
|
114 | - $class = ( 0 === $i ? 'monsterinsights-active' : '' ); |
|
113 | + foreach ((array) monsterinsights_get_reports() as $id => $title) { |
|
114 | + $class = (0 === $i ? 'monsterinsights-active' : ''); |
|
115 | 115 | ?> |
116 | - <div id="monsterinsights-main-tab-<?php echo esc_attr( $id ); ?>" class="monsterinsights-main-nav-tab monsterinsights-nav-tab <?php echo $class; ?>"> |
|
117 | - <?php if ( $dashboard_disabled ) { ?> |
|
116 | + <div id="monsterinsights-main-tab-<?php echo esc_attr($id); ?>" class="monsterinsights-main-nav-tab monsterinsights-nav-tab <?php echo $class; ?>"> |
|
117 | + <?php if ($dashboard_disabled) { ?> |
|
118 | 118 | <?php |
119 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
120 | - echo monsterinsights_get_message( 'error', sprintf( |
|
119 | + if (current_user_can('monsterinsights_save_settings')) { |
|
120 | + echo monsterinsights_get_message('error', sprintf( |
|
121 | 121 | sprintf( |
122 | - esc_html__( 'Please %1$senable the dashboard%2$s to see report data.', 'google-analytics-for-wordpress' ), |
|
123 | - '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
122 | + esc_html__('Please %1$senable the dashboard%2$s to see report data.', 'google-analytics-for-wordpress'), |
|
123 | + '<a href="' . admin_url('admin.php?page=monsterinsights_settings') . '">', |
|
124 | 124 | '</a>' |
125 | 125 | ) |
126 | - ) ); |
|
126 | + )); |
|
127 | 127 | } else { |
128 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
128 | + echo monsterinsights_get_message('error', esc_html__('The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress')); |
|
129 | 129 | } |
130 | 130 | ?> |
131 | - <?php } else if ( ! $profile_enabled ) { ?> |
|
131 | + <?php } else if ( ! $profile_enabled) { ?> |
|
132 | 132 | <?php |
133 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
134 | - echo monsterinsights_get_message( 'error', sprintf( |
|
133 | + if (current_user_can('monsterinsights_save_settings')) { |
|
134 | + echo monsterinsights_get_message('error', sprintf( |
|
135 | 135 | sprintf( |
136 | - esc_html__( 'Please %1$sauthenticate %2$swith Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ), |
|
137 | - '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
136 | + esc_html__('Please %1$sauthenticate %2$swith Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress'), |
|
137 | + '<a href="' . admin_url('admin.php?page=monsterinsights_settings') . '">', |
|
138 | 138 | '</a>' |
139 | 139 | ) |
140 | - ) ); |
|
140 | + )); |
|
141 | 141 | } else { |
142 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
142 | + echo monsterinsights_get_message('error', esc_html__('The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress')); |
|
143 | 143 | } |
144 | 144 | ?> |
145 | - <?php } else if ( $needs_re_auth ) { ?> |
|
145 | + <?php } else if ($needs_re_auth) { ?> |
|
146 | 146 | <?php |
147 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
148 | - echo monsterinsights_get_message( 'error', sprintf( |
|
147 | + if (current_user_can('monsterinsights_save_settings')) { |
|
148 | + echo monsterinsights_get_message('error', sprintf( |
|
149 | 149 | sprintf( |
150 | - esc_html__( 'Please %1$sre-authenticate%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ), |
|
151 | - '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
150 | + esc_html__('Please %1$sre-authenticate%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress'), |
|
151 | + '<a href="' . admin_url('admin.php?page=monsterinsights_settings') . '">', |
|
152 | 152 | '</a>' |
153 | 153 | ) |
154 | - ) ); |
|
154 | + )); |
|
155 | 155 | } else { |
156 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
156 | + echo monsterinsights_get_message('error', esc_html__('The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress')); |
|
157 | 157 | } |
158 | 158 | ?> |
159 | - <?php } else if ( $failed ) { ?> |
|
159 | + <?php } else if ($failed) { ?> |
|
160 | 160 | <?php |
161 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
162 | - echo monsterinsights_get_message( 'error', sprintf( |
|
161 | + if (current_user_can('monsterinsights_save_settings')) { |
|
162 | + echo monsterinsights_get_message('error', sprintf( |
|
163 | 163 | sprintf( |
164 | - esc_html__( 'Data is not up-to-date, there was an error in retrieving the data from Google Analytics. This error could be caused by several issues. If the error persists, please see %1$sthis page%2$s.', 'google-analytics-for-wordpress' ), |
|
164 | + esc_html__('Data is not up-to-date, there was an error in retrieving the data from Google Analytics. This error could be caused by several issues. If the error persists, please see %1$sthis page%2$s.', 'google-analytics-for-wordpress'), |
|
165 | 165 | '<a href="https://www.monsterinsights.com/docs/blocked-connection/">', |
166 | 166 | '</a>' |
167 | 167 | ) |
168 | - ) ); |
|
168 | + )); |
|
169 | 169 | } else { |
170 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
170 | + echo monsterinsights_get_message('error', esc_html__('The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress')); |
|
171 | 171 | } |
172 | 172 | ?> |
173 | 173 | <?php } else { ?> |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * or the hook may be removed at any time, without warning. |
182 | 182 | */ |
183 | 183 | ?> |
184 | - <?php do_action( 'monsterinsights_tab_reports_notices' ); ?> |
|
184 | + <?php do_action('monsterinsights_tab_reports_notices'); ?> |
|
185 | 185 | <?php |
186 | 186 | /** |
187 | 187 | * Developer Alert: |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * or the hook may be removed at any time, without warning. |
192 | 192 | */ |
193 | 193 | ?> |
194 | - <?php do_action( 'monsterinsights_tab_reports_' . $id ); ?> |
|
194 | + <?php do_action('monsterinsights_tab_reports_' . $id); ?> |
|
195 | 195 | </div> |
196 | 196 | <?php } ?> |
197 | 197 | </div> |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
14 | - exit; |
|
14 | + exit; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | * @return array Array of tab information. |
24 | 24 | */ |
25 | 25 | function monsterinsights_get_reports() { |
26 | - /** |
|
27 | - * Developer Alert: |
|
28 | - * |
|
29 | - * Per the README, this is considered an internal hook and should |
|
30 | - * not be used by other developers. This hook's behavior may be modified |
|
31 | - * or the hook may be removed at any time, without warning. |
|
32 | - */ |
|
33 | - $reports = apply_filters( 'monsterinsights_get_reports', array() ); |
|
34 | - return $reports; |
|
26 | + /** |
|
27 | + * Developer Alert: |
|
28 | + * |
|
29 | + * Per the README, this is considered an internal hook and should |
|
30 | + * not be used by other developers. This hook's behavior may be modified |
|
31 | + * or the hook may be removed at any time, without warning. |
|
32 | + */ |
|
33 | + $reports = apply_filters( 'monsterinsights_get_reports', array() ); |
|
34 | + return $reports; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -43,47 +43,47 @@ discard block |
||
43 | 43 | * @return void |
44 | 44 | */ |
45 | 45 | function monsterinsights_reports_page() { |
46 | - /** |
|
47 | - * Developer Alert: |
|
48 | - * |
|
49 | - * Per the README, this is considered an internal hook and should |
|
50 | - * not be used by other developers. This hook's behavior may be modified |
|
51 | - * or the hook may be removed at any time, without warning. |
|
52 | - */ |
|
53 | - do_action( 'monsterinsights_head' ); |
|
46 | + /** |
|
47 | + * Developer Alert: |
|
48 | + * |
|
49 | + * Per the README, this is considered an internal hook and should |
|
50 | + * not be used by other developers. This hook's behavior may be modified |
|
51 | + * or the hook may be removed at any time, without warning. |
|
52 | + */ |
|
53 | + do_action( 'monsterinsights_head' ); |
|
54 | 54 | |
55 | - if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
56 | - wp_die( esc_html__( 'Access denied' , 'google-analytics-for-wordpress' ) ); |
|
57 | - } |
|
55 | + if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
56 | + wp_die( esc_html__( 'Access denied' , 'google-analytics-for-wordpress' ) ); |
|
57 | + } |
|
58 | 58 | |
59 | - $dashboard_disabled = monsterinsights_get_option( 'dashboard_disabled', false ); |
|
60 | - $profile_enabled = monsterinsights_get_option( 'analytics_profile', false ); // not using profile |
|
61 | - $oauth_version = monsterinsights_get_option( 'oauth_version', '1.0' ); |
|
62 | - $last_run = monsterinsights_get_option( 'cron_last_run', false ); |
|
63 | - $failed = monsterinsights_get_option( 'cron_failed', false ); |
|
64 | - $pro_access_key = get_option( 'monsterinsights_pro_access_token', false ); |
|
65 | - $lite_access_key = get_option( 'monsterinsights_lite_access_token', false ); |
|
66 | - $needs_re_auth = ( ( $failed && ( $last_run === false || monsterinsights_hours_between( $last_run ) >= 48 ) ) || ( empty( $pro_access_key ) && empty( $lite_access_key ) ) || ( version_compare( $oauth_version, '1.0', '<' ) ) ) ? true : false; |
|
67 | - ?> |
|
59 | + $dashboard_disabled = monsterinsights_get_option( 'dashboard_disabled', false ); |
|
60 | + $profile_enabled = monsterinsights_get_option( 'analytics_profile', false ); // not using profile |
|
61 | + $oauth_version = monsterinsights_get_option( 'oauth_version', '1.0' ); |
|
62 | + $last_run = monsterinsights_get_option( 'cron_last_run', false ); |
|
63 | + $failed = monsterinsights_get_option( 'cron_failed', false ); |
|
64 | + $pro_access_key = get_option( 'monsterinsights_pro_access_token', false ); |
|
65 | + $lite_access_key = get_option( 'monsterinsights_lite_access_token', false ); |
|
66 | + $needs_re_auth = ( ( $failed && ( $last_run === false || monsterinsights_hours_between( $last_run ) >= 48 ) ) || ( empty( $pro_access_key ) && empty( $lite_access_key ) ) || ( version_compare( $oauth_version, '1.0', '<' ) ) ) ? true : false; |
|
67 | + ?> |
|
68 | 68 | <?php echo monsterinsights_ublock_notice(); ?> |
69 | 69 | |
70 | 70 | <!-- Tabs --> |
71 | 71 | <h1 id="monsterinsights-reports-page-main-nav" class="monsterinsights-main-nav-container monsterinsights-nav-container" data-container="#monsterinsights-reports-pages" data-update-hashbang="1"> |
72 | 72 | <?php |
73 | - $i = 0; |
|
74 | - ?> |
|
73 | + $i = 0; |
|
74 | + ?> |
|
75 | 75 | <a class="monsterinsights-main-nav-item monsterinsights-nav-item monsterinsights-spacing-item" href="#"> </a> |
76 | 76 | <?php |
77 | - foreach ( (array) monsterinsights_get_reports() as $id => $title ) { |
|
78 | - $class = ( 0 === $i ? 'monsterinsights-active' : '' ); |
|
79 | - ?> |
|
77 | + foreach ( (array) monsterinsights_get_reports() as $id => $title ) { |
|
78 | + $class = ( 0 === $i ? 'monsterinsights-active' : '' ); |
|
79 | + ?> |
|
80 | 80 | <a class="monsterinsights-main-nav-item monsterinsights-nav-item <?php echo $class; ?>" href="#monsterinsights-main-tab-<?php echo esc_attr( $id ); ?>" title="<?php echo esc_attr( $title ); ?>"> |
81 | 81 | <?php echo esc_html( $title ); ?> |
82 | 82 | </a> |
83 | 83 | <?php |
84 | - $i++; |
|
85 | - } |
|
86 | - ?> |
|
84 | + $i++; |
|
85 | + } |
|
86 | + ?> |
|
87 | 87 | </h1> |
88 | 88 | |
89 | 89 | <div id="monsterinsights-reports" class="wrap"> |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | <?php esc_html_e( 'Reports', 'google-analytics-for-wordpress' );?> |
94 | 94 | </div> |
95 | 95 | <div class="monsterinsights-reports-action-bar-actions"><?php |
96 | - /** |
|
97 | - * Developer Alert: |
|
98 | - * |
|
99 | - * Per the README, this is considered an internal hook and should |
|
100 | - * not be used by other developers. This hook's behavior may be modified |
|
101 | - * or the hook may be removed at any time, without warning. |
|
102 | - */ |
|
103 | - do_action( 'monsterinsights_tab_reports_actions' ); |
|
104 | - ?> |
|
96 | + /** |
|
97 | + * Developer Alert: |
|
98 | + * |
|
99 | + * Per the README, this is considered an internal hook and should |
|
100 | + * not be used by other developers. This hook's behavior may be modified |
|
101 | + * or the hook may be removed at any time, without warning. |
|
102 | + */ |
|
103 | + do_action( 'monsterinsights_tab_reports_actions' ); |
|
104 | + ?> |
|
105 | 105 | </div> |
106 | 106 | </div> |
107 | 107 | |
@@ -109,96 +109,96 @@ discard block |
||
109 | 109 | <div id="monsterinsights-reports-pages" class="monsterinsights-main-nav-tabs monsterinsights-nav-tabs" data-navigation="#monsterinsights-reports-page-main-nav"> |
110 | 110 | <h1 class="monsterinsights-hideme"></h1><!-- so wp notices are below the nav bar --> |
111 | 111 | <?php |
112 | - $i = 0; |
|
113 | - foreach ( (array) monsterinsights_get_reports() as $id => $title ) { |
|
114 | - $class = ( 0 === $i ? 'monsterinsights-active' : '' ); |
|
115 | - ?> |
|
112 | + $i = 0; |
|
113 | + foreach ( (array) monsterinsights_get_reports() as $id => $title ) { |
|
114 | + $class = ( 0 === $i ? 'monsterinsights-active' : '' ); |
|
115 | + ?> |
|
116 | 116 | <div id="monsterinsights-main-tab-<?php echo esc_attr( $id ); ?>" class="monsterinsights-main-nav-tab monsterinsights-nav-tab <?php echo $class; ?>"> |
117 | 117 | <?php if ( $dashboard_disabled ) { ?> |
118 | 118 | <?php |
119 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
120 | - echo monsterinsights_get_message( 'error', sprintf( |
|
121 | - sprintf( |
|
122 | - esc_html__( 'Please %1$senable the dashboard%2$s to see report data.', 'google-analytics-for-wordpress' ), |
|
123 | - '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
124 | - '</a>' |
|
125 | - ) |
|
126 | - ) ); |
|
127 | - } else { |
|
128 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
129 | - } |
|
130 | - ?> |
|
119 | + if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
120 | + echo monsterinsights_get_message( 'error', sprintf( |
|
121 | + sprintf( |
|
122 | + esc_html__( 'Please %1$senable the dashboard%2$s to see report data.', 'google-analytics-for-wordpress' ), |
|
123 | + '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
124 | + '</a>' |
|
125 | + ) |
|
126 | + ) ); |
|
127 | + } else { |
|
128 | + echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
129 | + } |
|
130 | + ?> |
|
131 | 131 | <?php } else if ( ! $profile_enabled ) { ?> |
132 | 132 | <?php |
133 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
134 | - echo monsterinsights_get_message( 'error', sprintf( |
|
135 | - sprintf( |
|
136 | - esc_html__( 'Please %1$sauthenticate %2$swith Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ), |
|
137 | - '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
138 | - '</a>' |
|
139 | - ) |
|
140 | - ) ); |
|
141 | - } else { |
|
142 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
143 | - } |
|
144 | - ?> |
|
133 | + if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
134 | + echo monsterinsights_get_message( 'error', sprintf( |
|
135 | + sprintf( |
|
136 | + esc_html__( 'Please %1$sauthenticate %2$swith Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ), |
|
137 | + '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
138 | + '</a>' |
|
139 | + ) |
|
140 | + ) ); |
|
141 | + } else { |
|
142 | + echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
143 | + } |
|
144 | + ?> |
|
145 | 145 | <?php } else if ( $needs_re_auth ) { ?> |
146 | 146 | <?php |
147 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
148 | - echo monsterinsights_get_message( 'error', sprintf( |
|
149 | - sprintf( |
|
150 | - esc_html__( 'Please %1$sre-authenticate%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ), |
|
151 | - '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
152 | - '</a>' |
|
153 | - ) |
|
154 | - ) ); |
|
155 | - } else { |
|
156 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
157 | - } |
|
158 | - ?> |
|
147 | + if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
148 | + echo monsterinsights_get_message( 'error', sprintf( |
|
149 | + sprintf( |
|
150 | + esc_html__( 'Please %1$sre-authenticate%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ), |
|
151 | + '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
152 | + '</a>' |
|
153 | + ) |
|
154 | + ) ); |
|
155 | + } else { |
|
156 | + echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
157 | + } |
|
158 | + ?> |
|
159 | 159 | <?php } else if ( $failed ) { ?> |
160 | 160 | <?php |
161 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
162 | - echo monsterinsights_get_message( 'error', sprintf( |
|
163 | - sprintf( |
|
164 | - esc_html__( 'Data is not up-to-date, there was an error in retrieving the data from Google Analytics. This error could be caused by several issues. If the error persists, please see %1$sthis page%2$s.', 'google-analytics-for-wordpress' ), |
|
165 | - '<a href="https://www.monsterinsights.com/docs/blocked-connection/">', |
|
166 | - '</a>' |
|
167 | - ) |
|
168 | - ) ); |
|
169 | - } else { |
|
170 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
171 | - } |
|
172 | - ?> |
|
161 | + if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
162 | + echo monsterinsights_get_message( 'error', sprintf( |
|
163 | + sprintf( |
|
164 | + esc_html__( 'Data is not up-to-date, there was an error in retrieving the data from Google Analytics. This error could be caused by several issues. If the error persists, please see %1$sthis page%2$s.', 'google-analytics-for-wordpress' ), |
|
165 | + '<a href="https://www.monsterinsights.com/docs/blocked-connection/">', |
|
166 | + '</a>' |
|
167 | + ) |
|
168 | + ) ); |
|
169 | + } else { |
|
170 | + echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
171 | + } |
|
172 | + ?> |
|
173 | 173 | <?php } else { ?> |
174 | 174 | <div class="monsterinsights-reports-wrap"> |
175 | 175 | <?php |
176 | - /** |
|
177 | - * Developer Alert: |
|
178 | - * |
|
179 | - * Per the README, this is considered an internal hook and should |
|
180 | - * not be used by other developers. This hook's behavior may be modified |
|
181 | - * or the hook may be removed at any time, without warning. |
|
182 | - */ |
|
183 | - ?> |
|
176 | + /** |
|
177 | + * Developer Alert: |
|
178 | + * |
|
179 | + * Per the README, this is considered an internal hook and should |
|
180 | + * not be used by other developers. This hook's behavior may be modified |
|
181 | + * or the hook may be removed at any time, without warning. |
|
182 | + */ |
|
183 | + ?> |
|
184 | 184 | <?php do_action( 'monsterinsights_tab_reports_notices' ); ?> |
185 | 185 | <?php |
186 | - /** |
|
187 | - * Developer Alert: |
|
188 | - * |
|
189 | - * Per the README, this is considered an internal hook and should |
|
190 | - * not be used by other developers. This hook's behavior may be modified |
|
191 | - * or the hook may be removed at any time, without warning. |
|
192 | - */ |
|
193 | - ?> |
|
186 | + /** |
|
187 | + * Developer Alert: |
|
188 | + * |
|
189 | + * Per the README, this is considered an internal hook and should |
|
190 | + * not be used by other developers. This hook's behavior may be modified |
|
191 | + * or the hook may be removed at any time, without warning. |
|
192 | + */ |
|
193 | + ?> |
|
194 | 194 | <?php do_action( 'monsterinsights_tab_reports_' . $id ); ?> |
195 | 195 | </div> |
196 | 196 | <?php } ?> |
197 | 197 | </div> |
198 | 198 | <?php |
199 | - $i++; |
|
200 | - } |
|
201 | - ?> |
|
199 | + $i++; |
|
200 | + } |
|
201 | + ?> |
|
202 | 202 | </div> |
203 | 203 | </div> |
204 | 204 | </div> |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | */ |
10 | 10 | function monsterinsights_get_dashboard_report() { |
11 | 11 | $reports = monsterinsights_get_reports(); |
12 | - $picked = monsterinsights_get_option( 'dashboard_report', 'overview' ); |
|
13 | - if ( ! empty( $reports ) && is_array( $reports ) && array_key_exists ( $picked, $reports ) ) { |
|
14 | - return array( 'id' => $picked, 'title' => $reports[ $picked ] ); |
|
12 | + $picked = monsterinsights_get_option('dashboard_report', 'overview'); |
|
13 | + if ( ! empty($reports) && is_array($reports) && array_key_exists($picked, $reports)) { |
|
14 | + return array('id' => $picked, 'title' => $reports[$picked]); |
|
15 | 15 | } else { |
16 | 16 | return array(); |
17 | 17 | } |
@@ -33,27 +33,27 @@ discard block |
||
33 | 33 | * not be used by other developers. This hook's behavior may be modified |
34 | 34 | * or the hook may be removed at any time, without warning. |
35 | 35 | */ |
36 | - do_action( 'monsterinsights_head' ); |
|
36 | + do_action('monsterinsights_head'); |
|
37 | 37 | |
38 | - if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
39 | - wp_die( esc_html__( 'Access denied' , 'google-analytics-for-wordpress' ) ); |
|
38 | + if ( ! current_user_can('monsterinsights_view_dashboard')) { |
|
39 | + wp_die(esc_html__('Access denied', 'google-analytics-for-wordpress')); |
|
40 | 40 | } |
41 | 41 | |
42 | - $dashboard_disabled = monsterinsights_get_option( 'dashboard_disabled', false ); |
|
43 | - $profile_enabled = monsterinsights_get_option( 'analytics_profile', false ); // not using profile |
|
44 | - $oauth_version = monsterinsights_get_option( 'oauth_version', '1.0' ); |
|
45 | - $last_run = monsterinsights_get_option( 'cron_last_run', false ); |
|
46 | - $failed = monsterinsights_get_option( 'cron_failed', false ); |
|
47 | - $pro_access_key = get_option( 'monsterinsights_pro_access_token', false ); |
|
48 | - $lite_access_key = get_option( 'monsterinsights_lite_access_token', false ); |
|
49 | - $needs_re_auth = ( ( $failed && ( $last_run === false || monsterinsights_hours_between( $last_run ) >= 48 ) ) || ( empty( $pro_access_key ) && empty( $lite_access_key ) ) || ( version_compare( $oauth_version, '1.0', '<' ) ) ) ? true : false; |
|
42 | + $dashboard_disabled = monsterinsights_get_option('dashboard_disabled', false); |
|
43 | + $profile_enabled = monsterinsights_get_option('analytics_profile', false); // not using profile |
|
44 | + $oauth_version = monsterinsights_get_option('oauth_version', '1.0'); |
|
45 | + $last_run = monsterinsights_get_option('cron_last_run', false); |
|
46 | + $failed = monsterinsights_get_option('cron_failed', false); |
|
47 | + $pro_access_key = get_option('monsterinsights_pro_access_token', false); |
|
48 | + $lite_access_key = get_option('monsterinsights_lite_access_token', false); |
|
49 | + $needs_re_auth = (($failed && ($last_run === false || monsterinsights_hours_between($last_run) >= 48)) || (empty($pro_access_key) && empty($lite_access_key)) || (version_compare($oauth_version, '1.0', '<'))) ? true : false; |
|
50 | 50 | ?> |
51 | 51 | <?php echo monsterinsights_ublock_notice(); ?> |
52 | 52 | <div id="monsterinsights-reports" class="wrap"> |
53 | 53 | <div class="monsterinsights-clear"> |
54 | 54 | <div class="monsterinsights-reports-action-bar"> |
55 | 55 | <div class="monsterinsights-reports-action-bar-title"> |
56 | - <?php esc_html_e( 'Dashboard', 'google-analytics-for-wordpress' );?> |
|
56 | + <?php esc_html_e('Dashboard', 'google-analytics-for-wordpress'); ?> |
|
57 | 57 | </div> |
58 | 58 | <div class="monsterinsights-reports-action-bar-actions"><?php |
59 | 59 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * not be used by other developers. This hook's behavior may be modified |
64 | 64 | * or the hook may be removed at any time, without warning. |
65 | 65 | */ |
66 | - do_action( 'monsterinsights_tab_reports_actions' ); |
|
66 | + do_action('monsterinsights_tab_reports_actions'); |
|
67 | 67 | ?> |
68 | 68 | </div> |
69 | 69 | </div> |
@@ -71,60 +71,60 @@ discard block |
||
71 | 71 | $report = monsterinsights_get_dashboard_report(); |
72 | 72 | ?> |
73 | 73 | <div id="monsterinsights_dashboard_container"> |
74 | - <?php if ( $dashboard_disabled ) { ?> |
|
74 | + <?php if ($dashboard_disabled) { ?> |
|
75 | 75 | <?php |
76 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
77 | - echo monsterinsights_get_message( 'error', sprintf( |
|
76 | + if (current_user_can('monsterinsights_save_settings')) { |
|
77 | + echo monsterinsights_get_message('error', sprintf( |
|
78 | 78 | sprintf( |
79 | - esc_html__( 'Please %1$senable the dashboard%2$s to see report data.', 'google-analytics-for-wordpress' ), |
|
80 | - '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
79 | + esc_html__('Please %1$senable the dashboard%2$s to see report data.', 'google-analytics-for-wordpress'), |
|
80 | + '<a href="' . admin_url('admin.php?page=monsterinsights_settings') . '">', |
|
81 | 81 | '</a>' |
82 | 82 | ) |
83 | - ) ); |
|
83 | + )); |
|
84 | 84 | } else { |
85 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
85 | + echo monsterinsights_get_message('error', esc_html__('The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress')); |
|
86 | 86 | } |
87 | 87 | ?> |
88 | - <?php } else if ( ! $profile_enabled ) { ?> |
|
88 | + <?php } else if ( ! $profile_enabled) { ?> |
|
89 | 89 | <?php |
90 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
91 | - echo monsterinsights_get_message( 'error', sprintf( |
|
90 | + if (current_user_can('monsterinsights_save_settings')) { |
|
91 | + echo monsterinsights_get_message('error', sprintf( |
|
92 | 92 | sprintf( |
93 | - esc_html__( 'Please %1$sauthenticate %2$swith Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ), |
|
94 | - '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
93 | + esc_html__('Please %1$sauthenticate %2$swith Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress'), |
|
94 | + '<a href="' . admin_url('admin.php?page=monsterinsights_settings') . '">', |
|
95 | 95 | '</a>' |
96 | 96 | ) |
97 | - ) ); |
|
97 | + )); |
|
98 | 98 | } else { |
99 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
99 | + echo monsterinsights_get_message('error', esc_html__('The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress')); |
|
100 | 100 | } |
101 | 101 | ?> |
102 | - <?php } else if ( $needs_re_auth ) { ?> |
|
102 | + <?php } else if ($needs_re_auth) { ?> |
|
103 | 103 | <?php |
104 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
105 | - echo monsterinsights_get_message( 'error', sprintf( |
|
104 | + if (current_user_can('monsterinsights_save_settings')) { |
|
105 | + echo monsterinsights_get_message('error', sprintf( |
|
106 | 106 | sprintf( |
107 | - esc_html__( 'Please %1$sre-authenticate%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ), |
|
108 | - '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
107 | + esc_html__('Please %1$sre-authenticate%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress'), |
|
108 | + '<a href="' . admin_url('admin.php?page=monsterinsights_settings') . '">', |
|
109 | 109 | '</a>' |
110 | 110 | ) |
111 | - ) ); |
|
111 | + )); |
|
112 | 112 | } else { |
113 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
113 | + echo monsterinsights_get_message('error', esc_html__('The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress')); |
|
114 | 114 | } |
115 | 115 | ?> |
116 | - <?php } else if ( $failed ) { ?> |
|
116 | + <?php } else if ($failed) { ?> |
|
117 | 117 | <?php |
118 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
119 | - echo monsterinsights_get_message( 'error', sprintf( |
|
118 | + if (current_user_can('monsterinsights_save_settings')) { |
|
119 | + echo monsterinsights_get_message('error', sprintf( |
|
120 | 120 | sprintf( |
121 | - esc_html__( 'Data is not up-to-date, there was an error in retrieving the data from Google Analytics. This error could be caused by several issues. If the error persists, please see %1$sthis page%2$s.', 'google-analytics-for-wordpress' ), |
|
121 | + esc_html__('Data is not up-to-date, there was an error in retrieving the data from Google Analytics. This error could be caused by several issues. If the error persists, please see %1$sthis page%2$s.', 'google-analytics-for-wordpress'), |
|
122 | 122 | '<a href="https://www.monsterinsights.com/docs/blocked-connection/">', |
123 | 123 | '</a>' |
124 | 124 | ) |
125 | - ) ); |
|
125 | + )); |
|
126 | 126 | } else { |
127 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
127 | + echo monsterinsights_get_message('error', esc_html__('The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress')); |
|
128 | 128 | } |
129 | 129 | ?> |
130 | 130 | <?php } else { ?> |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * or the hook may be removed at any time, without warning. |
139 | 139 | */ |
140 | 140 | ?> |
141 | - <?php do_action( 'monsterinsights_tab_reports_notices' ); ?> |
|
141 | + <?php do_action('monsterinsights_tab_reports_notices'); ?> |
|
142 | 142 | <?php |
143 | 143 | /** |
144 | 144 | * Developer Alert: |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * or the hook may be removed at any time, without warning. |
149 | 149 | */ |
150 | 150 | ?> |
151 | - <?php do_action( 'monsterinsights_tab_reports_' . $report['id'] ); ?> |
|
151 | + <?php do_action('monsterinsights_tab_reports_' . $report['id']); ?> |
|
152 | 152 | </div> |
153 | 153 | <?php } ?> |
154 | 154 | </div> |
@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | * @return array Array of tab information. |
9 | 9 | */ |
10 | 10 | function monsterinsights_get_dashboard_report() { |
11 | - $reports = monsterinsights_get_reports(); |
|
12 | - $picked = monsterinsights_get_option( 'dashboard_report', 'overview' ); |
|
13 | - if ( ! empty( $reports ) && is_array( $reports ) && array_key_exists ( $picked, $reports ) ) { |
|
14 | - return array( 'id' => $picked, 'title' => $reports[ $picked ] ); |
|
15 | - } else { |
|
16 | - return array(); |
|
17 | - } |
|
11 | + $reports = monsterinsights_get_reports(); |
|
12 | + $picked = monsterinsights_get_option( 'dashboard_report', 'overview' ); |
|
13 | + if ( ! empty( $reports ) && is_array( $reports ) && array_key_exists ( $picked, $reports ) ) { |
|
14 | + return array( 'id' => $picked, 'title' => $reports[ $picked ] ); |
|
15 | + } else { |
|
16 | + return array(); |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -26,28 +26,28 @@ discard block |
||
26 | 26 | * @return void |
27 | 27 | */ |
28 | 28 | function monsterinsights_dashboard_page() { |
29 | - /** |
|
30 | - * Developer Alert: |
|
31 | - * |
|
32 | - * Per the README, this is considered an internal hook and should |
|
33 | - * not be used by other developers. This hook's behavior may be modified |
|
34 | - * or the hook may be removed at any time, without warning. |
|
35 | - */ |
|
36 | - do_action( 'monsterinsights_head' ); |
|
29 | + /** |
|
30 | + * Developer Alert: |
|
31 | + * |
|
32 | + * Per the README, this is considered an internal hook and should |
|
33 | + * not be used by other developers. This hook's behavior may be modified |
|
34 | + * or the hook may be removed at any time, without warning. |
|
35 | + */ |
|
36 | + do_action( 'monsterinsights_head' ); |
|
37 | 37 | |
38 | - if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
39 | - wp_die( esc_html__( 'Access denied' , 'google-analytics-for-wordpress' ) ); |
|
40 | - } |
|
38 | + if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { |
|
39 | + wp_die( esc_html__( 'Access denied' , 'google-analytics-for-wordpress' ) ); |
|
40 | + } |
|
41 | 41 | |
42 | - $dashboard_disabled = monsterinsights_get_option( 'dashboard_disabled', false ); |
|
43 | - $profile_enabled = monsterinsights_get_option( 'analytics_profile', false ); // not using profile |
|
44 | - $oauth_version = monsterinsights_get_option( 'oauth_version', '1.0' ); |
|
45 | - $last_run = monsterinsights_get_option( 'cron_last_run', false ); |
|
46 | - $failed = monsterinsights_get_option( 'cron_failed', false ); |
|
47 | - $pro_access_key = get_option( 'monsterinsights_pro_access_token', false ); |
|
48 | - $lite_access_key = get_option( 'monsterinsights_lite_access_token', false ); |
|
49 | - $needs_re_auth = ( ( $failed && ( $last_run === false || monsterinsights_hours_between( $last_run ) >= 48 ) ) || ( empty( $pro_access_key ) && empty( $lite_access_key ) ) || ( version_compare( $oauth_version, '1.0', '<' ) ) ) ? true : false; |
|
50 | - ?> |
|
42 | + $dashboard_disabled = monsterinsights_get_option( 'dashboard_disabled', false ); |
|
43 | + $profile_enabled = monsterinsights_get_option( 'analytics_profile', false ); // not using profile |
|
44 | + $oauth_version = monsterinsights_get_option( 'oauth_version', '1.0' ); |
|
45 | + $last_run = monsterinsights_get_option( 'cron_last_run', false ); |
|
46 | + $failed = monsterinsights_get_option( 'cron_failed', false ); |
|
47 | + $pro_access_key = get_option( 'monsterinsights_pro_access_token', false ); |
|
48 | + $lite_access_key = get_option( 'monsterinsights_lite_access_token', false ); |
|
49 | + $needs_re_auth = ( ( $failed && ( $last_run === false || monsterinsights_hours_between( $last_run ) >= 48 ) ) || ( empty( $pro_access_key ) && empty( $lite_access_key ) ) || ( version_compare( $oauth_version, '1.0', '<' ) ) ) ? true : false; |
|
50 | + ?> |
|
51 | 51 | <?php echo monsterinsights_ublock_notice(); ?> |
52 | 52 | <div id="monsterinsights-reports" class="wrap"> |
53 | 53 | <div class="monsterinsights-clear"> |
@@ -56,98 +56,98 @@ discard block |
||
56 | 56 | <?php esc_html_e( 'Dashboard', 'google-analytics-for-wordpress' );?> |
57 | 57 | </div> |
58 | 58 | <div class="monsterinsights-reports-action-bar-actions"><?php |
59 | - /** |
|
60 | - * Developer Alert: |
|
61 | - * |
|
62 | - * Per the README, this is considered an internal hook and should |
|
63 | - * not be used by other developers. This hook's behavior may be modified |
|
64 | - * or the hook may be removed at any time, without warning. |
|
65 | - */ |
|
66 | - do_action( 'monsterinsights_tab_reports_actions' ); |
|
67 | - ?> |
|
59 | + /** |
|
60 | + * Developer Alert: |
|
61 | + * |
|
62 | + * Per the README, this is considered an internal hook and should |
|
63 | + * not be used by other developers. This hook's behavior may be modified |
|
64 | + * or the hook may be removed at any time, without warning. |
|
65 | + */ |
|
66 | + do_action( 'monsterinsights_tab_reports_actions' ); |
|
67 | + ?> |
|
68 | 68 | </div> |
69 | 69 | </div> |
70 | 70 | <?php |
71 | - $report = monsterinsights_get_dashboard_report(); |
|
72 | - ?> |
|
71 | + $report = monsterinsights_get_dashboard_report(); |
|
72 | + ?> |
|
73 | 73 | <div id="monsterinsights_dashboard_container"> |
74 | 74 | <?php if ( $dashboard_disabled ) { ?> |
75 | 75 | <?php |
76 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
77 | - echo monsterinsights_get_message( 'error', sprintf( |
|
78 | - sprintf( |
|
79 | - esc_html__( 'Please %1$senable the dashboard%2$s to see report data.', 'google-analytics-for-wordpress' ), |
|
80 | - '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
81 | - '</a>' |
|
82 | - ) |
|
83 | - ) ); |
|
84 | - } else { |
|
85 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
86 | - } |
|
87 | - ?> |
|
76 | + if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
77 | + echo monsterinsights_get_message( 'error', sprintf( |
|
78 | + sprintf( |
|
79 | + esc_html__( 'Please %1$senable the dashboard%2$s to see report data.', 'google-analytics-for-wordpress' ), |
|
80 | + '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
81 | + '</a>' |
|
82 | + ) |
|
83 | + ) ); |
|
84 | + } else { |
|
85 | + echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
86 | + } |
|
87 | + ?> |
|
88 | 88 | <?php } else if ( ! $profile_enabled ) { ?> |
89 | 89 | <?php |
90 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
91 | - echo monsterinsights_get_message( 'error', sprintf( |
|
92 | - sprintf( |
|
93 | - esc_html__( 'Please %1$sauthenticate %2$swith Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ), |
|
94 | - '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
95 | - '</a>' |
|
96 | - ) |
|
97 | - ) ); |
|
98 | - } else { |
|
99 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
100 | - } |
|
101 | - ?> |
|
90 | + if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
91 | + echo monsterinsights_get_message( 'error', sprintf( |
|
92 | + sprintf( |
|
93 | + esc_html__( 'Please %1$sauthenticate %2$swith Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ), |
|
94 | + '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
95 | + '</a>' |
|
96 | + ) |
|
97 | + ) ); |
|
98 | + } else { |
|
99 | + echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
100 | + } |
|
101 | + ?> |
|
102 | 102 | <?php } else if ( $needs_re_auth ) { ?> |
103 | 103 | <?php |
104 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
105 | - echo monsterinsights_get_message( 'error', sprintf( |
|
106 | - sprintf( |
|
107 | - esc_html__( 'Please %1$sre-authenticate%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ), |
|
108 | - '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
109 | - '</a>' |
|
110 | - ) |
|
111 | - ) ); |
|
112 | - } else { |
|
113 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
114 | - } |
|
115 | - ?> |
|
104 | + if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
105 | + echo monsterinsights_get_message( 'error', sprintf( |
|
106 | + sprintf( |
|
107 | + esc_html__( 'Please %1$sre-authenticate%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ), |
|
108 | + '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">', |
|
109 | + '</a>' |
|
110 | + ) |
|
111 | + ) ); |
|
112 | + } else { |
|
113 | + echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
114 | + } |
|
115 | + ?> |
|
116 | 116 | <?php } else if ( $failed ) { ?> |
117 | 117 | <?php |
118 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
119 | - echo monsterinsights_get_message( 'error', sprintf( |
|
120 | - sprintf( |
|
121 | - esc_html__( 'Data is not up-to-date, there was an error in retrieving the data from Google Analytics. This error could be caused by several issues. If the error persists, please see %1$sthis page%2$s.', 'google-analytics-for-wordpress' ), |
|
122 | - '<a href="https://www.monsterinsights.com/docs/blocked-connection/">', |
|
123 | - '</a>' |
|
124 | - ) |
|
125 | - ) ); |
|
126 | - } else { |
|
127 | - echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
128 | - } |
|
129 | - ?> |
|
118 | + if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
119 | + echo monsterinsights_get_message( 'error', sprintf( |
|
120 | + sprintf( |
|
121 | + esc_html__( 'Data is not up-to-date, there was an error in retrieving the data from Google Analytics. This error could be caused by several issues. If the error persists, please see %1$sthis page%2$s.', 'google-analytics-for-wordpress' ), |
|
122 | + '<a href="https://www.monsterinsights.com/docs/blocked-connection/">', |
|
123 | + '</a>' |
|
124 | + ) |
|
125 | + ) ); |
|
126 | + } else { |
|
127 | + echo monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); |
|
128 | + } |
|
129 | + ?> |
|
130 | 130 | <?php } else { ?> |
131 | 131 | <div class="monsterinsights-reports-wrap"> |
132 | 132 | <?php |
133 | - /** |
|
134 | - * Developer Alert: |
|
135 | - * |
|
136 | - * Per the README, this is considered an internal hook and should |
|
137 | - * not be used by other developers. This hook's behavior may be modified |
|
138 | - * or the hook may be removed at any time, without warning. |
|
139 | - */ |
|
140 | - ?> |
|
133 | + /** |
|
134 | + * Developer Alert: |
|
135 | + * |
|
136 | + * Per the README, this is considered an internal hook and should |
|
137 | + * not be used by other developers. This hook's behavior may be modified |
|
138 | + * or the hook may be removed at any time, without warning. |
|
139 | + */ |
|
140 | + ?> |
|
141 | 141 | <?php do_action( 'monsterinsights_tab_reports_notices' ); ?> |
142 | 142 | <?php |
143 | - /** |
|
144 | - * Developer Alert: |
|
145 | - * |
|
146 | - * Per the README, this is considered an internal hook and should |
|
147 | - * not be used by other developers. This hook's behavior may be modified |
|
148 | - * or the hook may be removed at any time, without warning. |
|
149 | - */ |
|
150 | - ?> |
|
143 | + /** |
|
144 | + * Developer Alert: |
|
145 | + * |
|
146 | + * Per the README, this is considered an internal hook and should |
|
147 | + * not be used by other developers. This hook's behavior may be modified |
|
148 | + * or the hook may be removed at any time, without warning. |
|
149 | + */ |
|
150 | + ?> |
|
151 | 151 | <?php do_action( 'monsterinsights_tab_reports_' . $report['id'] ); ?> |
152 | 152 | </div> |
153 | 153 | <?php } ?> |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | * not be used by other developers. This hook's behavior may be modified |
31 | 31 | * or the hook may be removed at any time, without warning. |
32 | 32 | */ |
33 | - do_action( 'monsterinsights_head' ); |
|
34 | - $network_license = get_site_option( 'monsterinsights_license' ); |
|
35 | - $license_key = ! empty( $network_license['key'] ) ? esc_attr( $network_license['key'] ) : ''; |
|
36 | - $license_key_type = ! empty( $network_license['type'] ) ? esc_html( $network_license['type'] ) : ''; |
|
37 | - $network_ua_code = get_site_option('monsterinsights_network_manual_ua_code', false ); |
|
33 | + do_action('monsterinsights_head'); |
|
34 | + $network_license = get_site_option('monsterinsights_license'); |
|
35 | + $license_key = ! empty($network_license['key']) ? esc_attr($network_license['key']) : ''; |
|
36 | + $license_key_type = ! empty($network_license['type']) ? esc_html($network_license['type']) : ''; |
|
37 | + $network_ua_code = get_site_option('monsterinsights_network_manual_ua_code', false); |
|
38 | 38 | ?> |
39 | 39 | <?php echo monsterinsights_ublock_notice(); ?> |
40 | 40 | <div id="monsterinsights-settings" class="wrap"> |
@@ -50,40 +50,40 @@ discard block |
||
50 | 50 | * not be used by other developers. This hook's behavior may be modified |
51 | 51 | * or the hook may be removed at any time, without warning. |
52 | 52 | */ |
53 | - do_action( 'monsterinsights_network_settings_general_tab_notice' ); |
|
53 | + do_action('monsterinsights_network_settings_general_tab_notice'); |
|
54 | 54 | ?> |
55 | - <h1><?php esc_html_e( 'Network Settings', 'google-analytics-for-wordpress'); ?></h1> |
|
56 | - <p><?php esc_html_e( 'Activate your MonsterInsights license key on this panel to hide the license key settings and addon pages for subsites.', 'google-analytics-for-wordpress'); ?></p> |
|
55 | + <h1><?php esc_html_e('Network Settings', 'google-analytics-for-wordpress'); ?></h1> |
|
56 | + <p><?php esc_html_e('Activate your MonsterInsights license key on this panel to hide the license key settings and addon pages for subsites.', 'google-analytics-for-wordpress'); ?></p> |
|
57 | 57 | <table class="form-table"> |
58 | 58 | <tbody> |
59 | - <?php if ( monsterinsights_is_pro_version() ) : ?> |
|
59 | + <?php if (monsterinsights_is_pro_version()) : ?> |
|
60 | 60 | <tr id="monsterinsights-settings-key-box"> |
61 | 61 | <th scope="row"> |
62 | - <label for="monsterinsights-settings-key"><?php esc_html_e( 'License Key', 'google-analytics-for-wordpress' ); ?></label> |
|
62 | + <label for="monsterinsights-settings-key"><?php esc_html_e('License Key', 'google-analytics-for-wordpress'); ?></label> |
|
63 | 63 | </th> |
64 | 64 | <td> |
65 | 65 | <form id="monsterinsights-settings-verify-key" method="post"> |
66 | - <input type="password" name="monsterinsights-license-key" id="monsterinsights-settings-key" value="<?php echo esc_attr( $license_key ); ?>" /> |
|
67 | - <?php wp_nonce_field( 'monsterinsights-key-nonce', 'monsterinsights-key-nonce' ); ?> |
|
68 | - <?php submit_button( esc_html__( 'Verify Key', 'google-analytics-for-wordpress' ), 'button-action', 'monsterinsights-verify-submit', false ); ?> |
|
69 | - <?php submit_button( esc_html__( 'Deactivate Key', 'google-analytics-for-wordpress' ), 'button-danger', 'monsterinsights-deactivate-submit', false ); ?> |
|
70 | - <p class="description"><?php esc_html_e( 'License key to enable automatic updates for MonsterInsights Pro & addons. Deactivate your license if you want to use it on another WordPress site.', 'google-analytics-for-wordpress' ); ?></p> |
|
66 | + <input type="password" name="monsterinsights-license-key" id="monsterinsights-settings-key" value="<?php echo esc_attr($license_key); ?>" /> |
|
67 | + <?php wp_nonce_field('monsterinsights-key-nonce', 'monsterinsights-key-nonce'); ?> |
|
68 | + <?php submit_button(esc_html__('Verify Key', 'google-analytics-for-wordpress'), 'button-action', 'monsterinsights-verify-submit', false); ?> |
|
69 | + <?php submit_button(esc_html__('Deactivate Key', 'google-analytics-for-wordpress'), 'button-danger', 'monsterinsights-deactivate-submit', false); ?> |
|
70 | + <p class="description"><?php esc_html_e('License key to enable automatic updates for MonsterInsights Pro & addons. Deactivate your license if you want to use it on another WordPress site.', 'google-analytics-for-wordpress'); ?></p> |
|
71 | 71 | </form> |
72 | 72 | </td> |
73 | 73 | </tr> |
74 | 74 | <?php endif; ?> |
75 | - <?php if ( ! empty( $license_key_type ) && monsterinsights_is_pro_version() ) : ?> |
|
75 | + <?php if ( ! empty($license_key_type) && monsterinsights_is_pro_version()) : ?> |
|
76 | 76 | <tr id="monsterinsights-settings-key-type-box"> |
77 | 77 | <th scope="row"> |
78 | - <label for="monsterinsights-settings-key-type"><?php esc_html_e( 'License Key Type', 'google-analytics-for-wordpress' ); ?></label> |
|
78 | + <label for="monsterinsights-settings-key-type"><?php esc_html_e('License Key Type', 'google-analytics-for-wordpress'); ?></label> |
|
79 | 79 | </th> |
80 | 80 | <td> |
81 | 81 | <form id="monsterinsights-settings-key-type" method="post"> |
82 | - <span class="monsterinsights-license-type"><?php printf( esc_html__( 'Your license key type for this site is %s.', 'google-analytics-for-wordpress' ), '<strong>' . $license_key_type . '</strong>' ); ?> |
|
83 | - <input type="hidden" name="monsterinsights-license-key" value="<?php echo esc_attr( $license_key ); ?>" /> |
|
84 | - <?php wp_nonce_field( 'monsterinsights-key-nonce', 'monsterinsights-key-nonce' ); ?> |
|
85 | - <?php submit_button( esc_html__( 'Refresh Key', 'google-analytics-for-wordpress' ), 'button-action', 'monsterinsights-refresh-submit', false ); ?> |
|
86 | - <p class="description"><?php esc_html_e( 'Your license key type (handles updates and Addons). Click refresh if your license has been upgraded or the type is incorrect.', 'google-analytics-for-wordpress' ); ?></p> |
|
82 | + <span class="monsterinsights-license-type"><?php printf(esc_html__('Your license key type for this site is %s.', 'google-analytics-for-wordpress'), '<strong>' . $license_key_type . '</strong>'); ?> |
|
83 | + <input type="hidden" name="monsterinsights-license-key" value="<?php echo esc_attr($license_key); ?>" /> |
|
84 | + <?php wp_nonce_field('monsterinsights-key-nonce', 'monsterinsights-key-nonce'); ?> |
|
85 | + <?php submit_button(esc_html__('Refresh Key', 'google-analytics-for-wordpress'), 'button-action', 'monsterinsights-refresh-submit', false); ?> |
|
86 | + <p class="description"><?php esc_html_e('Your license key type (handles updates and Addons). Click refresh if your license has been upgraded or the type is incorrect.', 'google-analytics-for-wordpress'); ?></p> |
|
87 | 87 | </form> |
88 | 88 | </td> |
89 | 89 | </tr> |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | <tr> |
92 | 92 | <form id="monsterinsights-network-general-tab" method="post"> |
93 | 93 | <th scope="row"> |
94 | - <label for="monsterinsights-google-ua"><?php esc_html_e( 'Network UA code', 'google-analytics-for-wordpress' ); ?></label> |
|
94 | + <label for="monsterinsights-google-ua"><?php esc_html_e('Network UA code', 'google-analytics-for-wordpress'); ?></label> |
|
95 | 95 | </th> |
96 | 96 | <td> |
97 | - <input type="text" id="monsterinsights-network-ua-code" name="network_manual_ua_code" value="<?php echo $network_ua_code; ?>" /><?php submit_button( esc_html__( 'Save Network UA code', 'google-analytics-for-wordpress' ), 'button-action', 'monsterinsights-network-settings-submit', false ); ?> |
|
98 | - <p class="description"><?php esc_html_e( 'This is the default UA code to use for subsites of a network (can be overriden at the single site level).', 'google-analytics-for-wordpress' ); ?></p> |
|
99 | - <?php wp_nonce_field( 'monsterinsights-network-settings-nonce', 'monsterinsights-network-settings-nonce' ); ?> |
|
97 | + <input type="text" id="monsterinsights-network-ua-code" name="network_manual_ua_code" value="<?php echo $network_ua_code; ?>" /><?php submit_button(esc_html__('Save Network UA code', 'google-analytics-for-wordpress'), 'button-action', 'monsterinsights-network-settings-submit', false); ?> |
|
98 | + <p class="description"><?php esc_html_e('This is the default UA code to use for subsites of a network (can be overriden at the single site level).', 'google-analytics-for-wordpress'); ?></p> |
|
99 | + <?php wp_nonce_field('monsterinsights-network-settings-nonce', 'monsterinsights-network-settings-nonce'); ?> |
|
100 | 100 | |
101 | 101 | </td> |
102 | 102 | </form> |
@@ -121,36 +121,36 @@ discard block |
||
121 | 121 | function monsterinsights_network_settings_save_general() { |
122 | 122 | |
123 | 123 | // Check if user pressed the 'Update' button and nonce is valid |
124 | - if ( ! isset( $_POST['monsterinsights-network-settings-submit'] ) ) { |
|
124 | + if ( ! isset($_POST['monsterinsights-network-settings-submit'])) { |
|
125 | 125 | return; |
126 | 126 | } |
127 | 127 | |
128 | - if ( ! wp_verify_nonce( $_POST['monsterinsights-network-settings-nonce'], 'monsterinsights-network-settings-nonce' ) ) { |
|
128 | + if ( ! wp_verify_nonce($_POST['monsterinsights-network-settings-nonce'], 'monsterinsights-network-settings-nonce')) { |
|
129 | 129 | return; |
130 | 130 | } |
131 | 131 | |
132 | - if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
132 | + if ( ! current_user_can('monsterinsights_save_settings')) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | - $throw_notice = false; |
|
137 | - $network_manual_ua_code = isset( $_POST['network_manual_ua_code'] ) ? $_POST['network_manual_ua_code'] : ''; |
|
138 | - $network_manual_ua_code = monsterinsights_is_valid_ua( $network_manual_ua_code ); // also sanitizes the string |
|
136 | + $throw_notice = false; |
|
137 | + $network_manual_ua_code = isset($_POST['network_manual_ua_code']) ? $_POST['network_manual_ua_code'] : ''; |
|
138 | + $network_manual_ua_code = monsterinsights_is_valid_ua($network_manual_ua_code); // also sanitizes the string |
|
139 | 139 | |
140 | - if ( $network_manual_ua_code ) { |
|
141 | - update_site_option( 'monsterinsights_network_manual_ua_code', $network_manual_ua_code ); |
|
140 | + if ($network_manual_ua_code) { |
|
141 | + update_site_option('monsterinsights_network_manual_ua_code', $network_manual_ua_code); |
|
142 | 142 | } else { |
143 | - if ( empty ( $network_manual_ua_code ) && isset( $_POST['network_manual_ua_code'] ) ) { |
|
143 | + if (empty ($network_manual_ua_code) && isset($_POST['network_manual_ua_code'])) { |
|
144 | 144 | $throw_notice = true; |
145 | 145 | } |
146 | - update_site_option( 'monsterinsights_network_manual_ua_code', '' ); |
|
146 | + update_site_option('monsterinsights_network_manual_ua_code', ''); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // Output an admin notice so the user knows what happened |
150 | - if ( $throw_notice ) { |
|
151 | - add_action( 'monsterinsights_network_settings_general_tab_notice', 'monsterinsights_invalid_ua_code' ); |
|
150 | + if ($throw_notice) { |
|
151 | + add_action('monsterinsights_network_settings_general_tab_notice', 'monsterinsights_invalid_ua_code'); |
|
152 | 152 | } else { |
153 | - add_action( 'monsterinsights_network_settings_general_tab_notice', 'monsterinsights_updated_settings' ); |
|
153 | + add_action('monsterinsights_network_settings_general_tab_notice', 'monsterinsights_updated_settings'); |
|
154 | 154 | } |
155 | 155 | } |
156 | -add_action( 'admin_init', 'monsterinsights_network_settings_save_general', 11 ); |
|
157 | 156 | \ No newline at end of file |
157 | +add_action('admin_init', 'monsterinsights_network_settings_save_general', 11); |
|
158 | 158 | \ No newline at end of file |
@@ -141,7 +141,7 @@ |
||
141 | 141 | update_site_option( 'monsterinsights_network_manual_ua_code', $network_manual_ua_code ); |
142 | 142 | } else { |
143 | 143 | if ( empty ( $network_manual_ua_code ) && isset( $_POST['network_manual_ua_code'] ) ) { |
144 | - $throw_notice = true; |
|
144 | + $throw_notice = true; |
|
145 | 145 | } |
146 | 146 | update_site_option( 'monsterinsights_network_manual_ua_code', '' ); |
147 | 147 | } |