Plugin Directory

Changeset 2313474


Ignore:
Timestamp:
05/28/2020 03:26:05 AM (6 years ago)
Author:
customdonations
Message:

ReCaptcha and parameter processing improvements.

Location:
customdonations/trunk
Files:
1 added
4 edited

Legend:

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

    r2286386 r2313474  
    44class CustomDonations_Shortcode {
    55
     6    /**
     7     * @var CustomDonations_Helper
     8     */
     9    private $helper;
    610    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;
    812    public $baseUrl = 'https://api.customdonations.com';
    913    public $apiVersion = 'v1';
    1014
    1115    public function __construct($atts) {
     16        $this->helper = new CustomDonations_Helper();
     17        $helper = $this->helper;
    1218        extract($atts); //convert the array keys into php variables with the same name.
    1319        $opts = get_option('customdonations_options'); //get settings from the database
    1420        $config_acctid = !empty($opts['customdonations_acctid']) ? $opts['customdonations_acctid'] : null; //is there an account id configured in the DB?
    1521        $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']);
    1723        $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; //optional
     24        $this->allocation = $helper::VarToBool($allocation) ? esc_attr($allocation) : null; //optional
    1925        $this->form = !empty($form) ? esc_attr($form) : null; //definitely required - not good if missing!
    2026        $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 value
     27        $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
    2228        $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);
    2533    }
    2634
     
    6876        $dateTime = new DateTime();
    6977        $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);
    7281        $data = [
    7382            'account' => $this->account,
     
    7988            'mode' => $this->mode,
    8089            'paymentVersion' => $this->paymentVersion,
    81             'interval' => $this->interval
     90            'interval' => $this->interval,
     91            'useReCaptcha' => $this->useReCaptcha,
     92            'shortcodeDebug' => $this->shortcodeDebug
    8293        ];
    8394        wp_localize_script('customdonations-shortcode', 'shortcode_data', $data); //PASS FORM DATA TO THE EMBED SCRIPT.
  • customdonations/trunk/customdonations.php

    r2286386 r2313474  
    66 * Author URI:      https://www.customdonations.com
    77 * Text Domain:     customdonations
    8  * Version:         1.1.2
     8 * Version:         1.1.3
    99 * License:         GPLv2
    1010 * License URI:     https://www.gnu.org/licenses/gpl-2.0.html
     
    1212defined('ABSPATH') or die(); //no access unless WordPress is running!
    1313
     14include 'classes/cd-helper-class.php';
    1415include 'classes/cd-config-class.php';
    1516include 'classes/cd-shortcode-class.php';
  • customdonations/trunk/js/cd-shortcode.js

    r1790427 r2313474  
    1 CustomDonations.BuildForm(shortcode_data);
     1class 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}
     14var cdLoad = new CustomDonations_WP(shortcode_data);
     15cdLoad.Load();
     16shortcode_data = null;
  • customdonations/trunk/readme.txt

    r2286390 r2313474  
    4242
    4343== Changelog ==
     44= 1.1.3 =
     45Addition of ReCaptcha parameter. More parameter processing improvements.
    4446= 1.1.2 =
    4547Improve interval parameter processing, minor adjustments to settings page.
Note: See TracChangeset for help on using the changeset viewer.