email-from.php
7 years ago
email-to.php
7 years ago
email.php
7 years ago
form.php
7 years ago
general.php
7 years ago
recipient.php
7 years ago
form.php
377 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Form Settings |
| 4 | * |
| 5 | * @since 1.13 |
| 6 | */ |
| 7 | $pages_list = wpmtst_get_pages(); |
| 8 | $form_options = get_option( 'wpmtst_form_options' ); |
| 9 | $plugins = apply_filters( 'wpmtst_captcha_plugins', get_option( 'wpmtst_captcha_plugins', array() ) ); |
| 10 | |
| 11 | /** |
| 12 | * If integration with selected Captcha plugin has been removed, disable Captcha. |
| 13 | */ |
| 14 | if ( ! is_array( $plugins ) || ! in_array( $form_options['captcha'], array_keys( $plugins ) ) ) { |
| 15 | $form_options['captcha'] = ''; |
| 16 | update_option( 'wpmtst_form_options', $form_options ); |
| 17 | } |
| 18 | |
| 19 | foreach ( $plugins as $key => $plugin ) { |
| 20 | |
| 21 | if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin['file'] ) ) { |
| 22 | $plugins[ $key ]['installed'] = true; |
| 23 | } |
| 24 | |
| 25 | $plugins[ $key ]['active'] = is_plugin_active( $plugin['file'] ); |
| 26 | |
| 27 | /** |
| 28 | * If current Captcha plugin has been deactivated, disable Captcha |
| 29 | * so corresponding div does not appear on front-end form. |
| 30 | */ |
| 31 | if ( $key == $form_options['captcha'] && ! $plugins[ $key ]['active'] ) { |
| 32 | $form_options['captcha'] = ''; |
| 33 | update_option( 'wpmtst_form_options', $form_options ); |
| 34 | } |
| 35 | |
| 36 | } |
| 37 | ?> |
| 38 | <input type="hidden" |
| 39 | name="wpmtst_form_options[default_recipient]" |
| 40 | value="<?php echo htmlentities( serialize( $form_options['default_recipient'] ) ); ?>"> |
| 41 | |
| 42 | <?php |
| 43 | /** |
| 44 | * ======================================== |
| 45 | * Labels & Messages |
| 46 | * ======================================== |
| 47 | */ |
| 48 | ?> |
| 49 | <h2><?php _e( 'Form Labels & Messages', 'strong-testimonials' ); ?></h2> |
| 50 | |
| 51 | <?php do_action( 'wpmtst_before_form_settings', 'form-messages' ); ?> |
| 52 | |
| 53 | <table class="form-table compact" cellpadding="0" cellspacing="0"> |
| 54 | <?php |
| 55 | $messages = $form_options['messages']; |
| 56 | foreach ( $messages as $key => $message ): |
| 57 | $required = isset( $message['required'] ) ? $message['required'] : true; |
| 58 | |
| 59 | $elid = str_replace( '-', '_', $key ); |
| 60 | // $string, $context, $name |
| 61 | $content = apply_filters( 'wpmtst_l10n', $message['text'], 'strong-testimonials-form-messages', $message['description'] ); |
| 62 | ?> |
| 63 | |
| 64 | <tr> |
| 65 | <th scope="row"> |
| 66 | <label for="<?php echo $elid; ?>"> |
| 67 | <?php _ex( $message['description'], 'description', 'strong-testimonials' ); ?> |
| 68 | </label> |
| 69 | <input type="hidden" name="wpmtst_form_options[messages][<?php echo esc_attr( $key ); ?>][description]" |
| 70 | value="<?php echo esc_attr( $message['description'] ); ?>"/> |
| 71 | </th> |
| 72 | <td> |
| 73 | <?php if ( 'submission_success' == $elid ): ?> |
| 74 | <?php |
| 75 | $settings = array( |
| 76 | 'textarea_name' => "wpmtst_form_options[messages][$key][text]", |
| 77 | 'textarea_rows' => 10, |
| 78 | ); |
| 79 | wp_editor( $content, $elid, $settings ); |
| 80 | ?> |
| 81 | <?php else: ?> |
| 82 | <?php if ( 'required_field' == $elid ): ?> |
| 83 | <fieldset> |
| 84 | <label> |
| 85 | <input type="checkbox" |
| 86 | name="wpmtst_form_options[messages][<?php echo esc_attr( $key ); ?>][enabled]" |
| 87 | <?php checked( $message['enabled'] ); ?>> |
| 88 | <?php esc_html_e( 'Display required notice at top of form', 'strong-testimonials' ); ?> |
| 89 | </label |
| 90 | </fieldset> |
| 91 | <?php endif; ?> |
| 92 | <input type="text" id="<?php echo esc_attr( $elid ); ?>" |
| 93 | name="wpmtst_form_options[messages][<?php echo esc_attr( $key ); ?>][text]" |
| 94 | value="<?php echo esc_attr( $content ); ?>" |
| 95 | <?php echo $required ? 'required' : '' ?>/> |
| 96 | <?php endif; ?> |
| 97 | </td> |
| 98 | <td class="actions"> |
| 99 | <input type="button" class="button secondary restore-default-message" |
| 100 | value="<?php _ex( 'restore default', 'singular', 'strong-testimonials' ); ?>" |
| 101 | data-target-id="<?php echo esc_attr( $elid ); ?>"/> |
| 102 | </td> |
| 103 | </tr> |
| 104 | |
| 105 | <?php endforeach; ?> |
| 106 | |
| 107 | <tr> |
| 108 | <td colspan="3"> |
| 109 | <input type="button" id="restore-default-messages" class="button" |
| 110 | name="restore-default-messages" |
| 111 | value="<?php esc_html_e( 'Restore Default Messages', 'strong-testimonials' ); ?>"/> |
| 112 | </td> |
| 113 | </tr> |
| 114 | </table> |
| 115 | |
| 116 | <table class="form-table" cellpadding="0" cellspacing="0"> |
| 117 | <tr> |
| 118 | <th scope="row" class="tall"> |
| 119 | <?php esc_html_e( 'Scroll', 'strong-testimonials' ); ?> |
| 120 | </th> |
| 121 | <td> |
| 122 | <fieldset> |
| 123 | <div> |
| 124 | <label> |
| 125 | <input type="checkbox" |
| 126 | name="wpmtst_form_options[scrolltop_error]" <?php checked( $form_options['scrolltop_error'] ); ?>/> |
| 127 | <?php printf( __( 'If errors, scroll to the first error minus %s pixels. On by default.', 'strong-testimonials' ), '<input type="text" name="wpmtst_form_options[scrolltop_error_offset]" value="' . $form_options['scrolltop_error_offset'] . '" size="3">' ); ?> |
| 128 | </label> |
| 129 | </div> |
| 130 | <div> |
| 131 | <label class="block"> |
| 132 | <input type="checkbox" |
| 133 | name="wpmtst_form_options[scrolltop_success]" <?php checked( $form_options['scrolltop_success'] ); ?>/> |
| 134 | <?php printf( __( 'If success, scroll to the success message minus %s pixels. On by default.', 'strong-testimonials' ), '<input type="text" name="wpmtst_form_options[scrolltop_success_offset]" value="' . $form_options['scrolltop_success_offset'] . '" size="3">' ); ?> |
| 135 | </label> |
| 136 | </div> |
| 137 | </fieldset> |
| 138 | </td> |
| 139 | </tr> |
| 140 | </table> |
| 141 | |
| 142 | <?php |
| 143 | /** |
| 144 | * ======================================== |
| 145 | * Actions |
| 146 | * ======================================== |
| 147 | */ |
| 148 | ?> |
| 149 | <hr> |
| 150 | <h3><?php _e( 'Form Actions', 'strong-testimonials' ); ?></h3> |
| 151 | |
| 152 | <table class="form-table" cellpadding="0" cellspacing="0"> |
| 153 | <tr> |
| 154 | <th scope="row"> |
| 155 | <label for="redirect-page"> |
| 156 | <?php esc_html_e( 'Upon Successful Submission', 'strong-testimonials' ); ?> |
| 157 | </label> |
| 158 | </th> |
| 159 | <td> |
| 160 | <div> |
| 161 | <label class="success-action"> |
| 162 | <input type="radio" name="wpmtst_form_options[success_action]" value="message" <?php checked( 'message', $form_options['success_action'] ); ?>/> <?php esc_html_e( 'display message', 'strong-testimonials' ); ?> |
| 163 | </label> |
| 164 | </div> |
| 165 | |
| 166 | <div> |
| 167 | <label class="success-action"> |
| 168 | <input type="radio" name="wpmtst_form_options[success_action]" value="id" <?php checked( 'id', $form_options['success_action'] ); ?>/> <?php esc_html_e( 'redirect to a page', 'strong-testimonials' ); ?> |
| 169 | </label> |
| 170 | |
| 171 | <select id="redirect-page" name="wpmtst_form_options[success_redirect_id]"> |
| 172 | |
| 173 | <option value=""><?php esc_html_e( '— select a page —', 'strong-testimonials' ); ?></option> |
| 174 | <?php foreach ( $pages_list as $pages ) : ?> |
| 175 | |
| 176 | <option value="<?php echo $pages->ID; ?>" <?php selected( isset( $form_options['success_redirect_id'] ) ? $form_options['success_redirect_id'] : 0, $pages->ID ); ?>> |
| 177 | <?php echo $pages->post_title; ?> |
| 178 | </option> |
| 179 | |
| 180 | <?php endforeach; ?> |
| 181 | |
| 182 | </select> |
| 183 | |
| 184 | <div style="display: inline-block; text-indent: 20px;"> |
| 185 | <label> |
| 186 | <?php echo esc_html_x( 'or enter its ID or slug', 'to select a redirect page', 'strong-testimonials' ); ?> |
| 187 | |
| 188 | <input type="text" id="redirect-page-2" name="wpmtst_form_options[success_redirect_2]" size="30"> |
| 189 | </label> |
| 190 | </div> |
| 191 | </div> |
| 192 | |
| 193 | <div> |
| 194 | <label class="success-action"> |
| 195 | <input type="radio" name="wpmtst_form_options[success_action]" value="url" <?php checked( 'url', $form_options['success_action'] ); ?>/> |
| 196 | <?php esc_html_e( 'redirect to a URL', 'strong-testimonials' ); ?> |
| 197 | </label> |
| 198 | <label> |
| 199 | <input type="text" id="redirect-page-3" name="wpmtst_form_options[success_redirect_url]" value="<?php echo esc_attr( $form_options['success_redirect_url'] ); ?>" size="75"/> |
| 200 | </label> |
| 201 | </div> |
| 202 | |
| 203 | </td> |
| 204 | </tr> |
| 205 | |
| 206 | <tr> |
| 207 | <th scope="row"> |
| 208 | <label> |
| 209 | <?php esc_html_e( 'Post Status', 'strong-testimonials' ); ?> |
| 210 | </label> |
| 211 | </th> |
| 212 | <td> |
| 213 | <ul class="compact"> |
| 214 | <li> |
| 215 | <label> |
| 216 | <input type="radio" name="wpmtst_form_options[post_status]" value="pending" <?php checked( 'pending', $form_options['post_status'] ); ?>/> |
| 217 | <?php esc_html_e( 'Pending', 'strong-testimonials' ); ?> |
| 218 | </label> |
| 219 | </li> |
| 220 | <li> |
| 221 | <label> |
| 222 | <input type="radio" name="wpmtst_form_options[post_status]" value="publish" <?php checked( 'publish', $form_options['post_status'] ); ?>/> |
| 223 | <?php esc_html_e( 'Published', 'strong-testimonials' ); ?> |
| 224 | </label> |
| 225 | </li> |
| 226 | </ul> |
| 227 | </td> |
| 228 | </tr> |
| 229 | |
| 230 | <tr> |
| 231 | <th scope="row"> |
| 232 | <label for="wpmtst-options-admin-notify"> |
| 233 | <?php esc_html_e( 'Notification Email', 'strong-testimonials' ); ?> |
| 234 | </label> |
| 235 | </th> |
| 236 | |
| 237 | <td> |
| 238 | <div class="match-height"> |
| 239 | <fieldset> |
| 240 | <label for="wpmtst-options-admin-notify"> |
| 241 | <input id="wpmtst-options-admin-notify" type="checkbox" name="wpmtst_form_options[admin_notify]" <?php checked( $form_options['admin_notify'] ); ?>/> |
| 242 | <?php esc_html_e( 'Send an email upon new testimonial submission.', 'strong-testimonials' ); ?> |
| 243 | </label> |
| 244 | </fieldset> |
| 245 | </div> |
| 246 | <div class="email-container" id="admin-notify-fields" <?php echo ( $form_options['admin_notify'] ) ? '' : 'style="display: none;"'; ?>> |
| 247 | <?php |
| 248 | include 'email-from.php'; |
| 249 | include 'email-to.php'; |
| 250 | include 'email.php'; |
| 251 | do_action( 'wpmtst_after_notification_fields', 'notification' ); |
| 252 | ?> |
| 253 | </div> |
| 254 | </td> |
| 255 | </tr> |
| 256 | </table> |
| 257 | |
| 258 | <?php |
| 259 | /** |
| 260 | * ======================================== |
| 261 | * Spam Control |
| 262 | * ======================================== |
| 263 | */ |
| 264 | ?> |
| 265 | <hr> |
| 266 | <h3><?php _e( 'Form Spam Control', 'strong-testimonials' ); ?></h3> |
| 267 | |
| 268 | <table class="form-table" cellpadding="0" cellspacing="0"> |
| 269 | <tr> |
| 270 | <th scope="row"> |
| 271 | <label> |
| 272 | <?php _ex( 'Honeypot', 'spam control techniques', 'strong-testimonials' ); ?> |
| 273 | </label> |
| 274 | </th> |
| 275 | <td> |
| 276 | <p> |
| 277 | <?php _e( 'These methods for trapping spambots are both time-tested and widely used. May be used simultaneously for more protection.', 'strong-testimonials' ); ?> |
| 278 | </p> |
| 279 | <p> |
| 280 | <?php _e( 'However, honeypots may not be compatible with WP-SpamShield, Ajax page loading, caching or minification.', 'strong-testimonials' ); ?> |
| 281 | </p> |
| 282 | <p> |
| 283 | <?php _e( 'If your form is not working properly, try disabling these.', 'strong-testimonials' ); ?> |
| 284 | </p> |
| 285 | <?php // TODO Add link to article that explains Ajax page loading. ?> |
| 286 | <ul> |
| 287 | <li class="checkbox"> |
| 288 | <label> |
| 289 | <input type="checkbox" |
| 290 | name="wpmtst_form_options[honeypot_before]" <?php checked( $form_options['honeypot_before'] ); ?>/> |
| 291 | <?php _e( 'Before', 'strong-testimonials' ); ?> |
| 292 | </label> |
| 293 | <p class="description"><?php _e( 'Adds a new empty field that is invisible to humans. Spambots tend to fill in every field they find in the form. Empty field = human. Not empty = spambot.', 'strong-testimonials' ); ?></p> |
| 294 | </li> |
| 295 | <li class="checkbox"> |
| 296 | <label> |
| 297 | <input type="checkbox" |
| 298 | name="wpmtst_form_options[honeypot_after]" <?php checked( $form_options['honeypot_after'] ); ?>/> |
| 299 | <?php _e( 'After', 'strong-testimonials' ); ?> |
| 300 | </label> |
| 301 | <p class="description"><?php _e( 'Adds a new field as soon as the form is submitted. Spambots cannot run JavaScript so the new field never gets added. New field = human. Missing = spambot.', 'strong-testimonials' ); ?></p> |
| 302 | </li> |
| 303 | </ul> |
| 304 | </td> |
| 305 | </tr> |
| 306 | <tr valign="top"> |
| 307 | <th scope="row"> |
| 308 | <label> |
| 309 | <a name="captcha-section"></a><?php _e( 'Captcha', 'strong-testimonials' ); ?> |
| 310 | </label> |
| 311 | </th> |
| 312 | <td class="stackem"> |
| 313 | <p> |
| 314 | <?php _e( 'Enable Captcha using one of these plugins. Be sure to configure any plugins first, if necessary.', 'strong-testimonials' ); ?> |
| 315 | <?php _e( 'May be used alongside honeypot methods.', 'strong-testimonials' ); ?> |
| 316 | </p> |
| 317 | <p> |
| 318 | <?php _e( 'May not be compatible with Ajax page loading.', 'strong-testimonials' ); ?> |
| 319 | </p> |
| 320 | <ul> |
| 321 | <li> |
| 322 | <label> |
| 323 | <input type="radio" |
| 324 | name="wpmtst_form_options[captcha]" <?php checked( '', $form_options['captcha'] ); ?> |
| 325 | value=""/> none |
| 326 | </label> |
| 327 | </li> |
| 328 | |
| 329 | <?php foreach ( $plugins as $key => $plugin ) : ?> |
| 330 | <li> |
| 331 | <label class="inline <?php if ( ! $plugin['active'] ) echo 'disabled'; ?>"> |
| 332 | <input type="radio" |
| 333 | name="wpmtst_form_options[captcha]" <?php disabled( ! $plugin['active'] ); ?><?php checked( $key, $form_options['captcha'] ); ?> |
| 334 | value="<?php echo $key; ?>"/> |
| 335 | <?php echo $plugin['name']; ?> |
| 336 | </label> |
| 337 | |
| 338 | <?php if ( isset( $plugin['installed'] ) && $plugin['installed'] ) : // installed ?> |
| 339 | |
| 340 | <?php if ( $plugin['active'] ) : // active ?> |
| 341 | |
| 342 | <?php if ( isset( $plugin['settings'] ) && $plugin['settings'] ) : ?> |
| 343 | <span class="link"><a href="<?php echo $plugin['settings']; ?>"><?php _ex( 'settings', 'link', 'strong-testimonials' ); ?></a></span> |
| 344 | <?php else : ?> |
| 345 | <span class="notice"><?php _e( 'no settings', 'strong-testimonials' ); ?></span> |
| 346 | <?php endif; ?> |
| 347 | |
| 348 | <?php else : // inactive ?> |
| 349 | |
| 350 | <span class="notice disabled"><?php _ex( 'inactive', 'adjective', 'strong-testimonials' ); ?></span> |
| 351 | |
| 352 | <?php endif; ?> |
| 353 | | |
| 354 | |
| 355 | <?php else : // not installed ?> |
| 356 | |
| 357 | <span class="notice disabled">(<?php _e( 'not installed', 'strong-testimonials' ); ?>)</span> |
| 358 | |
| 359 | <?php if ( isset( $plugin['search'] ) && $plugin['search'] ) : ?> |
| 360 | <span class="link"><a href="<?php echo $plugin['search']; ?>"><?php _ex( 'install plugin', 'link', 'strong-testimonials' ); ?></a></span> |
| 361 | | |
| 362 | <?php endif; ?> |
| 363 | |
| 364 | <?php endif; // whether installed ?> |
| 365 | |
| 366 | <span class="link"><a href="<?php echo $plugin['url']; ?>" target="_blank"><?php _ex( 'plugin page', 'link', 'strong-testimonials' ); ?></a></span> |
| 367 | |
| 368 | <?php if ( isset( $plugin['desc'] ) && $plugin['desc'] ) : ?> |
| 369 | <p class="description <?php if ( isset( $plugin['style'] ) ) echo $plugin['style']; ?>"><?php echo $plugin['desc']; ?></p> |
| 370 | <?php endif; ?> |
| 371 | </li> |
| 372 | <?php endforeach; ?> |
| 373 | </ul> |
| 374 | </td> |
| 375 | </tr> |
| 376 | </table> |
| 377 |