PluginProbe
Cool Timeline (Horizontal & Vertical Timeline) / trunk
Cool Timeline (Horizontal & Vertical Timeline) vtrunk
3.4.0 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 2.2.3 2.3.3 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.6.1 2.7.1 2.8.3 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 All 79 releases
cool-timeline / admin / codestar-framework / fields / number / number.php

number.php in Cool Timeline (Horizontal & Vertical Timeline) trunk, at admin/codestar-framework/fields/number/number.php

65 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 // phpcs:ignoreFile WordPress.Security.EscapeOutput.OutputNotEscaped
3 /**
4 *
5 * Field: number
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 *
10 */
11 if ( ! class_exists( 'CSF_Field_number' ) ) {
12 class CSF_Field_number extends CSF_Fields {
13
14 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
15 parent::__construct( $field, $value, $unique, $where, $parent );
16 }
17
18 public function render() {
19
20 $args = wp_parse_args( $this->field, array(
21 'min' => 'any',
22 'max' => 'any',
23 'step' => 'any',
24 'unit' => '',
25 ) );
26
27 echo $this->field_before();
28 echo '<div class="csf--wrap">';
29 echo '<input type="number" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes() .' min="'. esc_attr( $args['min'] ) .'" max="'. esc_attr( $args['max'] ) .'" step="'. esc_attr( $args['step'] ) .'"/>';
30 echo ( ! empty( $args['unit'] ) ) ? '<span class="csf--unit">'. esc_attr( $args['unit'] ) .'</span>' : '';
31 echo '</div>';
32 echo $this->field_after();
33
34 }
35
36 public function output() {
37
38 $output = '';
39 $elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
40 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
41 $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'width';
42 $unit = ( ! empty( $this->field['unit'] ) ) ? $this->field['unit'] : 'px';
43
44 if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
45 foreach ( $elements as $key_property => $element ) {
46 if ( is_numeric( $key_property ) ) {
47 if ( $mode ) {
48 $output = implode( ',', $elements ) .'{'. $mode .':'. $this->value . $unit . $important .';}';
49 }
50 break;
51 } else {
52 $output .= $element .'{'. $key_property .':'. $this->value . $unit . $important .'}';
53 }
54 }
55 }
56
57 $this->parent->output_css .= $output;
58
59 return $output;
60
61 }
62
63 }
64 }
65