Changeset 3145946
- Timestamp:
- 09/03/2024 12:37:19 PM (18 months ago)
- Location:
- simplest-analytics/trunk
- Files:
-
- 7 edited
-
README.txt (modified) (2 diffs)
-
admin/structure.php (modified) (5 diffs)
-
includes/class-activator.php (modified) (4 diffs)
-
includes/class-simplest-analytics.php (modified) (1 diff)
-
includes/class-uninstall.php (modified) (2 diffs)
-
public/class-public.php (modified) (3 diffs)
-
simplest-analytics.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simplest-analytics/trunk/README.txt
r2982206 r3145946 4 4 Tags: analytics, statistic, tracking, cookieless, video tracking 5 5 Requires at least: 4.0 6 Tested up to: 6. 3.26 Tested up to: 6.6.1 7 7 Requires PHP: 7.4 8 Stable tag: 1.3. 18 Stable tag: 1.3.2 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 83 83 == Changelog == 84 84 85 = 1.3.2 - 2024-09-03 = 86 * added possibility to define relevant cookie that needs to be set bevor tracking 87 85 88 = 1.3.1 - 2023-10-22 = 86 89 * removed max events and max parameters from 5 to unlimited -
simplest-analytics/trunk/admin/structure.php
r2982206 r3145946 5 5 6 6 7 $option_name_general = 'simplest_analytivs_general'; 7 8 $option_name_paras = 'simplest_analytivs_url_para'; 8 9 $option_name_events = 'simplest_analytivs_events'; 9 $tab = " url_paras";10 $tab = "general"; 10 11 11 12 // Processing form data when form is submitted 12 if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["submit_urlparas"])) { 13 if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["submit_general"])) { 14 $general_options = []; 15 $general_options["cookie_name"] = isset($_POST["cookie_name"]) ? sanitize_text_field(trim($_POST["cookie_name"])) : ""; 16 $general_options["cookie_value"] = isset($_POST["cookie_value"]) ? sanitize_text_field(trim($_POST["cookie_value"])) : ""; 17 18 if ($general_options["cookie_name"] == "" || $general_options["cookie_value"] == "") { 19 $general_options["cookie_name"] = ""; 20 $general_options["cookie_value"] = ""; 21 } 22 23 update_option($option_name_general, $general_options); 24 } else if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["submit_urlparas"])) { 13 25 14 26 $get_parameters = isset($_POST["parameter"]) ? array_map('sanitize_title', $_POST["parameter"]) : array(); … … 88 100 } 89 101 102 $general_options = get_option($option_name_general); 90 103 91 104 … … 98 111 99 112 <nav class="nav-tab-wrapper woo-nav-tab-wrapper" style="margin-bottom:10px;"> 113 <a id="general" onclick="simplest_analytics_toggle_tabs_by_id(this)" 114 class="nav-tab <?php echo $tab == "general" ? 'nav-tab-active' : '' ?>"> 115 <?php echo esc_html__('General', 'simplest-analytics') ?> 116 </a> 100 117 <a id="urlparas" onclick="simplest_analytics_toggle_tabs_by_id(this)" 101 118 class="nav-tab <?php echo $tab == "url_paras" ? 'nav-tab-active' : '' ?>"> … … 115 132 </a> 116 133 </nav> 134 135 <!-- tab: general --> 136 <div id="tab_general" class="all_tabs" <?php echo $tab == "general" ? '' : ' style="display:none"' ?>> 137 <form method="post" action="" class="simplest_analytics_form"> 138 <table class="settings_table"> 139 <tr class="head_th"> 140 <th></th> 141 <th> 142 <?php echo __('Cookie Name', 'simplest-analytics') ?> 143 </th> 144 <th> 145 <?php echo __('Cookie Value', 'simplest-analytics') ?> 146 </th> 147 </tr> 148 149 <tr> 150 <th></th> 151 <td colspan="2"> 152 <?php echo __('If you want to require a certain cookie to be set before data is tracked please fill out the fields. Otherwise leave the fields empty', 'simplest-analytics') ?> 153 </td> 154 </tr> 155 156 157 158 <tr> 159 <th> 160 <?php echo __('Cookie', 'simplest-analytics') ?> 161 </th> 162 <td> 163 <input type="text" name="cookie_name" 164 value="<?php echo isset($general_options["cookie_name"]) ? esc_html($general_options["cookie_name"]) : "" ?>" /> 165 <span class="desc"> 166 <?php echo __('Name of the cookie that has to be set to allow tracking. E.g. analytics_consent', 'simplest-analytics') ?> 167 </span> 168 169 </td> 170 <td> 171 <input type="text" name="cookie_value" 172 value="<?php echo isset($general_options["cookie_value"]) ? esc_html($general_options["cookie_value"]) : "" ?>" /> 173 <span class="desc"> 174 <?php echo __('Value that has to be set. E.g. true or yes or others', 'simplest-analytics') ?> 175 </span> 176 177 </td> 178 </tr> 179 180 181 </table> 182 <input type="submit" name="submit_general" style="margin-top:20px;" class="button-primary" 183 value="<?php echo __('save general settings', 'simplest-analytics') ?>" /> 184 </form> 185 </div> 186 <!-- END tab: general --> 117 187 118 188 <!-- tab: url parameters --> … … 485 555 if ($.inArray(this_val, para) !== -1) { 486 556 var alert_txt = '<?php echo esc_html__('Please use unique names. This name is used multiple times:', 'simplest-analytics') ?>'; 487 alert(alert_txt +' '+this_val);557 alert(alert_txt + ' ' + this_val); 488 558 e.preventDefault(); 489 559 return false; -
simplest-analytics/trunk/includes/class-activator.php
r2982206 r3145946 8 8 * 9 9 */ 10 class Simplest_Analytics_Activator { 10 class Simplest_Analytics_Activator 11 { 11 12 12 13 /** 13 14 * set up options necessary for functionality of this plugin to wp_options 14 15 */ 15 public static function activate() { 16 public static function activate() 17 { 16 18 17 19 // create webanalytics table 18 20 global $wpdb; 19 21 $charset_collate = $wpdb->get_charset_collate(); 20 22 21 23 $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}simplest_analytics` ( 22 24 id bigint(50) NOT NULL AUTO_INCREMENT, … … 33 35 PRIMARY KEY (id) 34 36 ) $charset_collate;"; 35 37 36 38 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 37 39 dbDelta($sql); … … 42 44 * Set Up Plugin Version 43 45 */ 44 45 update_option( 'simplest_analytics_version', '1.3.1' );46 46 47 /** 47 update_option('simplest_analytics_version', '1.3.2'); 48 49 /** 48 50 * Set Up tracking url parameter 49 51 */ … … 51 53 // check if simplest_analytivs_url_para is already set 52 54 $para_options = get_option('simplest_analytivs_url_para'); 53 if ( !isset($para_options)) {55 if (!isset($para_options)) { 54 56 $example_para["campaign"] = "Campaign Name"; 55 update_option( 'simplest_analytivs_url_para', $example_para);57 update_option('simplest_analytivs_url_para', $example_para); 56 58 } 57 59 58 60 59 61 } 60 62 -
simplest-analytics/trunk/includes/class-simplest-analytics.php
r2982206 r3145946 29 29 $this->version = SIMPLEST_ANALYTICS_VERSION; 30 30 } else { 31 $this->version = '1.3. 1';31 $this->version = '1.3.2'; 32 32 } 33 33 $this->simplest_analytics = 'simplest-analytics'; -
simplest-analytics/trunk/includes/class-uninstall.php
r2847231 r3145946 8 8 * 9 9 */ 10 class Simplest_Analytics_Uninstaller { 10 class Simplest_Analytics_Uninstaller 11 { 11 12 12 13 /** … … 14 15 * 15 16 */ 16 public static function uninstall() { 17 public static function uninstall() 18 { 17 19 18 global $wpdb;19 $table_name = $wpdb->prefix . 'simplest_analytics';20 $sql = "DROP TABLE IF EXISTS $table_name";21 $wpdb->query($sql);22 20 global $wpdb; 21 $table_name = $wpdb->prefix . 'simplest_analytics'; 22 $sql = "DROP TABLE IF EXISTS $table_name"; 23 $wpdb->query($sql); 24 23 25 // delete all plugin created options 24 delete_option('simplest_analytics_version');26 delete_option('simplest_analytics_version'); 25 27 delete_option('simplest_analytivs_url_para'); 26 28 delete_option('simplest_analytivs_events'); 27 29 delete_option('simplest_analytivs_general'); 28 30 29 31 } -
simplest-analytics/trunk/public/class-public.php
r2979293 r3145946 74 74 75 75 function onTrackedVideoFrame<?php echo esc_html($randmom_id) ?>(currentTime, duration, video_wrapper_id) { 76 var allowed = simplest_analytics_is_allowed(); 77 if (!allowed) { 78 return; 79 } 76 80 var percentage = Math.floor((currentTime / duration) * 100); 77 81 var one_sec = $("#" + video_wrapper_id + " .simplest_analytics_video_sec_1").val(); … … 186 190 { 187 191 192 $general_options = get_option('simplest_analytivs_general'); 193 $cookie_name = isset($general_options['cookie_name']) ? sanitize_text_field($general_options['cookie_name']) : ''; 194 $cookie_value = isset($general_options['cookie_value']) ? sanitize_text_field($general_options['cookie_value']) : ''; 195 196 188 197 189 198 ?> 190 199 <script> 200 201 function simplest_analytics_is_allowed() { 202 203 try { 204 205 var required_cookie_name = "<?php echo esc_html($cookie_name) ?>"; 206 var required_cookie_value = "<?php echo esc_html($cookie_value) ?>"; 207 if (required_cookie_name === "" && required_cookie_value === "") { 208 return true; 209 } 210 211 var name = required_cookie_name + "="; 212 var decodedCookie = decodeURIComponent(document.cookie); 213 var ca = decodedCookie.split(';'); 214 for (var i = 0; i < ca.length; i++) { 215 var c = ca[i]; 216 while (c.charAt(0) === ' ') { 217 c = c.substring(1); 218 } 219 if (c.indexOf(name) === 0) { 220 if (c.substring(name.length, c.length) === required_cookie_value) { 221 return true; 222 } 223 } 224 } 225 return false; 226 } catch (e) { 227 return false; 228 } 229 230 } 231 191 232 function simplest_analytics_track(type, event) { 233 var allowed = simplest_analytics_is_allowed(); 234 if (!allowed) { 235 return; 236 } 192 237 if (event !== "") { 193 238 var event = "&event=" + event; … … 256 301 ?> 257 302 <script> 258 var wc_simplest_analytics_url = "<?php echo esc_url(admin_url('admin-ajax.php')) ?>?action=simplest_analytics_tracking_action&type=event&event=sale&ref=" + document.referrer; 259 var xhttp = new XMLHttpRequest(); 260 xhttp.onreadystatechange = function () { 261 if (this.readyState == 4 && this.status == 200) { 262 // Typical action to be performed when the document is ready: 263 //alert(xhttp.responseText); 264 } 265 266 }; 267 xhttp.open("GET", wc_simplest_analytics_url, true); 268 xhttp.send(); 303 var allowed = simplest_analytics_is_allowed(); 304 if (allowed) { 305 306 var wc_simplest_analytics_url = "<?php echo esc_url(admin_url('admin-ajax.php')) ?>?action=simplest_analytics_tracking_action&type=event&event=sale&ref=" + document.referrer; 307 var xhttp = new XMLHttpRequest(); 308 xhttp.onreadystatechange = function () { 309 if (this.readyState == 4 && this.status == 200) { 310 // Typical action to be performed when the document is ready: 311 //alert(xhttp.responseText); 312 } 313 314 }; 315 xhttp.open("GET", wc_simplest_analytics_url, true); 316 xhttp.send(); 317 } 269 318 </script> 270 319 <?php -
simplest-analytics/trunk/simplest-analytics.php
r2982206 r3145946 13 13 * Plugin URI: https://www.coden-lassen.de 14 14 * Description: Serverside and cookieless webanalytics. 15 * Version: 1.3. 115 * Version: 1.3.2 16 16 * Author: Stefan Klaes 17 17 * Author URI: https://www.coden-lassen.de/wordpress-freelancer … … 32 32 /** 33 33 * Currently plugin version: 34 * version 1.3. 134 * version 1.3.2 35 35 */ 36 36 37 define( 'SIMPLEST_ANALYTICS_VERSION', '1.3. 1' );37 define( 'SIMPLEST_ANALYTICS_VERSION', '1.3.2' ); 38 38 39 39
Note: See TracChangeset
for help on using the changeset viewer.