Plugin Directory

Changeset 2048717


Ignore:
Timestamp:
03/12/2019 12:41:07 AM (7 years ago)
Author:
customdonations
Message:

Addition of paymentVersion parameter. Enables Google/Apple Pay for US Clients using inline form.

Location:
customdonations/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • customdonations/trunk/classes/cd-config-class.php

    r1791029 r2048717  
    2222        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']);
    2323        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');
    2525        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']);
    2627    }
    2728
     
    106107        <?php
    107108    }
     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    }
    108129
    109130    /**
  • customdonations/trunk/classes/cd-shortcode-class.php

    r1791029 r2048717  
    55
    66    private $memberid_enabled, $memberid_field; //fields set in settings.
    7     public $account, $form, $allocation, $mode, $memberId;
     7    public $account, $form, $allocation, $mode, $memberId, $paymentVersion;
    88    public $baseUrl = 'https://api.customdonations.com';
    99    public $apiVersion = 'v1';
     
    1212        extract($atts); //convert the array keys into php variables with the same name.
    1313        $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;
    1617        $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; //optional
    18         $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.
    2021        $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
    2122        $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!)
    2224    }
    2325
     
    6365     */
    6466    function enqueue_customdonations_scripts_js() {
     67        $dateTime = new DateTime();
    6568        $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);
    6871        $data = [
    6972            'account' => $this->account,
     
    7376            'apiVersion' => $this->apiVersion,
    7477            'baseUrl' => $this->baseUrl,
    75             'mode' => $this->mode
     78            'mode' => $this->mode,
     79            'paymentVersion' => $this->paymentVersion
    7680        ];
    7781        wp_localize_script('customdonations-shortcode', 'shortcode_data', $data); //PASS FORM DATA TO THE EMBED SCRIPT.
  • customdonations/trunk/customdonations.php

    r1791029 r2048717  
    66 * Author URI:      https://www.customdonations.com
    77 * Text Domain:     customdonations
    8  * Version:         1.0.1
     8 * Version:         1.1
    99 * License:         GPLv2
    1010 * License URI:     https://www.gnu.org/licenses/gpl-2.0.html
  • customdonations/trunk/readme.txt

    r1791029 r2048717  
    11=== CustomDonations.com ===
    2 Tested up to: 4.9.1
     2Tested up to: 5.1
    33Requires PHP: 5.2
    4 Stable tag: 1.0.1
     4Stable tag: 1.1
    55License: GPLv2
    66License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    3434To add a form to your site, add the following information from the Custom Donations site to your site in the following format:
    3535
    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]`
    3737
    3838The 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'.
     
    4242
    4343== Changelog ==
     44= 1.1 =
     45Addition of paymentVersion parameter for choosing either the modal or inline form.
     46Enables Google/Apple Pay for US Clients using inline form.
    4447= 1.0.1 =
    4548Minor settings fixes.
Note: See TracChangeset for help on using the changeset viewer.