Skip to content

Commit

Permalink
Initial commit (v1.4.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
duracelltomi committed Aug 15, 2016
1 parent 15af06d commit ecc90a4
Show file tree
Hide file tree
Showing 134 changed files with 55,895 additions and 55 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# gtm4wp
Google Tag Manager plugin for WordPress
Google Tag Manager for WordPress
================================
This GitHub repo was created to allow others to easily contribute to this WordPress plugin. You can find more about the plugin at [the plugin homepage](https://duracelltomi.com/)

Support
-------
If you have any issues not related to the source code of the plugin directly, please visit the [support forum](https://wordpress.org/plugins/duracelltomi-google-tag-manager/) and ask your questions there.

Bug report
----------
Please use the [issue tracker](https://github.com/duracelltomi/gtm4wp/issues/new) of this GitHub repo to report any problem related to the source code. If you also was able to find a solution, send a Pull Request so that you code can be reviewed and merged to the core.

Contribution
------------
If you would like to extend plugin functionality by adding your own code, please feel free to send a Pull Request. It is also important to note that not all requests will be merged to the core so please do not be mad at me if your code does not get added.
1,124 changes: 1,124 additions & 0 deletions admin/admin.php

Large diffs are not rendered by default.

Binary file added admin/images/tag_manager-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/images/tag_manager-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
214 changes: 214 additions & 0 deletions common/readoptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
<?php
define( 'GTM4WP_OPTIONS', 'gtm4wp-options' );
define( 'GTM4WP_OPTION_GTM_CODE', 'gtm-code' );
define( 'GTM4WP_OPTION_GTM_PLACEMENT', 'gtm-code-placement' );
define( 'GTM4WP_OPTION_DATALAYER_NAME', 'gtm-datalayer-variable-name' );

define( 'GTM4WP_OPTION_INCLUDE_REMARKETING', 'include-remarketing' );
define( 'GTM4WP_OPTION_INCLUDE_LOGGEDIN', 'include-loggedin' );
define( 'GTM4WP_OPTION_INCLUDE_USERROLE', 'include-userrole' );
define( 'GTM4WP_OPTION_INCLUDE_USERID', 'include-userid' );
define( 'GTM4WP_OPTION_INCLUDE_POSTTYPE', 'include-posttype' );
define( 'GTM4WP_OPTION_INCLUDE_CATEGORIES', 'include-categories' );
define( 'GTM4WP_OPTION_INCLUDE_TAGS', 'include-tags' );
define( 'GTM4WP_OPTION_INCLUDE_AUTHORID', 'include-authorid' );
define( 'GTM4WP_OPTION_INCLUDE_AUTHOR', 'include-author' );
define( 'GTM4WP_OPTION_INCLUDE_POSTDATE', 'include-postdate' );
define( 'GTM4WP_OPTION_INCLUDE_POSTTITLE', 'include-posttitle' );
define( 'GTM4WP_OPTION_INCLUDE_POSTCOUNT', 'include-postcount' );
define( 'GTM4WP_OPTION_INCLUDE_POSTID', 'include-postid' );
define( 'GTM4WP_OPTION_INCLUDE_SEARCHDATA', 'include-searchdata' );
define( 'GTM4WP_OPTION_INCLUDE_BROWSERDATA', 'include-browserdata' );
define( 'GTM4WP_OPTION_INCLUDE_OSDATA', 'include-osdata' );
define( 'GTM4WP_OPTION_INCLUDE_DEVICEDATA', 'include-devicedata' );
define( 'GTM4WP_OPTION_INCLUDE_WEATHER', 'include-weather' );
define( 'GTM4WP_OPTION_INCLUDE_WEATHERUNITS', 'weather-weatherunits' );
define( 'GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI', 'weather-openweathermap-apikey' );
define( 'GTM4WP_OPTION_INCLUDE_SITEID', 'include-siteid' );
define( 'GTM4WP_OPTION_INCLUDE_SITENAME', 'include-sitename' );

define( 'GTM4WP_OPTION_EVENTS_OUTBOUND', 'event-outbound' );
define( 'GTM4WP_OPTION_EVENTS_DOWNLOADS', 'event-downloads' );
define( 'GTM4WP_OPTION_EVENTS_DWLEXT', 'event-download-extensions' );
define( 'GTM4WP_OPTION_EVENTS_EMAILCLICKS', 'event-email-clicks' );
define( 'GTM4WP_OPTION_EVENTS_FORMMOVE', 'event-form-move' );
define( 'GTM4WP_OPTION_EVENTS_SOCIAL', 'event-social' );
define( 'GTM4WP_OPTION_EVENTS_YOUTUBE', 'event-youtube' );
define( 'GTM4WP_OPTION_EVENTS_VIMEO', 'event-vimeo' );
define( 'GTM4WP_OPTION_EVENTS_SOUNDCLOUD', 'event-soundcloud' );

define( 'GTM4WP_OPTION_SCROLLER_ENABLED', 'scroller-enabled' );
define( 'GTM4WP_OPTION_SCROLLER_DEBUGMODE', 'scroller-debug-mode' );
define( 'GTM4WP_OPTION_SCROLLER_CALLBACKTIME', 'scroller-callback-time' );
define( 'GTM4WP_OPTION_SCROLLER_DISTANCE', 'scroller-distance' );
define( 'GTM4WP_OPTION_SCROLLER_CONTENTID', 'scroller-contentid' );
define( 'GTM4WP_OPTION_SCROLLER_READERTIME', 'scroller-readertime' );

define( 'GTM4WP_OPTION_BLACKLIST_ENABLE', 'blacklist-enable' );
define( 'GTM4WP_OPTION_BLACKLIST_ADADVISOR', 'blacklist-adadvisor' );
define( 'GTM4WP_OPTION_BLACKLIST_ADROLL', 'blacklist-adroll' );
define( 'GTM4WP_OPTION_BLACKLIST_AWCONV', 'blacklist-adwords-conversion' );
define( 'GTM4WP_OPTION_BLACKLIST_AWREMARKET', 'blacklist-adwords-remarketing' );
define( 'GTM4WP_OPTION_BLACKLIST_BIZO', 'blacklist-bizo' );
define( 'GTM4WP_OPTION_BLACKLIST_CLICKTALE', 'blacklist-clicktale' );
define( 'GTM4WP_OPTION_BLACKLIST_COMSCORE', 'blacklist-comscore' );
define( 'GTM4WP_OPTION_BLACKLIST_CUSTOMHTML', 'blacklist-custom-html' );
define( 'GTM4WP_OPTION_BLACKLIST_CUSTOMIMG', 'blacklist-custom-img-tag' );
define( 'GTM4WP_OPTION_BLACKLIST_DBLCLKCOUNT', 'blacklist-doubleclick-counter' );
define( 'GTM4WP_OPTION_BLACKLIST_DBLCLKSALES', 'blacklist-doubleclick-sales' );
define( 'GTM4WP_OPTION_BLACKLIST_GACLASSIC', 'blacklist-google-analytics' );
define( 'GTM4WP_OPTION_BLACKLIST_MARIN', 'blacklist-marin' );
define( 'GTM4WP_OPTION_BLACKLIST_MPLEXIFRAME', 'blacklist-mediaplex-iframe' );
define( 'GTM4WP_OPTION_BLACKLIST_MPLEXROI', 'blacklist-mediaplex-roi' );
define( 'GTM4WP_OPTION_BLACKLIST_MEDIA6DEG', 'blacklist-media6degrees' );
define( 'GTM4WP_OPTION_BLACKLIST_TURNCONV', 'blacklist-turn-conversion' );
define( 'GTM4WP_OPTION_BLACKLIST_TURNDATA', 'blacklist-turn-data' );
define( 'GTM4WP_OPTION_BLACKLIST_UA', 'blacklist-universal-analytics' );

define( 'GTM4WP_OPTION_BLACKLIST_MACRO_DOMELEMENT', 'blacklist-macro-dom-element' );
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_CUSTOMJS', 'blacklist-macro-custom-js' );
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_CONSTANT', 'blacklist-macro-constant-string' );
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_1STCOOKIE', 'blacklist-macro-1st-party-cookie' );
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_EVENTNAME', 'blacklist-macro-event-name' );
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_JSVAR', 'blacklist-macro-javascript-variable' );
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_DLAYERVAR', 'blacklist-macro-datalayer-variable' );
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM', 'blacklist-macro-random-number' );
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER', 'blacklist-macro-referrer' );
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_URL', 'blacklist-macro-url' );
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT', 'blacklist-macro-autoevent-variable' );

define( 'GTM4WP_OPTION_INTEGRATE_WPCF7', 'integrate-wpcf7' );

define( 'GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE', 'integrate-woocommerce' );
define( 'GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC', 'integrate-woocommerce-track-classic-ecommerce' );
define( 'GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC', 'integrate-woocommerce-track-enhanced-ecommerce' );
define( 'GTM4WP_OPTION_INTEGRATE_WCREMARKETING', 'integrate-woocommerce-remarketing' );
define( 'GTM4WP_OPTION_INTEGRATE_WCREMARKETINGSKU', 'integrate-woocommerce-remarketing-usesku' );

define( 'GTM4WP_OPTION_INTEGRATE_WPECOMMERCE', 'integrate-wp-e-commerce' );

define( 'GTM4WP_PLACEMENT_FOOTER', 0 );
define( 'GTM4WP_PLACEMENT_BODYOPEN', 1 );
define( 'GTM4WP_PLACEMENT_BODYOPEN_AUTO', 2 );
define( 'GTM4WP_PLACEMENT_OFF', 3 );

$gtm4wp_options = array();

$gtm4wp_defaultoptions = array(
GTM4WP_OPTION_GTM_CODE => "",
GTM4WP_OPTION_DATALAYER_NAME => "",
GTM4WP_OPTION_GTM_PLACEMENT => GTM4WP_PLACEMENT_FOOTER,

GTM4WP_OPTION_INCLUDE_REMARKETING => false,
GTM4WP_OPTION_INCLUDE_LOGGEDIN => false,
GTM4WP_OPTION_INCLUDE_USERROLE => false,
GTM4WP_OPTION_INCLUDE_USERID => false,
GTM4WP_OPTION_INCLUDE_POSTTYPE => true,
GTM4WP_OPTION_INCLUDE_CATEGORIES => true,
GTM4WP_OPTION_INCLUDE_TAGS => true,
GTM4WP_OPTION_INCLUDE_AUTHOR => true,
GTM4WP_OPTION_INCLUDE_AUTHORID => false,
GTM4WP_OPTION_INCLUDE_POSTDATE => false,
GTM4WP_OPTION_INCLUDE_POSTTITLE => false,
GTM4WP_OPTION_INCLUDE_POSTCOUNT => false,
GTM4WP_OPTION_INCLUDE_POSTID => false,
GTM4WP_OPTION_INCLUDE_SEARCHDATA => false,
GTM4WP_OPTION_INCLUDE_BROWSERDATA => false,
GTM4WP_OPTION_INCLUDE_OSDATA => false,
GTM4WP_OPTION_INCLUDE_DEVICEDATA => false,
GTM4WP_OPTION_INCLUDE_WEATHER => false,
GTM4WP_OPTION_INCLUDE_WEATHERUNITS => 0,
GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI => '',
GTM4WP_OPTION_INCLUDE_SITEID => false,
GTM4WP_OPTION_INCLUDE_SITENAME => false,

GTM4WP_OPTION_EVENTS_OUTBOUND => false,
GTM4WP_OPTION_EVENTS_DOWNLOADS => false,
GTM4WP_OPTION_EVENTS_DWLEXT => "pdf,doc,docx,xls,xlsx,ppt,pptx,zip,rar,gz,tar",
GTM4WP_OPTION_EVENTS_EMAILCLICKS => false,
GTM4WP_OPTION_EVENTS_FORMMOVE => true,
GTM4WP_OPTION_EVENTS_SOCIAL => false,
GTM4WP_OPTION_EVENTS_YOUTUBE => false,
GTM4WP_OPTION_EVENTS_VIMEO => false,
GTM4WP_OPTION_EVENTS_SOUNDCLOUD => false,

GTM4WP_OPTION_SCROLLER_ENABLED => false,
GTM4WP_OPTION_SCROLLER_DEBUGMODE => false,
GTM4WP_OPTION_SCROLLER_CALLBACKTIME => 100,
GTM4WP_OPTION_SCROLLER_DISTANCE => 150,
GTM4WP_OPTION_SCROLLER_CONTENTID => "content",
GTM4WP_OPTION_SCROLLER_READERTIME => 60,

GTM4WP_OPTION_BLACKLIST_ENABLE => 0,
GTM4WP_OPTION_BLACKLIST_ADADVISOR => false,
GTM4WP_OPTION_BLACKLIST_ADROLL => false,
GTM4WP_OPTION_BLACKLIST_AWCONV => false,
GTM4WP_OPTION_BLACKLIST_AWREMARKET => false,
GTM4WP_OPTION_BLACKLIST_BIZO => false,
GTM4WP_OPTION_BLACKLIST_CLICKTALE => false,
GTM4WP_OPTION_BLACKLIST_COMSCORE => false,
GTM4WP_OPTION_BLACKLIST_CUSTOMHTML => false,
GTM4WP_OPTION_BLACKLIST_CUSTOMIMG => false,
GTM4WP_OPTION_BLACKLIST_DBLCLKCOUNT => false,
GTM4WP_OPTION_BLACKLIST_DBLCLKSALES => false,
GTM4WP_OPTION_BLACKLIST_GACLASSIC => false,
GTM4WP_OPTION_BLACKLIST_MARIN => false,
GTM4WP_OPTION_BLACKLIST_MPLEXIFRAME => false,
GTM4WP_OPTION_BLACKLIST_MPLEXROI => false,
GTM4WP_OPTION_BLACKLIST_MEDIA6DEG => false,
GTM4WP_OPTION_BLACKLIST_TURNCONV => false,
GTM4WP_OPTION_BLACKLIST_TURNDATA => false,
GTM4WP_OPTION_BLACKLIST_UA => false,

GTM4WP_OPTION_BLACKLIST_MACRO_DOMELEMENT => true,
GTM4WP_OPTION_BLACKLIST_MACRO_CUSTOMJS => true,
GTM4WP_OPTION_BLACKLIST_MACRO_CONSTANT => true,
GTM4WP_OPTION_BLACKLIST_MACRO_1STCOOKIE => true,
GTM4WP_OPTION_BLACKLIST_MACRO_EVENTNAME => true,
GTM4WP_OPTION_BLACKLIST_MACRO_JSVAR => true,
GTM4WP_OPTION_BLACKLIST_MACRO_DLAYERVAR => true,
GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM => true,
GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER => true,
GTM4WP_OPTION_BLACKLIST_MACRO_URL => true,
GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT => true,

GTM4WP_OPTION_INTEGRATE_WPCF7 => false,

// GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE => false,
GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC => false,
GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC => false,
GTM4WP_OPTION_INTEGRATE_WCREMARKETING => false,
GTM4WP_OPTION_INTEGRATE_WCREMARKETINGSKU => false,

GTM4WP_OPTION_INTEGRATE_WPECOMMERCE => false
);

function gtm4wp_reload_options() {
global $gtm4wp_defaultoptions;

$storedoptions = (array) get_option( GTM4WP_OPTIONS );
if ( ! is_array( $gtm4wp_defaultoptions ) ) {
$gtm4wp_defaultoptions = array();
}

// update WooCommerce settings from 0.7.x to 0.8
if ( isset( $storedoptions[ GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE ] ) && ! isset( $storedoptions[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) ) {
$storedoptions[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] = $storedoptions[ GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE ];
$storedoptions[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] = false;
$storedoptions[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] = $storedoptions[ GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE ];

unset( $storedoptions[ GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE ] );
}

return array_merge( $gtm4wp_defaultoptions, $storedoptions );
}

function gtp4wp_debug_file( $debug_data ) {
$fp = fopen( dirname( __FILE__ ) . "/" . date("Y-m-d-H-i-s-u") . ".txt", "w" );
if ( $fp ) {
fwrite( $fp, $debug_data );
fclose( $fp );
}
}

$gtm4wp_options = gtm4wp_reload_options();
72 changes: 72 additions & 0 deletions css/admin-gtm4wp.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.tabinfo {
display: block;
clear: both;
margin: 20px 10px;
}

.gtm4wp-plugin-active {
color: #0c0;
}

.gtm4wp-plugin-not-active {
color: #c00;
}

.adminsubtabs {
list-style: none;
margin: 16px 0;
padding: 0;
font-size: 13px;
float: left;
color: #666;
}

.adminsubtabs li {
display: inline-block;
margin: 0;
padding: 0 10px;
white-space: nowrap;
border-right: 1px solid #666;
}

.adminsubtabs li:last-child {
border-right: 0;
}

.adminsubtabs a {
padding: .2em;
text-decoration: none;
}

.adminsubtabs a.subtab-active {
color: #000;
font-weight: bold;
}

.gtm4wp-phase-beta,
.gtm4wp-phase-experimental,
.gtm4wp-phase-deprecated {
display: inline-block;
background-color: #f00;
color: #fff;
font-size: 9px;
padding: 2px;
margin-left: 5px;
}

.gtm4wp-phase-beta:before {
content: "beta";
}

.gtm4wp-phase-deprecated {
background-color: #ddd;
color: #000;
}

.gtm4wp-phase-experimental:before {
content: "experimental";
}

.gtm4wp-phase-deprecated:before {
content: "deprecated";
}
28 changes: 28 additions & 0 deletions duracelltomi-google-tag-manager-for-wordpress.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/*
Plugin Name: Google Tag Manager for Wordpress
Version: 1.4
Plugin URI: https://duracelltomi.com/google-tag-manager-for-wordpress/
Description: The first Google Tag Manager plugin for WordPress with business goals in mind
Author: Thomas Geiger
Author URI: https://duracelltomi.com/
Text Domain: duracelltomi-google-tag-manager
Domain Path: /languages
*/

define( 'GTM4WP_VERSION', '1.4' );
define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );

$gtp4wp_plugin_url = plugin_dir_url( __FILE__ );
$gtp4wp_plugin_basename = plugin_basename( __FILE__ );
require_once( GTM4WP_PATH."/common/readoptions.php" );

function gtm4wp_init() {
load_plugin_textdomain( 'duracelltomi-google-tag-manager', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
if ( is_admin() ) {
require_once( GTM4WP_PATH."/admin/admin.php" );
} else {
require_once( GTM4WP_PATH."/public/frontend.php" );
}
}
add_action('plugins_loaded', 'gtm4wp_init');
33 changes: 33 additions & 0 deletions integration/soundcloud.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/*
Altering query parameters no longer needed
function gtm4wp_soundcloud( $return, $url, $data ) {
if ( false !== strpos( $return, "soundcloud.com" ) ) {
if ( false === strpos( $return, ' id="' ) ) {
if ( preg_match('/src="([^\"]+?)"/i', $return, $r) ) {
$_urlquery = parse_url( $r[1], PHP_URL_QUERY );
if ( false !== $_urlquery ) {
parse_str( $_urlquery, $_urlparts );
if ( isset( $_urlparts[ "url" ] ) ) {
$_urlpartsid = explode( "/", $_urlparts[ "url" ] );
$_playerid = "soundcloudplayer_" . $_urlpartsid[ count( $_urlpartsid )-1 ];
$return = str_replace( '<iframe ', '<iframe id="' . $_playerid . '" ', $return);
}
}
}
}
}
return $return;
}
add_filter( "oembed_result", "gtm4wp_soundcloud", 10, 3 );
*/

if ( ! is_admin() ) {
$in_footer = apply_filters( 'gtm4wp_soundcloud', false);
wp_enqueue_script( "gtm4wp-soundcloud-api", "https://w.soundcloud.com/player/api.js", array(), "1.0", $in_footer );
wp_enqueue_script( "gtm4wp-soundcloud", $gtp4wp_plugin_url . "js/gtm4wp-soundcloud.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
}
28 changes: 28 additions & 0 deletions integration/vimeo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/*
Altering query parameters no longer needed with new Vimeo JS API
function gtm4wp_vimeo( $return, $url, $data ) {
if ( false !== strpos( $return, "vimeo.com" ) ) {
if ( false === strpos( $return, ' id="' ) ) {
$_urlparts = explode( "/", $url );
$_playerid = "vimeoplayer_" . $_urlparts[ count( $_urlparts )-1 ];
$return = str_replace( '<iframe ', '<iframe id="' . $_playerid . '" ', $return);
$return = str_replace( $url, $url . "?api=1&origin=" . site_url() . "&player_id=" . $_playerid, $return);
} else {
$return = str_replace( $url, $url . "?api=1&origin=" . site_url(), $return);
}
}
return $return;
}
add_filter( "oembed_result", "gtm4wp_vimeo", 10, 3 );
*/
if ( ! is_admin() ) {
$in_footer = apply_filters( 'gtm4wp_vimeo', false);
// wp_enqueue_script( "gtm4wp-vimeo-froogaloop", $gtp4wp_plugin_url . "js/froogaloop.js", array(), "2.0", $in_footer );
wp_enqueue_script( "gtm4wp-vimeo-api", "https://player.vimeo.com/api/player.js", array(), "1.0", $in_footer );
wp_enqueue_script( "gtm4wp-vimeo", $gtp4wp_plugin_url . "js/gtm4wp-vimeo.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
}
Loading

0 comments on commit ecc90a4

Please sign in to comment.