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
if (!defined('ABSPATH')) {
exit;
}
if ( !class_exists('Wcap_Load_Hooks' ) ) {
class Wcap_Load_Hooks {
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' ) );
}
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_filter( 'plugin_action_links_' . $wcap_plugin_dir, array( 'Wcap_Common', 'wcap_plugin_action_links' ) );
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 );
}
add_action( 'admin_menu', array( 'Wcap_Menu', 'wcap_admin_menu' ) );
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' ) );
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' );
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_action( 'woocommerce_before_cart_table', array( 'Wcap_Coupon', 'wcap_apply_direct_coupon_code' ) );
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();
}
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 );
$wcap_auto_cron = get_option ( 'wcap_use_auto_cron' );
if ( isset( $wcap_auto_cron ) && $wcap_auto_cron != false && '' != $wcap_auto_cron ) {
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 );
}
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( 'wp_enqueue_scripts', array( 'Wcap_Load_Scripts', 'wcap_enqueue_css_atc_modal' ),10, 1 );
}
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'] ) ) {
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 );
}
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' ) );
}
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' ) );
add_action( 'wp_ajax_wcap_dashboard_widget_report', array( 'Wcap_Dashboard_Widget', 'wcap_dashboard_widget_report' ), 10 );
add_action( 'wp_ajax_wcap_toggle_atc_enable_status', array( 'Wcap_Ajax', 'wcap_toggle_atc_enable_status' ) );
add_action( 'wp_ajax_wcap_atc_reset_setting', array( 'Wcap_Ajax', 'wcap_atc_reset_setting' ) );
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' ) );
}
add_action( 'wp_ajax_wcap_is_atc_enable', array( 'Wcap_Ajax', 'wcap_is_atc_enable' ) );
add_action( 'wp_ajax_wcap_preview_wc_email', array( 'Wcap_Ajax', 'wcap_preview_wc_email' ) );
add_action( 'wp_ajax_wcap_preview_email', array( 'Wcap_Ajax', 'wcap_preview_email' ) );
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 );
}
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' ) );
}
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" />' );
}
}
}