PluginProbe ʕ •ᴥ•ʔ
ShareThis Dashboard for Google Analytics / trunk
ShareThis Dashboard for Google Analytics vtrunk
3.3.2 trunk 1.0.7 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.5 2.3.5 2.3.6 2.3.7 2.3.8 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.0.0 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.3.0 3.3.1
googleanalytics / view / ga-ga4-settings.php
googleanalytics / view Last commit date
templates 2 months ago ga-accounts-selector.php 2 months ago ga-auth-button.php 2 months ago ga-code.php 2 months ago ga-dashboard-widget.php 2 months ago ga-debug-modal.php 2 months ago ga-ga4-settings.php 2 months ago ga-googleanalytics-loader.php 2 months ago ga-notice.php 2 months ago ga-oauth-notice.php 2 months ago ga-wp-notice.php 2 months ago old-page.php 2 months ago page.php 2 months ago statistics.php 2 months ago stats.php 2 months ago trending.php 2 months ago
ga-ga4-settings.php
294 lines
1 <?php
2 if (!defined('ABSPATH')) exit;
3
4 $ga4_exclude_roles = true === is_array( $ga4_exclude_roles ) ? $ga4_exclude_roles : array();
5 $ga_admin = new Ga_Admin();
6 $auth_info = $ga_admin->getGa4AuthInfo();
7 $oauth = new GA_OAuth();
8 ?>
9 <script type="text/javascript">
10 const GA_NONCE = '<?php echo esc_js( $ga_nonce ); ?>';
11 const GA_NONCE_FIELD = 'ga4-setup';
12 </script>
13 <div class="settings-wrap setup-wrap<?php echo true === $setup_done ? ' hide' : ''; ?>">
14 <div class="ga-step ga-step-1<?php echo false === $has_code && false === $has_property ? ' engage' : ''; ?>">
15 <div class="ga-steps">
16 1 of 3
17 <div class="ga-dots"><span class="dark-green"></span> </div>
18 </div>
19 <h2>Setup Google Authentication</h2>
20 <p>Use our configuration wizard to properly setup Google Analytics with WordPress (with just a few clicks).</p>
21 <a id="google-auth-link" href="<?php echo esc_url( $oauth->get_connect_url() ); ?>">
22 <img src="<?php echo esc_url( plugins_url() ) . '/googleanalytics/assets/images/Google-logo.svg'; ?>" alt="Google Logo">Sign in with Google
23 </a>
24 </div>
25 <div class="ga-step ga-step-2<?php echo false !== $has_code && false === $has_property ? ' engage' : ''; ?>">
26 <div class="ga-steps">
27 2 of 3
28 <div class="ga-dots">• <span class="dark-green">•</span> •</div>
29 </div>
30 <h2>Select Account Property</h2>
31 <p>Choose the view you want to use for your reports.</p>
32 <label for="ga4-property">
33 <select id="ga4-property">
34 <option>Choose Property</option>
35 <?php
36 foreach ( $auth_info['properties'] as $account => $properties ) :
37 if ( false === empty( $properties ) ) :
38 ?>
39 <option disabled><?php echo esc_html( $account ); ?>:</option>
40 <?php
41 foreach ( $properties as $property ) :
42 // Only add UA properties with default profile IDs.
43 if ( true === isset( $property['id'] ) &&
44 false !== strpos( $property['id'], 'UA-' ) &&
45 false === isset( $property['defaultProfileId'] )
46 ) {
47 continue;
48 }
49 ?>
50 <option data-view-id="<?php echo isset( $property['defaultProfileId'] ) ? esc_attr( $property['defaultProfileId'] ) : ''; ?>" value="<?php echo isset( $property['defaultProfileId'] ) ? 'properties/' . esc_attr( $property['internalWebPropertyId'] ) : esc_attr( $property['name'] ); ?>">
51 <?php echo isset( $property['displayName'] ) ? esc_html( $property['displayName'] ) : esc_html( $property['name'] ); ?>
52 </option>
53 <?php
54 endforeach;
55 endif;
56 endforeach;
57 ?>
58 </select>
59 </label>
60 <a id="to-step-3">Next</a>
61 </div>
62 <div class="ga-step ga-step-3<?php echo false === $setup_done && false !== $has_code && false !== $has_property ? ' engage' : ''; ?>">
63 <div class="ga-steps">
64 3 of 3
65 <div class="ga-dots">• • <span class="dark-green">•</span></div>
66 </div>
67 <div class="extra-settings">
68 <h2>Settings</h2>
69 <div class="ga-row">
70 <div class="ua-dual-settings">
71 <div class="ga-ua-col">
72 <h2>If using Google Optimize, enter optimize code here</h2>
73 <label>
74 <input id="ga4-google-optimize" type="text" placeholder="GMT-XXXXXX" value="">
75 </label>
76
77 <h2>Exclude Tracking for Roles</h2>
78 <div class="ga-exclude-roles">
79 <div class="switch">
80 <label class="item">
81 <input type="checkbox" value="administrator">
82 <span class="lever"></span>
83 Administrator
84 </label>
85 </div>
86 <div class="switch">
87 <label class="item">
88 <input type="checkbox" value="contributor">
89 <span class="lever"></span>
90 Contributor
91 </label>
92 </div>
93 <div class="switch">
94 <label class="item">
95 <input type="checkbox" value="editor">
96 <span class="lever"></span>
97 Editor
98 </label>
99 </div>
100 <div class="switch">
101 <label class="item">
102 <input type="checkbox" value="subscriber">
103 <span class="lever"></span>
104 Subscriber
105 </label>
106 </div>
107 <div class="switch">
108 <label class="item">
109 <input type="checkbox" value="author">
110 <span class="lever"></span>
111 Author
112 </label>
113 </div>
114 </div>
115 </div>
116 <div class="ga-ua-col">
117 <div class="switch">
118 <label class="item">
119 Enable Demographics
120 <input id="ga4-enable-demo" type="checkbox">
121 <span class="lever"></span>
122 </label>
123 </div>
124 <div class="switch">
125 <label class="item">
126 Enable IP Anonymization
127 <input type="checkbox" id="ga4-enable-ip-anon">
128 <span class="lever"></span>
129 </label>
130 </div>
131 <div class="switch">
132 <label class="item">
133 Enable GDPR Consent Management Tool
134 <input type="checkbox" id="ga4-enable-gdpr">
135 <span class="lever"></span>
136 </label>
137 </div>
138 </div>
139 </div>
140 </div>
141 <a id="complete-ga4-setup" class="green-button" href="<?php echo esc_url( get_admin_url() ); ?>admin.php?page=googleanalytics">Complete and go to dashboard</a>
142 </div>
143 </div>
144 </div>
145
146 <?php if (true === $setup_done) : ?>
147 <div style="margin-top: 0;<?php echo true === $setup_done ? '' : ' display: none;'; ?>" class="ga4_container ga_container">
148 <?php if ( false === empty( $data['error_message'] ) ) : ?>
149 <?php echo wp_kses_post( $data['error_message'] ); ?>
150 <?php endif; ?>
151 <h1>Settings</h1>
152 <form id="ga4_form" method="post" action="options.php">
153 <?php settings_fields( 'googleanalyticsga4' ); ?>
154 <table class="form-table">
155 <tr>
156 <?php if ( false === empty( $data['popup_url'] ) ) : ?>
157 <th scope="row">
158 <label class="<?php echo esc_attr( false === Ga_Helper::are_features_enabled() ? 'label-grey ga-tooltip"' : '' ); ?>">
159 <?php esc_html_e( 'Google Profile', 'googleanalytics' ); ?>:
160 <span class="ga-tooltiptext ga-tt-abs"><?php echo esc_html( $tooltip ); ?></span>
161 </label>
162 </th>
163 <?php endif; ?>
164 </tr>
165 <?php if ( false === empty( $auth_info['properties'] ) ) : ?>
166 <tr>
167 <td>
168 <select id="ga_account_selector" name="googleanalytics-ga4-property">
169 <option>Please select your Google Analytics account:</option>
170 <?php
171 foreach ( $auth_info['properties'] as $account => $properties ) :
172 if ( false === empty( $properties ) ) :
173 ?>
174 <option disabled><?php echo esc_html( $account ); ?>:</option>
175 <?php
176 foreach ( $properties as $property ) :
177 // Only add UA properties with default profile IDs.
178 if ( true === isset( $property['id'] ) &&
179 false !== strpos( $property['id'], 'UA-' ) &&
180 false === isset( $property['defaultProfileId'] )
181 ) {
182 continue;
183 }
184
185 $property_name = isset( $property['defaultProfileId'] ) ? 'properties/' . esc_attr( $property['internalWebPropertyId'] ) : esc_attr( $property['name'] );
186 ?>
187 <option data-view-id="<?php echo isset( $property['defaultProfileId'] ) ? esc_attr( $property['defaultProfileId'] ) : ''; ?>" value="<?php echo esc_attr( $property_name ); ?>" <?php echo $property_name === $has_property ? 'selected' : ''; ?>>
188 <?php echo isset( $property['displayName'] ) ? esc_html( $property['displayName'] ) : esc_html( $property['name'] ); ?>
189 </option>
190 <?php
191 endforeach;
192 endif;
193 endforeach;
194 ?>
195 </select>
196 </td>
197 <td>
198 <button id="ga4_sign_out" class="button-secondary" type="button">
199 <?php esc_html_e( 'Sign out', 'googleanalytics' ); ?>
200 </button>
201 </td>
202 </tr>
203 <?php endif; ?>
204 <tr id="ga_roles_wrapper">
205 <th scope="row">
206 <label class="<?php echo esc_attr( false === Ga_Helper::are_features_enabled() ? 'label-grey ga-tooltip' : '' ); ?>">
207 <?php esc_html_e( 'Exclude Tracking for Roles', 'googleanalytics' ); ?>
208 :
209 <span class="ga-tooltiptext ga-tt-abs"><?php echo esc_html( $tooltip ); ?></span>
210 </label>
211 </th>
212 </tr>
213 <tr>
214 <td>
215 <?php
216 if ( false === empty( $data['roles'] ) && true === is_array( $ga4_exclude_roles ) ) {
217 $roles = $data['roles'];
218 foreach ( $roles as $role_item ) {
219 $role_id = true === isset( $role_item['id'] ) ? $role_item['id'] : '';
220 $role_name = true === isset( $role_item['name'] ) ? $role_item['name'] : '';
221 ?>
222 <div class="checkbox">
223 <label class="ga_checkbox_label <?php echo esc_attr( false === Ga_Helper::are_features_enabled() ? 'label-grey ga-tooltip' : '' ); ?>"
224 for="checkbox_<?php echo esc_attr( $role_id ); ?>">
225 <input id="checkbox_<?php echo esc_attr( $role_id ); ?>" type="checkbox"
226 <?php echo disabled( false === Ga_Helper::are_features_enabled() ); ?>
227 name="googleanalytics-ga4-exclude-roles[<?php echo esc_attr( str_replace( 'role-id-', '', $role_id ) ); ?>]"
228 id="<?php echo esc_attr( $role_id ); ?>"
229 <?php echo esc_attr( ( true === in_array( str_replace( 'role-id-', '', $role_id ), array_keys( $ga4_exclude_roles ), true ) ? 'checked="checked"' : '' ) ); ?> />&nbsp;
230 <?php echo esc_html( $role_name ); ?>
231 <span class="ga-tooltiptext"><?php echo esc_html( $tooltip ); ?></span>
232 </label>
233 </div>
234 <?php
235 }
236 }
237 ?>
238 </td>
239 </tr>
240 <tr>
241 <th scope="row"><?php esc_html_e( 'Enable IP Anonymization', 'googleanalytics' ); ?>:</th>
242 </tr>
243 <tr>
244 <td>
245 <label class="ga-switch <?php echo esc_attr( false === Ga_Helper::are_features_enabled() ? 'label-grey ga-tooltip' : '' ); ?>">
246 <?php if ( true === Ga_Helper::are_features_enabled() ) : ?>
247 <input id="ga-anonymization" name="googleanalytics-ga4-ip-anon"
248 type="checkbox" <?php echo checked( $ga4_ip, 'on' ); ?>>
249
250 <div id="ga-slider" class="ga-slider round"></div>
251 <?php else : ?>
252 <input id="ga-anonymization" name="googleanalytics-ga4-ip-anon"
253 type="checkbox" disabled="disabled">
254
255 <div id="ga-slider" class="ga-slider round"></div>
256 <span class="ga-tooltiptext ga-tt-abs"><?php echo esc_html( $tooltip ); ?></span>
257 <?php endif; ?>
258 </label>
259 </td>
260 </tr>
261 <tr>
262 <td>
263 <input name="googleanalytics-ga4-demo" value="<?php echo esc_attr( $ga4_demo ); ?>" type="hidden">
264 </td>
265 </tr>
266 <tr>
267 <th scope="row"><?php esc_html_e( 'If using Google Optimize, enter optimize code here', 'googleanalytics' ); ?>:</th>
268 </tr>
269 <tr>
270 <td>
271 <label class="ga-text <?php echo esc_attr( false === Ga_Helper::are_features_enabled() ? 'label-grey ga-tooltip' : '' ); ?>">
272 <?php if ( true === Ga_Helper::are_features_enabled() ) : ?>
273 <input id="ga-optimize" name="googleanalytics-ga4-optimize"
274 type="text" placeholder="GTM-XXXXXX"
275 value="<?php echo esc_attr( $ga4_optimize ); ?>">
276 <?php else : ?>
277 <input id="ga-optimize" name="googleanalytics-ga4-optimize"
278 type="text" placeholder="GTM-XXXXXX"
279 value="<?php echo esc_attr( $ga4_optimize ); ?>" readonly>
280 <span class="ga-tooltiptext ga-tt-abs"><?php echo esc_html( $tooltip ); ?></span>
281 <?php endif; ?>
282 </label>
283 </td>
284 </tr>
285 <?php require $plugin_dir . 'templates/gdpr.php'; ?>
286 </table>
287
288 <p class="submit">
289 <input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Changes', 'googleanalytics' ); ?>"/>
290 </p>
291 </form>
292 </div>
293 <?php endif; ?>
294