";
echo $aimtell_tracking_code;
//if woocommerce is activated, abandoned browse tracking is enabled, and it's a product page, add the script
if(is_woocommerce_activated()){
if(get_aimtell_woocommerce_abandoned_browse()){
if(is_product()){
$product_details = get_woocommerce_product_data();
$product_available = $product_details->available;
$product_name = $product_details->name;
$product_image = $product_details->image;
$product_price = $product_details->price;
$product_url = $product_details->url;
$browse_abandoned_delay = get_aimtell_woocommerce_abandoned_browse_delay();
//json encode so values containing quotes, apostrophes or tags stay valid JS
$aimtell_json_flags = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP;
$product_name_js = wp_json_encode( $product_name, $aimtell_json_flags );
$product_image_js = wp_json_encode( $product_image, $aimtell_json_flags );
$product_price_js = wp_json_encode( $product_price, $aimtell_json_flags );
$product_url_js = wp_json_encode( $product_url, $aimtell_json_flags );
$woocommerce_abaondoned_browse_tracking_code = "";
if($product_available){
echo $woocommerce_abaondoned_browse_tracking_code;
}
else{
echo "";
}
}
else{
echo "";
}
}
else{
echo "";
}
}
else{
echo "";
}
}
/***************Plugin Functions****************/
// Define the function in the main plugin file
function get_aimtell_woocommerce_tracking() {
global $wpdb;
$table_name = $wpdb->prefix . 'options';
$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s", 'aimtell_woocommerce_tracking'));
return $value ? intval($value) : 0;
}
function get_aimtell_woocommerce_abandoned_browse() {
global $wpdb;
$table_name = $wpdb->prefix . 'options';
$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s", 'aimtell_woocommerce_abandoned_browse'));
return $value ? intval($value) : 0;
}
function get_aimtell_woocommerce_abandoned_browse_delay() {
global $wpdb;
$table_name = $wpdb->prefix . 'options';
$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s", 'aimtell_woocommerce_abandoned_browse_delay'));
return $value ? intval($value) : 10;
}
function get_aimtell_woocommerce_logging_level() {
global $wpdb;
$table_name = $wpdb->prefix . 'options';
$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s", 'aimtell_woocommerce_logging_level'));
return $value ? intval($value) : 0;
}
/**
* Full path to the log file. It lives in a folder under uploads that Apache refuses to
* serve, and its name carries a random key so it can't be guessed where .htaccess is
* ignored (e.g. Nginx). The old plugin-folder location could be fetched by URL.
*/
function get_aimtell_log_path() {
$key = get_option( 'aimtell_log_key' );
if ( ! $key ) {
$key = wp_generate_password( 20, false );
update_option( 'aimtell_log_key', $key, 'no' );
}
$uploads = wp_upload_dir( null, false );
return trailingslashit( $uploads['basedir'] ) . 'aimtell/aimtell-' . $key . '.log';
}
/**
* Log file location relative to the WordPress root, for display on the settings screen.
*/
function get_aimtell_log_file() {
return '/' . str_replace( ABSPATH, '', get_aimtell_log_path() );
}
/**
* Create the log folder with files that block web access and directory listing.
*/
function aimtell_prepare_log_dir() {
$dir = dirname( get_aimtell_log_path() );
if ( ! is_dir( $dir ) && ! wp_mkdir_p( $dir ) ) {
return false;
}
if ( ! file_exists( $dir . '/.htaccess' ) ) {
// Apache 2.4 and 2.2 syntax, each only where its module is loaded
@file_put_contents( $dir . '/.htaccess', "