3v4l.org

run code in 300+ PHP versions simultaneously
<?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 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
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.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Call to undefined function add_action() in /in/BpHb7 on line 109
Process exited with code 255.
Output for 5.2.3 - 5.2.17
Parse error: syntax error, unexpected T_STATIC in /in/BpHb7 on line 51
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
<br /> <b>Parse error</b>: syntax error, unexpected T_STATIC in <b>/in/BpHb7</b> on line <b>51</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.0.5
<br /> <b>Parse error</b>: parse error, unexpected T_STATIC in <b>/in/BpHb7</b> on line <b>51</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/BpHb7</b> on line <b>36</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/BpHb7</b> on line <b>36</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in <b>/in/BpHb7</b> on line <b>36</b><br />
Process exited with code 255.

preferences:
329 ms | 401 KiB | 468 Q