PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.5.2
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.5.2
2.1.3 2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 trunk 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 All 57 releases
darkify / src / Admin / Framework / fields / button_set / button_set.php

button_set.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.5.2, at src/Admin/Framework/fields/button_set/button_set.php

68 lines 2.1 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: button_set
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'DarkifyField_button_set' ) ) {
11 class DarkifyField_button_set extends DarkifyFields {
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(
20 $this->field,
21 array(
22 'multiple' => false,
23 'options' => array(),
24 'query_args' => array(),
25 )
26 );
27
28 $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
29
30 echo wp_kses_post( $this->field_before() );
31
32 if ( isset( $this->field['options'] ) ) {
33
34 $options = $this->field['options'];
35 $options = ( is_array( $options ) ) ? $options : array_filter( $this->field_data( $options, false, $args['query_args'] ) );
36
37 if ( is_array( $options ) && ! empty( $options ) ) {
38
39 echo '<div class="darkify-siblings darkify--button-group" data-multiple="' . esc_attr( $args['multiple'] ) . '">';
40
41 foreach ( $options as $key => $option ) {
42
43 $type = ( $args['multiple'] ) ? 'checkbox' : 'radio';
44 $extra = ( $args['multiple'] ) ? '[]' : '';
45 $active = ( in_array( $key, $value ) || ( empty( $value ) && empty( $key ) ) ) ? ' darkify--active' : '';
46 $checked = ( in_array( $key, $value ) || ( empty( $value ) && empty( $key ) ) ) ? ' checked' : '';
47
48 echo '<div class="darkify--sibling darkify--button' . esc_attr( $active ) . '">';
49 echo '<input type="' . esc_attr( $type ) . '" name="' . esc_attr( $this->field_name( $extra ) ) . '" value="' . esc_attr( $key ) . '"' . wp_kses_post( $this->field_attributes() ) . esc_attr( $checked ) . '/>';
50 echo esc_html($option);
51 echo '</div>';
52
53 }
54
55 echo '</div>';
56
57 } else {
58
59 echo ( ! empty( $this->field['empty_message'] ) ) ? esc_attr( $this->field['empty_message'] ) : esc_html__( 'No data available.', 'darkify' );
60
61 }
62 }
63
64 echo wp_kses_post( $this->field_after() );
65 }
66 }
67 }
68