Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hook Reference
  • Docs Home

Packages

  • Abandoned-Cart-Pro-for-WooCommerce
    • Admin
      • Action
      • Activate-plugin
      • Component
      • I18N
      • Import-Pro
      • License
      • Menu
      • Notices
      • Popup-Modal
        • Cart-Detail
      • Recover
      • Report
      • Setting
      • Settings
      • SMS
      • Tab
      • Template
    • Ajax-Functions
    • Classes
    • Common-Functions
    • Database-Layer
    • Encrypt-Decrypt-Data
    • Frontend
      • Cart-Capture
      • Cart-Populate
      • Coupon
      • Place-Order
    • Setting
    • Update
  • None

Classes

  • EDD_AC_WOO_Plugin_Updater
  • Wcap_Abandoned_Cart_Details
  • Wcap_Abandoned_Cart_List
  • Wcap_Abandoned_Orders_Table
  • Wcap_Abandoned_Trash_Orders_Table
  • Wcap_Actions
  • Wcap_Actions_Handler
  • Wcap_Activate_Plugin
  • wcap_active_license_notice
  • Wcap_Add_Cart_Popup_Modal
  • Wcap_Add_Settings
  • Wcap_Admin_Recovery
  • Wcap_Adv_settings
  • Wcap_Aes
  • Wcap_Aes_Ctr
  • Wcap_Ajax
  • Wcap_All_Component
  • Wcap_Atc_Dashboard
  • Wcap_Cart_Updated
  • Wcap_Common
  • Wcap_Coupon
  • Wcap_Dashboard
  • Wcap_Dashboard_Report
  • Wcap_Dashboard_Report_Action
  • Wcap_Dashboard_Widget
  • WCAP_Dashboard_Widget_Heartbeat
  • Wcap_Dashboard_Widget_Report
  • WCAP_DB_Layer
  • Wcap_Default_Settings
  • Wcap_Display_Notices
  • Wcap_EDD
  • Wcap_Eent_Email_List
  • Wcap_Email_Settings
  • Wcap_Email_Template_Fields
  • Wcap_Email_Template_List
  • Wcap_Import_Lite_to_Pro
  • Wcap_Load_Hooks
  • Wcap_Load_Scripts
  • Wcap_Localization
  • WCAP_Manual_Email
  • Wcap_Menu
  • WCAP_On_Placed_Order
  • Wcap_Order_Received
  • Wcap_Personal_Data_Eraser
  • Wcap_Personal_Data_Export
  • Wcap_Populate_Cart_Of_User
  • Wcap_Print_And_CSV
  • Wcap_Product_Report_List
  • Wcap_Product_Report_Table
  • Wcap_Recover_Orders_Table
  • Wcap_Recover_Trash_Orders_Table
  • Wcap_Recovered_Order_List
  • Wcap_Send_Manual_Email
  • Wcap_Sent_Emails_Table
  • Wcap_SMS
  • Wcap_SMS_Templates
  • Wcap_Templates_Table
  • Wcap_Tiny_Mce
  • WCAP_Tiny_Url
  • Wcap_Tracking_msg
  • Wcap_TS_deactivate
  • Wcap_TS_Faq_Support
  • Wcap_TS_Tracker
  • Wcap_TS_tracking
  • Wcap_TS_Welcome
  • Wcap_TS_Woo_Active
  • Wcap_Update_Check
  • Woocommerce_Abandon_Cart

Functions

  • wcap_add_notification_meta
  • wcap_get_notification_meta
  • wcap_get_notification_meta_by_key
  • wcap_get_template_status
  • wcap_update_notification_meta
  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 
<?php
/**
 * Abandoned Cart Pro for WooCommerce
 *
 * This file will load all hooks, filters which will be used all over the plugin.
 * 
 * @author   Tyche Softwares
 * @package  Abandoned-Cart-Pro-for-WooCommerce/Classes
 * @category Classes
 * @since    5.0
 */

