PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.3.3
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.3.3
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
← All changes | includes/fields/class-field-url.php +95 -109 1.6.261.3.3 View file →
@@ -1,109 +1,95 @@
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 - $use_theme_css = isset( $form_settings['use_theme_css'] ) ? $form_settings['use_theme_css'] : 'wpuf-style';
25 - ?>
26 - <li <?php $this->print_list_attributes( $field_settings ); ?>>
27 - <?php $this->print_label( $field_settings, $form_id ); ?>
28 -
29 - <div class="wpuf-fields">
30 - <input
31 - title = "<?php echo esc_attr__( 'The URL must contain a protocol i.e. http://example.com', 'weforms' ); ?>"
32 - id = "<?php echo esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>"
33 - type = "url" class="url <?php echo ' wpuf_'. esc_attr( $field_settings['name'] ).'_'. esc_attr( $form_id ); ?>"
34 - data-duplicate = "<?php echo esc_attr( $field_settings['duplicate'] ) ? esc_attr( $field_settings['duplicate'] ) : 'no'; ?>"
35 - data-required = "<?php echo esc_attr( $field_settings['required'] ) ?>"
36 - data-type = "url"
37 - data-style="<?php echo esc_attr( $use_theme_css ); ?>"
38 - name = "<?php echo esc_attr( $field_settings['name'] ); ?>"
39 - placeholder = "<?php echo esc_attr( $field_settings['placeholder'] ); ?>"
40 - value = "<?php echo esc_attr( $value ); ?>" size="<?php echo esc_attr( $field_settings['size'] ); ?>"
41 - autocomplete = "url"
42 - />
43 - <?php $this->help_text( $field_settings ); ?>
44 - </div>
45 -
46 - </li>
47 - <?php
48 - }
49 -
50 - /**
51 - * Get field options setting
52 - *
53 - * @return array
54 - */
55 - public function get_options_settings() {
56 - $default_options = $this->get_default_option_settings();
57 - $default_text_options = $this->get_default_text_option_settings( false ); // word_restriction = false
58 - $check_duplicate = [
59 - [
60 - 'name' => 'duplicate',
61 - 'title' => 'No Duplicates',
62 - 'type' => 'checkbox',
63 - 'is_single_opt' => true,
64 - 'options' => [
65 - 'no' => __( 'Unique Values Only', 'weforms' ),
66 - ],
67 - 'default' => '',
68 - 'section' => 'advanced',
69 - 'priority' => 23,
70 - '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' ),
71 - ],
72 - ];
73 -
74 - return array_merge( $default_options, $default_text_options, $check_duplicate );
75 - }
76 -
77 - /**
78 - * Get the field props
79 - *
80 - * @return array
81 - */
82 - public function get_field_props() {
83 - $defaults = $this->default_attributes();
84 - $defaults['duplicate'] = '';
85 -
86 - return $defaults;
87 - }
88 -
89 - /**
90 - * Prepare entry
91 - *
92 - * @param $field
93 - *
94 - * @return mixed
95 - */
96 - public function prepare_entry( $field, $args = [] ) {
97 - if( empty( $_POST[ '_wpnonce' ] ) ) {
98 - wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
99 - }
100 -
101 - if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'wpuf_form_add' ) ) {
102 - wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
103 - }
104 -
105 - $args = ! empty( $args ) ? $args : weforms_clean( $_POST );
106 -
107 - return esc_url( trim( $args[$field['name']] ) );
108 - }
109 -}
1 +<?php
2 +
3 +/**
4 + * Text Field Class
5 + */
6 +class WeForms_Form_Field_URL extends WeForms_Form_Field_Text {
7 +
8 + 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 integer $form_id
19 + *
20 + * @return void
21 + */
22 + public function render( $field_settings, $form_id ) {
23 + $value = $field_settings['default'];
24 + ?>
25 + <li <?php $this->print_list_attributes( $field_settings ); ?>>
26 + <?php $this->print_label( $field_settings, $form_id ); ?>
27 +
28 + <div class="wpuf-fields">
29 + <input
30 + id="<?php echo $field_settings['name'] . '_' . $form_id; ?>"
31 + type="url" class="url <?php echo ' wpuf_'.$field_settings['name'].'_'.$form_id; ?>"
32 + data-duplicate="<?php echo $field_settings['duplicate'] ? $field_settings['duplicate'] : 'no'; ?>"
33 + data-required="<?php echo $field_settings['required'] ?>"
34 + data-type="text"
35 + name="<?php echo esc_attr( $field_settings['name'] ); ?>"
36 + placeholder="<?php echo esc_attr( $field_settings['placeholder'] ); ?>"
37 + value="<?php echo esc_attr( $value ) ?>" size="<?php echo esc_attr( $field_settings['size'] ) ?>"
38 + autocomplete="url"
39 + />
40 + <?php $this->help_text( $field_settings ); ?>
41 + </div>
42 +
43 + </li>
44 + <?php
45 + }
46 +
47 + /**
48 + * Get field options setting
49 + *
50 + * @return array
51 + */
52 + public function get_options_settings() {
53 + $default_options = $this->get_default_option_settings();
54 + $default_text_options = $this->get_default_text_option_settings( false ); // word_restriction = false
55 + $check_duplicate = array(
56 + array(
57 + 'name' => 'duplicate',
58 + 'title' => 'No Duplicates',
59 + 'type' => 'checkbox',
60 + 'is_single_opt' => true,
61 + 'options' => array(
62 + 'no' => __( 'Unique Values Only', 'weforms' )
63 + ),
64 + 'default' => '',
65 + 'section' => 'advanced',
66 + 'priority' => 23,
67 + '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' ),
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 + return $defaults;
82 + }
83 +
84 +
85 + /**
86 + * Prepare entry
87 + *
88 + * @param $field
89 + *
90 + * @return mixed
91 + */
92 + public function prepare_entry( $field ) {
93 + return esc_url( trim( $_POST[$field['name']] ) );
94 + }
95 +}