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 / LifterLMS.class.php
postaffiliatepro / Form / Settings Last commit date
AdditionalOptions.class.php 3 months ago CampaignInfo.class.php 3 months ago Campaigns.class.php 3 months ago ClickTracking.class.php 3 months ago ContactForm7.class.php 3 months ago Debugging.class.php 2 months ago EDD.class.php 2 months ago General.class.php 2 months ago Integrations.class.php 3 months ago LifterLMS.class.php 3 months ago Marketpress.class.php 2 months ago MemberPress.class.php 3 months ago Membership2.class.php 3 months ago PMPro.class.php 3 months ago PPBuyNowButton.class.php 3 months ago RestrictContentPro.class.php 3 months ago S2Member.class.php 3 months ago Signup.class.php 3 months ago SimplePayPro.class.php 3 months ago StripePayments.class.php 2 months ago SureCart.class.php 3 months ago WPEasyCart.class.php 3 months ago WPPayForms.class.php 3 months ago WishListMember.class.php 3 months ago WooComm.class.php 2 months ago
LifterLMS.class.php
192 lines
1 <?php
2 if (!defined('ABSPATH')) exit;
3
4 class postaffiliatepro_Form_Settings_LifterLMS extends postaffiliatepro_Form_Base {
5 const LIFTERLMS_COMMISSION_ENABLED = 'lifterlms-commission-enabled';
6 const LIFTERLMS_CONFIG_PAGE = 'lifterlms-config-page';
7 const LIFTERLMS_PRODUCT_ID = 'lifterlms-product-id';
8 const LIFTERLMS_DATA1 = 'lifterlms-data1';
9 const LIFTERLMS_DATA2 = 'lifterlms-data2';
10 const LIFTERLMS_DATA3 = 'lifterlms-data3';
11 const LIFTERLMS_DATA4 = 'lifterlms-data4';
12 const LIFTERLMS_DATA5 = 'lifterlms-data5';
13 const LIFTERLMS_CAMPAIGN = 'lifterlms-campaign';
14
15 public function __construct() {
16 parent::__construct(self::LIFTERLMS_CONFIG_PAGE, 'options.php');
17 }
18
19 protected function getTemplateFile() {
20 return WP_PLUGIN_DIR . '/postaffiliatepro/Template/LifterLMSConfig.xtpl';
21 }
22
23 protected function initForm() {
24 $this->addSelect(self::LIFTERLMS_PRODUCT_ID, array(
25 '0' => ' ',
26 'product_id' => 'product ID',
27 'product_title' => 'product title',
28 'product_sku' => 'product SKU',
29 'product_type' => 'product type',
30 'plan_id' => 'plan ID',
31 'plan_title' => 'plan title',
32 'plan_sku' => 'plan SKU'
33 ));
34
35 $dataOptions = array(
36 '0' => ' ',
37 'user_id' => 'customer ID',
38 'billing_email' => 'customer billing email',
39 'billing_phone' => 'customer billing phone',
40 'name' => 'customer billing name', // billing_first_name billing_last_name
41 'address' => 'customer billing address', // billing_address_1 billing_address_2 billing_city billing_zip billing_state billing_country
42 'coupon_code' => 'coupon code',
43 'product_id' => 'product ID',
44 'product_title' => 'product title',
45 'product_sku' => 'product SKU',
46 'product_type' => 'product type',
47 'plan_id' => 'plan ID',
48 'plan_title' => 'plan title',
49 'plan_sku' => 'plan SKU'
50 );
51 $this->addSelect(self::LIFTERLMS_DATA1, $dataOptions);
52 $this->addSelect(self::LIFTERLMS_DATA2, $dataOptions);
53 $this->addSelect(self::LIFTERLMS_DATA3, $dataOptions);
54 $this->addSelect(self::LIFTERLMS_DATA4, $dataOptions);
55 $this->addSelect(self::LIFTERLMS_DATA5, $dataOptions);
56
57 $campaignHelper = new postaffiliatepro_Util_CampaignHelper();
58 $campaignList = $campaignHelper->getCampaignsList();
59
60 $campaigns = array(
61 '0' => ' '
62 );
63 foreach ($campaignList as $row) {
64 $campaigns[$row->get('campaignid')] = htmlspecialchars($row->get('name'));
65 }
66 $this->addSelect(self::LIFTERLMS_CAMPAIGN, $campaigns);
67
68 $this->addSubmit();
69 }
70
71 public function initSettings() {
72 register_setting(postaffiliatepro::INTEGRATIONS_SETTINGS_PAGE_NAME, self::LIFTERLMS_COMMISSION_ENABLED);
73 register_setting(self::LIFTERLMS_CONFIG_PAGE, self::LIFTERLMS_PRODUCT_ID);
74 register_setting(self::LIFTERLMS_CONFIG_PAGE, self::LIFTERLMS_DATA1);
75 register_setting(self::LIFTERLMS_CONFIG_PAGE, self::LIFTERLMS_DATA2);
76 register_setting(self::LIFTERLMS_CONFIG_PAGE, self::LIFTERLMS_DATA3);
77 register_setting(self::LIFTERLMS_CONFIG_PAGE, self::LIFTERLMS_DATA4);
78 register_setting(self::LIFTERLMS_CONFIG_PAGE, self::LIFTERLMS_DATA5);
79 register_setting(self::LIFTERLMS_CONFIG_PAGE, self::LIFTERLMS_CAMPAIGN);
80 }
81
82 public function addPrimaryConfigMenu() {
83 if (get_option(self::LIFTERLMS_COMMISSION_ENABLED) === 'true') {
84 add_submenu_page('integrations-config-page-handle', 'LifterLMS', 'LifterLMS', 'manage_options', 'lifterlmsintegration-settings-page', array(
85 $this,
86 'printConfigPage'
87 ));
88 }
89 }
90
91 public function printConfigPage() {
92 $this->render();
93 }
94
95 public function addHiddenCodeToForm() {
96 if (get_option(self::LIFTERLMS_COMMISSION_ENABLED) === 'true') {
97 postaffiliatepro::addHiddenFieldToPaymentForm();
98 }
99 }
100
101 public function papLifterTrackSale($order) {
102 if (get_option(self::LIFTERLMS_COMMISSION_ENABLED) !== 'true') {
103 return;
104 }
105 if (!is_object($order)) {
106 $order = new LLMS_Order($order);
107 }
108
109 $cookie = '';
110 if (isset($_POST['pap_custom']) && !empty(wp_unslash($_POST['pap_custom']))) {
111 $cookie = sanitize_text_field(wp_unslash($_POST['pap_custom']));
112 }
113 $query = 'AccountId=' . postaffiliatepro::getAccountName() . '&visitorId=' . substr($cookie, -32);
114 $campaignId = get_option(self::LIFTERLMS_CAMPAIGN);
115 if ($campaignId != '' && $campaignId !== '0') {
116 $query .= '&CampaignID=' . $campaignId;
117 }
118 $totalCost = ($order->get('trial_offer') === 'yes') ? $order->get('trial_total') : $order->get('total');
119 $query .= "&TotalCost=$totalCost&OrderID={$order->get('id')}&ProductID={$order->get('product_id')}";
120 $query .= "&Currency={$order->get('currency')}&ip={$order->get('user_ip_address')}&Coupon={$order->get('coupon_code')}";
121 for ($d = 1; $d <=5; $d++) {
122 $query .= "&Data$d=" . urlencode($this->getTrackingData($order, $d));
123 }
124 self::_log('Sending a tracking request with these details: ' . print_r($query, true));
125 self::sendRequest(postaffiliatepro::parseSaleScriptPath(), $query);
126 }
127
128 public function papLifterTrackRecurring($order) {
129 if (get_option(self::LIFTERLMS_COMMISSION_ENABLED) !== 'true') {
130 return;
131 }
132 if (!is_object($order)) {
133 $order = new LLMS_Order($order);
134 }
135 self::_log('Tracking of recurring order: ' . $order->get('id'));
136
137 $session = $this->getApiSession();
138 if ($session === null || $session === '0') {
139 self::_log('We have no session to PAP installation! Recurring commission failed. Try to create a regular commission.');
140 $this->papLifterTrackSale($order);
141 return;
142 }
143
144 if (!$this->fireRecurringCommissions($session, $order->get('id'), $order->get('total'))) {
145 self::_log('Recurring commission for order ID ' . $order->get('id') . ' failed, trying to create a regular commission.');
146 $this->papLifterTrackSale($order);
147 }
148 }
149
150 private function getTrackingData($order, $n) {
151 $data = get_option(constant('self::LIFTERLMS_DATA'.$n));
152 switch ($data) {
153 case '0':
154 return '';
155 case 'name':
156 return $order->get('billing_first_name') . ' ' . $order->get('billing_last_name');
157 case 'address':
158 return $order->get('billing_address_1') . ' ' . $order->get('billing_address_2') . ' ' . $order->get('billing_city') . ' ' . $order->get('billing_zip') . ' ' . $order->get('billing_state') . ' ' . $order->get('billing_country');
159 case 'user_id':
160 if ($order->get('user_id') != '') {
161 return $order->get('user_id');
162 }
163 return crc32($order->get('billing_email'));
164 default: return $order->get($data);
165 }
166 }
167 }
168
169 $papSubmenuPriority = 20;
170 $papIntegrationLifterLMS = new postaffiliatepro_Form_Settings_LifterLMS();
171 add_action('admin_init', array(
172 $papIntegrationLifterLMS,
173 'initSettings'
174 ), 99);
175 add_action('admin_menu', array(
176 $papIntegrationLifterLMS,
177 'addPrimaryConfigMenu'
178 ), $papSubmenuPriority);
179
180 add_action('lifterlms_after_checkout_form', array(
181 $papIntegrationLifterLMS,
182 'addHiddenCodeToForm'
183 ));
184 add_action('lifterlms_order_status_active', array(
185 $papIntegrationLifterLMS,
186 'papLifterTrackSale'
187 ));
188 add_action('llms_charge_recurring_payment', array(
189 $papIntegrationLifterLMS,
190 'papLifterTrackRecurring'
191 ));
192