PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.1.2
JetFormBuilder — Dynamic Blocks Form Builder v2.1.2
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / file-upload.php
jetformbuilder / includes Last commit date
actions 3 years ago addons 3 years ago admin 3 years ago blocks 3 years ago classes 3 years ago compatibility 3 years ago db-queries 3 years ago dev-mode 3 years ago exceptions 3 years ago form-actions 3 years ago form-messages 3 years ago form-patterns 3 years ago form-response 3 years ago gateways 3 years ago generators 3 years ago integrations 3 years ago migrations 3 years ago presets 3 years ago request 3 years ago rest-api 3 years ago shortcodes 3 years ago widgets 3 years ago wp-cli 3 years ago autoloader.php 3 years ago file-upload.php 3 years ago form-break.php 3 years ago form-handler.php 3 years ago form-manager.php 3 years ago live-form.php 3 years ago plugin.php 3 years ago post-type.php 3 years ago
file-upload.php
103 lines
1 <?php
2
3 namespace Jet_Form_Builder;
4
5 use Jet_Form_Builder\Classes\Instance_Trait;
6 use Jet_Form_Builder\Classes\Tools;
7
8 // If this file is called directly, abort.
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13 /**
14 * @method static File_Upload instance()
15 *
16 * Class description
17 *
18 * @package package_name
19 * @author Cherry Team
20 * @license GPL-2.0+
21 */
22 class File_Upload {
23
24 use Instance_Trait;
25
26 private $rendered_scripts = false;
27
28 public function __construct() {
29 }
30
31
32 public function get_loader() {
33 return '<div class="jet-form-builder-file-upload__loader">' . apply_filters(
34 'jet-form-builder/file-upload/loader',
35 '<svg xmlns="http://www.w3.org/2000/svg" width="38" height="38" viewBox="0 0 38 38" stroke="#fff"><g fill="none" fill-rule="evenodd"><g transform="translate(1 1)" stroke-width="2"><circle stroke-opacity=".5" cx="18" cy="18" r="18"/><path d="M36 18c0-9.94-8.06-18-18-18" transform="rotate(137.826 18 18)"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="1s" repeatCount="indefinite"/></path></g></g></svg>'
36 ) . '</div>';
37 }
38
39 /**
40 * Resturns max upload size based on field arguments
41 *
42 * @param array $args [description]
43 *
44 * @return [type] [description]
45 */
46 public function get_max_size_for_field( $args = array() ) {
47
48 $max_size = wp_max_upload_size();
49 $field_max_size = $max_size;
50
51 if ( ! empty( $args['max_size'] ) ) {
52
53 $field_max_size = intval( floatval( $args['max_size'] ) * MB_IN_BYTES );
54
55 if ( $field_max_size > $max_size ) {
56 $field_max_size = $max_size;
57 }
58 }
59
60 return $field_max_size;
61
62 }
63
64 /**
65 * Register form-specific assets
66 *
67 * @return void
68 */
69 public function enqueue_scripts() {
70 wp_enqueue_script( 'jet-form-builder-sortable' );
71 wp_enqueue_script( 'jet-form-builder-file-upload' );
72
73 $messages = wp_json_encode( jet_form_builder()->msg_router->get_manager()->get_messages() );
74 $form_id = (int) Live_Form::instance()->form_id;
75
76 wp_add_inline_script(
77 'jet-form-builder-file-upload',
78 "
79 window.JetFormBuilderFileUploadConfig = window.JetFormBuilderFileUploadConfig || {};
80 window.JetFormBuilderFileUploadConfig.errors = window.JetFormBuilderFileUploadConfig.errors || {};
81
82 window.JetFormBuilderFileUploadConfig.errors[ $form_id ] = $messages;
83 "
84 );
85 }
86
87 public function ensure_media_js( $content = '' ) {
88 if ( $this->rendered_scripts ) {
89 return $content;
90 }
91 $this->rendered_scripts = true;
92
93 ob_start();
94 jet_form_builder()->blocks->register_form_scripts();
95
96 $this->enqueue_scripts();
97 wp_scripts()->print_scripts( 'jet-form-builder-file-upload' );
98
99 return $content . ob_get_clean();
100 }
101
102 }
103