Changeset 2048717
- Timestamp:
- 03/12/2019 12:41:07 AM (7 years ago)
- Location:
- customdonations/trunk
- Files:
-
- 4 edited
-
classes/cd-config-class.php (modified) (2 diffs)
-
classes/cd-shortcode-class.php (modified) (4 diffs)
-
customdonations.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
customdonations/trunk/classes/cd-config-class.php
r1791029 r2048717 22 22 add_settings_field('customdonations_memberid_field', __('The following field will be used as memberId for logged-in users:', 'customdonations'), [$this, 'customdonations_field_memberid_field_callback'], 'customdonations', 'customdonations_section_loggedin', ['label_for' => 'customdonations_memberid_field', 'class' => 'customdonations_memberid_field_row', 'customdonations_custom_data' => 'custom']); 23 23 add_settings_field('customdonations_firsttime', '', [$this, 'customdonations_field_firsttime_callback'], 'customdonations', 'customdonations_section_loggedin', ['label_for' => 'customdonations_firsttime', 'customdonations_custom_data' => 'custom']); 24 add_settings_section('customdonations_section_account', __(' Account Information (optional)', 'customdonations'), null, 'customdonations');24 add_settings_section('customdonations_section_account', __('Optional Settings', 'customdonations'), null, 'customdonations'); 25 25 add_settings_field('customdonations_acctid', __('Account', 'customdonations'), [$this, 'customdonations_field_account_callback'], 'customdonations', 'customdonations_section_account', ['label_for' => 'customdonations_acctid', 'class' => 'customdonations_account_row', 'customdonations_custom_data' => 'custom']); 26 add_settings_field('customdonations_paymentver', __('Default Payment Version', 'customdonations'), [$this, 'customdonations_paymentver_callback'],'customdonations','customdonations_section_account', ['label_for' => 'customdonations_paymentver', 'class' => 'customdonations_account_row', 'customdonations_custom_data' => 'custom']); 26 27 } 27 28 … … 106 107 <?php 107 108 } 109 110 /** 111 * Allows the paymentVersion to have a different default, if the user wants to use inline forms across their site. 112 */ 113 function customdonations_paymentver_callback($args){ 114 ?> 115 <select id="<?php echo esc_attr($args['label_for']); ?>" name="customdonations_options[<?php echo esc_attr($args['label_for']); ?>]" 116 > 117 <option value="1" <?php echo isset($this->config[$args['label_for']]) ? ( selected($this->config[$args['label_for']], 1, false) ) : ( '' ); ?>> 118 <?php esc_html_e('Modal Window', 'customdonations'); ?> 119 </option> 120 <option value="2" <?php echo isset($this->config[$args['label_for']]) ? ( selected($this->config[$args['label_for']], 2, false) ) : ( '' ); ?>> 121 <?php esc_html_e('Inline (US Clients Only)', 'customdonations'); ?> 122 </option> 123 </select> 124 <p class="description"> 125 <?php esc_html_e('You may set the default payment form type for existing shortcodes which do not have "paymentVersion" specified.', 'customdonations'); ?> 126 </p> 127 <?php 128 } 108 129 109 130 /** -
customdonations/trunk/classes/cd-shortcode-class.php
r1791029 r2048717 5 5 6 6 private $memberid_enabled, $memberid_field; //fields set in settings. 7 public $account, $form, $allocation, $mode, $memberId ;7 public $account, $form, $allocation, $mode, $memberId, $paymentVersion; 8 8 public $baseUrl = 'https://api.customdonations.com'; 9 9 public $apiVersion = 'v1'; … … 12 12 extract($atts); //convert the array keys into php variables with the same name. 13 13 $opts = get_option('customdonations_options'); //get settings from the database 14 $config_acctid = boolval($opts['customdonations_acctid']) ? $opts['customdonations_acctid'] : null; //is there an account id configured in the DB? 15 $this->memberid_enabled = (isset($opts['customdonations_memberid_enabled']) && $opts['customdonations_memberid_enabled'] === 'on') ? true : false; 14 $config_acctid = !empty($opts['customdonations_acctid']) ? $opts['customdonations_acctid'] : null; //is there an account id configured in the DB? 15 $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; 16 17 $this->memberid_field = $opts['customdonations_memberid_field']; //what field should be used for logged-in users? 17 $this->allocation = isset($allocation) ? esc_attr($allocation) : null; //optional18 $this->form = isset($form) ? esc_attr($form) : null; //definitely required - not good if missing!19 $this->account = isset($account) ? $account : $config_acctid; //if value for account is changed in shortcode, use that - otherwise go with the value specified in the config.18 $this->allocation = !empty($allocation) ? esc_attr($allocation) : null; //optional 19 $this->form = !empty($form) ? esc_attr($form) : null; //definitely required - not good if missing! 20 $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. 20 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 value 21 22 $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!) 22 24 } 23 25 … … 63 65 */ 64 66 function enqueue_customdonations_scripts_js() { 67 $dateTime = new DateTime(); 65 68 $frm_builder_script_url = sprintf('%s/%s/js/form-builder.min.js', $this->baseUrl, $this->apiVersion); 66 wp_enqueue_script('customdonations-form-builder', $frm_builder_script_url, '', '0.1.0', true);67 wp_enqueue_script('customdonations-shortcode', plugins_url('../js/cd-shortcode.js', __FILE__), '', '0.1.0', true);69 wp_enqueue_script('customdonations-form-builder', $frm_builder_script_url, '', $dateTime->getTimestamp(), true); 70 wp_enqueue_script('customdonations-shortcode', plugins_url('../js/cd-shortcode.js', __FILE__), '', '1.1', true); 68 71 $data = [ 69 72 'account' => $this->account, … … 73 76 'apiVersion' => $this->apiVersion, 74 77 'baseUrl' => $this->baseUrl, 75 'mode' => $this->mode 78 'mode' => $this->mode, 79 'paymentVersion' => $this->paymentVersion 76 80 ]; 77 81 wp_localize_script('customdonations-shortcode', 'shortcode_data', $data); //PASS FORM DATA TO THE EMBED SCRIPT. -
customdonations/trunk/customdonations.php
r1791029 r2048717 6 6 * Author URI: https://www.customdonations.com 7 7 * Text Domain: customdonations 8 * Version: 1. 0.18 * Version: 1.1 9 9 * License: GPLv2 10 10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html -
customdonations/trunk/readme.txt
r1791029 r2048717 1 1 === CustomDonations.com === 2 Tested up to: 4.9.12 Tested up to: 5.1 3 3 Requires PHP: 5.2 4 Stable tag: 1. 0.14 Stable tag: 1.1 5 5 License: GPLv2 6 6 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 34 34 To add a form to your site, add the following information from the Custom Donations site to your site in the following format: 35 35 36 `[CustomDonations account="account-id-goes-here" form="form-id-goes-here" mode="live" allocation="optional" ]`36 `[CustomDonations account="account-id-goes-here" form="form-id-goes-here" mode="live" allocation="optional" paymentVersion=1]` 37 37 38 38 The value for allocation is optional and may be omitted from the shortcode if it doesn't apply to your form. The value for 'mode' if you wish to test your form is 'test'. … … 42 42 43 43 == Changelog == 44 = 1.1 = 45 Addition of paymentVersion parameter for choosing either the modal or inline form. 46 Enables Google/Apple Pay for US Clients using inline form. 44 47 = 1.0.1 = 45 48 Minor settings fixes.
Note: See TracChangeset
for help on using the changeset viewer.