PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.1.1
Kirki – Freeform Page Builder, Website Builder & Customizer v6.1.1
6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / customizer / packages / controls / upload / src / Control / Upload.php
kirki / customizer / packages / controls / upload / src / Control Last commit date
Upload.php 5 months ago
Upload.php
73 lines
1 <?php
2 /**
3 * Kirki upload control.
4 *
5 * @package kirki-framework/control-upload
6 * @since 1.0.1
7 */
8
9 namespace Kirki\Control;
10
11 // Exit if accessed directly.
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 /**
17 * Upload control
18 */
19 class Upload extends \WP_Customize_Media_Control {
20
21 /**
22 * Control type.
23 *
24 * @since 1.0.1
25 * @var string
26 */
27 public $type = 'upload';
28
29 /**
30 * Media control mime type.
31 *
32 * @since 1.0.1
33 * @var string
34 */
35 public $mime_type = '';
36
37 /**
38 * Button labels.
39 *
40 * @since 1.0.1
41 * @var array
42 */
43 public $button_labels = array();
44
45 /**
46 * Refresh the parameters passed to the JavaScript via JSON.
47 *
48 * @since 1.0.1
49 *
50 * @uses WP_Customize_Media_Control::to_json()
51 */
52 public function to_json() {
53 parent::to_json();
54
55 $value = $this->value();
56
57 if ( ! empty( $value ) ) {
58 if ( is_array( $value ) && isset( $value['id'] ) ) {
59 $attachment_id = $value['id'];
60 } elseif ( is_numeric( $value ) ) {
61 $attachment_id = absint( $value );
62 } elseif ( is_string( $value ) && ! is_numeric( $value ) ) {
63 $attachment_id = attachment_url_to_postid( $value );
64 }
65
66 if ( ! empty( $attachment_id ) ) {
67 $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id );
68 }
69 }
70 }
71
72 }
73