PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.2.1
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.2.1
2.1.3 2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 trunk 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 All 57 releases
darkify / admin / ta-framework / fields / upload / upload.php

upload.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.2.1, at admin/ta-framework/fields/upload/upload.php

64 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) {
2 die; } // Cannot access directly.
3 /**
4 *
5 * Field: upload
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'DRK_LITE_Field_upload' ) ) {
11 class DRK_LITE_Field_upload extends DRK_LITE_Fields {
12
13 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 parent::__construct( $field, $value, $unique, $where, $parent );
15 }
16
17 public function render() {
18
19 $args = wp_parse_args(
20 $this->field,
21 array(
22 'library' => array(),
23 'preview' => false,
24 'preview_width' => '',
25 'preview_height' => '',
26 'button_title' => esc_html__( 'Upload', 'darkify' ),
27 'remove_title' => esc_html__( 'Remove', 'darkify' ),
28 )
29 );
30
31 echo wp_kses_post( $this->field_before() );
32
33 $library = ( is_array( $args['library'] ) ) ? $args['library'] : array_filter( (array) $args['library'] );
34 $library = ( ! empty( $library ) ) ? implode( ',', $library ) : '';
35 $hidden = ( empty( $this->value ) ) ? ' hidden' : '';
36
37 if ( ! empty( $args['preview'] ) ) {
38
39 $preview_type = ( ! empty( $this->value ) ) ? strtolower( substr( strrchr( $this->value, '.' ), 1 ) ) : '';
40 $preview_src = ( ! empty( $preview_type ) && in_array( $preview_type, array( 'jpg', 'jpeg', 'gif', 'png', 'svg', 'webp' ) ) ) ? $this->value : '';
41 $preview_width = ( ! empty( $args['preview_width'] ) ) ? 'max-width:' . esc_attr( $args['preview_width'] ) . 'px;' : '';
42 $preview_height = ( ! empty( $args['preview_height'] ) ) ? 'max-height:' . esc_attr( $args['preview_height'] ) . 'px;' : '';
43 $preview_style = ( ! empty( $preview_width ) || ! empty( $preview_height ) ) ? ' style="' . esc_attr( $preview_width . $preview_height ) . '"' : '';
44 $preview_hidden = ( empty( $preview_src ) ) ? ' hidden' : '';
45
46 echo '<div class="drk_lite--preview' . esc_attr( $preview_hidden ) . '">';
47 echo '<div class="drk_lite-image-preview"' . wp_kses_post( $preview_style ) . '>';
48 echo '<i class="drk_lite--remove fas fa-times"></i><span><img src="' . esc_url( $preview_src ) . '" class="drk_lite--src" /></span>';
49 echo '</div>';
50 echo '</div>';
51
52 }
53
54 echo '<div class="drk_lite--wrap">';
55 echo '<input type="text" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '"' . wp_kses_post( $this->field_attributes() ) . '/>';
56 echo '<a href="#" class="button button-primary drk_lite--button" data-library="' . esc_attr( $library ) . '">' . esc_html( $args['button_title'] ) . '</a>';
57 echo '<a href="#" class="button button-secondary drk_lite-warning-primary drk_lite--remove' . esc_attr( $hidden ) . '">' . esc_html( $args['remove_title'] ) . '</a>';
58 echo '</div>';
59
60 echo wp_kses_post( $this->field_after() );
61 }
62 }
63 }
64