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
weforms / includes / fields / class-field-image.php

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

120 lines 4.2 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_Image extends WeForms_Field_Contract {
7
8 function __construct() {
9 $this->name = __( 'Image Upload', 'weforms' );
10 $this->input_type = 'image_upload';
11 $this->icon = 'file-image-o';
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 $unique_id = sprintf( '%s-%d', $field_settings['name'], $form_id );
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 <div id="wpuf-<?php echo $unique_id; ?>-upload-container">
30 <div class="wpuf-attachment-upload-filelist" data-type="file" data-required="<?php echo $field_settings['required']; ?>">
31 <a id="wpuf-<?php echo $unique_id; ?>-pickfiles" data-form_id="<?php echo $form_id; ?>" class="button file-selector <?php echo ' wpuf_' . $field_settings['name'] . '_' . $form_id; ?>" href="#"><?php echo $field_settings['button_label']; ?></a>
32
33 <ul class="wpuf-attachment-list thumbnails"></ul>
34 </div>
35 </div><!-- .container -->
36
37 <?php $this->help_text( $field_settings ); ?>
38
39 </div> <!-- .wpuf-fields -->
40
41 <script type="text/javascript">
42 ;(function($) {
43 $(document).ready( function(){
44 var uploader = new WPUF_Uploader('wpuf-<?php echo $unique_id; ?>-pickfiles', 'wpuf-<?php echo $unique_id; ?>-upload-container', <?php echo $field_settings['count']; ?>, '<?php echo $field_settings['name']; ?>', 'jpg,jpeg,gif,png,bmp', <?php echo $field_settings['max_size'] ?>);
45 wpuf_plupload_items.push(uploader);
46 });
47 })(jQuery);
48 </script>
49
50 </li>
51 <?php
52 }
53
54 /**
55 * Get field options setting
56 *
57 * @return array
58 */
59 public function get_options_settings() {
60 $default_options = $this->get_default_option_settings(true, array('dynamic', 'width') ); // exclude dynamic
61
62 $settings = array(
63 array(
64 'name' => 'max_size',
65 'title' => __( 'Max. file size', 'weforms' ),
66 'type' => 'text',
67 'section' => 'advanced',
68 'priority' => 20,
69 'help_text' => __( 'Enter maximum upload size limit in KB', 'weforms' ),
70 ),
71
72 array(
73 'name' => 'count',
74 'title' => __( 'Max. files', 'weforms' ),
75 'type' => 'text',
76 'section' => 'advanced',
77 'priority' => 21,
78 'help_text' => __( 'Number of images can be uploaded', 'weforms' ),
79 ),
80 array(
81 'name' => 'button_label',
82 'title' => __( 'Button Label', 'weforms' ),
83 'type' => 'text',
84 'default' => __( 'Select Image', 'weforms' ),
85 'section' => 'basic',
86 'priority' => 22,
87 'help_text' => __( 'Enter a label for the Select button', 'weforms' ),
88 )
89 );
90
91 return array_merge( $default_options, $settings );
92 }
93
94 /**
95 * Get the field props
96 *
97 * @return array
98 */
99 public function get_field_props() {
100 $defaults = $this->default_attributes();
101 $props = array(
102 'max_size' => '1024',
103 'count' => '1',
104 'button_label' => __( 'Select Image', 'weforms' ),
105 );
106
107 return array_merge( $defaults, $props );
108 }
109
110 /**
111 * Prepare entry
112 *
113 * @param $field
114 *
115 * @return @return mixed
116 */
117 public function prepare_entry( $field ) {
118 return isset( $_POST['wpuf_files'][$field['name']] ) ? $_POST['wpuf_files'][$field['name']] : array();
119 }
120 }