PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 2.25.0
Block Animations, Motion & Scroll Effects – Ghost Kit v2.25.0
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 2.25.0, at gutenberg/blocks/form/fields/number/block.php

88 lines 2.2 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 if ( ! function_exists( 'register_block_type' ) ) {
28 return;
29 }
30
31 register_block_type(
32 'ghostkit/form-field-number',
33 array(
34 'parent' => array( 'ghostkit/form' ),
35 'render_callback' => array( $this, 'block_render' ),
36 'attributes' => GhostKit_Form_Field_Attributes::get_block_attributes(
37 array(
38 'label' => array(
39 'default' => esc_html__( 'Number', 'ghostkit' ),
40 ),
41 'min' => array(
42 'type' => 'string',
43 ),
44 'max' => array(
45 'type' => 'string',
46 ),
47 'step' => array(
48 'type' => 'string',
49 ),
50 )
51 ),
52 )
53 );
54 }
55
56 /**
57 * Register gutenberg block output
58 *
59 * @param array $attributes - block attributes.
60 *
61 * @return string
62 */
63 public function block_render( $attributes ) {
64 ob_start();
65
66 $class = 'ghostkit-form-field ghostkit-form-field-number';
67
68 if ( isset( $attributes['className'] ) ) {
69 $class .= ' ' . $attributes['className'];
70 }
71
72 ?>
73
74 <div class="<?php echo esc_attr( $class ); ?>">
75 <?php GhostKit_Form_Field_Label::get( $attributes ); ?>
76
77 <input type="number" <?php GhostKit_Form_Field_Attributes::get( $attributes ); ?> />
78
79 <?php GhostKit_Form_Field_Description::get( $attributes ); ?>
80 </div>
81
82 <?php
83
84 return ob_get_clean();
85 }
86 }
87 new GhostKit_Form_Field_Number_Block();
88