PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.9.8
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.9.8
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / assets / lib / wck-api / fields / upload.php

upload.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.9.8, at assets/lib/wck-api/fields/upload.php

76 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /* @param string $meta Meta name.
3 * @param array $details Contains the details for the field.
4 * @param string $value Contains input value;
5 * @param string $context Context where the function is used. Depending on it some actions are preformed.;
6 * @return string $element input element html string. */
7
8 /* since the slug below is generated dinamically from other elements we need to determine here if we have a slug or not and not let the wck_generate_slug() function do that */
9 if( !empty( $details['slug'] ) )
10 $slug_from = $details['slug'];
11 else
12 $slug_from = $details['title'];
13
14 /* define id's for input and info div */
15 $upload_input_id = str_replace( '-', '_', Wordpress_Creation_Kit_PB::wck_generate_slug( $meta . $slug_from ) );
16 $upload_info_div_id = str_replace( '-', '_', Wordpress_Creation_Kit_PB::wck_generate_slug( $meta .'_info_container_'. $slug_from ) );
17
18 /* hidden input that will hold the attachment id */
19 $element.= '<input id="'. esc_attr( $upload_input_id ) .'" type="hidden" size="36" name="'. $single_prefix . esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $details['title'], $details ) ) .'" value="'. $value .'" class="mb-text-input mb-field"/>';
20
21 /* container for the image preview (or file ico) and name and file type */
22 if( !empty ( $value ) ){
23 /* it can hold multiple attachments separated by comma */
24 $values = explode( ',', $value );
25 foreach( $values as $value ){
26 $file_src = wp_get_attachment_url($value);
27 $thumbnail = wp_get_attachment_image( $value, array( 80, 80 ), true );
28 $file_name = get_the_title( $value );
29 $file_type = get_post_mime_type( $value );
30 $attachment_url = admin_url( "post.php?post={$value}&action=edit" );
31
32 $element.= '<div id="'.esc_attr( $upload_info_div_id ).'_info_container" class="upload-field-details" data-attachment_id="'. $value .'">';
33 $element.= '<div class="file-thumb">';
34 $element.= "<a href='{$attachment_url}' target='_blank' class='wck-attachment-link'>" . $thumbnail . "</a>";
35 $element.= '</div>';
36
37 $element.= '<p><span class="file-name">';
38 $element.= $file_name;
39 $element.= '</span><span class="file-type">';
40 $element.= $file_type;
41 $element.= '</span>';
42 if( !empty ( $value ) )
43 $element.= '<span class="wck-remove-upload">'.__( 'Remove', 'profile-builder' ).'</span>';
44 $element.= '</p></div>';
45 }
46 }
47
48 $element.= '<a href="#" class="button wck_upload_button" id="upload_'. esc_attr(Wordpress_Creation_Kit_PB::wck_generate_slug( $details['title'], $details ) ) .'_button" data-uploader_title="'. $details['title'] .'" data-uploader_button_text="Select Files" data-upload_input="'.esc_attr( $upload_input_id ).'" ';
49 if( is_user_logged_in() )
50 $element.= 'data-uploader_logged_in="true"';
51
52 if( !empty( $post_id ) )
53 $element.= ' data-post_id="'. $post_id .'"';
54
55 if( !empty( $details['multiple_upload'] ) ){
56 if( $details['multiple_upload'] == 'true' )
57 $element.= ' data-multiple_upload="true"';
58 else
59 $element.= ' data-multiple_upload="false"';
60 }
61
62 if( !empty( $details['attach_to_post'] ) ){
63 if( $details['attach_to_post'] == true )
64 $element.= ' data-attach_to_post="true"';
65 }
66
67 if( $context != 'fep' )
68 $element.= ' data-upload_in_backend="true"';
69 else
70 $element.= ' data-upload_in_backend="false"';
71
72 if( !empty( $details['allowed_types'] ) )
73 $element.= ' data-allowed_types="'. $details['allowed_types'] .'"';
74
75 $element.= '>'. __( 'Upload ', 'profile-builder' ) . $details['title'] .'</a>';
76 ?>