PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.4.0
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.4.0
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 / spinner / spinner.php

spinner.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 2.4.0, at admin/views/sp-framework/fields/spinner/spinner.php

82 lines 2.3 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: spinner
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'SP_PC_Field_spinner' ) ) {
11 class SP_PC_Field_spinner extends SP_PC_Fields {
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 echo wp_kses_post( $this->field_before() );
30 echo '<div class="spf--spin"><input type="number" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '"' . wp_kses_post( $this->field_attributes( array( 'class' => 'spf-input-number' ) ) ) . ' data-max="' . esc_attr( $args['max'] ) . '" data-min="' . esc_attr( $args['min'] ) . '" data-step="' . esc_attr( $args['step'] ) . '" data-unit="' . esc_attr( $args['unit'] ) . '"/></div>';
31 echo wp_kses_post( $this->field_after() );
32
33 }
34
35 /**
36 * Enqueue jQuery UI Spinner.
37 *
38 * @return void
39 */
40 public function enqueue() {
41
42 if ( ! wp_script_is( 'jquery-ui-spinner' ) ) {
43 wp_enqueue_script( 'jquery-ui-spinner' );
44 }
45
46 }
47
48 /**
49 * The output method.
50 *
51 * @return mixed
52 */
53 public function output() {
54
55 $output = '';
56 $elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
57 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
58 $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'width';
59 $unit = ( ! empty( $this->field['unit'] ) ) ? $this->field['unit'] : 'px';
60
61 if ( ! empty( $elements ) && isset( $this->value ) && '' !== $this->value ) {
62 foreach ( $elements as $key_property => $element ) {
63 if ( is_numeric( $key_property ) ) {
64 if ( $mode ) {
65 $output = implode( ',', $elements ) . '{' . $mode . ':' . $this->value . $unit . $important . ';}';
66 }
67 break;
68 } else {
69 $output .= $element . '{' . $key_property . ':' . $this->value . $unit . $important . '}';
70 }
71 }
72 }
73
74 $this->parent->output_css .= $output;
75
76 return $output;
77
78 }
79
80 }
81 }
82