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

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

78 lines 2.5 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: slider
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'DarkifyField_slider' ) ) {
11 class DarkifyField_slider 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 'max' => 100,
23 'min' => 0,
24 'step' => 1,
25 'unit' => '',
26 )
27 );
28
29 $is_unit = ( ! empty( $args['unit'] ) ) ? ' darkify--is-unit' : '';
30
31 echo wp_kses_post( $this->field_before() );
32
33 echo '<div class="darkify--wrap">';
34 echo '<div class="darkify-slider-ui"></div>';
35 echo '<div class="darkify--input">';
36 echo '<input type="number" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '"' . wp_kses_post($this->field_attributes( array( 'class' => 'darkify-input-number' . esc_attr( $is_unit ) ) )) . ' data-min="' . esc_attr( $args['min'] ) . '" data-max="' . esc_attr( $args['max'] ) . '" data-step="' . esc_attr( $args['step'] ) . '" step="any" />';
37 echo ( ! empty( $args['unit'] ) ) ? '<span class="darkify--unit">' . esc_attr( $args['unit'] ) . '</span>' : '';
38 echo '</div>';
39 echo '</div>';
40
41 echo wp_kses_post( $this->field_after() );
42 }
43
44 public function enqueue() {
45
46 if ( ! wp_script_is( 'jquery-ui-slider' ) ) {
47 wp_enqueue_script( 'jquery-ui-slider' );
48 }
49 }
50
51 public function output() {
52
53 $output = '';
54 $elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
55 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
56 $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'width';
57 $unit = ( ! empty( $this->field['unit'] ) ) ? $this->field['unit'] : 'px';
58
59 if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
60 foreach ( $elements as $key_property => $element ) {
61 if ( is_numeric( $key_property ) ) {
62 if ( $mode ) {
63 $output = implode( ',', $elements ) . '{' . $mode . ':' . $this->value . $unit . $important . ';}';
64 }
65 break;
66 } else {
67 $output .= $element . '{' . $key_property . ':' . $this->value . $unit . $important . '}';
68 }
69 }
70 }
71
72 $this->parent->output_css .= $output;
73
74 return $output;
75 }
76 }
77 }
78