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
S2Member.class.php
109 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | |
| 4 | class postaffiliatepro_Form_Settings_S2Member extends postaffiliatepro_Form_Base { |
| 5 | const S2MEMBER_COMMISSION_ENABLED = 's2member-commission-enabled'; |
| 6 | const S2MEMBER_CONFIG_PAGE = 's2member-config-page'; |
| 7 | const S2MEMBER_CAMPAIGN = 's2member-campaign'; |
| 8 | const S2MEMBER_TRACK_RECURRING = 's2member-track-recurring'; |
| 9 | |
| 10 | public function __construct() { |
| 11 | parent::__construct(self::S2MEMBER_CONFIG_PAGE, 'options.php'); |
| 12 | } |
| 13 | |
| 14 | public function initSettings() { |
| 15 | register_setting(postaffiliatepro::INTEGRATIONS_SETTINGS_PAGE_NAME, self::S2MEMBER_COMMISSION_ENABLED); |
| 16 | register_setting(self::S2MEMBER_CONFIG_PAGE, self::S2MEMBER_CAMPAIGN); |
| 17 | register_setting(self::S2MEMBER_CONFIG_PAGE, self::S2MEMBER_TRACK_RECURRING); |
| 18 | } |
| 19 | |
| 20 | public function addPrimaryConfigMenu() { |
| 21 | if (get_option(postaffiliatepro_Form_Settings_S2Member::S2MEMBER_COMMISSION_ENABLED) === 'true') { |
| 22 | add_submenu_page( |
| 23 | 'integrations-config-page-handle', |
| 24 | 's2Member', |
| 25 | 's2Member', |
| 26 | 'manage_options', |
| 27 | 's2memberintegration-settings-page', |
| 28 | array($this, 'printConfigPage') |
| 29 | ); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | public function printConfigPage() { |
| 34 | $this->render(); |
| 35 | } |
| 36 | |
| 37 | protected function getTemplateFile() { |
| 38 | return WP_PLUGIN_DIR . '/postaffiliatepro/Template/S2MemberConfig.xtpl'; |
| 39 | } |
| 40 | |
| 41 | protected function initForm() { |
| 42 | $campaignHelper = new postaffiliatepro_Util_CampaignHelper(); |
| 43 | $campaignList = $campaignHelper->getCampaignsList(); |
| 44 | |
| 45 | $campaigns = array('0' => ' '); |
| 46 | foreach ($campaignList as $row) { |
| 47 | $campaigns[$row->get('campaignid')] = htmlspecialchars($row->get('name')); |
| 48 | } |
| 49 | $this->addSelect(self::S2MEMBER_CAMPAIGN, $campaigns); |
| 50 | $this->addCheckbox(self::S2MEMBER_TRACK_RECURRING); |
| 51 | |
| 52 | $this->addSubmit(); |
| 53 | } |
| 54 | |
| 55 | public function s2MemberPayPalButton($buttoncode, $params) { |
| 56 | $buttoncode = str_replace('name="notify_url"', 'name="notify_url" id="pap_ab78y5t4a"', $buttoncode); |
| 57 | |
| 58 | $contentToAsync = 'PostAffTracker.setAccountId(\''.postaffiliatepro_Base::getAccountName().'\'); |
| 59 | PostAffTracker.writeCookieToCustomField(\'pap_ab78y5t4a\', \'\', \'pap_custom\');'; |
| 60 | |
| 61 | if (get_option(postaffiliatepro::ASYNC_ENABLED) != 'true') { |
| 62 | $result = postaffiliatepro::getPAPTrackJSDynamicCode().'<script type="text/javascript">'; |
| 63 | $result .= $contentToAsync . "</script>\n"; |
| 64 | } else { |
| 65 | $result = postaffiliatepro::getPAPTrackJSAsyncCode($contentToAsync); |
| 66 | } |
| 67 | |
| 68 | return $buttoncode.$result; |
| 69 | } |
| 70 | |
| 71 | public function s2MemberRecurringTracking($params) { |
| 72 | // payment notification handling... |
| 73 | $paypal = $_REQUEST; |
| 74 | $this->_log('Received notification from Paypal: '.print_r($paypal, true)); |
| 75 | |
| 76 | if ($paypal['txn_type'] != 'subscr_payment') { |
| 77 | $this->_log('Paypal transaction type: '.$paypal['txn_type']); |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | $papCookies = ''; |
| 82 | if (isset($_GET['pap_custom'])) { |
| 83 | $papCookies = sanitize_text_field(wp_unslash($_GET['pap_custom'])); |
| 84 | } |
| 85 | |
| 86 | $query = 'AccountId='.substr($papCookies,0,8). '&visitorId='.substr($papCookies,-32); |
| 87 | $query .= '&TotalCost='.$paypal['mc_gross'].'&OrderID='.$paypal['txn_id'].'(1)'; |
| 88 | $query .= '&ProductID='.urlencode($paypal['item_name']); |
| 89 | $query .= '&Currency='.$paypal['mc_currency']; |
| 90 | $query .= '&Data1='.urlencode($paypal['payer_email']); |
| 91 | |
| 92 | if (get_option(self::S2MEMBER_CAMPAIGN) !== '' && |
| 93 | get_option(self::S2MEMBER_CAMPAIGN) !== null && |
| 94 | get_option(self::S2MEMBER_CAMPAIGN) !== 0 && |
| 95 | get_option(self::S2MEMBER_CAMPAIGN) !== '0') { |
| 96 | $query .= '&CampaignID='.get_option(self::S2MEMBER_CAMPAIGN); |
| 97 | } |
| 98 | |
| 99 | postaffiliatepro::sendRequest(postaffiliatepro::parseSaleScriptPath(), $query); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | $papSubmenuPriority = 40; |
| 104 | $papIntegrationS2Member = new postaffiliatepro_Form_Settings_S2Member(); |
| 105 | add_action('admin_init', array($papIntegrationS2Member, 'initSettings'), 99); |
| 106 | add_action('admin_menu', array($papIntegrationS2Member, 'addPrimaryConfigMenu'), $papSubmenuPriority); |
| 107 | |
| 108 | add_filter('ws_plugin__s2member_sc_paypal_button', array($papIntegrationS2Member, 's2MemberPayPalButton'), 99, 2); |
| 109 | add_action('ws_plugin__s2member_before_paypal_notify', array($papIntegrationS2Member, 's2MemberRecurringTracking')); |