Plugin Directory

Changeset 1448367


Ignore:
Timestamp:
07/04/2016 07:43:44 AM (10 years ago)
Author:
alwex
Message:
  • update to 0.3
  • block dates from the calendar
Location:
experitus-form
Files:
17 added
7 edited

Legend:

Unmodified
Added
Removed
  • experitus-form/trunk/experitus-form.php

    r1445037 r1448367  
    44Plugin URI: 
    55Description: This plugins integrates your WP site and Experitus account by installing an orders form
    6 Version:     0.2
     6Version:     0.3
    77Author:      Experitus
    88*/
     
    1919define( 'EXPERITUS_ROOT_FILE', __FILE__ );
    2020define( 'EXPERITUS_URL',  'https://app.experitus.io/');
     21
    2122/**
    2223 * Adds options to database
     
    3031    add_option( 'experitus_payments_data' );
    3132    add_option( 'experitus_options_check' );
     33    add_option( 'experitus_block_dates' );
    3234}
    3335register_activation_hook( __FILE__, 'add_experitus_options' );
     
    4446    delete_option( 'experitus_payments_data' );
    4547    delete_option( 'experitus_options_check' );
     48    delete_option( 'experitus_block_dates' );
    4649}
    4750register_uninstall_hook( __FILE__, 'remove_experitus_options' );
  • experitus-form/trunk/includes/controllers/experitus-admin-controller.php

    r1445037 r1448367  
    171171                        esc_attr( 'settings_updated' ),
    172172                        __( 'You successfully connected to your Experitus account.' ),
    173                         'success'
     173                        'notice-success'
    174174                    );
    175175                }
     
    196196            return;
    197197        update_option( 'experitus_request_attributes', $response['attributes'] );
    198         if ( isset( $response['items'] ) )
    199             update_option( 'experitus_request_items', $response['items'] );
    200         if ( isset( $response['payments_data'] ) )
    201             update_option( 'experitus_payments_data', $response['payments_data'] );
     198        update_option( 'experitus_request_items', $response['items'] );
     199        update_option( 'experitus_payments_data', $response['payments_data'] );
     200        update_option( 'experitus_block_dates', $response['block_dates'] );
    202201        update_option( 'experitus_options_check', ['outdated' => false, 'time' => time()] );
    203202    }
     
    231230                esc_attr( 'settings_updated' ),
    232231                __( 'Google reCaptcha credentials added to your form.' ),
    233                 'success'
     232                'notice-success'
    234233            );
    235234            return $input;
     
    323322    private function reload_form_attributes() {
    324323        if ( !$this->options['experitus_connection_data'] ) {
    325             $this->add_notification( 'error', __( 'Please conect to your Experitus account first!' ) );
     324            $this->add_notification( 'error', __( 'Please connect to your Experitus account first!' ) );
    326325            return false;
    327326        }
     
    364363        if ( $this->options['experitus_request_attributes'] != $response['attributes'] )
    365364            $result = true;
    366         if ( isset( $response['items'] ) && $this->options['experitus_request_items'] != $response['items'] || !isset( $response['items'] ) && $this->options['experitus_request_items'] )
     365        if ( $this->options['experitus_request_items'] != $response['items'] )
    367366            $result = true;
    368         if ( isset( $response['payments_data'] ) && $this->options['experitus_payments_data'] != $response['payments_data'] || !isset( $response['payments_data'] ) && $this->options['experitus_payments_data'] )
     367        if ( $this->options['experitus_payments_data'] != $response['payments_data'] )
     368            $result = true;
     369        if ($this->options['experitus_block_dates'] != $response['block_dates'] )
    369370            $result = true;
    370371        update_option( 'experitus_options_check', ['outdated' => $result, 'time' => time()] );
     
    378379        if ( !current_user_can( 'manage_options' ) )
    379380            return false;
     381       
     382        //get options
     383        $this->populateOptions();
    380384       
    381385        //check if options outdated
  • experitus-form/trunk/includes/controllers/experitus-base-controller.php

    r1445037 r1448367  
    2424     */
    2525    public function __construct() {
     26        add_shortcode( 'experitus_orders_form', array($this, 'handle_shortcode') );
     27    }
     28   
     29    protected function populateOptions() {
    2630        $this->options['experitus_request_attributes'] = get_option('experitus_request_attributes');
    2731        $this->options['experitus_connection_data'] = get_option( 'experitus_connection_data' );
     
    3135        $this->options['experitus_payments_data'] = get_option( 'experitus_payments_data' );
    3236        $this->options['experitus_options_check'] = get_option( 'experitus_options_check' );
    33         add_shortcode( 'experitus_orders_form', array($this, 'handle_shortcode') );
     37        $this->options['experitus_block_dates'] = get_option( 'experitus_block_dates' );
    3438    }
    3539   
  • experitus-form/trunk/includes/controllers/experitus-form-controller.php

    r1445037 r1448367  
    2121     */
    2222    public function handle_shortcode() {
     23       
     24        //get options
     25        $this->populateOptions();
     26       
    2327        //add payments
    2428        if ( is_ssl() && $this->options['experitus_request_attributes']['paid'] && $this->options['experitus_payments_data'] && isset( $this->options['experitus_payments_data']['gateway'] ) ) {
  • experitus-form/trunk/includes/views/form.php

    r1445037 r1448367  
    4646                        </select>
    4747                   
     48                    <?php elseif ( $attribute == 'date' ): ?>
     49                        <input value="<?php echo get_input_value($attribute); ?>" type="text" id="request_form_<?php echo $attribute; ?>" name="RequestForm[<?php echo $attribute; ?>]" data-block-dates="<?php echo $this->options['experitus_block_dates'] ? $this->options['experitus_block_dates'] : ''; ?>" />
     50                   
    4851                    <?php else: ?>
    4952                        <input value="<?php echo get_input_value($attribute); ?>" type="text" id="request_form_<?php echo $attribute; ?>" name="RequestForm[<?php echo $attribute; ?>]" />
  • experitus-form/trunk/readme.txt

    r1445049 r1448367  
    44Requires at least: 4.4.2
    55Tested up to: 4.4.2
    6 Stable tag: 0.2
     6Stable tag: 0.3
    77License: GPLv2 or later
    88
     
    6565== Changelog ==
    6666
     67= 0.3 Jul 04 2016 =
     68* Added 'block dates' functionality
     69
    6770= 0.2 Jun 27 2016 =
    6871* Added 'check availability' functionality
  • experitus-form/trunk/web/experitus-form.js

    r1445037 r1448367  
    140140                allowRememberMe:!1
    141141            });
    142         }
    143     }
    144    
    145    
    146     if (jQuery('#request_form_date').length > 0) {
    147         jQuery('#request_form_date').datepicker({
    148             dateFormat: 'mm/dd/yy',
    149             minDate: 0
    150         });
     142        },
     143        initDatePicker: function(field) {
     144            var blockDates = field.attr('data-block-dates');
     145            data = {
     146                dateFormat: 'mm/dd/yy',
     147                minDate: 0
     148            };
     149            if (blockDates) {
     150                arr = blockDates.split(',');
     151                data.beforeShowDay = function(date) {
     152                    var string = jQuery.datepicker.formatDate('mm/dd/yy', date);
     153                    return [ arr.indexOf(string) == -1 ]
     154                };
     155            }
     156            field.datepicker(data);
     157        }
     158    }
     159   
     160   
     161    if (jQuery('input[name="RequestForm[date]"]').length > 0) {
     162        experitusFormFns.initDatePicker(jQuery('input[name="RequestForm[date]"]'));
    151163    }
    152164    if (jQuery('#request_form_time').length > 0) {
Note: See TracChangeset for help on using the changeset viewer.