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 / image_select / image_select.php

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

80 lines 2.6 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: image_select
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'STREAMCAST_STREAMCAST_CSF_Field_image_select' ) ) {
11 class STREAMCAST_STREAMCAST_CSF_Field_image_select 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 'multiple' => false,
21 'inline' => false,
22 'options' => array(),
23 ) );
24
25 $inline = ( $args['inline'] ) ? ' streamcast-csf--inline-list' : '';
26
27 $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
28
29 echo wp_kses_post( $this->field_before() );
30
31 if ( ! empty( $args['options'] ) ) {
32
33 echo '<div class="streamcast-csf-siblings streamcast-csf--image-group'. esc_attr( $inline ) .'" data-multiple="'. esc_attr( $args['multiple'] ) .'">';
34
35 $num = 1;
36
37 foreach ( $args['options'] as $key => $option ) {
38
39 $type = ( $args['multiple'] ) ? 'checkbox' : 'radio';
40 $extra = ( $args['multiple'] ) ? '[]' : '';
41 $active = ( in_array( $key, $value ) ) ? ' streamcast-csf--active' : '';
42 $checked = ( in_array( $key, $value ) ) ? ' checked' : '';
43
44 echo '<div class="streamcast-csf--sibling streamcast-csf--image'. esc_attr( $active ) .'">';
45 echo '<figure>';
46 echo '<img src="'. esc_url( $option ) .'" alt="img-'. esc_attr( $num++ ) .'" />';
47 echo '<input type="'. esc_attr( $type ) .'" name="'. esc_attr( $this->field_name( $extra ) ) .'" value="'. esc_attr( $key ) .'"'. $this->field_attributes() . esc_attr( $checked ) .'/>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
48 echo '</figure>';
49 echo '</div>';
50
51 }
52
53 echo '</div>';
54
55 }
56
57 echo wp_kses_post( $this->field_after() );
58
59 }
60
61 public function output() {
62
63 $output = '';
64 $bg_image = array();
65 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
66 $elements = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
67
68 if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
69 $output = $elements .'{background-image:url('. $this->value .')'. $important .';}';
70 }
71
72 $this->parent->output_css .= $output;
73
74 return $output;
75
76 }
77
78 }
79 }
80