Changeset 2313474
- Timestamp:
- 05/28/2020 03:26:05 AM (6 years ago)
- Location:
- customdonations/trunk
- Files:
-
- 1 added
- 4 edited
-
classes/cd-helper-class.php (added)
-
classes/cd-shortcode-class.php (modified) (3 diffs)
-
customdonations.php (modified) (2 diffs)
-
js/cd-shortcode.js (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
customdonations/trunk/classes/cd-shortcode-class.php
r2286386 r2313474 4 4 class CustomDonations_Shortcode { 5 5 6 /** 7 * @var CustomDonations_Helper 8 */ 9 private $helper; 6 10 private $memberid_enabled, $memberid_field; //fields set in settings. 7 public $account, $form, $allocation, $mode, $memberId, $paymentVersion, $interval ;11 public $account, $form, $allocation, $mode, $memberId, $paymentVersion, $interval, $useReCaptcha, $shortcodeDebug; 8 12 public $baseUrl = 'https://api.customdonations.com'; 9 13 public $apiVersion = 'v1'; 10 14 11 15 public function __construct($atts) { 16 $this->helper = new CustomDonations_Helper(); 17 $helper = $this->helper; 12 18 extract($atts); //convert the array keys into php variables with the same name. 13 19 $opts = get_option('customdonations_options'); //get settings from the database 14 20 $config_acctid = !empty($opts['customdonations_acctid']) ? $opts['customdonations_acctid'] : null; //is there an account id configured in the DB? 15 21 $config_paymentver = !empty($opts['customdonations_paymentver']) && is_numeric($opts['customdonations_paymentver']) ? (int) $opts['customdonations_paymentver'] : 1; 16 $this->memberid_enabled = (!empty($opts['customdonations_memberid_enabled']) && $opts['customdonations_memberid_enabled'] === 'on') ? true : false;22 $this->memberid_enabled = $helper::VarToBool($opts['customdonations_memberid_enabled']); 17 23 $this->memberid_field = $opts['customdonations_memberid_field']; //what field should be used for logged-in users? 18 $this->allocation = !empty($allocation) ? esc_attr($allocation) : null; //optional24 $this->allocation = $helper::VarToBool($allocation) ? esc_attr($allocation) : null; //optional 19 25 $this->form = !empty($form) ? esc_attr($form) : null; //definitely required - not good if missing! 20 26 $this->account = !empty($account) ? $account : $config_acctid; //if value for account is changed in shortcode, use that - otherwise go with the value specified in the config. 21 $this->memberId = boolval($this->memberid_enabled)? $this->fill_memberid_field() : null; //if we aren't wanting to fill memberId for logged-in users, use null as the value27 $this->memberId = $this->memberid_enabled ? $this->fill_memberid_field() : null; //if we aren't wanting to fill memberId for logged-in users, use null as the value 22 28 $this->mode = ($mode === 'live' || $mode === 'test') ? esc_attr($mode) : null; //there is an issue if mode isn't provided. 23 $this->paymentVersion = !empty($paymentVersion) && $paymentVersion > 0 && $paymentVersion <= 2 ? $paymentVersion : $config_paymentver; //1: for modal payment window. 2: for inline payment with Google/Apple Pay options (US CLIENTS ONLY!) 24 $this->interval = !empty($interval) && !(strtolower($interval) === "null") ? trim(strtolower($interval)) : null; // once, monthly, quarterly, yearly, or empty. 29 $this->paymentVersion = !empty($paymentversion) && $paymentversion > 0 && $paymentversion <= 2 ? $paymentversion : $config_paymentver; //1: for modal payment window. 2: for inline payment with Google/Apple Pay options (US CLIENTS ONLY!) 30 $this->interval = $helper::VarToBool($interval) ? trim(strtolower($interval)) : null; // once, monthly, quarterly, yearly, or empty. 31 $this->useReCaptcha = $helper::VarToBool($userecaptcha); 32 $this->shortcodeDebug = $helper::VarToBool($shortcodedebug); 25 33 } 26 34 … … 68 76 $dateTime = new DateTime(); 69 77 $frm_builder_script_url = "{$this->baseUrl}/{$this->apiVersion}/js/form-builder.min.js"; 70 wp_enqueue_script('customdonations-form-builder', $frm_builder_script_url, '', $dateTime->getTimestamp(), true); 71 wp_enqueue_script('customdonations-shortcode', plugins_url('../js/cd-shortcode.js', __FILE__), '', '1.1', true); 78 $cacheBust = $dateTime->getTimestamp(); 79 wp_enqueue_script('customdonations-form-builder', $frm_builder_script_url, '', $cacheBust, true); 80 wp_enqueue_script('customdonations-shortcode', plugins_url('../js/cd-shortcode.js', __FILE__), '', $cacheBust, true); 72 81 $data = [ 73 82 'account' => $this->account, … … 79 88 'mode' => $this->mode, 80 89 'paymentVersion' => $this->paymentVersion, 81 'interval' => $this->interval 90 'interval' => $this->interval, 91 'useReCaptcha' => $this->useReCaptcha, 92 'shortcodeDebug' => $this->shortcodeDebug 82 93 ]; 83 94 wp_localize_script('customdonations-shortcode', 'shortcode_data', $data); //PASS FORM DATA TO THE EMBED SCRIPT. -
customdonations/trunk/customdonations.php
r2286386 r2313474 6 6 * Author URI: https://www.customdonations.com 7 7 * Text Domain: customdonations 8 * Version: 1.1. 28 * Version: 1.1.3 9 9 * License: GPLv2 10 10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 12 12 defined('ABSPATH') or die(); //no access unless WordPress is running! 13 13 14 include 'classes/cd-helper-class.php'; 14 15 include 'classes/cd-config-class.php'; 15 16 include 'classes/cd-shortcode-class.php'; -
customdonations/trunk/js/cd-shortcode.js
r1790427 r2313474 1 CustomDonations.BuildForm(shortcode_data); 1 class CustomDonations_WP{ 2 constructor(formData){ 3 this.debugEnabled = !!(formData.shortcodeDebug); 4 delete(formData.shortcodeDebug); 5 this.formData = formData; 6 this.formData.paymentVersion = parseInt(formData.paymentVersion); 7 this.formData.useReCaptcha = !!(formData.useReCaptcha); 8 } 9 Load(){ 10 this.debugEnabled ? console.log(this.formData) : null; 11 CustomDonations.BuildForm(this.formData); 12 } 13 } 14 var cdLoad = new CustomDonations_WP(shortcode_data); 15 cdLoad.Load(); 16 shortcode_data = null; -
customdonations/trunk/readme.txt
r2286390 r2313474 42 42 43 43 == Changelog == 44 = 1.1.3 = 45 Addition of ReCaptcha parameter. More parameter processing improvements. 44 46 = 1.1.2 = 45 47 Improve interval parameter processing, minor adjustments to settings page.
Note: See TracChangeset
for help on using the changeset viewer.