PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.3.3
StreamCast – bring live radio to your site with a sleek player v2.3.3
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 / admin / codestar-framework / fields / dimensions / dimensions.php

dimensions.php in StreamCast – bring live radio to your site with a sleek player 2.3.3, at admin/codestar-framework/fields/dimensions/dimensions.php

102 lines 4.5 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: dimensions
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'CSF_Field_dimensions' ) ) {
11 class CSF_Field_dimensions extends 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 'width_icon' => '<i class="fas fa-arrows-alt-h"></i>',
21 'height_icon' => '<i class="fas fa-arrows-alt-v"></i>',
22 'width_placeholder' => esc_html__( 'width', 'csf' ),
23 'height_placeholder' => esc_html__( 'height', 'csf' ),
24 'width' => true,
25 'height' => true,
26 'unit' => true,
27 'show_units' => true,
28 'units' => array( 'px', '%', 'em' )
29 ) );
30
31 $default_values = array(
32 'width' => '',
33 'height' => '',
34 'unit' => 'px',
35 );
36
37 $value = wp_parse_args( $this->value, $default_values );
38 $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
39 $is_unit = ( ! empty( $unit ) ) ? ' csf--is-unit' : '';
40
41 echo $this->field_before();
42
43 echo '<div class="csf--inputs" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
44
45 if ( ! empty( $args['width'] ) ) {
46 $placeholder = ( ! empty( $args['width_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args['width_placeholder'] ) .'"' : '';
47 echo '<div class="csf--input">';
48 echo ( ! empty( $args['width_icon'] ) ) ? '<span class="csf--label csf--icon">'. $args['width_icon'] .'</span>' : '';
49 echo '<input type="number" name="'. esc_attr( $this->field_name( '[width]' ) ) .'" value="'. esc_attr( $value['width'] ) .'"'. $placeholder .' class="csf-input-number'. esc_attr( $is_unit ) .'" step="any" />';
50 echo ( ! empty( $unit ) ) ? '<span class="csf--label csf--unit">'. esc_attr( $args['units'][0] ) .'</span>' : '';
51 echo '</div>';
52 }
53
54 if ( ! empty( $args['height'] ) ) {
55 $placeholder = ( ! empty( $args['height_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args['height_placeholder'] ) .'"' : '';
56 echo '<div class="csf--input">';
57 echo ( ! empty( $args['height_icon'] ) ) ? '<span class="csf--label csf--icon">'. $args['height_icon'] .'</span>' : '';
58 echo '<input type="number" name="'. esc_attr( $this->field_name( '[height]' ) ) .'" value="'. esc_attr( $value['height'] ) .'"'. $placeholder .' class="csf-input-number'. esc_attr( $is_unit ) .'" step="any" />';
59 echo ( ! empty( $unit ) ) ? '<span class="csf--label csf--unit">'. esc_attr( $args['units'][0] ) .'</span>' : '';
60 echo '</div>';
61 }
62
63 if ( ! empty( $args['unit'] ) && ! empty( $args['show_units'] ) && count( $args['units'] ) > 1 ) {
64 echo '<div class="csf--input">';
65 echo '<select name="'. esc_attr( $this->field_name( '[unit]' ) ) .'">';
66 foreach ( $args['units'] as $unit ) {
67 $selected = ( $value['unit'] === $unit ) ? ' selected' : '';
68 echo '<option value="'. esc_attr( $unit ) .'"'. esc_attr( $selected ) .'>'. esc_attr( $unit ) .'</option>';
69 }
70 echo '</select>';
71 echo '</div>';
72 }
73
74 echo '</div>';
75
76 echo $this->field_after();
77
78 }
79
80 public function output() {
81
82 $output = '';
83 $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
84 $prefix = ( ! empty( $this->field['output_prefix'] ) ) ? $this->field['output_prefix'] .'-' : '';
85 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
86 $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
87 $width = ( isset( $this->value['width'] ) && $this->value['width'] !== '' ) ? $prefix .'width:'. $this->value['width'] . $unit . $important .';' : '';
88 $height = ( isset( $this->value['height'] ) && $this->value['height'] !== '' ) ? $prefix .'height:'. $this->value['height'] . $unit . $important .';' : '';
89
90 if ( $width !== '' || $height !== '' ) {
91 $output = $element .'{'. $width . $height .'}';
92 }
93
94 $this->parent->output_css .= $output;
95
96 return $output;
97
98 }
99
100 }
101 }
102