PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.7.0
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.7.0
1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 1.8.0 All 210 releases
charitable / templates / form-fields / picture.php

picture.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.7.0, at templates/form-fields/picture.php

119 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The template used to display file form fields.
4 *
5 * @author WP Charitable LLC
6 * @package Charitable/Templates/Form Fields
7 * @since 1.0.0
8 * @version 1.6.13
9 */
10
11 if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) {
12 return;
13 }
14
15 if ( array_key_exists( 'uploader', $view_args['field'] ) && ! $view_args['field']['uploader'] ) {
16 return charitable_template( 'form-fields/file.php', $view_args );
17 }
18
19 $form = $view_args['form'];
20 $field = $view_args['field'];
21 $classes = $view_args['classes'];
22 $is_required = isset( $field['required'] ) ? $field['required'] : false;
23 $placeholder = isset( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '';
24 $size = isset( $field['size'] ) ? $field['size'] : 'thumbnail';
25 $max_uploads = isset( $field['max_uploads'] ) ? $field['max_uploads'] : 1;
26 $max_file_size = isset( $field['max_file_size'] ) ? $field['max_file_size'] : wp_max_upload_size();
27 $pictures = isset( $field['value'] ) ? $field['value'] : array();
28
29 if ( wp_is_mobile() ) {
30 $classes .= ' mobile';
31 }
32
33 if ( ! is_array( $pictures ) ) {
34 $pictures = array( $pictures );
35 }
36
37 foreach ( $pictures as $i => $picture ) {
38 if ( false === strpos( $picture, 'img' ) && ! wp_attachment_is_image( $picture ) ) {
39 unset( $pictures[ $i ] );
40 }
41 }
42
43 $has_max_uploads = count( $pictures ) >= $max_uploads;
44 $params = array(
45 'runtimes' => 'html5,silverlight,flash,html4',
46 'file_data_name' => 'async-upload',
47 'container' => $field['key'] . '-dragdrop',
48 'browse_button' => $field['key'] . '-browse-button',
49 'drop_element' => $field['key'] . '-dragdrop-dropzone',
50 'multiple_queues' => true,
51 'url' => admin_url( 'admin-ajax.php' ),
52 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
53 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
54 'multipart' => true,
55 'urlstream_upload' => true,
56 'filters' => array(
57 array(
58 'title' => _x( 'Allowed Image Files', 'image upload', 'charitable' ),
59 'extensions' => 'jpg,jpeg,gif,png',
60 ),
61 ),
62 'multipart_params' => array(
63 'field_id' => $field['key'],
64 'action' => 'charitable_plupload_image_upload',
65 '_ajax_nonce' => wp_create_nonce( "charitable-upload-images-{$field[ 'key' ]}" ),
66 'post_id' => isset( $field['parent_id'] ) && strlen( $field['parent_id'] ) ? $field['parent_id'] : '0',
67 'size' => $size,
68 'max_uploads' => $max_uploads,
69 ),
70 );
71
72 wp_enqueue_script( 'charitable-plup-fields' );
73 wp_enqueue_style( 'charitable-plup-styles' );
74
75 ?>
76 <div id="charitable_field_<?php echo $field['key']; ?>" class="<?php echo $classes; ?>">
77 <?php if ( isset( $field['label'] ) ) : ?>
78 <label>
79 <?php echo $field['label']; ?>
80 <?php if ( $is_required ) : ?>
81 <abbr class="required" title="required">*</abbr>
82 <?php endif ?>
83 </label>
84 <?php endif ?>
85 <?php if ( isset( $field['help'] ) ) : ?>
86 <p class="charitable-field-help"><?php echo $field['help']; ?></p>
87 <?php endif ?>
88 <div id="<?php echo $field['key']; ?>-dragdrop"
89 class="charitable-drag-drop"
90 data-max-size="<?php echo $max_file_size; ?>"
91 data-images="<?php echo $field['key']; ?>-dragdrop-images"
92 data-params="<?php echo esc_attr( wp_json_encode( $params ) ); ?>">
93 <div id="<?php echo $field['key']; ?>-dragdrop-dropzone" class="charitable-drag-drop-dropzone" <?php echo $has_max_uploads ? 'style="display:none;"' : ''; ?>>
94 <p class="charitable-drag-drop-info"><?php echo 1 == $max_uploads ? _x( 'Drop image here', 'image upload', 'charitable' ) : _x( 'Drop images here', 'image upload plural', 'charitable' ); ?></p>
95 <p><?php _ex( 'or', 'image upload', 'charitable' ); ?></p>
96 <p class="charitable-drag-drop-buttons">
97 <button id="<?php echo $field['key']; ?>-browse-button" class="button" type="button"><?php _ex( 'Select Files', 'image upload', 'charitable' ); ?></button>
98 </p>
99 </div>
100 <div class="charitable-drag-drop-image-loader" style="display: none;">
101 <p class="loader-title"><?php _e( 'Uploading...', 'charitable' ); ?></p>
102 <ul class="images"></ul>
103 </div>
104 <ul id="<?php echo $field['key']; ?>-dragdrop-images" class="charitable-drag-drop-images charitable-drag-drop-images-<?php echo $max_uploads; ?>">
105 <?php
106 foreach ( $pictures as $image ) :
107 charitable_template(
108 'form-fields/picture-preview.php',
109 array(
110 'image' => $image,
111 'field' => $field,
112 )
113 );
114 endforeach;
115 ?>
116 </ul>
117 </div>
118 </div>
119