Plugin Directory

Changeset 2321931


Ignore:
Timestamp:
06/11/2020 02:38:22 AM (6 years ago)
Author:
wprequal
Message:

Commit v7.7.2

Location:
wprequal/trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • wprequal/trunk/app/abstracts/class.Mail.php

    r2315196 r2321931  
    3737        if ( $contact_form_id = get_post_meta( $post_id, 'contact_form_id', TRUE ) ) {
    3838
    39             if ( $details = get_post_meta( (int) $contact_form_id, 'details', TRUE ) ) {
     39            $details = ContactForm::get_details( $contact_form_id );
    4040
    41                 Log::write( 'details', $details );
     41            Log::write( 'details', $details );
    4242
    43                 return $details;
    44 
    45             }
     43            return $details;
    4644
    4745        }
     
    4947        Log::write( 'no-details', "Post ID: $post_id - Contact Form ID: $contact_form_id" );
    5048
    51         return FALSE;
     49        return ContactForm::get_details( 0 );;
    5250
    5351    }
     
    6260    public function email_headers( $args ) {
    6361
    64         $headers    = array();
    65         $headers[]  = $this->from_email();
     62        $from_name  = $this->from_name();
     63        $from_email = $this->from_email();
     64
     65        $headers    = [];
     66        $headers[]  = "From: $from_name <$from_email>";
    6667        $headers[]  = 'MIME-Version: 1.0';
    6768
     
    121122    public function from_email() {
    122123
    123         $from_email = $this->details['from_email'];
     124        $from_email = 'leads@wprequal.com';
    124125
    125         $from_email = empty( $from_email ) ? get_option( 'admin_email' ) : $from_email;
    126 
    127         $from_email = "From: WPrequal Leads <{$from_email}>";
     126        if ( ! empty( $this->details['from_email'] ) ) {
     127            $from_email = $this->details['from_email'];
     128        }
    128129
    129130        Log::write( 'from-email', $from_email );
    130131
    131         return apply_filters( 'wprequal_from_email_header', $from_email );
     132        return apply_filters( 'wprequal_from_email', $from_email );
     133
     134    }
     135
     136    /**
     137     * Frome Name.
     138     *
     139     * @return mixed|void
     140     */
     141
     142    public function from_name() {
     143
     144        $from_name = 'WPrequal Leads';
     145
     146        if ( ! empty( $this->details['from_name'] ) ) {
     147            $from_name = $this->details['from_name'];
     148        }
     149
     150        Log::write( 'from-name', $from_name );
     151
     152        return apply_filters( 'wprequal_from_name', $from_name );
    132153
    133154    }
  • wprequal/trunk/app/classes/class.ContactForm.php

    r2315196 r2321931  
    106106
    107107        add_shortcode( 'wprequal_contact_form', array( $this, 'contact_form' ) );
    108 
    109         add_filter( 'wprequal_contact_get_details', array( $this, 'get_details' ) );
    110108
    111109    }
     
    203201     * @param $post_id
    204202     *
    205      * @return array|mixed
    206      */
    207 
    208     public function get_details( $post_id ) {
    209 
    210         if ( is_int( $post_id ) && 0 < $post_id ) {
    211             $meta = get_post_meta( $post_id, 'details', TRUE );
    212         }
    213 
    214         return ( ! empty( $meta ) ) ? $meta : array(
     203     * @return array
     204     */
     205
     206    public static function get_details( $post_id ) {
     207
     208        $details = [
    215209            'button_text' => 'Submit',
    216             'from_email'  => get_option( 'wprequal_from_email' ) ?: 'support@wprequal.com',
     210            'from_name'   => 'WPrequal Leads',
     211            'from_email'  => get_option( 'wprequal_from_email' ) ?: 'leads@wprequal.com',
    217212            'to_email'    => get_option( 'wprequal_email' ) ?: get_option( 'admin_email' ),
    218213            'bcc_email'   => get_option( 'wprequal_bcc_email' ) ?: '',
    219214            'sms_text'    => get_option( 'wprequal_sms_carrier_gateway' ) ?: ''
    220         );
     215        ];
     216
     217        if ( is_int( $post_id ) && 0 < $post_id ) {
     218
     219            if ( $saved = get_post_meta( $post_id, 'details', TRUE ) ) {
     220
     221                foreach ( $saved as $key => $value ) {
     222
     223                    if ( ! empty( $value ) ) {
     224                        $details[$key] = $value;
     225                    }
     226
     227                }
     228
     229            }
     230
     231        }
     232
     233        return $details;
    221234
    222235    }
     
    231244
    232245        $inputs  = $this->get_inputs( $args['contact_form_id'] );
    233         $details = $this->get_details( $args['contact_form_id'] );
     246        $details = self::get_details( $args['contact_form_id'] );
    234247        $view    = ( $args['type'] === 'contact' ) ?  'contact-form' : 'contact-inputs';
    235248
  • wprequal/trunk/app/classes/class.ContactFormAdmin.php

    r2315196 r2321931  
    5959    public function actions() {
    6060
    61         add_action( 'admin_menu', array( $this, 'replace_submit_meta_box' ) );
    62         add_action( "add_meta_boxes_{$this->post_type}", array( $this, 'add_meta_box' ) );
    63         add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
    64         add_action( "save_post_{$this->post_type}", array( $this, 'save_inputs' ), 10, 1 );
    65 
    66         add_filter( "bulk_actions-edit-{$this->post_type}", array( $this, 'custom_bulk_actions' ), 99 );
    67         add_filter( 'page_row_actions', array( $this, 'modify_list_row_actions' ), 10, 2 );
     61        add_action( 'admin_menu', [ $this, 'replace_submit_meta_box' ] );
     62        add_action( "add_meta_boxes_{$this->post_type}", [ $this, 'add_meta_box' ] );
     63        add_action( 'admin_enqueue_scripts', [ $this, 'admin_scripts' ] );
     64        add_action( "save_post_{$this->post_type}", [ $this, 'save_inputs' ], 10, 1 );
     65
     66        add_filter( "bulk_actions-edit-{$this->post_type}", [ $this, 'custom_bulk_actions' ], 99 );
     67        add_filter( 'page_row_actions', [ $this, 'modify_list_row_actions' ], 10, 2 );
    6868
    6969    }
     
    8181                wp_enqueue_script( 'wprequal_admin_js' );
    8282
    83                 wp_localize_script( 'wprequal_admin_js', 'contactAdmin', array(
     83                wp_localize_script( 'wprequal_admin_js', 'contactAdmin', [
    8484                    'inputs' => $this->inputs(),
    8585                    'msg'    => $this->alert_messages()
    86                 ) );
     86                ] );
    8787
    8888            }
     
    100100    public function inputs() {
    101101
    102         $inputs = array();
     102        $inputs = [];
    103103        $views  = $this->input_types();
    104104
     
    119119    public function input_types() {
    120120
    121         return array(
     121        return [
    122122            // Contact Fields
    123123            'name'     => __( 'Name', 'wprequal' ),
     
    135135            'hidden'   => __( 'Hidden', 'wprequal' ),
    136136            'section'  => __( 'Section', 'wprequal' )
    137         );
     137        ];
    138138
    139139    }
     
    147147    public function contact_fields() {
    148148
    149         return array(
     149        return [
    150150            'name',
    151151            'email',
    152152            'phone',
    153153            'comments'
    154         );
     154        ];
    155155
    156156    }
     
    180180    public function default_values() {
    181181
    182         return array(
     182        return [
    183183            'type'          => '{type}',
    184184            'key'           => '{key}',
     
    188188            'placeholder'   => '',
    189189            'default_value' => '',
    190             'labels'        => array(),
     190            'labels'        => [],
    191191            'min'           => 0,
    192192            'max'           => 0,
    193193            'step'          => 0,
    194194            'default'       => ''
    195         );
     195        ];
    196196
    197197    }
     
    205205    public function alert_messages() {
    206206
    207         return array(
     207        return [
    208208            'correctErrors'  => __( 'Please correct the errors and try again!' ),
    209209            'onlyOneAllowed' => __( 'Only 1 {label} field is allowed. Please use a lead field instead.' )
    210         );
     210        ];
    211211
    212212    }
     
    223223            'contact-fields',
    224224            __( 'Form Builder - Contact Fields', 'wprequal' ),
    225             array( $this, 'meta_box'),
     225            [ $this, 'meta_box' ],
    226226            $this->post_type,
    227227            'side'
     
    231231            'lead-fields',
    232232            __( 'Form Builder - Lead Fields', 'wprequal' ),
    233             array( $this, 'meta_box'),
     233            [ $this, 'meta_box' ],
    234234            $this->post_type,
    235235            'side'
     
    239239            'inputs',
    240240            __( 'Form Builder - Inputs', 'wprequal' ),
    241             array( $this, 'meta_box'),
     241            [ $this, 'meta_box' ],
    242242            $this->post_type,
    243243            'advanced',
     
    248248            'details',
    249249            __( 'Form Builder - Details', 'wprequal' ),
    250             array( $this, 'meta_box'),
     250            [ $this, 'meta_box' ],
    251251            $this->post_type,
    252252            'advanced',
     
    257257            'shortcode',
    258258            __( 'Form Builder - Shortcode', 'wprequal' ),
    259             array( $this, 'meta_box'),
     259            [ $this, 'meta_box' ],
    260260            $this->post_type,
    261261            'side'
     
    274274
    275275        $view_path = $this->view_path;
    276         $allow     = array( 'shortcode', 'contact-fields', 'details', 'inputs' );
     276        $allow     = [ 'shortcode', 'contact-fields', 'details', 'inputs' ];
    277277
    278278        if ( ! Core::status( 1 ) && ! in_array( $view['id'], $allow ) ) {
     
    318318        else {
    319319
    320             update_post_meta( $post_id, 'inputs', array() );
     320            update_post_meta( $post_id, 'inputs', [] );
    321321
    322322        }
     
    333333        else {
    334334
    335             update_post_meta( $post_id, 'details', array() );
     335            update_post_meta( $post_id, 'details', [] );
    336336
    337337        }
  • wprequal/trunk/app/classes/class.Email.php

    r2315196 r2321931  
    8484    public function send_email() {
    8585       
    86         add_action( 'wp_mail_failed', array( $this, 'log_mailer_error' ), 10, 1 );
    87         add_filter( 'wp_mail', array( $this, 'email_headers' ) );
     86        add_action( 'wp_mail_failed', [ $this, 'log_mailer_error' ], 10, 1 );
     87        add_filter( 'wp_mail', [ $this, 'email_headers' ] );
    8888
    8989        $contact = get_post_meta( $this->post_id, 'contact', TRUE );
  • wprequal/trunk/app/classes/class.RegisterForm.php

    r2315196 r2321931  
    162162
    163163    /**
    164      * Get the form details.
    165      *
    166      * @param $post_id
    167      *
    168      * @return array|mixed
    169      */
    170 
    171     public function get_details( $post_id ) {
    172 
    173         return apply_filters( 'wprequal_contact_get_details', (int) $post_id );
    174 
    175     }
    176 
    177     /**
    178164     * Get the contact form view.
    179165     *
     
    185171
    186172        $input   = $this->get_input( $contact_form_id );
    187         $details = $this->get_details( $contact_form_id );
     173        $details = ContactForm::get_details( $contact_form_id );
    188174
    189175        if ( $view = apply_filters( 'wprequal_view', 'contact/form/register-form' ) ) {
  • wprequal/trunk/app/classes/class.Settings.php

    r2315196 r2321931  
    152152        }
    153153
    154         return array();
     154        return [];
    155155    }
    156156
     
    389389
    390390            default:
    391                 return array();
     391                return [];
    392392        }
    393393
  • wprequal/trunk/app/classes/class.Update.php

    r2315196 r2321931  
    422422            update_post_meta( $contact_form_id, 'inputs', $inputs );
    423423
    424             $details = $fofm->get_details( 0 );
     424            $details = ContactForm::get_details( 0 );
    425425            update_post_meta( $contact_form_id, 'details', $details );
    426426
     
    483483            update_post_meta( $post_id, 'input', $input );
    484484
    485             $details = $fofm->get_details( 0 );
     485            $details = ContactForm::get_details( 0 );
    486486            update_post_meta( $post_id, 'details', $details );
    487487
  • wprequal/trunk/app/functions/deactivate.php

    r2219953 r2321931  
    2727function clear_options() {
    2828
    29     $options = array_merge( deactivate_options(), depricated_options() );
     29    $options = array_merge( deactivate_options(), deprecated_options() );
    3030
    3131    foreach ( $options as $option ) {
     
    4343function deactivate_options() {
    4444
    45     return array(
    46         WPREQUAL_OPTIONS
    47     );
     45    return [ WPREQUAL_OPTIONS ];
    4846
    4947}
     
    5553 */
    5654
    57 function depricated_options() {
     55function deprecated_options() {
    5856
    59     return array(
     57    return [
    6058        'wprequal_dark',
    6159        'wprequal_admin_settings',
     
    9290        // Deprecated v7.5
    9391        'wprequal_settings'
    94     );
     92    ];
    9593
    9694}
     
    102100function clear_transients() {
    103101
    104     $transients = array(
    105         WPREQUAL_OPTIONS
    106     );
     102    $transients = [ WPREQUAL_OPTIONS ];
    107103
    108104    foreach ( $transients as $transient ) {
  • wprequal/trunk/app/functions/refresh.php

    r2152886 r2321931  
    1616function refresh() {
    1717    if ( isset( $_GET['wprequal_refresh'] ) ) {
    18         deactivate();
     18        clear_transients();
    1919    }
    2020}
  • wprequal/trunk/assets/js/admin/80_survey-form.js

    r2286071 r2321931  
    243243    function populateEditor($this) {
    244244        if (typeof $this.editor !== 'undefined') {
    245             $('.editor-' + $this.key).val($this.editor);
     245            var value = (! $this.editor || '' === $this.editor) ? '' : $this.editor;
     246            $('.editor-' + $this.key).val(value);
    246247        }
    247248    }
  • wprequal/trunk/readme.txt

    r2321317 r2321931  
    159159== Change Log ==
    160160
     161= 7.7.2 =
     162* Improvement - Add from name to email options
     163* Improvement - Additional survey form builder notes
     164* Tweek - Require contact form selection on survey forms
     165* Tweek - Clear transients with refresh
     166
    161167= 7.7.1 =
    162168* Tweek - Add version to endpoints
  • wprequal/trunk/views/contact/admin/details.php

    r2315196 r2321931  
    1212namespace WPrequal\App;
    1313
    14 $details = $this->get_details( get_the_ID() );
     14$details = ContactForm::get_details( get_the_ID() );
    1515
    1616extract( $details ); ?>
     
    2626
    2727            <td><input type="text" id="button_text" name="details[button_text]" value="<?php esc_attr_e( $button_text ); ?>" class="regular-text"></td>
     28        </tr>
     29
     30        <tr>
     31            <th>
     32                <label for="from_name"><?php _e( 'From Name', 'wprequal' ); ?></label>
     33            </th>
     34
     35            <td><input type="text" id="from_name" name="details[from_name]" value="<?php esc_attr_e( $from_name ); ?>" class="regular-text"></td>
     36
     37            <td><?php _e( 'What name should your leads be sent from?', 'wprequal' ); ?></td>
    2838        </tr>
    2939
  • wprequal/trunk/views/survey/admin/confirmation.php

    r2315196 r2321931  
    1010 */
    1111
    12 namespace WPrequal\App;
    13 
    14 // FIXME: Fix wp editor or remove these settings
    15 $settings = array(
    16     'wpautop'       => FALSE,
    17     'textarea_name' => 'slide[{key}][editor]',
    18     'textarea_rows' => 5,
    19     'editor_class'  => 'editor-{key}'
    20 ); ?>
     12namespace WPrequal\App; ?>
    2113
    2214<?php $this->view( 'survey', 'admin/slide-start' ); ?>
     
    3224        <td colspan="3">
    3325            <textarea name="slide[{key}][editor]" class="editor-{key} large-text" rows="5"></textarea>
    34             <?php //wp_editor( '', 'confirmation-msg', $settings ); ?>
    3526        </td>
    3627
  • wprequal/trunk/views/survey/admin/contact.php

    r2315196 r2321931  
    1212namespace WPrequal\App;
    1313
    14 $args = array(
    15     'post_type' => 'wpq_contact_form',
    16     'name'      => 'slide[{key}][contact_form_id]',
    17     'class'     => 'contact_form_id regular-text',
    18     'id'        => 'contact_form_id'
    19 ); ?>
     14$args = [
     15    'post_type'        => 'wpq_contact_form',
     16    'name'             => 'slide[{key}][contact_form_id]',
     17    'class'            => 'contact_form_id regular-text wpq-required',
     18    'id'               => 'contact_form_id',
     19    'show_option_none' => __( 'Select One', 'wprequal' )
     20]; ?>
    2021
    2122<?php $this->view( 'survey', 'admin/slide-start' ); ?>
  • wprequal/trunk/views/survey/admin/slides.php

    r2315196 r2321931  
    2020<ul class="survey-slides"></ul>
    2121
    22 <div><?php _e( 'Note: All forms must end with a contact form, processing slide, and a confirmation message or redirect.', 'wprequal' ); ?></div>
     22<div><b><?php _e( 'Note:', 'wprequal' ); ?></b></div>
     23<div><?php _e( 'All survey forms must end with a contact form with Lead Fields, processing slide, and confirmation message or redirect.', 'wprequal' ); ?></div>
     24<div><?php _e( 'Only 1 contact form with contact fields can be submitted per request. Use contact forms with Text Input lead fields instead.', 'wprequal' ); ?></div>
    2325
    2426<div class="wpq-loading">
  • wprequal/trunk/wprequal.php

    r2321317 r2321931  
    44Plugin URI:  https://wprequal.com
    55Description: Mortgage and Real Estate Lead Capture System
    6 Version:     7.7.1
     6Version:     7.7.2
    77Author:      WPrequal
    88Author URI:  https://wprequal.com
     
    4040
    4141$constants = array(
    42     'WPREQUAL_VERSION'            => '7.7.1',
     42    'WPREQUAL_VERSION'            => '7.7.2',
    4343    'WPREQOAL_PLUGIN'             => plugin_basename( __FILE__ ),
    4444    'WPREQUAL_OPTIONS'            => 'wprequal_options',
Note: See TracChangeset for help on using the changeset viewer.