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 / phone / block.php

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

79 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Form Field Phone block.
4 *
5 * @package ghostkit
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 /**
13 * Class GhostKit_Form_Field_Phone_Block
14 */
15 class GhostKit_Form_Field_Phone_Block {
16 /**
17 * GhostKit_Form_Field_Phone_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-phone',
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__( 'Phone', 'ghostkit' ),
40 ),
41 )
42 ),
43 )
44 );
45 }
46
47 /**
48 * Register gutenberg block output
49 *
50 * @param array $attributes - block attributes.
51 *
52 * @return string
53 */
54 public function block_render( $attributes ) {
55 ob_start();
56
57 $class = 'ghostkit-form-field ghostkit-form-field-phone';
58
59 if ( isset( $attributes['className'] ) ) {
60 $class .= ' ' . $attributes['className'];
61 }
62
63 ?>
64
65 <div class="<?php echo esc_attr( $class ); ?>">
66 <?php GhostKit_Form_Field_Label::get( $attributes ); ?>
67
68 <input type="tel" <?php GhostKit_Form_Field_Attributes::get( $attributes ); ?> />
69
70 <?php GhostKit_Form_Field_Description::get( $attributes ); ?>
71 </div>
72
73 <?php
74
75 return ob_get_clean();
76 }
77 }
78 new GhostKit_Form_Field_Phone_Block();
79