Plugin Directory

Changeset 1791029


Ignore:
Timestamp:
12/22/2017 03:27:54 AM (8 years ago)
Author:
customdonations
Message:

Minor settings fixes.

Location:
customdonations/trunk
Files:
4 edited

Legend:

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

    r1790427 r1791029  
    1919        register_setting('customdonations', 'customdonations_options');
    2020        add_settings_section('customdonations_section_loggedin', __('Logged-in User Options', 'customdonations'), null, 'customdonations');
    21         //add_settings_section('customdonations_section_loggedin', __('Logged-in User Options', 'customdonations'), [$this, 'customdonations_section_loggedin_callback'], 'customdonations');
    2221        add_settings_field('customdonations_memberid_enabled', __('Fill a value for <em>memberId</em> when a logged-in user donates?', 'customdonations'), [$this, 'customdonations_field_memberid_enabled_callback'], 'customdonations', 'customdonations_section_loggedin', ['label_for' => 'customdonations_memberid_enabled', 'class' => 'customdonations_memberid_enabled_row', 'customdonations_custom_data' => 'custom']);
    2322        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']);
    2423        add_settings_field('customdonations_firsttime', '', [$this, 'customdonations_field_firsttime_callback'], 'customdonations', 'customdonations_section_loggedin', ['label_for' => 'customdonations_firsttime', 'customdonations_custom_data' => 'custom']);
    2524        add_settings_section('customdonations_section_account', __('Account Information (optional)', 'customdonations'), null, 'customdonations');
    26         //add_settings_section('customdonations_section_account', __('Account Information (optional)', 'customdonations'), [$this, 'customdonations_section_account_callback'], 'customdonations');
    2725        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']);
    2826    }
     
    3230     */
    3331    function customdonations_field_memberid_enabled_callback($args) {
    34         $value = is_null($this->config['customdonations_firsttime']) ? 'on' : $this->config[$args['label_for']]; //value is true by default - if there is ever a save, then the value provided in that save is the value we will go with.
     32        $checked_orig = !isset($this->config[$args['label_for']]) ? false : $this->config[$args['label_for']];
     33        $value = is_null($this->config['customdonations_firsttime']) ? 'on' : $checked_orig; //value is true by default - if there is ever a save, then the value provided in that save is the value we will go with.
    3534        ?>
    3635        <input type=checkbox id="<?php echo esc_attr($args['label_for']); ?>" name="customdonations_options[<?php echo esc_attr($args['label_for']); ?>]" <?php checked($value, 'on') ?>>
     
    113112    function customdonations_configuration_page() {
    114113        $this->config_page = add_menu_page('Shortcode Configuration', 'CustomDonations', 'manage_options', 'customdonations', [$this, 'customdonations_configuration_page_html'], plugins_url('../cd-logo-sq.svg', __FILE__));
    115         add_action('admin_print_scripts-' . $this->config_page, [$this, 'customdonations_config_inline_js'], 9999);
    116114    }
    117115
  • customdonations/trunk/classes/cd-shortcode-class.php

    r1790427 r1791029  
    1313        $opts = get_option('customdonations_options'); //get settings from the database
    1414        $config_acctid = boolval($opts['customdonations_acctid']) ? $opts['customdonations_acctid'] : null; //is there an account id configured in the DB?
    15         $this->memberid_enabled = ($opts['customdonations_memberid_enabled'] === 'on') ? true : false;
     15        $this->memberid_enabled = (isset($opts['customdonations_memberid_enabled']) && $opts['customdonations_memberid_enabled'] === 'on') ? true : false;
    1616        $this->memberid_field = $opts['customdonations_memberid_field']; //what field should be used for logged-in users?
    17         $this->allocation = boolval($allocation) ? esc_attr($allocation) : null; //optional
    18         $this->form = boolval($form) ? esc_attr($form) : null; //definitely required - not good if missing!
    19         $this->account = boolval($account) ? $account : $config_acctid; //if value for account is changed in shortcode, use that - otherwise go with the value specified in the config.
     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.
    2020        $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
    2121        $this->mode = ($mode === 'live' || $mode === 'test') ? esc_attr($mode) : null; //there is an issue if mode isn't provided.
  • customdonations/trunk/customdonations.php

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

    r1790427 r1791029  
    22Tested up to: 4.9.1
    33Requires PHP: 5.2
    4 Stable tag: 1.0
     4Stable tag: 1.0.1
    55License: GPLv2
    66License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4242
    4343== Changelog ==
    44 = 1.0.0 =
     44= 1.0.1 =
     45Minor settings fixes.
     46= 1.0 =
    4547Initial release
Note: See TracChangeset for help on using the changeset viewer.