<?php
/**
* @package gm_Tracking
*/
/*
Plugin Name: User-tracking codes for GM
Plugin URI: http://www.groupemoniteur.fr/
Description: Adds js codes for user-tracking
Version: 1.0
Author: Pierre GERRIER
Author URI: mailto:pierre@gerrier.fr
License: GPLv2 or later
*/
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
if(!class_exists('gmTracking')) {
class gmTracking {
static protected $default_trackers = array(
'CookieApprovalTracking'
);
static public function get_defined_trackers() {
$trackers = apply_filters('gm_tracking_default_trackers', self::$default_trackers);
foreach($trackers as $tracker) {
require_once(dirname(__FILE__) . '/gm_Tracking/' . $tracker . '.php');
}
return apply_filters('gm_tracking_defined_trackers', $trackers);
}
static public function display_trackings() {
$trackers = static::get_defined_trackers();
$codes = array();
foreach($trackers as $tracker) {
if(class_exists($tracker)) {
// TODO: add enable/disable flags
$codes[$tracker] = $tracker::get_tracking_code();
}
}
echo implode($codes);
}
static public function admin_bar_init() {
if(!is_super_admin() || !is_admin_bar_showing() || (isset($_SERVER['SCRIPT_NAME']) && 'wp-login.php' == basename($_SERVER['SCRIPT_NAME']))) {
return;
}
add_action('admin_bar_menu', array(__CLASS__, 'admin_bar_menu'), 1000);
}
static public function admin_bar_menu(WP_Admin_Bar $wp_admin_bar) {
$wp_admin_bar->add_menu(array(
'id' => 'gm-tracking',
'title' => 'Tracking',
));
$trackers = static::get_defined_trackers();
foreach($trackers as $tracker) {
if(class_exists($tracker)) {
$wp_admin_bar->add_menu(array(
'id' => 'gm-tracking-' . $tracker,
'parent' => 'gm-tracking',
'title' => $tracker::get_admin_bar_label(),
));
if(false !== $content = $tracker::get_admin_bar_content()) {
if(!is_array($content)) {
$content = array($content);
}
foreach($content as $k => $v) {
$wp_admin_bar->add_menu(array(
'id' => 'gm-tracking-' . $tracker . '-' . $k,
'parent' => 'gm-tracking-' . $tracker,
'title' => $v,
));
}
}
}
}
}
}
}
if(class_exists('gmTracking')) {
add_action('wp_footer', array('gmTracking', 'display_trackings'));
add_action('admin_bar_init', array('gmTracking', 'admin_bar_init'));
}
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function add_action() in /in/BpHb7:109
Stack trace:
#0 {main}
thrown in /in/BpHb7 on line 109
Process exited with code 255.
This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.