diff --git a/admin/class-paypal-for-woocommerce-multi-account-management-admin.php b/admin/class-paypal-for-woocommerce-multi-account-management-admin.php index a792d93..1ff0a94 100644 --- a/admin/class-paypal-for-woocommerce-multi-account-management-admin.php +++ b/admin/class-paypal-for-woocommerce-multi-account-management-admin.php @@ -31,6 +31,7 @@ class Paypal_For_Woocommerce_Multi_Account_Management_Admin { private $version; public $final_associate_account; public $gateway_key; + public $message; /** * Initialize the class and set its properties. @@ -60,11 +61,16 @@ public function enqueue_styles() { * * @since 1.0.0 */ - public function enqueue_scripts() { + public function enqueue_scripts($hook_suffix) { $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; wp_register_script('jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array('jquery'), '2.70', true); wp_enqueue_script('jquery-blockui'); wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/paypal-for-woocommerce-multi-account-management-admin.js', array('jquery'), $this->version, true); + if ('plugins.php' === $hook_suffix) { + wp_enqueue_style('deactivation-pfwma-css', plugin_dir_url(__FILE__) . 'css/deactivation-modal.css', null, $this->version); + wp_enqueue_script('deactivation-pfwma-js', plugin_dir_url(__FILE__) . 'js/deactivation-form-modal.js', null, $this->version, true); + wp_localize_script('deactivation-pfwma', 'angelleye_ajax_data', array('nonce' => wp_create_nonce('angelleye-ajax'))); + } } public function angelleye_post_exists($id) { @@ -114,7 +120,6 @@ public function angelleye_display_multi_account_list() { $microprocessing_key_array = array('woocommerce_paypal_express_enable', 'woocommerce_paypal_express_testmode', 'woocommerce_paypal_express_account_name', 'woocommerce_paypal_express_sandbox_email', 'woocommerce_paypal_express_sandbox_merchant_id', 'woocommerce_paypal_express_sandbox_api_username', 'woocommerce_paypal_express_sandbox_api_password', 'woocommerce_paypal_express_sandbox_api_signature', 'woocommerce_paypal_express_email', 'woocommerce_paypal_express_merchant_id', 'woocommerce_paypal_express_api_username', 'woocommerce_paypal_express_api_password', 'woocommerce_paypal_express_api_signature', 'woocommerce_paypal_express_api_condition_field', 'woocommerce_paypal_express_api_condition_sign', 'woocommerce_paypal_express_api_condition_value', 'woocommerce_paypal_express_api_user_role', 'woocommerce_paypal_express_api_user', 'woocommerce_paypal_express_api_product_ids', 'product_categories', 'product_tags', 'buyer_countries', 'woocommerce_priority', 'angelleye_multi_account_choose_payment_gateway', 'store_countries', 'shipping_class', 'currency_code', 'ec_site_owner_commission', 'ec_site_owner_commission_label'); foreach ($microprocessing_key_array as $key => $value) { $microprocessing_new[$value] = isset($microprocessing[$value]) ? $microprocessing[$value] : array(); - } $microprocessing = $microprocessing_new; foreach ($microprocessing as $microprocessing_key => $microprocessing_value) { @@ -161,7 +166,7 @@ public function angelleye_display_multi_account_list() { case 'ec_site_owner_commission': echo sprintf('
', __('Site Owner Commission %', 'paypal-for-woocommerce-multi-account-management'), !empty($microprocessing_value[0]) ? $microprocessing_value[0] : ''); break; - case 'ec_site_owner_commission_label': + case 'ec_site_owner_commission_label': echo sprintf('
', __('Site Owner Commission Item Label', 'paypal-for-woocommerce-multi-account-management'), !empty($microprocessing_value[0]) ? $microprocessing_value[0] : ''); break; case 'woocommerce_paypal_express_api_user_role': @@ -349,24 +354,21 @@ public function angelleye_display_multi_account_list() { } } $option_five .= ''; - + $option_five_one = '

' . __('Select Author', 'paypal-for-woocommerce-multi-account-management') . '

'; $option_five_one .= ''; for ($x = 0; $x <= 100; $x++) { - if($x == 0) { - $woocommerce_priority_text = $x .' - Lowest'; - } elseif($x == 100) { - $woocommerce_priority_text = $x .' - Highest'; + if ($x == 0) { + $woocommerce_priority_text = $x . ' - Lowest'; + } elseif ($x == 100) { + $woocommerce_priority_text = $x . ' - Highest'; } else { $woocommerce_priority_text = $x; } @@ -395,7 +397,7 @@ public function angelleye_display_multi_account_list() { $option_seven = '

' . __('Buyer country', 'paypal-for-woocommerce-multi-account-management') . '

'; $option_seven .= ''; - + $option_fifteen = '

' . __('Shipping Class', 'paypal-for-woocommerce-multi-account-management') . '

'; $option_fifteen .= ''; - - $option_eight = '

' . apply_filters('angelleye_multi_account_display_category_label',__('Product categories', 'paypal-for-woocommerce-multi-account-management')) . '

'; + + $option_eight = '

' . apply_filters('angelleye_multi_account_display_category_label', __('Product categories', 'paypal-for-woocommerce-multi-account-management')) . '

'; $option_eight .= ''; $option_nine = '

' . __('Product tags', 'paypal-for-woocommerce-multi-account-management') . '

'; $option_nine .= ''; @@ -522,7 +523,7 @@ public function angelleye_display_multi_account_list() { echo sprintf(' - + %3$s %4$s @@ -531,47 +532,92 @@ public function angelleye_display_multi_account_list() { $this->angelleye_multi_account_tooltip_box(); } - public function angelleye_multi_account_tooltip_box() { + public function angelleye_multi_account_settings_fields() { + if (!empty($_POST['global_commission_microprocessing_save'])) { + update_option('global_ec_site_owner_commission', wc_clean($_POST['global_ec_site_owner_commission'])); + update_option('global_ec_site_owner_commission_label', wc_clean($_POST['global_ec_site_owner_commission_label'])); + update_option('global_automatic_rule_creation_enable', wc_clean($_POST['global_automatic_rule_creation_enable'])); + update_option('global_automatic_rule_creation_testmode', wc_clean($_POST['global_automatic_rule_creation_testmode'])); + $this->message = __('Your settings have been saved.', 'paypal-for-woocommerce-multi-account-management'); + } + if (!empty($this->message)) { + echo '

' . esc_html($this->message) . '

'; + } $global_ec_site_owner_commission = get_option('global_ec_site_owner_commission', ''); $global_ec_site_owner_commission_label = get_option('global_ec_site_owner_commission_label', ''); + $global_automatic_rule_creation_enable = get_option('global_automatic_rule_creation_enable', ''); + $global_automatic_rule_creation_testmode = get_option('global_automatic_rule_creation_testmode', ''); ?> -
+
+ +
+ angelleye_pfwma_display_marketing_sidebar(); + } + + public function angelleye_multi_account_tooltip_box() { + ?> +

+ + +
+
+ + +
diff --git a/template/sidebar-process.php b/template/sidebar-process.php new file mode 100644 index 0000000..77a01d3 --- /dev/null +++ b/template/sidebar-process.php @@ -0,0 +1,64 @@ +request)); + } + $url = 'https://sendy.angelleye.com/subscribe'; + $response = wp_remote_post($url, array( + 'method' => 'POST', + 'timeout' => 45, + 'redirection' => 5, + 'httpversion' => '1.0', + 'blocking' => true, + 'headers' => array(), + 'body' => array('list' => 'pjFolYKqSdLe57i4uuUz0g', + 'boolean' => 'true', + 'email' => $_POST['email'], + 'gdpr' => 'true', + 'silent' => 'true', + 'api_key' => 'qFcoVlU2uG3AMYabNTrC', + 'referrer' => $current_url + ), + 'cookies' => array() + ) + ); + if (is_wp_error($response)) { + wp_send_json(wp_remote_retrieve_body($response)); + } else { + $body = wp_remote_retrieve_body($response); + $apiResponse = strval($body); + switch ($apiResponse) { + case 'true': + case '1': + prepareResponse("true", 'Thank you for subscribing!'); + case 'Already subscribed.': + prepareResponse("true", 'Already subscribed!'); + default: + prepareResponse("false", $apiResponse); + } + } + } + +} + +if (!function_exists('prepareResponse')) { + + function prepareResponse($status = false, $msg = 'Something went wrong!') { + $return = array( + 'result' => $status, + 'message' => $msg + ); + wp_send_json($return); + } + +} \ No newline at end of file