Plugin Directory

Changeset 2099672


Ignore:
Timestamp:
06/03/2019 08:30:15 AM (7 years ago)
Author:
walljet
Message:

add tracking code to footer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-etracker/trunk/tracklet.php

    r2092835 r2099672  
    44Plugin URI: https://developer.wordpress.org/plugins/wpetracker/
    55Description: Analysiere dein WordPress mit etracker.
    6 Version: 1.0.9
     6Version: 1.0.10
    77Author: WP-etracker
    88Author URI: https://wp-etracker.com
     
    5050        // Init Plugin Scripts
    5151        add_action('admin_menu', array($this, 'wpetracker_add_admin_page'));
    52         add_action('wp_enqueue_scripts', array($this, 'wpetracker_add_tracking_script'));
     52        // K. Meffert: Optionally add etracker tracking code to footer instead of header
     53        if(get_option('tracking_code_hf_option') == 'on') {
     54            $toFooter=true;
     55            add_action('wp_footer', array($this, 'wpetracker_add_tracking_script'));
     56    }
     57        else {
     58            $toFooter=false;
     59            add_action('wp_enqueue_scripts', array($this, 'wpetracker_add_tracking_script'));
     60        }
     61       
    5362        add_action('wp_print_scripts', array($this, 'wpetracker_ajax_load_scripts'));
    5463
     
    5867        add_action('wp_ajax_auto_update', array($this, 'wpetracker_auto_update'));
    5968        add_action('wp_ajax_youtube_tracking', array($this, 'wpetracker_youtube_tracking'));
     69        add_action('wp_ajax_tracking_code_hf', array($this, 'wpetracker_tracking_code_hf'));
    6070        add_action('wp_ajax_wpetracker_accept_tos', array($this, 'wpetracker_accept_tos'));
    6171
     
    153163
    154164    /**
     165     * Allow to disable YouTube tracking
    155166     * @author Dr. Klaus Meffert
    156167     * @email mail@doktor-meffert,de
     
    162173    }
    163174
     175    /**
     176     * Allow to add tracking code either to header or to footer of page
     177     * @author Dr. Klaus Meffert
     178     * @email mail@doktor-meffert,de
     179     * --------------------------------------------
     180     * Function wpetracker_tracking_code_hf
     181     */
     182    function wpetracker_tracking_code_hf() {
     183        update_option('tracking_code_hf_option', $_POST['item']);
     184    }
    164185    function wpetracker_accept_tos() {
    165186        $updateTos = update_option('wpetracker_accept_tos', $_POST['accept_tos_value']);
     
    224245        $wpetrackerKey = get_option('wpetracker-key');
    225246        //K. Meffert: Add own plugin version to etracker call (as requested by etracker)
    226 //      $wp_version_plugin="1.0.9";
    227247        $plugin_data = get_plugin_data( __FILE__ );
    228248        $wp_version_plugin = $plugin_data['Version'];
     
    342362
    343363    function wpetracker_add_tracking_script() {
    344         if (get_option('wpetracker_accept_tos') == 'on') :
     364        if (get_option('wpetracker_accept_tos') == 'on') {
     365//          wp_enqueue_script('etracker-tracking',$code,);
    345366            Tracklet::wpetracker_get_main_tracking_script();
    346         endif;
     367        }
    347368    }
    348369
Note: See TracChangeset for help on using the changeset viewer.