PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.12.3
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.12.3
1.8.13.1 1.8.13 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 All 212 releases
charitable / templates / form-fields / picture.php

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

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