PluginProbe ʕ •ᴥ•ʔ
Post Affiliate Pro / trunk
Post Affiliate Pro vtrunk
1.29.5 1.29.4 1.29.3 1.29.0 1.29.1 1.29.2 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.5.0 1.5.1 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.1 1.6.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.9.0 1.9.1 1.9.2 1.9.3 1.9.4 trunk 1.0.1 1.0.10 1.0.11 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.10.1 1.10.2 1.10.3 1.10.4 1.11.1 1.11.2 1.12.1 1.12.2 1.12.3 1.12.4 1.12.5 1.13.0 1.13.1 1.13.2 1.13.3 1.13.4 1.13.5 1.13.6 1.14.0 1.14.1 1.14.2 1.15.0 1.15.1 1.15.2 1.15.3 1.15.4 1.15.5 1.16.0 1.16.1 1.16.2 1.16.3 1.16.4 1.16.5 1.17.0 1.18.0 1.18.1 1.18.2 1.18.3 1.18.4 1.19.0 1.19.1 1.19.10 1.19.11 1.19.12 1.19.13 1.19.14 1.19.15 1.19.16 1.19.17 1.19.2 1.19.3 1.19.4 1.19.5 1.19.6 1.19.7 1.19.8 1.19.9 1.2.0 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.28 1.2.3 1.2.31 1.2.32 1.2.33 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.20.0 1.20.1 1.21.0 1.21.1 1.21.2 1.21.3 1.21.4 1.21.5 1.21.6 1.21.7 1.22.0 1.22.1 1.22.2 1.23.0 1.23.1 1.23.2 1.23.3 1.23.4 1.23.5 1.23.6 1.23.7 1.23.8 1.24.1 1.24.2 1.24.3 1.24.4 1.24.5 1.24.6 1.24.7 1.24.8 1.24.9 1.25.0 1.26.0 1.26.1 1.26.10 1.26.11 1.26.2 1.26.3 1.26.4 1.26.5 1.26.6 1.26.7 1.26.8 1.26.9 1.27.0 1.27.1 1.27.10 1.27.11 1.27.12 1.27.13 1.27.14 1.27.15 1.27.2 1.27.3 1.27.5 1.27.6 1.27.7 1.27.8 1.27.9 1.28.0 1.28.1 1.28.2 1.28.3
postaffiliatepro / Form / Settings / SimplePayPro.class.php
postaffiliatepro / Form / Settings Last commit date
AdditionalOptions.class.php 2 months ago CampaignInfo.class.php 2 months ago Campaigns.class.php 2 months ago ClickTracking.class.php 2 months ago ContactForm7.class.php 2 months ago Debugging.class.php 4 weeks ago EDD.class.php 4 weeks ago General.class.php 4 weeks ago Integrations.class.php 2 months ago LifterLMS.class.php 2 months ago Marketpress.class.php 4 weeks ago MemberPress.class.php 2 months ago Membership2.class.php 2 months ago PMPro.class.php 2 months ago PPBuyNowButton.class.php 2 months ago RestrictContentPro.class.php 2 months ago S2Member.class.php 2 months ago Signup.class.php 2 months ago SimplePayPro.class.php 2 months ago StripePayments.class.php 4 weeks ago SureCart.class.php 2 months ago WPEasyCart.class.php 2 months ago WPPayForms.class.php 2 months ago WishListMember.class.php 2 months ago WooComm.class.php 4 weeks ago
SimplePayPro.class.php
196 lines
1 <?php
2 if (!defined('ABSPATH')) exit;
3
4 class postaffiliatepro_Form_Settings_SimplePayPro extends postaffiliatepro_Form_Base {
5 const SIMPLEPAYPRO_COMMISSION_ENABLED = 'simplepaypro-commission-enabled';
6 const SIMPLEPAYPRO_CONFIG_PAGE = 'simplepaypro-config-page';
7 const SIMPLEPAYPRO_CAMPAIGN = 'simplepaypro-campaign';
8 const SIMPLEPAYPRO_TRACK_RECURRING = 'simplepaypro-track-recurring';
9 const SIMPLEPAYPRO_DATA1 = 'simplepaypro-data1';
10 const SIMPLEPAYPRO_DATA2 = 'simplepaypro-data2';
11 const SIMPLEPAYPRO_DATA3 = 'simplepaypro-data3';
12 const SIMPLEPAYPRO_DATA4 = 'simplepaypro-data4';
13 const SIMPLEPAYPRO_DATA5 = 'simplepaypro-data5';
14
15 public function __construct() {
16 parent::__construct(self::SIMPLEPAYPRO_CONFIG_PAGE, 'options.php');
17 }
18
19 protected function getTemplateFile() {
20 return WP_PLUGIN_DIR . '/postaffiliatepro/Template/SimplePayProConfig.xtpl';
21 }
22
23 protected function initForm() {
24 $campaignHelper = new postaffiliatepro_Util_CampaignHelper();
25 $campaignList = $campaignHelper->getCampaignsList();
26
27 $campaigns = array('0' => ' ');
28 foreach ($campaignList as $row) {
29 $campaigns[$row->get('campaignid')] = htmlspecialchars($row->get('name'));
30 }
31 $this->addSelect(self::SIMPLEPAYPRO_CAMPAIGN, $campaigns);
32
33 $this->addCheckbox(self::SIMPLEPAYPRO_TRACK_RECURRING, null, 'onchange="hideConfigTable2()"');
34 $productOptions = array(
35 '0' => ' ',
36 'id' => __('customer ID','postaffiliatepro'),
37 'email' => __('customer email','postaffiliatepro'),
38 'name' => __('customer name','postaffiliatepro')
39 );
40 $this->addSelect(self::SIMPLEPAYPRO_DATA1, $productOptions);
41 $this->addSelect(self::SIMPLEPAYPRO_DATA2, $productOptions);
42 $this->addSelect(self::SIMPLEPAYPRO_DATA3, $productOptions);
43 $this->addSelect(self::SIMPLEPAYPRO_DATA4, $productOptions);
44 $this->addSelect(self::SIMPLEPAYPRO_DATA5, $productOptions);
45
46 $this->addSubmit();
47
48 $code = '<script type="text/javascript">
49 const isRecurringEnabled = "' . get_option(self::SIMPLEPAYPRO_TRACK_RECURRING) . '";
50 if (isRecurringEnabled === "true") {
51 document.getElementById(\'form-table2\').style.display = "none";
52 }
53
54 function hideConfigTable2() {
55 if (document.getElementById(\''.self::SIMPLEPAYPRO_TRACK_RECURRING.'_\').checked == false) {
56 document.getElementById(\'form-table2\').style.display = "";
57 } else {
58 document.getElementById(\'form-table2\').style.display = "none";
59 }
60 }
61 </script>';
62 $this->addHtml('hider', $code);
63 $this->addHtml('papURL', get_option(postaffiliatepro::PAP_URL_SETTING_NAME).'plugins/Stripe/stripe.php'.((get_option(postaffiliatepro::CLICK_TRACKING_ACCOUNT_SETTING_NAME) != '')?'?AccountId='.get_option(postaffiliatepro::CLICK_TRACKING_ACCOUNT_SETTING_NAME):''));
64 }
65
66 public function initSettings() {
67 register_setting(postaffiliatepro::INTEGRATIONS_SETTINGS_PAGE_NAME, self::SIMPLEPAYPRO_COMMISSION_ENABLED);
68 register_setting(self::SIMPLEPAYPRO_CONFIG_PAGE, self::SIMPLEPAYPRO_CAMPAIGN);
69 register_setting(self::SIMPLEPAYPRO_CONFIG_PAGE, self::SIMPLEPAYPRO_DATA1);
70 register_setting(self::SIMPLEPAYPRO_CONFIG_PAGE, self::SIMPLEPAYPRO_DATA2);
71 register_setting(self::SIMPLEPAYPRO_CONFIG_PAGE, self::SIMPLEPAYPRO_DATA3);
72 register_setting(self::SIMPLEPAYPRO_CONFIG_PAGE, self::SIMPLEPAYPRO_DATA4);
73 register_setting(self::SIMPLEPAYPRO_CONFIG_PAGE, self::SIMPLEPAYPRO_DATA5);
74 register_setting(self::SIMPLEPAYPRO_CONFIG_PAGE, self::SIMPLEPAYPRO_TRACK_RECURRING);
75 }
76
77 public function addPrimaryConfigMenu() {
78 if (get_option(self::SIMPLEPAYPRO_COMMISSION_ENABLED) === 'true') {
79 add_submenu_page(
80 'integrations-config-page-handle',
81 'Simple Pay Pro',
82 'Simple Pay Pro',
83 'manage_options',
84 'simplepayprointegration-settings-page',
85 array($this, 'printConfigPage')
86 );
87 }
88 }
89
90 public function printConfigPage() {
91 $this->render();
92 }
93
94 public function addHiddenCodeToForm($formId, $form) {
95 // Adding hidden code to form so we could work with cookie in Stripe Customer object later
96 if (get_option(self::SIMPLEPAYPRO_TRACK_RECURRING) === 'true') {
97 postaffiliatepro::addHiddenFieldToPaymentForm();
98 }
99 }
100
101 public function modifyCustomerInfo($customer_args) {
102 if (get_option(self::SIMPLEPAYPRO_TRACK_RECURRING) == 'true' && !empty(sanitize_text_field(wp_unslash($_POST['form_values']['pap_custom'])))) {
103 $papCookie = sanitize_text_field(wp_unslash($_POST['form_values']['pap_custom']));
104 if (isset($customer_args['description'])) {
105 $customer_args['description'] = $customer_args['description'] . '||' . $papCookie;
106 } else {
107 $customer_args['description'] = $papCookie;
108 }
109 }
110 return $customer_args;
111 }
112
113 public function confirmationMessage($paymentData) {
114 if (get_option(self::SIMPLEPAYPRO_COMMISSION_ENABLED) !== 'true') {
115 echo "<!-- Post Affiliate Pro sale tracking error - tracking not enabled -->\n";
116 return;
117 }
118 $HTMLcontent = '';
119 if (get_option(self::SIMPLEPAYPRO_TRACK_RECURRING) !== 'true') {
120 $HTMLcontent .= "<!-- Post Affiliate Pro sale tracking -->\n";
121 $contentToAsync = 'PostAffTracker.setAccountId(\'' . postaffiliatepro::getAccountName() . '\');';
122 $contentToAsync .= "var sale = PostAffTracker.createSale();\n";
123 $contentToAsync .= "sale.setTotalCost('" . ($paymentData['paymentintents'][0]->amount_received / 100) . "');\n";
124 $contentToAsync .= "sale.setOrderID('". $paymentData['paymentintents'][0]->id ."');\n";
125 $contentToAsync .= "sale.setProductID('". $paymentData['form']->id ."');\n";
126 $contentToAsync .= "sale.setData1('". str_replace("'","\'",$this->getTrackingData($paymentData['customer'], 1))."');\n";
127 $contentToAsync .= "sale.setData2('". str_replace("'","\'",$this->getTrackingData($paymentData['customer'], 2))."');\n";
128 $contentToAsync .= "sale.setData3('". str_replace("'","\'",$this->getTrackingData($paymentData['customer'], 3))."');\n";
129 $contentToAsync .= "sale.setData4('". str_replace("'","\'",$this->getTrackingData($paymentData['customer'], 4))."');\n";
130 $contentToAsync .= "sale.setData5('". str_replace("'","\'",$this->getTrackingData($paymentData['customer'], 5))."');\n";
131
132 if (get_option(self::SIMPLEPAYPRO_CAMPAIGN) != '') {
133 $contentToAsync .= "sale.setCampaignID('".get_option(self::SIMPLEPAYPRO_CAMPAIGN)."');\n";
134 }
135
136 if (isset($paymentData['customer']->discount->coupon->id)) {
137 $contentToAsync .= "sale.setCoupon('". str_replace("'","\'",$paymentData['customer']->discount->coupon->id)."');\n";
138 }
139
140 $currency = $paymentData['form']->currency;
141 if (isset($paymentData['paymentintents'][0]->currency)) {
142 $currency = strtoupper($paymentData['paymentintents'][0]->currency);
143 }
144 $contentToAsync .= "sale.setCurrency('".$currency."');\n";
145
146 $contentToAsync .= 'PostAffTracker.register();';
147
148 if (get_option(postaffiliatepro::ASYNC_ENABLED) !== 'true') {
149 $HTMLcontent .= postaffiliatepro::getPAPTrackJSDynamicCode().'<script type="text/javascript">';
150 $HTMLcontent .= $contentToAsync . "</script>\n";
151 } else {
152 $HTMLcontent .= postaffiliatepro::getPAPTrackJSAsyncCode($contentToAsync);
153 }
154 }
155
156 echo $HTMLcontent;
157 }
158
159 private function getTrackingData($customer, $n) {
160 $data = get_option(constant('self::SIMPLEPAYPRO_DATA'.$n));
161 switch ($data) {
162 case 'id':
163 if ($customer->id != '') {
164 return $customer->id;
165 }
166 return crc32($customer->email);
167 case 'email':
168 case 'name':
169 return $customer->{$data};
170 default: return '';
171 }
172 }
173 }
174
175 $papSubmenuPriority = 43;
176 $papIntegrationSimplePayPro = new postaffiliatepro_Form_Settings_SimplePayPro();
177 add_action('admin_init', array(
178 $papIntegrationSimplePayPro,
179 'initSettings'
180 ), 99);
181 add_action('admin_menu', array(
182 $papIntegrationSimplePayPro,
183 'addPrimaryConfigMenu'
184 ), $papSubmenuPriority);
185 add_filter('simpay_payment_receipt_viewed', array(
186 $papIntegrationSimplePayPro,
187 'confirmationMessage'
188 ), 99);
189 add_action('simpay_form_before_form_bottom', array(
190 $papIntegrationSimplePayPro,
191 'addHiddenCodeToForm'
192 ), 99, 2);
193 add_filter('simpay_create_customer_args', array(
194 $papIntegrationSimplePayPro,
195 'modifyCustomerInfo'
196 ), 99);