Plugin Directory

Changeset 1942148


Ignore:
Timestamp:
09/16/2018 10:45:38 AM (7 years ago)
Author:
nir0ma
Message:

v1.2.1

Location:
matomo-tracker/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • matomo-tracker/trunk/README.txt

    r1933857 r1942148  
    66Tested up to: 4.9.8
    77Requires PHP: 5.6.0
    8 Stable tag: 1.2.0
     8Stable tag: 1.2.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6161* JS Tracking file loading mode is now customizable (defer, async or nothing)
    6262* 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  
    191191                    $messageLog .= 'Settings saved';
    192192                }
    193                 if ( $matomoMode == 'js' ) $this->update_tracker_settings();
     193                /*$this->update_tracker_settings();*/
    194194                $this->custom_redirect( $admin_notice, $messageLog);
    195195                die();
     
    201201            }
    202202    }
    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            }
    212214        }
    213215       
    214216    }
    215217   
     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    */
    216228    public function custom_redirect( $admin_notice, $response ) {
    217229        wp_redirect( esc_url_raw( add_query_arg( array(
  • matomo-tracker/trunk/inc/admin/views/html-matomo-tracker-admin-display.php

    r1933857 r1942148  
    6060                <td>                               
    6161                    <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>
    6364                        <option value="php"<?php if ( get_option( $this->plugin_name.'-tracking-mode' ) == 'php') echo ' selected';  ?>>PHP</option>
    6465                    </select>
  • matomo-tracker/trunk/inc/core/class-init.php

    r1933857 r1942148  
    133133        $this->loader->add_action( 'admin_post_matomo_tracker_form_response', $plugin_admin, 'check_for_event_submissions');
    134134        $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');*/
    136136
    137137    }
     
    145145    private function define_public_hooks() {
    146146
    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() );
    148148
    149149        //$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
  • matomo-tracker/trunk/inc/frontend/class-frontend.php

    r1933857 r1942148  
    4343     */
    4444    private $plugin_text_domain;
     45   
     46    private $plugin_name_dir;
    4547
    4648    /**
     
    5254     * @param       string $plugin_text_domain The text domain of this plugin.
    5355     */
    54     public function __construct( $plugin_name, $version, $plugin_text_domain ) {
     56    public function __construct( $plugin_name, $version, $plugin_text_domain, $plugin_name_dir ) {
    5557
    5658        $this->plugin_name = $plugin_name;
    5759        $this->version = $version;
    5860        $this->plugin_text_domain = $plugin_text_domain;
     61       
     62        $this->plugin_name_dir = $plugin_name_dir;
    5963
    6064    }
     
    108112    public function add_tracking_code_footer() {
    109113        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            }
    117128        }
    118129    }
     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   
    119144   
    120145    public function disallow_javascript_tracking( $output, $public ) {
  • matomo-tracker/trunk/matomo-tracker.php

    r1933857 r1942148  
    1616 * Plugin URI:        https://wordpress.org/plugins/matomo-tracker/
    1717 * Description:       Matomo tracker adds matomo (formerly piwik) tracking code to your website while hiding your matomo installation url
    18  * Version:           1.2.0
     18 * Version:           1.2.1
    1919 * Author:            Niroma
    2020 * Author URI:        https://www.niroma.net/
     
    4040define( NS . 'PLUGIN_NAME', 'matomo-tracker' );
    4141
    42 define( NS . 'PLUGIN_VERSION', '1.2.0' );
     42define( NS . 'PLUGIN_VERSION', '1.2.1' );
    4343
    4444define( NS . 'PLUGIN_NAME_DIR', plugin_dir_path( __FILE__ ) );
Note: See TracChangeset for help on using the changeset viewer.