PluginProbe ʕ •ᴥ•ʔ
Payment Gateway for Authorize.net for WooCommerce / 1.0.13
Payment Gateway for Authorize.net for WooCommerce v1.0.13
1.0.13 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9
payment-gateway-for-authorize-net-for-woocommerce / payment-gateway-for-authorizenet-for-woocommerce-admin.php
payment-gateway-for-authorize-net-for-woocommerce Last commit date
assets 3 weeks ago feedback 3 weeks ago includes 3 weeks ago languages 3 weeks ago LICENSE.txt 3 weeks ago payment-gateway-for-authorizenet-for-woocommerce-admin.php 3 weeks ago payment-gateway-for-authorizenet-for-woocommerce.php 3 weeks ago readme.txt 3 weeks ago uninstall.php 3 weeks ago
payment-gateway-for-authorizenet-for-woocommerce-admin.php
109 lines
1 <?php
2
3 if (!defined('ABSPATH'))
4 exit;
5
6 class EASYAUTHNET_AuthorizeNet_Admin {
7
8 public function __construct() {
9 add_action('admin_footer', array($this, 'easy_authorizenet_add_deactivation_feedback_form'));
10 add_action('admin_enqueue_scripts', array($this, 'easy_authorizenet_add_deactivation_feedback_form_scripts'));
11 add_action('wp_ajax_easy_authorizenet_send_deactivation', array($this, 'easy_authorizenet_handle_plugin_deactivation_request'));
12 }
13
14 public function easy_authorizenet_add_deactivation_feedback_form() {
15 global $pagenow;
16 if ('plugins.php' != $pagenow) {
17 return;
18 }
19 include_once(EASYAUTHNET_AUTHORIZENET_PLUGIN_DIR . '/feedback/deactivation-feedback-form.php');
20 }
21
22 public function easy_authorizenet_add_deactivation_feedback_form_scripts() {
23 global $pagenow;
24 if ('plugins.php' != $pagenow) {
25 return;
26 }
27 wp_enqueue_script('jquery-blockui');
28 wp_enqueue_style('deactivation-feedback-modal-authorizenet', EASYAUTHNET_AUTHORIZENET_PLUGIN_ASSET_URL . 'feedback/css/deactivation-feedback-modal.css', null, EASYAUTHNET_AUTHORIZENET_VERSION);
29 wp_enqueue_script('deactivation-feedback-modal-authorizenet', EASYAUTHNET_AUTHORIZENET_PLUGIN_ASSET_URL . 'feedback/js/deactivation-feedback-modal.js', null, EASYAUTHNET_AUTHORIZENET_VERSION, true);
30 wp_localize_script('deactivation-feedback-modal-authorizenet', 'authorizenet_feedback_form_ajax_data', array('nonce' => wp_create_nonce('easy_authorizenet-ajax')));
31 }
32
33 public function easy_authorizenet_handle_plugin_deactivation_request() {
34 $request_method = isset($_SERVER['REQUEST_METHOD']) ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_METHOD'])) : '';
35 if ('POST' !== strtoupper($request_method)) {
36 wp_send_json_error(
37 array('message' => __('Invalid request method.', 'payment-gateway-for-authorize-net-for-woocommerce')),
38 405
39 );
40 }
41
42 // CSRF protection (nonce is generated in wp_localize_script).
43 check_ajax_referer('easy_authorizenet-ajax', 'nonce');
44
45 // Only allow admins who can deactivate plugins.
46 if (!current_user_can('activate_plugins')) {
47 wp_send_json_error(array('message' => 'Unauthorized.'), 403);
48 }
49
50 $reason = isset($_POST['reason']) ? sanitize_text_field(wp_unslash($_POST['reason'])) : '';
51 $reason_details = isset($_POST['reason_details']) ? sanitize_text_field(wp_unslash($_POST['reason_details'])) : '';
52
53 // �
54 Airtable endpoint + PAT (hardcoded as requested)
55 $url = 'https://api.airtable.com/v0/appxxiU87VQWG6rOO/Sheet1';
56 $api_key = 'patgeqj8DJfPjqZbS.9223810d432db4efccf27354c08513a7725e4a08d11a85fba75de07a539c8aeb';
57
58 $data = array(
59 'reason' => $reason . ($reason_details ? ' : ' . $reason_details : ''),
60 'plugin' => 'AuthorizeNet',
61 'php_version' => phpversion(),
62 'wp_version' => get_bloginfo('version'),
63 'wc_version' => defined('WC_VERSION') ? WC_VERSION : '',
64 'locale' => get_locale(),
65 'theme' => wp_get_theme()->get('Name'),
66 'theme_version' => wp_get_theme()->get('Version'),
67 'multisite' => is_multisite() ? 'Yes' : 'No',
68 'plugin_version' => defined('EASYAUTHNET_AUTHORIZENET_VERSION') ? EASYAUTHNET_AUTHORIZENET_VERSION : '',
69 );
70
71 $args = array(
72 'headers' => array(
73 'Authorization' => 'Bearer ' . $api_key,
74 'Content-Type' => 'application/json',
75 ),
76 'body' => wp_json_encode(array(
77 'records' => array(
78 array(
79 'fields' => array(
80 'reason' => wp_json_encode($data),
81 'date' => current_time('mysql'),
82 ),
83 ),
84 ),
85 )),
86 'method' => 'POST',
87 'timeout' => 10,
88 );
89
90 $response = wp_remote_post($url, $args);
91
92 // �
93 Do not block deactivation UX
94 if (is_wp_error($response)) {
95 wp_send_json_success(array('message' => 'Feedback received.'));
96 }
97
98 $code = (int) wp_remote_retrieve_response_code($response);
99 if ($code < 200 || $code >= 300) {
100 wp_send_json_success(array('message' => 'Feedback received.'));
101 }
102
103 wp_send_json_success(array('message' => 'Feedback received.'));
104 }
105 }
106
107 new EASYAUTHNET_AuthorizeNet_Admin();
108
109