Changeset 1189088
- Timestamp:
- 06/28/2015 06:56:43 PM (11 years ago)
- Location:
- raidify-contact-form/trunk
- Files:
-
- 3 edited
-
admin/admin-page.php (modified) (1 diff)
-
raidify-contact-form-display.php (modified) (17 diffs)
-
raidify-contact-form.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
raidify-contact-form/trunk/admin/admin-page.php
r1187209 r1189088 21 21 * 22 22 */ 23 function __construct() { 24 $this->rcf_init_settings(); 23 function __construct() { 25 24 $this->rcf_get_options(); 26 25 $this->rcf_save_button_clicked(); 27 26 $this->rcf_display_settings(); 28 }29 30 /**31 * Initializes the admin page options and adds it to the32 * options table in wordpress database33 *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);73 27 } 74 28 -
raidify-contact-form/trunk/raidify-contact-form-display.php
r1187209 r1189088 14 14 var $error = ''; 15 15 var $default_input_type = 'text'; 16 var $rcf_input_elements = array();16 //var $rcf_input_elements = array(); 17 17 var $rcf_text_area_element = array(); 18 18 var $rcf_input_type = array( 19 'color', 19 'color', 20 20 'date', 21 21 'datetime', … … 27 27 'search', 28 28 'tel', 29 'time', 29 'time', 30 30 'url', 31 31 'week' 32 ); 33 32 ); 34 33 var $placeholder = array(); 35 34 36 35 /** 37 36 * Construct the contact form display object … … 39 38 * 40 39 * 41 */40 */ 42 41 function __construct() { 43 42 include 'raidify-contact-form-processmail.php'; 44 45 43 $options = get_option('rcf_admin_settings'); 46 44 $this->rcf_input_elements = $options['input-elements']; 47 45 $this->rcf_text_area_element = $options['text-area-elements']; 48 46 $this->placeholder = $options['placeholder']; 49 47 50 48 $smtp_option = $options['smtp-option']; 51 49 52 50 define('RCF_MAILER', $options['mailer']); 53 if (RCF_MAILER == 'smtp'){51 if (RCF_MAILER == 'smtp') { 54 52 define('RCF_SMTP_PORT_NUMBER', $smtp_option['port-number']); 55 53 define('RCF_SMTP_PASSWORD', $smtp_option['password']); … … 60 58 define('RCF_SMTP_AUTHENTICATION', $smtp_option['authentication']); 61 59 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')); 66 64 } 67 65 … … 73 71 $this->send = $send; 74 72 } 75 73 76 74 /** 77 75 * This function gets the placeholder and assigns it to … … 79 77 * 80 78 * @return String the placeholder 81 */82 private function rcf_get_placeholder($element) {79 */ 80 private function rcf_get_placeholder($element) { 83 81 $placeholders = $this->placeholder; 84 82 foreach ($placeholders as $key => $value) { 85 if ($key == $element){83 if ($key == $element) { 86 84 return $value; 87 85 } … … 95 93 * Name, Email, Subject, Message, and the Submit buttons 96 94 */ 97 public function rcf_display_form() { 95 96 public function rcf_display_form() { 98 97 echo '<div id="rcf-contact-form-display">'; 99 98 $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 105 102 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 111 108 $this->rcf_generate_form_input_elements(); 112 109 $this->rcf_generate_form_text_area_elements(60, 8); 113 110 $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 121 118 echo '</form>'; 122 119 echo '</div>'; … … 129 126 * Name, Email, Subject, Message, and the Submit buttons 130 127 */ 128 131 129 function rcf_encode_values($value) { 132 130 $encodedValue = filter_input(INPUT_POST, $value); … … 137 135 * Generates the input elements 138 136 * 139 */137 */ 140 138 private function rcf_generate_form_input_elements() { 141 139 $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 } 157 156 } 158 157 } … … 163 162 * @param int $col column size 164 163 * @param int $row row size 165 */164 */ 166 165 private function rcf_generate_form_text_area_elements($col, $row) { 167 166 $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-'. $item175 . '" class="rcf-form" col="' . $col . '" rows="' . $row176 . '" 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>' 179 178 ; 179 } 180 180 } 181 181 } … … 186 186 * 187 187 * @param string $value html input type attribute values 188 */188 */ 189 189 private function rcf_generate_element_type($value) { 190 190 $input_type = $this->rcf_input_type; 191 if(is_array($input_type)){ 191 192 foreach ($input_type as $type) { 192 193 if ($type == $value) { 193 194 $this->default_input_type = $type; 194 195 } 196 } 197 195 198 } 196 199 } … … 201 204 * validates the email 202 205 * and check if the mail has been sent 203 */206 */ 204 207 public function rcf_check_if_submitted() { 205 208 $submitted = filter_input(INPUT_POST, 'rcf_submit'); … … 210 213 ProcessMail::rcf_check_mail_sent(); 211 214 } 212 } 215 } 213 216 214 217 /** … … 216 219 * respective Wordpress SMTP options 217 220 * 218 */221 */ 219 222 function send_smtp_email($phpmailer) { 220 223 // Define that we are sending with SMTP … … 225 228 226 229 // Use SMTP authentication (true|false) 227 if (RCF_SMTP_AUTHENTICATION == 'on'){230 if (RCF_SMTP_AUTHENTICATION == 'on') { 228 231 $phpmailer->SMTPAuth = true; 229 } else{230 $phpmailer->SMTPAuth = false;231 } 232 } else { 233 $phpmailer->SMTPAuth = false; 234 } 232 235 233 236 // SMTP port number - likely to be 25, 465 or 587 … … 239 242 // Password to use for SMTP authentication 240 243 $phpmailer->Password = RCF_SMTP_PASSWORD; 241 244 242 245 // The encryption system to use - ssl (deprecated) or tls 243 if (RCF_SMTP_ENCRYPTION == 'noencryption'){246 if (RCF_SMTP_ENCRYPTION == 'noencryption') { 244 247 $phpmailer->SMTPSecure = ''; 245 } else{248 } else { 246 249 $phpmailer->SMTPSecure = RCF_SMTP_ENCRYPTION; 247 } 250 } 248 251 249 252 $phpmailer->From = RCF_SMTP_FROM; 250 if (RCF_SMTP_FROMNAME == ''){253 if (RCF_SMTP_FROMNAME == '') { 251 254 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 { 257 258 $phpmailer->FromName = RCF_SMTP_FROMNAME; 258 } 259 259 } 260 260 } elseif (RCF_MAILER == 'phpmail') { 261 261 //sets the phpmailer to phpmail if SMTP is not selected … … 267 267 * Sets the name of the sender of the mail 268 268 * 269 */269 */ 270 270 function rcf_my_mail_from_name($name) { 271 271 $from_name = filter_input(INPUT_POST, 'rcf-name'); -
raidify-contact-form/trunk/raidify-contact-form.php
r1187209 r1189088 6 6 * Description: Raidify contact form is a free customizable contact form with SMTP (Simple Mail Transfer Protocol) support. 7 7 * Author: Olaleye Osunsanya 8 * Version: 1.0. 18 * Version: 1.0.2 9 9 * Author URI: http://raidify.com/ 10 10 * Text Domain: raidify-contact-form … … 58 58 //load the text domain for internationalization 59 59 add_action('plugins_loaded', array($this, 'rcf_load_textdomain')); 60 61 $this->rcf_init_settings(); 60 62 61 63 } … … 121 123 ); 122 124 } 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 } 123 170 124 171 }
Note: See TracChangeset
for help on using the changeset viewer.