PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.5.3
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.5.3
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 / switcher / switcher.php

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

39 lines 1.6 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: switcher
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'DarkifyField_switcher' ) ) {
11 class DarkifyField_switcher 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 $active = ( ! empty( $this->value ) ) ? ' darkify--active' : '';
20 $text_on = ( ! empty( $this->field['text_on'] ) ) ? $this->field['text_on'] : esc_html__( 'On', 'darkify' );
21 $text_off = ( ! empty( $this->field['text_off'] ) ) ? $this->field['text_off'] : esc_html__( 'Off', 'darkify' );
22 $text_width = ( ! empty( $this->field['text_width'] ) ) ? ' style="width: ' . esc_attr( $this->field['text_width'] ) . 'px;"' : '';
23
24 echo wp_kses_post( $this->field_before() );
25
26 echo '<div class="darkify--switcher' . esc_attr( $active ) . '"' . wp_kses_post($text_width) . '>';
27 echo '<span class="darkify--on">' . esc_attr( $text_on ) . '</span>';
28 echo '<span class="darkify--off">' . esc_attr( $text_off ) . '</span>';
29 echo '<span class="darkify--ball"></span>';
30 echo '<input type="hidden" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '"' . wp_kses_post( $this->field_attributes() ) . ' />';
31 echo '</div>';
32
33 echo ( ! empty( $this->field['label'] ) ) ? '<span class="darkify--label">' . esc_attr( $this->field['label'] ) . '</span>' : '';
34
35 echo wp_kses_post( $this->field_after() );
36 }
37 }
38 }
39