PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.4.8
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.4.8
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / includes / fields / class-field-url.php

class-field-url.php in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.4.8, at includes/fields/class-field-url.php

106 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Text Field Class
5 */
6 class WeForms_Form_Field_URL extends WeForms_Form_Field_Text {
7
8 public function __construct() {
9 $this->name = __( 'Website URL', 'weforms' );
10 $this->input_type = 'website_url';
11 $this->icon = 'link';
12 }
13
14 /**
15 * Render the text field
16 *
17 * @param array $field_settings
18 * @param int $form_id
19 *
20 * @return void
21 */
22 public function render( $field_settings, $form_id ) {
23 $value = $field_settings['default']; ?>
24 <li <?php $this->print_list_attributes( $field_settings ); ?>>
25 <?php $this->print_label( $field_settings, $form_id ); ?>
26
27 <div class="wpuf-fields">
28 <input
29 id="<?php echo esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>"
30 type="url" class="url <?php echo ' wpuf_'. esc_attr( $field_settings['name'] ).'_'. esc_attr( $form_id ); ?>"
31 data-duplicate="<?php echo esc_attr( $field_settings['duplicate'] ) ? esc_attr( $field_settings['duplicate'] ) : 'no'; ?>"
32 data-required="<?php echo esc_attr( $field_settings['required'] ) ?>"
33 data-type="text"
34 name="<?php echo esc_attr( $field_settings['name'] ); ?>"
35 placeholder="<?php echo esc_attr( $field_settings['placeholder'] ); ?>"
36 value="<?php echo esc_attr( $value ); ?>" size="<?php echo esc_attr( $field_settings['size'] ); ?>"
37 autocomplete="url"
38 />
39 <?php $this->help_text( $field_settings ); ?>
40 </div>
41
42 </li>
43 <?php
44 }
45
46 /**
47 * Get field options setting
48 *
49 * @return array
50 */
51 public function get_options_settings() {
52 $default_options = $this->get_default_option_settings();
53 $default_text_options = $this->get_default_text_option_settings( false ); // word_restriction = false
54 $check_duplicate = [
55 [
56 'name' => 'duplicate',
57 'title' => 'No Duplicates',
58 'type' => 'checkbox',
59 'is_single_opt' => true,
60 'options' => [
61 'no' => __( 'Unique Values Only', 'weforms' ),
62 ],
63 'default' => '',
64 'section' => 'advanced',
65 'priority' => 23,
66 'help_text' => __( 'Select this option to limit user input to unique values only. This will require that a value entered in a field does not currently exist in the entry database for that field.', 'weforms' ),
67 ],
68 ];
69
70 return array_merge( $default_options, $default_text_options, $check_duplicate );
71 }
72
73 /**
74 * Get the field props
75 *
76 * @return array
77 */
78 public function get_field_props() {
79 $defaults = $this->default_attributes();
80 $defaults['duplicate'] = '';
81
82 return $defaults;
83 }
84
85 /**
86 * Prepare entry
87 *
88 * @param $field
89 *
90 * @return mixed
91 */
92 public function prepare_entry( $field, $args = [] ) {
93 if( empty( $_POST[ '_wpnonce' ] ) ) {
94 wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
95 }
96
97 if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'wpuf_form_add' ) ) {
98 wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
99 }
100
101 $args = ! empty( $args ) ? $args : weforms_clean( $_POST );
102
103 return esc_url( trim( $args[$field['name']] ) );
104 }
105 }
106