Changeset 1942148
- Timestamp:
- 09/16/2018 10:45:38 AM (7 years ago)
- Location:
- matomo-tracker/trunk
- Files:
-
- 6 edited
-
README.txt (modified) (2 diffs)
-
inc/admin/class-admin.php (modified) (2 diffs)
-
inc/admin/views/html-matomo-tracker-admin-display.php (modified) (1 diff)
-
inc/core/class-init.php (modified) (2 diffs)
-
inc/frontend/class-frontend.php (modified) (3 diffs)
-
matomo-tracker.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
matomo-tracker/trunk/README.txt
r1933857 r1942148 6 6 Tested up to: 4.9.8 7 7 Requires PHP: 5.6.0 8 Stable tag: 1.2. 08 Stable tag: 1.2.1 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 61 61 * JS Tracking file loading mode is now customizable (defer, async or nothing) 62 62 * JS Tracking file can be disallowed in robots.txt 63 64 = 1.2.1 = 65 * Added new settings to inline javascript as in previous version 66 * Workaround to solve js tarcking reported issue (https://wordpress.org/support/topic/js-tracking-mode-doesnt-work-since-v-1-2-0/) -
matomo-tracker/trunk/inc/admin/class-admin.php
r1933857 r1942148 191 191 $messageLog .= 'Settings saved'; 192 192 } 193 if ( $matomoMode == 'js' ) $this->update_tracker_settings();193 /*$this->update_tracker_settings();*/ 194 194 $this->custom_redirect( $admin_notice, $messageLog); 195 195 die(); … … 201 201 } 202 202 } 203 204 private function update_tracker_settings() { 205 if ( get_option( $this->plugin_name.'-tracking-mode' ) == 'js' &&!empty(get_option( $this->plugin_name.'-url' )) && !empty(get_option( $this->plugin_name.'-tracking-id' )) && !empty(get_option( $this->plugin_name.'-token' )) ) { 206 $piwikId = get_option( $this->plugin_name.'-tracking-id' ); 207 208 $piwikFileDir = $this->plugin_name_url . 'inc/frontend/'; 209 $piwikJsFile = $this->plugin_name_dir . 'inc/frontend/track.js'; 210 $js = 'var _paq = _paq || []; _paq.push(["trackPageView"]); _paq.push(["enableLinkTracking"]); (function() { var u="'. $piwikFileDir .'piwik.php"; _paq.push(["setTrackerUrl", u]); _paq.push(["setSiteId", "'. $piwikId .'"]); var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript"; g.async=true; g.defer=true; g.src=u; s.parentNode.insertBefore(g,s); })();'; 211 file_put_contents($piwikJsFile, $js); 203 /* 204 private function check_for_update() { 205 $our_plugin = plugin_basename( __FILE__ ); 206 // If an update has taken place and the updated type is plugins and the plugins element exists 207 if( $options['action'] == 'update' && $options['type'] == 'plugin' && isset( $options['plugins'] ) ) { 208 // Iterate through the plugins being updated and check if ours is there 209 foreach( $options['plugins'] as $plugin ) { 210 if( $plugin == $our_plugin ) { 211 $this->update_tracker_settings(); 212 } 213 } 212 214 } 213 215 214 216 } 215 217 218 private function update_tracker_settings() { 219 if ( get_option( $this->plugin_name.'-tracking-mode' ) != 'php' && !empty(get_option( $this->plugin_name.'-url' )) && !empty(get_option( $this->plugin_name.'-tracking-id' )) && !empty(get_option( $this->plugin_name.'-token' )) ) { 220 $piwikId = get_option( $this->plugin_name.'-tracking-id' ); 221 $piwikFileDir = $this->plugin_name_url . 'inc/frontend/'; 222 $piwikJsFile = $this->plugin_name_dir . 'inc/frontend/track.js'; 223 $js = 'var _paq = _paq || []; _paq.push(["trackPageView"]); _paq.push(["enableLinkTracking"]); (function() { var u="'. $piwikFileDir .'piwik.php"; _paq.push(["setTrackerUrl", u]); _paq.push(["setSiteId", "'. $piwikId .'"]); var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript"; g.async=true; g.defer=true; g.src=u; s.parentNode.insertBefore(g,s); })();'; 224 file_put_contents($piwikJsFile, $js); 225 } 226 } 227 */ 216 228 public function custom_redirect( $admin_notice, $response ) { 217 229 wp_redirect( esc_url_raw( add_query_arg( array( -
matomo-tracker/trunk/inc/admin/views/html-matomo-tracker-admin-display.php
r1933857 r1942148 60 60 <td> 61 61 <select id="<?php echo $this->plugin_name; ?>-tracking-mode" name="<?php echo $this->plugin_name; ?>-tracking-mode"> 62 <option value="js"<?php if (( get_option( $this->plugin_name.'-tracking-mode' ) == 'js') || empty(get_option( $this->plugin_name.'-tracking-mode' )) ) echo ' selected'; ?>>Javascript</option> 62 <option value="js"<?php if (( get_option( $this->plugin_name.'-tracking-mode' ) == 'js') || empty(get_option( $this->plugin_name.'-tracking-mode' )) ) echo ' selected'; ?>>Javascript (External File)</option> 63 <option value="jsi"<?php if ( get_option( $this->plugin_name.'-tracking-mode' ) == 'jsi') echo ' selected'; ?>>Javascript (Inlined)</option> 63 64 <option value="php"<?php if ( get_option( $this->plugin_name.'-tracking-mode' ) == 'php') echo ' selected'; ?>>PHP</option> 64 65 </select> -
matomo-tracker/trunk/inc/core/class-init.php
r1933857 r1942148 133 133 $this->loader->add_action( 'admin_post_matomo_tracker_form_response', $plugin_admin, 'check_for_event_submissions'); 134 134 $this->loader->add_action( 'admin_notices', $plugin_admin, 'print_plugin_admin_notices'); 135 $this->loader->add_action( 'upgrader_process_complete', $plugin_admin, 'update_tracker_settings');135 /*$this->loader->add_action( 'upgrader_process_complete', $plugin_admin, 'check_for_update');*/ 136 136 137 137 } … … 145 145 private function define_public_hooks() { 146 146 147 $plugin_public = new Frontend\Frontend( $this->get_plugin_name(), $this->get_version(), $this->get_plugin_text_domain() );147 $plugin_public = new Frontend\Frontend( $this->get_plugin_name(), $this->get_version(), $this->get_plugin_text_domain(), $this->get_plugin_name_dir() ); 148 148 149 149 //$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); -
matomo-tracker/trunk/inc/frontend/class-frontend.php
r1933857 r1942148 43 43 */ 44 44 private $plugin_text_domain; 45 46 private $plugin_name_dir; 45 47 46 48 /** … … 52 54 * @param string $plugin_text_domain The text domain of this plugin. 53 55 */ 54 public function __construct( $plugin_name, $version, $plugin_text_domain ) {56 public function __construct( $plugin_name, $version, $plugin_text_domain, $plugin_name_dir ) { 55 57 56 58 $this->plugin_name = $plugin_name; 57 59 $this->version = $version; 58 60 $this->plugin_text_domain = $plugin_text_domain; 61 62 $this->plugin_name_dir = $plugin_name_dir; 59 63 60 64 } … … 108 112 public function add_tracking_code_footer() { 109 113 if ( !empty(get_option( $this->plugin_name.'-url' )) && !empty(get_option( $this->plugin_name.'-tracking-id' )) && !empty(get_option( $this->plugin_name.'-token' )) ) { 110 $piwikFileDir = plugin_dir_url( __FILE__ ); 111 $matomoJsMode = get_option( $this->plugin_name.'-javascript-mode' ); 112 $matomoScript = "<script type='text/javascript'"; 113 if ($matomoJsMode == 'defer') $matomoScript .= " defer='defer'"; 114 if ($matomoJsMode == 'async') $matomoScript .= " async='async'"; 115 $matomoScript .= " src='".$piwikFileDir."track.js'></script>"; 116 echo $matomoScript; 114 $matomoJsType = get_option( $this->plugin_name.'-tracking-mode' ); 115 if ($matomoJsType == 'jsi') { 116 echo '<script type="text/javascript">'. $this->get_javascript_tracking_code() .'</script>'; 117 } else { 118 $piwikJsFile = $this->plugin_name_dir . 'inc/frontend/track.js'; 119 file_put_contents($piwikJsFile, $this->get_javascript_tracking_code()); 120 $matomoJsMode = get_option( $this->plugin_name.'-javascript-mode' ); 121 $piwikFileDir = plugin_dir_url( __FILE__ ); 122 $matomoScript = "<script type='text/javascript'"; 123 if ($matomoJsMode == 'defer') $matomoScript .= " defer='defer'"; 124 if ($matomoJsMode == 'async') $matomoScript .= " async='async'"; 125 $matomoScript .= " src='".$piwikFileDir."track.js'></script>"; 126 echo $matomoScript; 127 } 117 128 } 118 129 } 130 /* 131 private function update_tracker_settings() { 132 if ( get_option( $this->plugin_name.'-tracking-mode' ) != 'php' && !empty(get_option( $this->plugin_name.'-url' )) && !empty(get_option( $this->plugin_name.'-tracking-id' )) && !empty(get_option( $this->plugin_name.'-token' )) ) { 133 $piwikJsFile = plugin_dir_url( __FILE__ ) . 'track.js'; 134 file_put_contents($piwikJsFile, $this->get_javascript_tracking_code()); 135 } 136 } 137 */ 138 private function get_javascript_tracking_code() { 139 $piwikFileDir = plugin_dir_url( __FILE__ ); 140 $piwikId = get_option( $this->plugin_name.'-tracking-id' ); 141 return 'var _paq = _paq || []; _paq.push(["trackPageView"]); _paq.push(["enableLinkTracking"]); (function() { var u="'. $piwikFileDir .'piwik.php"; _paq.push(["setTrackerUrl", u]); _paq.push(["setSiteId", "'. $piwikId .'"]); var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript"; g.async=true; g.defer=true; g.src=u; s.parentNode.insertBefore(g,s); })();'; 142 } 143 119 144 120 145 public function disallow_javascript_tracking( $output, $public ) { -
matomo-tracker/trunk/matomo-tracker.php
r1933857 r1942148 16 16 * Plugin URI: https://wordpress.org/plugins/matomo-tracker/ 17 17 * Description: Matomo tracker adds matomo (formerly piwik) tracking code to your website while hiding your matomo installation url 18 * Version: 1.2. 018 * Version: 1.2.1 19 19 * Author: Niroma 20 20 * Author URI: https://www.niroma.net/ … … 40 40 define( NS . 'PLUGIN_NAME', 'matomo-tracker' ); 41 41 42 define( NS . 'PLUGIN_VERSION', '1.2. 0' );42 define( NS . 'PLUGIN_VERSION', '1.2.1' ); 43 43 44 44 define( NS . 'PLUGIN_NAME_DIR', plugin_dir_path( __FILE__ ) );
Note: See TracChangeset
for help on using the changeset viewer.