if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}
if ( !class_exists('Wcap_Load_Hooks' ) ) {
    /** 
     * It will add the hooks, filters, menu and the variables and all the necessary actions for the plugins which will be used all over the plugin.
     * 
     * @since 2.5
     */
    class Wcap_Load_Hooks {
        /** 
         * This function is used for adding the hooks, filters, menu and the variables and all the necessary actions for the plugins.
         * 
         * @since 2.5
         */
        public static function wcap_load_hooks_and_filters() {

            if ( class_exists( 'Wcap_Update_Check' ) ) {
                add_action( 'admin_init',  array( 'Wcap_Update_Check',    'wcap_update_db_check' ) );
            }
            // WordPress settings API
            if ( class_exists( 'Wcap_Add_Settings' ) ) {
                add_action( 'admin_init',  array( 'Wcap_Add_Settings', 'wcap_initialize_plugin_options' ) );
            }
            
            $wcap_plugin_dir  = dirname( dirname( plugin_basename( __FILE__ ) ) );
            $wcap_plugin_dir .= '/woocommerce-ac.php';
            // Add settings link on plugins page
            add_filter( 'plugin_action_links_' . $wcap_plugin_dir,     array( 'Wcap_Common',         'wcap_plugin_action_links' ) );
            //Add plugin doc and forum link in description
            add_filter( 'plugin_row_meta',                             array( 'Wcap_Common',         'wcap_plugin_row_meta' ), 10, 2 );
            
            if ( class_exists( 'Wcap_Cart_Updated' ) ) {
                add_action( 'woocommerce_cart_updated',                array( 'Wcap_Cart_Updated',   'wcap_store_cart_timestamp' ), 100 );              
            }
            // WordPress Administration Menu
            add_action( 'admin_menu',                                  array( 'Wcap_Menu',            'wcap_admin_menu' ) );
            // delete added temp fields after order is placed
            add_filter( 'woocommerce_order_details_after_order_table', array( 'Wcap_Order_Received', 'wcap_action_after_delivery_session' ) );
            add_action( 'admin_enqueue_scripts',                       array( 'Wcap_Load_Scripts',   'wcap_enqueue_scripts_js' ) );
            add_action( 'admin_enqueue_scripts',                       array( 'Wcap_Load_Scripts',   'wcap_enqueue_scripts_css' ) );
            // track links
            add_filter( 'template_include',                            array( 'Wcap_Populate_Cart_Of_User', 'wcap_email_track_links' ), 99, 1 );
            
            $sms_setting = get_option( 'wcap_enable_sms_reminders' );
            if ( isset( $sms_setting ) && $sms_setting === 'on' ) {
                add_filter( 'template_include',                            array( 'Wcap_Populate_Cart_Of_User', 'wcap_shortcode_redirects' ), 100, 1 );
                add_filter( 'template_include',                            array( 'Wcap_Populate_Cart_Of_User', 'wcap_sms_redirects' ), 101, 1 );
            }
            
            if( class_exists( 'Wcap_Tiny_Mce' ) ) {
                add_action( 'admin_init',                              array( 'Wcap_Tiny_Mce',              'wcap_add_tiny_mce_button_and_plugin' ) );            
            }
            add_action( 'template_include',                            array( 'Wcap_Populate_Cart_Of_User', 'wcap_email_track_open_and_unsubscribe') );
            add_action( 'template_include',                            array( 'Wcap_Populate_Cart_Of_User', 'wcap_if_email_address_exists') );
            
            $display_tracked_coupons = get_option( 'ac_track_coupons' );
            // This is added as we have decided that we will always show the coupon code and eventually we will delte the setting of coupon code. 
            if( $display_tracked_coupons == '' || $display_tracked_coupons == null ) {
                update_option( 'ac_track_coupons', 'on' );
                $display_tracked_coupons = 'on';
            }
            if( $display_tracked_coupons == 'on' ) {
                add_action( 'woocommerce_coupon_error',                array( 'Wcap_Coupon', 'wcap_capture_coupon_error' ), 15, 2 );
                add_action( 'woocommerce_applied_coupon',              array( 'Wcap_Coupon', 'wcap_capture_applied_coupon' ), 15, 2 );
            }
            // Add coupon when user views cart page
            add_action( 'woocommerce_before_cart_table',               array( 'Wcap_Coupon', 'wcap_apply_direct_coupon_code' ) );
            // Add coupon when user views checkout page (would not be added otherwise, unless user views cart first).
            add_action( 'woocommerce_before_checkout_form',            array( 'Wcap_Coupon', 'wcap_apply_direct_coupon_code' ) );
            if( is_admin() ) {
                add_action( 'wp_dashboard_setup',                      array( 'Wcap_Dashboard_Widget', 'wcap_register_dashboard_widget' ), 10 );
                add_filter( 'ts_tracker_data',                         array( 'Wcap_Common', 'ts_add_plugin_tracking_data' ), 10, 1 );
                add_filter( 'ts_tracker_opt_out_data',                 array( 'Wcap_Common', 'wcap_get_data_for_opt_out' ), 10, 1 );
                
                add_filter ( 'ts_deativate_plugin_questions',          array( 'Wcap_Common', 'wcap_deactivate_add_questions' ), 10, 1 );

                Wcap_Load_Hooks::wcap_load_ajax_function();
            }
            // Language translation
            add_action( 'init',                                        array( __CLASS__ ,   'wcap_update_po_file' ) );
            if ( class_exists( 'Wcap_Localization' ) ) {
                add_action( 'admin_init',                              array( 'Wcap_Localization',   'wcap_register_template_string_for_wpml' ) );
            }
            if ( class_exists( 'Wcap_EDD' ) ) {
                add_action( 'admin_init',                              array( 'Wcap_EDD',            'wcap_edd_ac_register_option' ) );
                add_action( 'admin_init',                              array( 'Wcap_EDD',            'wcap_edd_ac_deactivate_license' ) );
                add_action( 'admin_init',                              array( 'Wcap_EDD',            'wcap_edd_ac_activate_license' ) );
            }
            add_action( 'woocommerce_order_status_changed',            array( 'Wcap_Admin_Recovery', 'wcap_email_admin_recovery' ), 10, 3 );
            // Cron Job call action, which will run the function based on standard wordpress way.
            // It has been done to over come the Wp-Load.php file include issue.
            $wcap_auto_cron = get_option ( 'wcap_use_auto_cron' );
            if ( isset( $wcap_auto_cron ) && $wcap_auto_cron != false && '' != $wcap_auto_cron ) {
                // Hook into that action that'll fire every 5 minutes
                add_action( 'woocommerce_ac_send_email_action',        array( 'Wcap_Send_Email_Using_Cron', 'wcap_abandoned_cart_send_email_notification' ) );
                add_action( 'woocommerce_ac_send_email_action',        array( 'Wcap_Send_Email_Using_Cron', 'wcap_send_sms_notifications' ), 11 );
            }
            //delete abandoned order after X number of days
            if ( class_exists( 'Wcap_Actions_Handler' ) ) {
                add_action( 'admin_init',                              array( 'Wcap_Actions_Handler', 'wcap_delete_abandoned_carts_after_x_days' ) );
            }
            add_action('update_option_wcap_cron_time_duration',        array( 'Wcap_Common', 'wcap_cron_time_duration' ) );

            if ( class_exists( 'Wcap_Print_And_CSV' ) ) {
                add_action( 'admin_init',                              array( 'Wcap_Print_And_CSV', 'wcap_print_data' ) );                
            }
            if( class_exists( 'WCAP_On_Placed_Order' ) ) {
                add_action( 'woocommerce_checkout_order_processed',      array( 'WCAP_On_Placed_Order' , 'wcap_order_placed' ), 10 , 1 );
                add_filter( 'woocommerce_payment_complete_order_status', array( 'WCAP_On_Placed_Order' , 'wcap_order_complete_action'), 10 , 2 );
                add_filter( 'woocommerce_cancel_unpaid_order',           array( 'WCAP_On_Placed_Order', 'wcap_update_cart_status' ), 10, 2 );
            }    
            add_action( 'admin_init',                                  array( 'Wcap_Common', 'wcap_output_buffer') );
            add_action( 'wp_login',                                    array( 'Wcap_Common', 'wcap_remove_action_hook' ), 1 );
            add_filter( 'wc_session_expiring',                         array( 'Wcap_Common', 'wcap_set_session_expiring' ),10,1 );
            add_filter( 'wc_session_expiration',                       array( 'Wcap_Common', 'wcap_set_session_expired' ),10,1 );
            add_filter( 'woocommerce_checkout_fields',                 array( 'Wcap_Common','guest_checkout_fields' ) );
            if( class_exists( 'Wcap_Load_Scripts' ) ) {
                add_action( 'woocommerce_after_checkout_billing_form',     array( 'Wcap_Load_Scripts', 'wcap_include_js_for_guest' ) ) ;
                add_action( 'wp_enqueue_scripts',                          array( 'Wcap_Load_Scripts',   'wcap_enqueue_scripts_atc_modal' ), 200 );
                //add_action( 'plugins_loaded',                              array( 'Wcap_Load_Scripts',   'wcap_dequeue_scripts_atc_modal' ) );
                add_action( 'wp_enqueue_scripts',                          array( 'Wcap_Load_Scripts',   'wcap_enqueue_css_atc_modal' ),10, 1 );
            }
            // This condition confirm that the lite plugin active, so we need to perform further action.
            if ( in_array( 'woocommerce-abandoned-cart/woocommerce-ac.php', (array) get_option( 'active_plugins', array() ) ) || 
                ( isset( $_GET ['wcap_plugin_link'] ) && 'wcap-update' == $_GET ['wcap_plugin_link'] ) ) {
                // Import information page.
                // Allows customers to import data of the lite version to the pro.
                add_action( 'admin_menu',                              array( 'Wcap_Import_Lite_to_Pro', 'wcap_admin_menus' ) );
                add_action( 'admin_init',                              array( 'Wcap_Import_Lite_to_Pro', 'wcap_admin_init' ) );
            }
            Wcap_Load_Hooks::wcap_load_front_end_ajax_function();
            add_action( 'media_buttons', array( 'Wcap_Load_Hooks', 'wcap_add_extra_button' ), 10, 1 );
            
            add_action( 'admin_init', array( 'Wcap_Load_Hooks', 'wcap_load_admin_ajax' ), 20 );
        }
        
        /**
         * Adds AJAX calls for SMS in WP Dashboard
         * @since 7.9
         */
        public static function wcap_load_admin_ajax() {
            add_action( 'wp_ajax_wcap_delete_sms_template', array( 'Wcap_SMS', 'wcap_delete_sms' ) );
            add_action( 'wp_ajax_wcap_save_bulk_sms_template', array( 'Wcap_SMS', 'wcap_save_bulk_sms' ) );
            add_action( 'wp_ajax_wcap_test_sms', array( 'Wcap_Adv_settings', 'wcap_send_test_sms' ) );
        }
        
        /** 
         * This function is used for loading AJAX which we will use for Add To Cart Popup Modal, Test email, Preview email template, capturing cart from checkout page.
         * 
         * @since 6.0
         */
        public static function wcap_load_ajax_function() {
            add_action( 'wp_ajax_wcap_preview_email_sent',             array( 'Wcap_Ajax', 'wcap_preview_email_sent' ) );
            add_action( 'wp_ajax_wcap_toggle_template_status',         array( 'Wcap_Ajax', 'wcap_toggle_template_status' ) );
            add_action( 'wp_ajax_wcap_abandoned_cart_info',            array( 'Wcap_Ajax', 'wcap_abandoned_cart_info' ) );
            add_action( 'wp_ajax_wcap_json_find_coupons',              array( 'Wcap_Ajax', 'wcap_json_find_coupons' ) );
            add_action( 'wp_ajax_wcap_change_manual_email_data',       array( 'Wcap_Ajax', 'wcap_change_manual_email_data' ) );
            // We keep this function in the dashboard widget file.
            add_action( 'wp_ajax_wcap_dashboard_widget_report',        array( 'Wcap_Dashboard_Widget', 'wcap_dashboard_widget_report' ), 10 );
            /** 
             * Enable or disable the ATC modal 
             *  @since: 6.0
             */
            add_action( 'wp_ajax_wcap_toggle_atc_enable_status',       array( 'Wcap_Ajax', 'wcap_toggle_atc_enable_status' ) );
            /** 
             *  Mandatory email fields for the ATC modal
             *  @since: 6.0
             */
            add_action( 'wp_ajax_wcap_atc_reset_setting',              array( 'Wcap_Ajax', 'wcap_atc_reset_setting' ) );
            /** 
             * Reset to default values in ATC modal 
             *  @since: 6.0
             */
            add_action( 'wp_ajax_wcap_toggle_atc_mandatory_status',    array( 'Wcap_Ajax', 'wcap_toggle_atc_mandatory_status' ) );

            $guest_cart = get_option( 'ac_disable_guest_cart_email' );
            if ( $guest_cart != "on" ) {
                add_action( 'wp_ajax_nopriv_wcap_save_guest_data',     array( 'Wcap_Ajax','wcap_save_guest_data' ) );
                add_action( 'wp_ajax_wcap_save_guest_data',            array( 'Wcap_Ajax','wcap_save_guest_data' ) );
            }

            /**
             * This ajax check if the atc is enabled or not when we disabled the guest cart capturing.
             * @since: 7.0
             */
            add_action( 'wp_ajax_wcap_is_atc_enable',                  array( 'Wcap_Ajax', 'wcap_is_atc_enable' ) );
            
            /**
             * This ajax create the preview email content for the WC setting.
             * @since: 7.0
             */
            add_action( 'wp_ajax_wcap_preview_wc_email',               array( 'Wcap_Ajax', 'wcap_preview_wc_email' ) );

            /**
             * This ajax create the preview email content for the without WC setting.
             * @since: 7.0
             */
            add_action( 'wp_ajax_wcap_preview_email',                  array( 'Wcap_Ajax', 'wcap_preview_email' ) );

            /**
             * This function will import the data of the lite version.
             * @since: 8.0
             */
            add_action( 'wp_ajax_wcap_import_lite_data',               array( 'Wcap_Ajax', 'wcap_import_lite_data' ) );
            add_action( 'wp_ajax_wcap_do_not_import_lite_data',        array( 'Wcap_Ajax', 'wcap_do_not_import_lite_data' ) );  


            add_action( 'edit_user_profile',                           array( 'Wcap_Common', 'wcap_add_restrict_user_meta_field' ),50 );    
            add_action( 'show_user_profile',                           array( 'Wcap_Common', 'wcap_add_restrict_user_meta_field' ),50  );    

            add_action( 'personal_options_update',                     array( 'Wcap_Common', 'wcap_save_restrict_user_meta_field' ), 50 );
            add_action( 'edit_user_profile_update',                    array( 'Wcap_Common', 'wcap_save_restrict_user_meta_field' ),50  );  
        }

        /**
         * We have used WC ajax because the wp-ajax was not runing on the shop page. When we run the wp-admin ajax, it was giving the 302 status of the ajax call.
         *
         * @since 6.0 
         */
        public static function wcap_load_front_end_ajax_function() {
            add_action( 'init',                                       array( 'Wcap_Ajax', 'wcap_add_ajax_for_atc'  ) );
            add_action( 'wp_ajax_nopriv_wcap_atc_store_guest_email',  array( 'Wcap_Ajax', 'wcap_atc_store_guest_email' ) );
            add_action( 'wc_ajax_wcap_track_notice', array( 'Wcap_Ajax', 'wcap_track_carts' ) );
        }

        /**
         * This function is used for loading the text domain of the plugin.  
         *   
         * @hook init
         *    
         * @since 4.5
         */
        Public static function wcap_update_po_file() {
            $domain = 'woocommerce-ac';
            $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
            if ( $loaded = load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '-' . $locale . '.mo' ) ) {
                return $loaded;
            } else {
                load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/i18n/languages/' );
            }
        }

        public static function wcap_add_extra_button( $param ) {

            print( '<input type="button" class="button ac-insert-template add_media" data-toggle="modal" data-target=".wcap-preview-modal" value="Insert Template" />' );
            print( '<input type="button" class="button ac-import-template add_media" value="Import Template" />' );
        }

    }
}
API documentation generated by ApiGen