PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4.1
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4.1
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
← All changes | Libs/adminify-framework/fields/upload/upload.php +43 -44 4.2.213.2.4.1 View file →
@@ -1,5 +1,6 @@
1 -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
1 +<?php if ( ! defined( 'ABSPATH' ) ) {
2 + die; } // Cannot access directly.
2 3 /**
3 4 *
4 5 * Field: upload
5 6 *
@@ -4,58 +5,56 @@
4 5 * Field: upload
5 6 *
6 7 * @since 1.0.0
7 8 * @version 1.0.0
8 - *
9 9 */
10 10 if ( ! class_exists( 'ADMINIFY_Field_upload' ) ) {
11 - class ADMINIFY_Field_upload extends ADMINIFY_Fields {
11 + class ADMINIFY_Field_upload extends ADMINIFY_Fields {
12 12
13 - public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 - parent::__construct( $field, $value, $unique, $where, $parent );
15 - }
13 + public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 + parent::__construct( $field, $value, $unique, $where, $parent );
15 + }
16 16
17 - public function render() {
17 + public function render() {
18 + $args = wp_parse_args(
19 + $this->field,
20 + [
21 + 'library' => [],
22 + 'preview' => false,
23 + 'preview_width' => '',
24 + 'preview_height' => '',
25 + 'button_title' => esc_html__( 'Upload', 'adminify' ),
26 + 'remove_title' => esc_html__( 'Remove', 'adminify' ),
27 + ]
28 + );
18 29
19 - $args = wp_parse_args( $this->field, array(
20 - 'library' => array(),
21 - 'preview' => false,
22 - 'preview_width' => '',
23 - 'preview_height' => '',
24 - 'button_title' => esc_html__( 'Upload', 'adminify' ),
25 - 'remove_title' => esc_html__( 'Remove', 'adminify' ),
26 - ) );
30 + echo wp_kses_post( $this->field_before() );
27 31
28 - echo wp_kses_post( $this->field_before() );
32 + $library = ( is_array( $args['library'] ) ) ? $args['library'] : array_filter( (array) $args['library'] );
33 + $library = ( ! empty( $library ) ) ? implode( ',', $library ) : '';
34 + $hidden = ( empty( $this->value ) ) ? ' hidden' : '';
29 35
30 - $library = ( is_array( $args['library'] ) ) ? $args['library'] : array_filter( (array) $args['library'] );
31 - $library = ( ! empty( $library ) ) ? implode(',', $library ) : '';
32 - $hidden = ( empty( $this->value ) ) ? ' hidden' : '';
36 + if ( ! empty( $args['preview'] ) ) {
37 + $preview_type = ( ! empty( $this->value ) ) ? strtolower( substr( strrchr( $this->value, '.' ), 1 ) ) : '';
38 + $preview_src = ( ! empty( $preview_type ) && in_array( $preview_type, [ 'jpg', 'jpeg', 'gif', 'png', 'svg', 'webp' ] ) ) ? $this->value : '';
39 + $preview_width = ( ! empty( $args['preview_width'] ) ) ? 'max-width:' . esc_attr( $args['preview_width'] ) . 'px;' : '';
40 + $preview_height = ( ! empty( $args['preview_height'] ) ) ? 'max-height:' . esc_attr( $args['preview_height'] ) . 'px;' : '';
41 + $preview_style = ( ! empty( $preview_width ) || ! empty( $preview_height ) ) ? ' style="' . esc_attr( $preview_width . $preview_height ) . '"' : '';
42 + $preview_hidden = ( empty( $preview_src ) ) ? ' hidden' : '';
33 43
34 - if ( ! empty( $args['preview'] ) ) {
44 + echo '<div class="adminify--preview' . esc_attr( $preview_hidden ) . '">';
45 + echo '<div class="adminify-image-preview"' . esc_attr( $preview_style ) . '>';
46 + echo '<i class="adminify--remove fas fa-times"></i><span><img src="' . esc_url( $preview_src ) . '" class="adminify--src" /></span>';
47 + echo '</div>';
48 + echo '</div>';
49 + }
35 50
36 - $preview_type = ( ! empty( $this->value ) ) ? strtolower( substr( strrchr( $this->value, '.' ), 1 ) ) : '';
37 - $preview_src = ( ! empty( $preview_type ) && in_array( $preview_type, array( 'jpg', 'jpeg', 'gif', 'png', 'svg', 'webp' ) ) ) ? $this->value : '';
38 - $preview_width = ( ! empty( $args['preview_width'] ) ) ? 'max-width:'. esc_attr( $args['preview_width'] ) .'px;' : '';
39 - $preview_height = ( ! empty( $args['preview_height'] ) ) ? 'max-height:'. esc_attr( $args['preview_height'] ) .'px;' : '';
40 - $preview_style = ( ! empty( $preview_width ) || ! empty( $preview_height ) ) ? ' style="'. esc_attr( $preview_width . $preview_height ) .'"': '';
41 - $preview_hidden = ( empty( $preview_src ) ) ? ' hidden' : '';
51 + echo '<div class="adminify--wrap">';
52 + echo '<input type="text" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '"' . wp_kses_post( $this->field_attributes() ) . '/>';
53 + echo '<a href="#" class="button button-primary adminify--button" data-library="' . esc_attr( $library ) . '">' . wp_kses_post( $args['button_title'] ) . '</a>';
54 + echo '<a href="#" class="button button-secondary adminify-warning-primary adminify--remove' . esc_attr( $hidden ) . '">' . wp_kses_post( $args['remove_title'] ) . '</a>';
55 + echo '</div>';
42 56
43 - echo '<div class="adminify--preview'. esc_attr( $preview_hidden ) .'">';
44 - echo '<div class="adminify-image-preview"'. $preview_style .'>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- attribute value pre-escaped with esc_attr() where built.
45 - echo '<i class="adminify--remove fas fa-times"></i><span><img src="'. esc_url( $preview_src ) .'" class="adminify--src" /></span>';
46 - echo '</div>';
47 - echo '</div>';
48 -
49 - }
50 -
51 - echo '<div class="adminify--wrap">';
52 - echo '<input type="text" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes() .'/>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- field_attributes() escapes each attribute via esc_attr()
53 - echo '<a href="#" class="button button-primary adminify--button" data-library="'. esc_attr( $library ) .'">'. esc_html( $args['button_title'] ) .'</a>';
54 - echo '<a href="#" class="button button-secondary adminify-warning-primary adminify--remove'. esc_attr( $hidden ) .'">'. esc_html( $args['remove_title'] ) .'</a>';
55 - echo '</div>';
56 -
57 - echo wp_kses_post( $this->field_after() );
58 -
59 - }
60 - }
57 + echo wp_kses_post( $this->field_after() );
58 + }
59 + }
61 60 }