File "class-wc-coupons-tracking.php"

Full path: /home/kosmetik/public_html/wp-content/plugins/woocommerce/includes/tracks/events/class-wc-coupons-tracking.php
File size: 1.6 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php

defined('ABSPATH') || exit;
class WC_Coupons_Tracking
{
    public function init()
    {
        add_action('load-edit.php', array($this, 'tracks_coupons_events'), 10);
    }
    public function tracks_coupons_bulk_actions()
    {
        wc_enqueue_js("\n\t\t\tfunction onApplyBulkActions( event ) {\n\t\t\t\tvar id = event.data.id;\n\t\t\t\tvar action = \$( '#' + id ).val();\n\t\t\t\t\n\t\t\t\tif ( action && '-1' !== action ) {\n\t\t\t\t\twindow.wcTracks.recordEvent( 'coupons_view_bulk_action', {\n\t\t\t\t\t\taction: action\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t\t\$( '#doaction' ).on( 'click', { id: 'bulk-action-selector-top' }, onApplyBulkActions );\n\t\t\t\$( '#doaction2' ).on( 'click', { id: 'bulk-action-selector-bottom' }, onApplyBulkActions );\n\t\t");
    }
    public function tracks_coupons_events()
    {
        if (isset($_GET['post_type']) && 'shop_coupon' === $_GET['post_type']) {
            $this->tracks_coupons_bulk_actions();
            WC_Tracks::record_event('coupons_view', array('status' => isset($_GET['post_status']) ? sanitize_text_field(wp_unslash($_GET['post_status'])) : 'all'));
            if (isset($_GET['filter_action']) && 'Filter' === sanitize_text_field(wp_unslash($_GET['filter_action'])) && isset($_GET['coupon_type'])) {
                WC_Tracks::record_event('coupons_filter', array('filter' => 'coupon_type', 'value' => sanitize_text_field(wp_unslash($_GET['coupon_type']))));
            }
            if (isset($_GET['s']) && 0 < strlen(sanitize_text_field(wp_unslash($_GET['s'])))) {
                WC_Tracks::record_event('coupons_search');
            }
        }
    }
}