PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.4.2
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.4.2
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 / checkbox / checkbox.php

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

95 lines 3.2 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: checkbox
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'SP_PC_Field_checkbox' ) ) {
11 class SP_PC_Field_checkbox extends SP_PC_Fields {
12
13 /**
14 * The checkbox field constructor.
15 *
16 * @param string $field The field type.
17 * @param string $value The field value.
18 * @param string $unique The unique ID.
19 * @param string $where The place to show the field.
20 * @param string $parent If it has any parent.
21 */
22 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
23 parent::__construct( $field, $value, $unique, $where, $parent );
24 }
25
26 /**
27 * The render of the field.
28 *
29 * @return void
30 */
31 public function render() {
32
33 $args = wp_parse_args(
34 $this->field,
35 array(
36 'inline' => false,
37 'query_args' => array(),
38 )
39 );
40
41 $inline_class = ( $args['inline'] ) ? ' class="spf--inline-list"' : '';
42
43 echo wp_kses_post( $this->field_before() );
44
45 if ( isset( $this->field['options'] ) ) {
46
47 $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
48 $options = $this->field['options'];
49 $options = ( is_array( $options ) ) ? $options : array_filter( $this->field_data( $options, false, $args['query_args'] ) );
50
51 if ( is_array( $options ) && ! empty( $options ) ) {
52
53 echo '<ul' . wp_kses_post( $inline_class ) . '>';
54 foreach ( $options as $option_key => $pcp_metabox_value ) {
55 if ( is_array( $pcp_metabox_value ) && ! empty( $pcp_metabox_value ) ) {
56
57 echo '<li>';
58 echo '<ul>';
59 echo '<li><strong>' . esc_html( $option_key ) . '</strong></li>';
60 foreach ( $pcp_metabox_value as $sub_key => $sub_value ) {
61 $checked = ( in_array( $sub_key, $value ) ) ? ' checked' : '';
62 echo '<li><label><input type="checkbox" name="' . esc_attr( $this->field_name( '[]' ) ) . '" value="' . esc_attr( $sub_key ) . '"' . wp_kses_post( $this->field_attributes() ) . esc_attr( $checked ) . '/> ' . esc_html( $sub_value ) . '</label></li>';
63 }
64 echo '</ul>';
65 echo '</li>';
66
67 } else {
68
69 $checked = ( in_array( $option_key, $value ) ) ? ' checked' : '';
70 echo '<li><label><input type="checkbox" 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>';
71
72 }
73 }
74 echo '</ul>';
75
76 } else {
77
78 echo ( esc_html( ! empty( $this->field['empty_message'] ) ) ) ? esc_html( $this->field['empty_message'] ) : esc_html__( 'No data provided for this option type.', 'smart-post-show' );
79
80 }
81 } else {
82 echo '<label class="spf-checkbox">';
83 echo '<input type="hidden" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '" class="spf--input"' . wp_kses_post( $this->field_attributes() ) . '/>';
84 echo '<input type="checkbox" name="_pseudo" class="spf--checkbox"' . checked( $this->value, 1, false ) . '/>';
85 echo ( ! empty( $this->field['label'] ) ) ? ' ' . esc_html( $this->field['label'] ) : '';
86 echo '</label>';
87 }
88
89 echo wp_kses_post( $this->field_after() );
90
91 }
92
93 }
94 }
95