PluginProbe
StreamCast – bring live radio to your site with a sleek player / trunk
StreamCast – bring live radio to your site with a sleek player vtrunk
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
streamcast / vendor / codestar-framework / fields / upload / upload.php

upload.php in StreamCast – bring live radio to your site with a sleek player trunk, at vendor/codestar-framework/fields/upload/upload.php

62 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 /**
3 *
4 * Field: upload
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'STREAMCAST_STREAMCAST_CSF_Field_upload' ) ) {
11 class STREAMCAST_STREAMCAST_CSF_Field_upload extends STREAMCAST_STREAMCAST_CSF_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( $this->field, array(
20 'library' => array(),
21 'preview' => false,
22 'preview_width' => '',
23 'preview_height' => '',
24 'button_title' => esc_html__( 'Upload', 'streamcast' ),
25 'remove_title' => esc_html__( 'Remove', 'streamcast' ),
26 ) );
27
28 echo wp_kses_post( $this->field_before() );
29
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' : '';
33
34 if ( ! empty( $args['preview'] ) ) {
35
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' : '';
42
43 echo '<div class="streamcast-csf--preview'. esc_attr( $preview_hidden ) .'">';
44 echo '<div class="streamcast-csf-image-preview"'. $preview_style .'>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
45 echo '<i class="streamcast-csf--remove fas fa-times"></i><span><img src="'. esc_url( $preview_src ) .'" class="streamcast-csf--src" /></span>';
46 echo '</div>';
47 echo '</div>';
48
49 }
50
51 echo '<div class="streamcast-csf--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
53 echo '<a href="#" class="button button-primary streamcast-csf--button" data-library="'. esc_attr( $library ) .'">'. wp_kses_post( $args['button_title'] ) .'</a>';
54 echo '<a href="#" class="button button-secondary streamcast-csf-warning-primary streamcast-csf--remove'. esc_attr( $hidden ) .'">'. wp_kses_post( $args['remove_title'] ) .'</a>';
55 echo '</div>';
56
57 echo wp_kses_post( $this->field_after() );
58
59 }
60 }
61 }
62