PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.2
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.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 4.0.2, at admin/views/sp-framework/fields/checkbox/checkbox.php

99 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The framework checkbox 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_checkbox' ) ) {
14 /**
15 * SP_PC_Field_checkbox
16 */
17 class SP_PC_Field_checkbox extends SP_PC_Fields {
18
19 /**
20 * The checkbox 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 of the field.
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 $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
54 $options = $this->field['options'];
55 $options = ( is_array( $options ) ) ? $options : array_filter( $this->field_data( $options, false, $args['query_args'] ) );
56
57 if ( is_array( $options ) && ! empty( $options ) ) {
58
59 echo '<ul' . wp_kses_post( $inline_class ) . '>';
60 foreach ( $options as $option_key => $pcp_metabox_value ) {
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 = ( in_array( $sub_key, $value ) ) ? ' checked' : '';
68 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>';
69 }
70 echo '</ul>';
71 echo '</li>';
72
73 } else {
74
75 $checked = ( in_array( $option_key, $value ) ) ? ' checked' : '';
76 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>';
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 echo '<label class="spf-checkbox">';
89 echo '<input type="hidden" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '" class="spf--input"' . wp_kses_post( $this->field_attributes() ) . '/>';
90 echo '<input type="checkbox" name="_pseudo" class="spf--checkbox"' . checked( $this->value, 1, false ) . '/>';
91 echo ( ! empty( $this->field['label'] ) ) ? ' ' . esc_html( $this->field['label'] ) : '';
92 echo '</label>';
93 }
94
95 echo wp_kses_post( $this->field_after() );
96 }
97 }
98 }
99