PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4.1
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4.1
4.3.2 4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 All 165 releases
← All changes | Libs/adminify-framework/fields/slider/slider.php +54 -57 4.2.113.2.4.1 View file →
@@ -1,5 +1,6 @@
1 -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
1 +<?php if ( ! defined( 'ABSPATH' ) ) {
2 + die; } // Cannot access directly.
2 3 /**
3 4 *
4 5 * Field: slider
5 6 *
@@ -4,75 +5,71 @@
4 5 * Field: slider
5 6 *
6 7 * @since 1.0.0
7 8 * @version 1.0.0
8 - *
9 9 */
10 10 if ( ! class_exists( 'ADMINIFY_Field_slider' ) ) {
11 - class ADMINIFY_Field_slider extends ADMINIFY_Fields {
11 + class ADMINIFY_Field_slider extends ADMINIFY_Fields {
12 12
13 - public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 - parent::__construct( $field, $value, $unique, $where, $parent );
15 - }
13 + public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 + parent::__construct( $field, $value, $unique, $where, $parent );
15 + }
16 16
17 - public function render() {
17 + public function render() {
18 + $args = wp_parse_args(
19 + $this->field,
20 + [
21 + 'max' => 100,
22 + 'min' => 0,
23 + 'step' => 1,
24 + 'unit' => '',
25 + ]
26 + );
18 27
19 - $args = wp_parse_args( $this->field, array(
20 - 'max' => 100,
21 - 'min' => 0,
22 - 'step' => 1,
23 - 'unit' => '',
24 - ) );
28 + $is_unit = ( ! empty( $args['unit'] ) ) ? ' adminify--is-unit' : '';
25 29
26 - $is_unit = ( ! empty( $args['unit'] ) ) ? ' adminify--is-unit' : '';
30 + echo wp_kses_post( $this->field_before() );
27 31
28 - echo wp_kses_post( $this->field_before() );
32 + echo '<div class="adminify--wrap">';
33 + echo '<div class="adminify-slider-ui"></div>';
34 + echo '<div class="adminify--input">';
35 + echo '<input type="number" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '"' . wp_kses_post( $this->field_attributes( [ 'class' => 'adminify-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" />';
36 + echo ( ! empty( $args['unit'] ) ) ? '<span class="adminify--unit">' . esc_attr( $args['unit'] ) . '</span>' : '';
37 + echo '</div>';
38 + echo '</div>';
29 39
30 - echo '<div class="adminify--wrap">';
31 - echo '<div class="adminify-slider-ui"></div>';
32 - echo '<div class="adminify--input">';
33 - echo '<input type="number" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes( array( 'class' => 'adminify-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" />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- field_attributes() escapes each attribute via esc_attr()
34 - echo ( ! empty( $args['unit'] ) ) ? '<span class="adminify--unit">'. esc_attr( $args['unit'] ) .'</span>' : '';
35 - echo '</div>';
36 - echo '</div>';
40 + echo wp_kses_post( $this->field_after() );
41 + }
37 42
38 - echo wp_kses_post( $this->field_after() );
43 + public function enqueue() {
44 + if ( ! wp_script_is( 'jquery-ui-slider' ) ) {
45 + wp_enqueue_script( 'jquery-ui-slider' );
46 + }
47 + }
39 48
40 - }
49 + public function output() {
50 + $output = '';
51 + $elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
52 + $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
53 + $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'width';
54 + $unit = ( ! empty( $this->field['unit'] ) ) ? $this->field['unit'] : 'px';
41 55
42 - public function enqueue() {
56 + if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
57 + foreach ( $elements as $key_property => $element ) {
58 + if ( is_numeric( $key_property ) ) {
59 + if ( $mode ) {
60 + $output = implode( ',', $elements ) . '{' . $mode . ':' . $this->value . $unit . $important . ';}';
61 + }
62 + break;
63 + } else {
64 + $output .= $element . '{' . $key_property . ':' . $this->value . $unit . $important . '}';
65 + }
66 + }
67 + }
43 68
44 - if ( ! wp_script_is( 'jquery-ui-slider' ) ) {
45 - wp_enqueue_script( 'jquery-ui-slider' );
46 - }
69 + $this->parent->output_css .= $output;
47 70
48 - }
71 + return $output;
72 + }
49 73
50 - public function output() {
51 -
52 - $output = '';
53 - $elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
54 - $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
55 - $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'width';
56 - $unit = ( ! empty( $this->field['unit'] ) ) ? $this->field['unit'] : 'px';
57 -
58 - if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
59 - foreach ( $elements as $key_property => $element ) {
60 - if ( is_numeric( $key_property ) ) {
61 - if ( $mode ) {
62 - $output = implode( ',', $elements ) .'{'. $mode .':'. $this->value . $unit . $important .';}';
63 - }
64 - break;
65 - } else {
66 - $output .= $element .'{'. $key_property .':'. $this->value . $unit . $important .'}';
67 - }
68 - }
69 - }
70 -
71 - $this->parent->output_css .= $output;
72 -
73 - return $output;
74 -
75 - }
76 -
77 - }
74 + }
78 75 }