Plugin Directory

Changeset 1189088


Ignore:
Timestamp:
06/28/2015 06:56:43 PM (11 years ago)
Author:
olaleye
Message:

Modification to array returning null values

Location:
raidify-contact-form/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • raidify-contact-form/trunk/admin/admin-page.php

    r1187209 r1189088  
    2121     *
    2222    */   
    23     function __construct() {
    24         $this->rcf_init_settings();       
     23    function __construct() {       
    2524        $this->rcf_get_options();
    2625        $this->rcf_save_button_clicked();
    2726        $this->rcf_display_settings();
    28     }
    29 
    30     /**
    31      * Initializes the admin page options and adds it to the
    32      * options table in wordpress database
    33      *
    34     */
    35     function rcf_init_settings() {
    36         $rcf_options = array(
    37             'input-elements' => array(
    38                 __('name', 'raidify-contact-form'),
    39                 __('subject', 'raidify-contact-form'),
    40                 __('email', 'raidify-contact-form')),
    41             'text-area-elements' => array(
    42                 __('message', 'raidify-contact-form')),
    43             'required' => array(
    44                 __('name', 'raidify-contact-form'),
    45                 __('subject', 'raidify-contact-form'),
    46                 __('email', 'raidify-contact-form'),
    47                 __('message', 'raidify-contact-form')),
    48             'required-label' => '(required)',
    49             'placeholder' => array(
    50                 __('name', 'raidify-contact-form') => '',
    51                 __('subject', 'raidify-contact-form') => '',
    52                 __('email', 'raidify-contact-form') => '',
    53                 __('message', 'raidify-contact-form') => ''
    54             ),
    55             'sendto' => array(
    56                 'user' => 'rcf-wpuser',
    57                 'user-email' => ''
    58             ),
    59             'mailer' => 'phpmail',
    60             'smtp-option' => array(
    61                 'authentication' => '',
    62                 'host-server' => '',
    63                 'port-number' => '',
    64                 'encryption' => 'noencryption',
    65                 'from' => '',
    66                 'from-name' => '',
    67                 'username' => '',
    68                 'password' => ''
    69             )
    70         );
    71 
    72         add_option('rcf_admin_settings', $rcf_options);
    7327    }
    7428
  • raidify-contact-form/trunk/raidify-contact-form-display.php

    r1187209 r1189088  
    1414        var $error = '';
    1515        var $default_input_type = 'text';
    16         var $rcf_input_elements = array();
     16        //var $rcf_input_elements = array();
    1717        var $rcf_text_area_element = array();
    1818        var $rcf_input_type = array(
    19             'color', 
     19            'color',
    2020            'date',
    2121            'datetime',
     
    2727            'search',
    2828            'tel',
    29             'time', 
     29            'time',
    3030            'url',
    3131            'week'
    32             );
    33        
     32        );
    3433        var $placeholder = array();
    35        
     34
    3635        /**
    3736         * Construct the contact form display object
     
    3938         *
    4039         *
    41         */
     40         */
    4241        function __construct() {
    4342            include 'raidify-contact-form-processmail.php';
    44 
    4543            $options = get_option('rcf_admin_settings');
    4644            $this->rcf_input_elements = $options['input-elements'];
    4745            $this->rcf_text_area_element = $options['text-area-elements'];
    4846            $this->placeholder = $options['placeholder'];
    49            
     47
    5048            $smtp_option = $options['smtp-option'];
    5149
    5250            define('RCF_MAILER', $options['mailer']);
    53             if(RCF_MAILER == 'smtp'){
     51            if (RCF_MAILER == 'smtp') {
    5452                define('RCF_SMTP_PORT_NUMBER', $smtp_option['port-number']);
    5553                define('RCF_SMTP_PASSWORD', $smtp_option['password']);
     
    6058                define('RCF_SMTP_AUTHENTICATION', $smtp_option['authentication']);
    6159                define('RCF_SMTP_USERNAME', $smtp_option['username']);
    62             }           
    63 
    64             add_action('phpmailer_init', array($this,'send_smtp_email'));
    65             add_filter( 'wp_mail_from_name', array($this,'rcf_my_mail_from_name'));
     60            }
     61
     62            add_action('phpmailer_init', array($this, 'send_smtp_email'));
     63            add_filter('wp_mail_from_name', array($this, 'rcf_my_mail_from_name'));
    6664        }
    6765
     
    7371            $this->send = $send;
    7472        }
    75        
     73
    7674        /**
    7775         * This function gets the placeholder and assigns it to
     
    7977         *
    8078         * @return String the placeholder
    81         */       
    82         private function rcf_get_placeholder($element){
     79         */
     80        private function rcf_get_placeholder($element) {
    8381            $placeholders = $this->placeholder;
    8482            foreach ($placeholders as $key => $value) {
    85                 if($key == $element){
     83                if ($key == $element) {
    8684                    return $value;
    8785                }
     
    9593         * Name, Email, Subject, Message, and the Submit buttons
    9694         */
    97         public function rcf_display_form() {
     95
     96        public function rcf_display_form() {
    9897            echo '<div id="rcf-contact-form-display">';
    9998            $request_uri = filter_input(
    100                     INPUT_SERVER,
    101                     'REQUEST_URI',
    102                     FILTER_SANITIZE_STRING
    103                     );
    104            
     99                    INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING
     100            );
     101
    105102            echo '<form id="feedback" method="post" action="'
    106                     . esc_url($request_uri)
    107                     .'#rcf-contact-form-display'
    108                     .'">'
    109                     ;
    110            
     103            . esc_url($request_uri)
     104            . '#rcf-contact-form-display'
     105            . '">'
     106            ;
     107
    111108            $this->rcf_generate_form_input_elements();
    112109            $this->rcf_generate_form_text_area_elements(60, 8);
    113110            $this->set_send("rcf_submit");
    114             echo '<p><input type="submit" id="rcf-submit" name="' 
    115                     . $this->get_send()
    116                     . '" class="rcf-form" value='
    117                     .__('send', 'raidify-contact-form')
    118                     . '></p>'
    119                     ;
    120            
     111            echo '<p><input type="submit" id="rcf-submit" name="'
     112            . $this->get_send()
     113            . '" class="rcf-form" value='
     114            . __('send', 'raidify-contact-form')
     115            . '></p>'
     116            ;
     117
    121118            echo '</form>';
    122119            echo '</div>';
     
    129126         * Name, Email, Subject, Message, and the Submit buttons
    130127         */
     128
    131129        function rcf_encode_values($value) {
    132130            $encodedValue = filter_input(INPUT_POST, $value);
     
    137135         * Generates the input elements
    138136         *
    139         */
     137         */
    140138        private function rcf_generate_form_input_elements() {
    141139            $input_elements = $this->rcf_input_elements;
    142             foreach ($input_elements as $item) {
    143                 $this->rcf_generate_element_type($item);
    144                 echo '<p><label for="' . $item . '">'
    145                         . ucfirst(__($item, 'raidify-contact-form'))
    146                         .ProcessMail::rcf_set_required_label($item)
    147                         . ' : '
    148                         . ProcessMail::rcf_set_form_element_error($item)
    149                         . '</label><br>'
    150                        
    151                 . '<input type="' . $this->default_input_type . '" id="' .'rcf-'
    152                         . $item . '" name="'
    153                         .'rcf-'.$item . '" class="rcf-form" placeholder="'
    154                         .$this->rcf_get_placeholder($item)
    155                         .'" value="' . ProcessMail::rcf_preserve_input_value('rcf-'.$item)
    156                         . '"></p>';
     140            if (is_array($input_elements)) {
     141                foreach ($input_elements as $item) {
     142                    $this->rcf_generate_element_type($item);
     143                    echo '<p><label for="' . $item . '">'
     144                    . ucfirst(__($item, 'raidify-contact-form'))
     145                    . ProcessMail::rcf_set_required_label($item)
     146                    . ' : '
     147                    . ProcessMail::rcf_set_form_element_error($item)
     148                    . '</label><br>'
     149                    . '<input type="' . $this->default_input_type . '" id="' . 'rcf-'
     150                    . $item . '" name="'
     151                    . 'rcf-' . $item . '" class="rcf-form" placeholder="'
     152                    . $this->rcf_get_placeholder($item)
     153                    . '" value="' . ProcessMail::rcf_preserve_input_value('rcf-' . $item)
     154                    . '"></p>';
     155                }
    157156            }
    158157        }
     
    163162         * @param int $col column size
    164163         * @param int $row row size
    165         */
     164         */
    166165        private function rcf_generate_form_text_area_elements($col, $row) {
    167166            $text_area_element = $this->rcf_text_area_element;
    168             foreach ($text_area_element as $item) {
    169                 echo '<p><label for="' . $item . '">' . ucfirst($item)
    170                         .ProcessMail::rcf_set_required_label($item)
    171                         . ' : ' . ProcessMail::rcf_set_form_element_error($item)
    172                         . '</label><br>'
    173                        
    174                 . '<textarea id="' .'rcf-'. $item . '" name="' .'rcf-'. $item
    175                         . '" class="rcf-form" col="' . $col . '" rows="' . $row
    176                         . '" placeholder="'.$this->rcf_get_placeholder($item)
    177                         .'">' . ProcessMail::rcf_preserve_input_value('rcf-'.$item)
    178                         . '</textarea></p>'
     167            if (is_array($text_area_element)) {
     168                foreach ($text_area_element as $item) {
     169                    echo '<p><label for="' . $item . '">' . ucfirst($item)
     170                    . ProcessMail::rcf_set_required_label($item)
     171                    . ' : ' . ProcessMail::rcf_set_form_element_error($item)
     172                    . '</label><br>'
     173                    . '<textarea id="' . 'rcf-' . $item . '" name="' . 'rcf-' . $item
     174                    . '" class="rcf-form" col="' . $col . '" rows="' . $row
     175                    . '" placeholder="' . $this->rcf_get_placeholder($item)
     176                    . '">' . ProcessMail::rcf_preserve_input_value('rcf-' . $item)
     177                    . '</textarea></p>'
    179178                    ;
     179                }
    180180            }
    181181        }
     
    186186         *
    187187         * @param string $value html input type attribute values
    188         */
     188         */
    189189        private function rcf_generate_element_type($value) {
    190190            $input_type = $this->rcf_input_type;
     191            if(is_array($input_type)){               
    191192            foreach ($input_type as $type) {
    192193                if ($type == $value) {
    193194                    $this->default_input_type = $type;
    194195                }
     196            }
     197           
    195198            }
    196199        }
     
    201204         * validates the email
    202205         * and check if the mail has been sent
    203         */
     206         */
    204207        public function rcf_check_if_submitted() {
    205208            $submitted = filter_input(INPUT_POST, 'rcf_submit');
     
    210213                ProcessMail::rcf_check_mail_sent();
    211214            }
    212         }     
     215        }
    213216
    214217        /**
     
    216219         * respective Wordpress SMTP options
    217220         *
    218         */
     221         */
    219222        function send_smtp_email($phpmailer) {
    220223            // Define that we are sending with SMTP
     
    225228
    226229                // Use SMTP authentication (true|false)
    227                 if(RCF_SMTP_AUTHENTICATION == 'on'){
     230                if (RCF_SMTP_AUTHENTICATION == 'on') {
    228231                    $phpmailer->SMTPAuth = true;
    229                 }else{
    230                    $phpmailer->SMTPAuth = false;
    231                 }               
     232                } else {
     233                    $phpmailer->SMTPAuth = false;
     234                }
    232235
    233236                // SMTP port number - likely to be 25, 465 or 587
     
    239242                // Password to use for SMTP authentication
    240243                $phpmailer->Password = RCF_SMTP_PASSWORD;
    241                
     244
    242245                // The encryption system to use - ssl (deprecated) or tls
    243                 if(RCF_SMTP_ENCRYPTION == 'noencryption'){
     246                if (RCF_SMTP_ENCRYPTION == 'noencryption') {
    244247                    $phpmailer->SMTPSecure = '';
    245                 }else{
     248                } else {
    246249                    $phpmailer->SMTPSecure = RCF_SMTP_ENCRYPTION;
    247                 }                               
     250                }
    248251
    249252                $phpmailer->From = RCF_SMTP_FROM;
    250                 if(RCF_SMTP_FROMNAME == ''){
     253                if (RCF_SMTP_FROMNAME == '') {
    251254                    add_filter(
    252                             'wp_mail_from_name',
    253                             array($this,'rcf_my_mail_from_name')
    254                             );
    255                    
    256                 }else{
     255                            'wp_mail_from_name', array($this, 'rcf_my_mail_from_name')
     256                    );
     257                } else {
    257258                    $phpmailer->FromName = RCF_SMTP_FROMNAME;
    258                 }             
    259 
     259                }
    260260            } elseif (RCF_MAILER == 'phpmail') {
    261261                //sets the phpmailer to phpmail if SMTP is not selected
     
    267267         * Sets the name of the sender of the mail
    268268         *
    269         */
     269         */
    270270        function rcf_my_mail_from_name($name) {
    271271            $from_name = filter_input(INPUT_POST, 'rcf-name');
  • raidify-contact-form/trunk/raidify-contact-form.php

    r1187209 r1189088  
    66 * Description: Raidify contact form is a free customizable contact form with SMTP (Simple Mail Transfer Protocol) support.
    77 * Author: Olaleye Osunsanya
    8  * Version: 1.0.1
     8 * Version: 1.0.2
    99 * Author URI: http://raidify.com/
    1010 * Text Domain: raidify-contact-form
     
    5858            //load the text domain for internationalization
    5959            add_action('plugins_loaded', array($this, 'rcf_load_textdomain'));
     60           
     61            $this->rcf_init_settings();
    6062           
    6163        }
     
    121123                );       
    122124    }
     125   
     126    /**
     127     * Initializes the admin page options and adds it to the
     128     * options table in wordpress database
     129     *
     130    */     
     131    function rcf_init_settings() {
     132        $rcf_options = array(
     133            'input-elements' => array(
     134                __('name', 'raidify-contact-form'),
     135                __('subject', 'raidify-contact-form'),
     136                __('email', 'raidify-contact-form')),
     137            'text-area-elements' => array(
     138                __('message', 'raidify-contact-form')),
     139            'required' => array(
     140                __('name', 'raidify-contact-form'),
     141                __('subject', 'raidify-contact-form'),
     142                __('email', 'raidify-contact-form'),
     143                __('message', 'raidify-contact-form')),
     144            'required-label' => '(required)',
     145            'placeholder' => array(
     146                __('name', 'raidify-contact-form') => '',
     147                __('subject', 'raidify-contact-form') => '',
     148                __('email', 'raidify-contact-form') => '',
     149                __('message', 'raidify-contact-form') => ''
     150            ),
     151            'sendto' => array(
     152                'user' => 'rcf-wpuser',
     153                'user-email' => ''
     154            ),
     155            'mailer' => 'phpmail',
     156            'smtp-option' => array(
     157                'authentication' => '',
     158                'host-server' => '',
     159                'port-number' => '',
     160                'encryption' => 'noencryption',
     161                'from' => '',
     162                'from-name' => '',
     163                'username' => '',
     164                'password' => ''
     165            )
     166        );
     167
     168        add_option('rcf_admin_settings', $rcf_options);
     169    }
    123170   
    124171    }   
Note: See TracChangeset for help on using the changeset viewer.