PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.9.2.7
Advanced Custom Fields: Extended v0.9.2.7
0.9.2.7 0.9.2.6 0.9.2.5 0.8.6 0.8.6.1 0.8.6.3 0.8.6.5 0.8.6.6 0.8.6.7 0.8.6.8 0.8.6.9 0.8.7 0.8.7.1 0.8.7.2 0.8.7.3 0.8.7.4 0.8.7.5 0.8.7.6 0.8.8 0.8.8.1 0.8.8.10 0.8.8.11 0.8.8.2 0.8.8.3 0.8.8.4 0.8.8.5 0.8.8.6 0.8.8.7 0.8.8.8 0.8.8.9 0.8.9 0.8.9.1 0.8.9.2 0.8.9.3 0.8.9.4 0.8.9.5 0.9 0.9.0.1 0.9.0.2 0.9.0.3 0.9.0.4 0.9.0.5 0.9.0.6 0.9.0.7 0.9.0.8 0.9.0.9 0.9.1 0.9.1.1 0.9.2 0.9.2.1 0.9.2.2 0.9.2.3 0.9.2.4 trunk 0.5 0.5.1 0.5.2 0.5.2.1 0.5.2.3 0.5.5 0.5.5.1 0.5.8 0.5.8.1 0.6 0.6.0.1 0.6.0.2 0.6.1 0.6.3 0.6.5 0.6.7 0.6.7.2 0.7 0.7.0.3 0.7.5 0.7.5.5 0.7.8 0.7.9 0.7.9.3 0.7.9.4 0.7.9.9.8 0.7.9.9.9 0.8 0.8.1 0.8.2 0.8.3 0.8.3.1 0.8.4 0.8.4.1 0.8.4.5 0.8.4.6 0.8.5 0.8.5.5
acf-extended / includes / fields / field-file.php
acf-extended / includes / fields Last commit date
field-advanced-link.php 3 months ago field-button-group.php 1 week ago field-button.php 7 months ago field-checkbox.php 3 months ago field-clone.php 2 years ago field-code-editor.php 3 months ago field-column.php 3 years ago field-dynamic-render.php 3 years ago field-file.php 3 months ago field-flexible-content-actions-title.php 3 months ago field-flexible-content-actions-toggle.php 3 months ago field-flexible-content-actions.php 3 months ago field-flexible-content-async.php 4 months ago field-flexible-content-compatibility.php 3 months ago field-flexible-content-controls.php 9 months ago field-flexible-content-hide.php 3 months ago field-flexible-content-hooks.php 9 months ago field-flexible-content-modal-edit.php 9 months ago field-flexible-content-modal-select.php 3 months ago field-flexible-content-modal-settings.php 3 months ago field-flexible-content-popup.php 3 months ago field-flexible-content-preview.php 3 months ago field-flexible-content-state.php 9 months ago field-flexible-content-thumbnail.php 9 months ago field-flexible-content-wysiwyg.php 9 months ago field-flexible-content.php 3 months ago field-forms.php 3 months ago field-gallery.php 3 months ago field-google-map.php 3 months ago field-group.php 3 months ago field-hidden.php 3 years ago field-image.php 3 months ago field-post-object.php 3 months ago field-post-statuses.php 3 months ago field-post-types.php 3 months ago field-radio.php 3 months ago field-recaptcha.php 3 months ago field-relationship.php 3 months ago field-repeater.php 3 months ago field-select.php 3 months ago field-slug.php 1 year ago field-taxonomies.php 3 months ago field-taxonomy-terms.php 3 months ago field-taxonomy.php 3 months ago field-textarea.php 3 months ago field-user-roles.php 3 months ago field-user.php 3 months ago field-wysiwyg.php 3 months ago
field-file.php
222 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_field_file')):
8
9 class acfe_field_file extends acfe_field_extend{
10
11 /**
12 * initialize
13 */
14 function initialize(){
15
16 $this->name = 'file';
17 $this->defaults = array(
18 'uploader' => '',
19 );
20
21 $this->add_filter('gettext', array($this, 'gettext'), 99, 3);
22 $this->add_filter('acf/prepare_field/name=min_size', array($this, 'prepare_size'));
23 $this->add_filter('acf/prepare_field/name=max_size', array($this, 'prepare_size'));
24 $this->add_filter('acf/prepare_field/name=library', array($this, 'prepare_library'));
25
26 $this->add_field_action('acf/render_field_settings', array($this, '_render_field_settings'), 0);
27
28 }
29
30
31 /**
32 * gettext
33 *
34 * @param $translated_text
35 * @param $text
36 * @param $domain
37 *
38 * @return string
39 */
40 function gettext($translated_text, $text, $domain){
41
42 if($domain === 'acf' && $text === 'No file selected'){
43 return '';
44 }
45
46 return $translated_text;
47
48 }
49
50
51 /**
52 * prepare_size
53 *
54 * @param $field
55 *
56 * @return mixed
57 */
58 function prepare_size($field){
59
60 if(acfe_get($field['wrapper'], 'data-setting') === 'file'){
61
62 switch($field['_name']){
63
64 case 'min_size': {
65
66 $field['label'] = __('File size', 'acf');
67 $field['prepend'] = __('Min size', 'acfe');
68 break;
69
70 }
71
72 case 'max_size': {
73
74 $field['prepend'] = __('Max size', 'acfe');
75 $field['wrapper']['data-append'] = 'min_size';
76 break;
77
78 }
79
80 }
81
82 }
83
84 return $field;
85
86 }
87
88
89 /**
90 * prepare_library
91 *
92 * @param $field
93 *
94 * @return mixed
95 */
96 function prepare_library($field){
97
98 // check if field group ui setting
99 if(acfe_get($field['wrapper'], 'data-setting') === 'file'){
100
101 // add conditional logic
102 $field['conditional_logic'] = array(
103 array(
104 array(
105 'field' => 'uploader',
106 'operator' => '==',
107 'value' => 'wp',
108 )
109 )
110 );
111
112 }
113
114 return $field;
115
116 }
117
118
119 /**
120 * _render_field_settings
121 *
122 * acf/render_field_settings:0
123 *
124 * @param $field
125 */
126 function _render_field_settings($field){
127
128 // uploader
129 acf_render_field_setting($field, array(
130 'label' => __('Uploader Type', 'acfe'),
131 'name' => 'uploader',
132 'key' => 'uploader',
133 'instructions' => __('Choose the uploader type', 'acfe'),
134 'type' => 'radio',
135 'choices' => array(
136 '' => __('Default', 'acf'),
137 'wp' => 'WordPress',
138 'basic' => __('Browser', 'acfe'),
139 ),
140 'default_value' => '',
141 'layout' => 'horizontal',
142 'return_format' => 'value',
143 ));
144
145 }
146
147
148 /**
149 * prepare_field
150 *
151 * @param $field
152 *
153 * @return mixed
154 */
155 function prepare_field($field){
156
157 // let acfe form force specific uploader
158 if(acf_is_filter_enabled('acfe/form/uploader')){
159 $field['uploader'] = '';
160 }
161
162 // default uploader in settings
163 // use global acf uploader
164 if(empty($field['uploader'])){
165 $field['uploader'] = acf_get_setting('uploader');
166 }
167
168 // current user can't upload files
169 // force basic
170 if(!current_user_can('upload_files')){
171 $field['uploader'] = 'basic';
172 }
173
174 // update global uploader
175 acf_update_setting('uploader', $field['uploader']);
176
177 // return
178 return $field;
179
180 }
181
182
183 /**
184 * format_front_value
185 *
186 * @param $formatted
187 * @param $unformatted
188 * @param $post_id
189 * @param $field
190 * @param $form
191 *
192 * @return string
193 */
194 function format_front_value($formatted, $unformatted, $post_id, $field, $form){
195
196 // vars
197 $value = acfe_as_array($unformatted);
198 $array = array();
199
200 // loop values
201 foreach($value as $p_id){
202
203 // get post
204 $post = get_post($p_id);
205
206 // validate
207 if($post && !is_wp_error($post)){
208 $array[] = get_the_title($post->ID);
209 }
210
211 }
212
213 // merge
214 return implode(', ', $array);
215
216 }
217
218 }
219
220 acf_new_instance('acfe_field_file');
221
222 endif;