| Server IP : 37.27.51.148 / Your IP : 37.27.51.148 Web Server : nginx/1.14.1 System : Linux libra 4.18.0-553.51.1.el8_10.x86_64 #1 SMP Wed Apr 30 20:24:04 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.31 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/wp-content/plugins/pixel-caffeine/includes/ |
Upload File : |
<?php
/**
* Collection of helper functions
*
* @package Pixel Caffeine
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Print the track code for a specific event
*
* @param string|array|object $args List of arguments of the event.
*
* @return string|null
*/
function aepc_pixel_event_code( $args = array() ) {
$defaults = array(
'event_id' => '',
'event_name' => '',
'value' => '',
'currency' => '',
'content_name' => '',
'content_category' => '',
'content_ids' => array(),
'content_type' => '',
'num_items' => '',
'search_string' => '',
'status' => '',
'return' => false,
);
// Set arguments.
$args = wp_parse_args( $args, $defaults );
$standard_params = $args;
// Set standard parameters.
$standard_params = array_intersect_key( $standard_params, $defaults );
// Get custom parameters.
$custom_params = array_diff_key( $args, $standard_params );
// Set standard parameters.
foreach ( array( 'event_name', 'return' ) as $key ) {
unset( $standard_params[ $key ], $custom_params[ $key ] );
}
// Get the event ID.
if ( ! empty( $args['event_id'] ) ) {
$standard_params['event_id'] = $args['event_id'];
}
// Get track code.
$code = AEPC_Track::track( $args['event_name'], array_filter( $standard_params ), array_filter( $custom_params ) );
// If option is on footer, must be returned and not printed.
if ( 'footer' === get_option( 'aepc_pixel_position' ) ) {
return null;
}
// Otherwise return according to argument.
if ( ! $args['return'] ) {
printf( "<script>\n\t%s\n</script>", wp_kses_post( $code ) );
}
// Anyway, unregister track.
AEPC_Track::remove_event( $args['event_name'], 'last' );
return $code;
}