PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.3
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.3
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / blocks / form / fields / number / block.php

block.php in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.3, at gutenberg/blocks/form/fields/number/block.php

83 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Form Field Number block.
4 *
5 * @package ghostkit
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 /**
13 * Class GhostKit_Form_Field_Number_Block
14 */
15 class GhostKit_Form_Field_Number_Block {
16 /**
17 * GhostKit_Form_Field_Number_Block constructor.
18 */
19 public function __construct() {
20 add_action( 'init', array( $this, 'init' ) );
21 }
22
23 /**
24 * Init.
25 */
26 public function init() {
27 register_block_type_from_metadata(
28 dirname( __FILE__ ),
29 array(
30 'render_callback' => array( $this, 'block_render' ),
31 'attributes' => GhostKit_Form_Field_Attributes::get_block_attributes(
32 array(
33 'label' => array(
34 'default' => esc_html__( 'Number', 'ghostkit' ),
35 ),
36 'min' => array(
37 'type' => 'string',
38 ),
39 'max' => array(
40 'type' => 'string',
41 ),
42 'step' => array(
43 'type' => 'string',
44 ),
45 )
46 ),
47 )
48 );
49 }
50
51 /**
52 * Register gutenberg block output
53 *
54 * @param array $attributes - block attributes.
55 *
56 * @return string
57 */
58 public function block_render( $attributes ) {
59 ob_start();
60
61 $class = 'ghostkit-form-field ghostkit-form-field-number';
62
63 if ( isset( $attributes['className'] ) ) {
64 $class .= ' ' . $attributes['className'];
65 }
66
67 ?>
68
69 <div class="<?php echo esc_attr( $class ); ?>">
70 <?php GhostKit_Form_Field_Label::get( $attributes ); ?>
71
72 <input type="number" <?php GhostKit_Form_Field_Attributes::get( $attributes ); ?> />
73
74 <?php GhostKit_Form_Field_Description::get( $attributes ); ?>
75 </div>
76
77 <?php
78
79 return ob_get_clean();
80 }
81 }
82 new GhostKit_Form_Field_Number_Block();
83