PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.3
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.3
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / admin / views / sp-framework / fields / radio / radio.php

radio.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.3, at admin/views/sp-framework/fields/radio/radio.php

96 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The framework radio fields file.
4 *
5 * @package Smart_Post_Show
6 * @subpackage Smart_Post_Show/admin
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 die;
11 } // Cannot access directly.
12
13 if ( ! class_exists( 'SP_PC_Field_radio' ) ) {
14 /**
15 * SP_PC_Field_radio
16 */
17 class SP_PC_Field_radio extends SP_PC_Fields {
18
19 /**
20 * The radio field constructor.
21 *
22 * @param string $field The field type.
23 * @param string $value The field value.
24 * @param string $unique The unique ID.
25 * @param string $where The place to show the field.
26 * @param string $parent If it has any parent.
27 */
28 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
29 parent::__construct( $field, $value, $unique, $where, $parent );
30 }
31
32 /**
33 * The render function.
34 *
35 * @return void
36 */
37 public function render() {
38
39 $args = wp_parse_args(
40 $this->field,
41 array(
42 'inline' => false,
43 'query_args' => array(),
44 )
45 );
46
47 $inline_class = ( $args['inline'] ) ? ' class="spf--inline-list"' : '';
48
49 echo wp_kses_post( $this->field_before() );
50
51 if ( isset( $this->field['options'] ) ) {
52
53 $options = $this->field['options'];
54 $options = ( is_array( $options ) ) ? $options : array_filter( $this->field_data( $options, false, $args['query_args'] ) );
55
56 if ( is_array( $options ) && ! empty( $options ) ) {
57
58 echo '<ul' . wp_kses_post( $inline_class ) . '>';
59 foreach ( $options as $option_key => $pcp_metabox_value ) {
60
61 if ( is_array( $pcp_metabox_value ) && ! empty( $pcp_metabox_value ) ) {
62
63 echo '<li>';
64 echo '<ul>';
65 echo '<li><strong>' . esc_html( $option_key ) . '</strong></li>';
66 foreach ( $pcp_metabox_value as $sub_key => $sub_value ) {
67 $checked = ( $sub_key == $this->value ) ? ' checked' : '';
68 echo '<li><label><input type="radio" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $sub_key ) . '"' . wp_kses_post( $this->field_attributes() ) . esc_attr( $checked ) . '/> ' . wp_kses_post( $sub_value ) . '</label></li>';
69 }
70 echo '</ul>';
71 echo '</li>';
72
73 } else {
74
75 $checked = ( $option_key == $this->value ) ? ' checked' : '';
76 echo '<li><label><input type="radio" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $option_key ) . '"' . wp_kses_post( $this->field_attributes() ) . esc_attr( $checked ) . '/> ' . esc_html( $pcp_metabox_value ) . '</label></li>';
77
78 }
79 }
80 echo '</ul>';
81
82 } else {
83
84 echo ( esc_html( ! empty( $this->field['empty_message'] ) ) ) ? esc_html( $this->field['empty_message'] ) : esc_html__( 'No data provided for this option type.', 'post-carousel' );
85
86 }
87 } else {
88 $label = ( isset( $this->field['label'] ) ) ? $this->field['label'] : '';
89 echo '<label><input type="radio" name="' . esc_attr( $this->field_name() ) . '" value="1"' . wp_kses_post( $this->field_attributes() . checked( $this->value, 1, false ) ) . '/> ' . esc_html( $label ) . '</label>';
90 }
91
92 echo wp_kses_post( $this->field_after() );
93 }
94 }
95 }
96