| 1 |
<?php |
| 2 |
/** |
| 3 |
* Framework slider field. |
| 4 |
* |
| 5 |
* @link https://shapedplugin.com/ |
| 6 |
* |
| 7 |
* @package Smart_Post_Show |
| 8 |
* @subpackage Smart_Post_Show/admin/views |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
die; |
| 13 |
} // Cannot access directly. |
| 14 |
|
| 15 |
if ( ! class_exists( 'SP_PC_Field_slider' ) ) { |
| 16 |
/** |
| 17 |
* |
| 18 |
* Field: slider |
| 19 |
* |
| 20 |
* @since 1.0.0 |
| 21 |
* @version 1.0.0 |
| 22 |
*/ |
| 23 |
class SP_PC_Field_slider extends SP_PC_Fields { |
| 24 |
|
| 25 |
/** |
| 26 |
* Field constructor. |
| 27 |
* |
| 28 |
* @param array $field The field type. |
| 29 |
* @param string $value The values of the field. |
| 30 |
* @param string $unique The unique ID for the field. |
| 31 |
* @param string $where To where show the output CSS. |
| 32 |
* @param string $parent The parent args. |
| 33 |
*/ |
| 34 |
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) { |
| 35 |
parent::__construct( $field, $value, $unique, $where, $parent ); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Render |
| 40 |
* |
| 41 |
* @return void |
| 42 |
*/ |
| 43 |
public function render() { |
| 44 |
|
| 45 |
$args = wp_parse_args( |
| 46 |
$this->field, |
| 47 |
array( |
| 48 |
'max' => 100, |
| 49 |
'min' => 0, |
| 50 |
'step' => 1, |
| 51 |
'unit' => '', |
| 52 |
) |
| 53 |
); |
| 54 |
|
| 55 |
$is_unit = ( ! empty( $args['unit'] ) ) ? ' spf--is-unit' : ''; |
| 56 |
|
| 57 |
echo wp_kses_post( $this->field_before() ); |
| 58 |
|
| 59 |
echo '<div class="spf--wrap">'; |
| 60 |
echo '<div class="spf-slider-ui"></div>'; |
| 61 |
echo '<div class="spf--input">'; |
| 62 |
echo '<input type="number" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '"' . $this->field_attributes( array( 'class' => 'spf-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 |
| 63 |
echo ( ! empty( $args['unit'] ) ) ? '<span class="spf--unit">' . esc_attr( $args['unit'] ) . '</span>' : ''; |
| 64 |
echo '</div>'; |
| 65 |
echo '</div>'; |
| 66 |
|
| 67 |
echo wp_kses_post( $this->field_after() ); |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Enqueue |
| 72 |
* |
| 73 |
* @return void |
| 74 |
*/ |
| 75 |
public function enqueue() { |
| 76 |
|
| 77 |
if ( ! wp_script_is( 'jquery-ui-slider' ) ) { |
| 78 |
wp_enqueue_script( 'jquery-ui-slider' ); |
| 79 |
} |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
|