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

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

123 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Form Field Email block.
4 *
5 * @package ghostkit
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 /**
13 * Class GhostKit_Form_Field_Email_Block
14 */
15 class GhostKit_Form_Field_Email_Block {
16 /**
17 * GhostKit_Form_Field_Email_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__( 'Email', 'ghostkit' ),
35 ),
36 'emailConfirmation' => array(
37 'type' => 'boolean',
38 ),
39 'descriptionConfirmation' => array(
40 'type' => 'string',
41 ),
42 'placeholderConfirmation' => array(
43 'type' => 'string',
44 ),
45 'defaultConfirmation' => array(
46 'type' => 'string',
47 ),
48 )
49 ),
50 )
51 );
52 }
53
54 /**
55 * Register gutenberg block output
56 *
57 * @param array $attributes - block attributes.
58 *
59 * @return string
60 */
61 public function block_render( $attributes ) {
62 $attributes = array_merge(
63 array(
64 'slug' => '',
65 'description' => '',
66 'descriptionConfirmation' => '',
67 'placeholderConfirmation' => '',
68 'defaultConfirmation' => '',
69 'emailConfirmation' => false,
70 'hideDescription' => false,
71 ),
72 $attributes
73 );
74
75 ob_start();
76
77 $class = 'ghostkit-form-field ghostkit-form-field-email';
78
79 if ( isset( $attributes['className'] ) ) {
80 $class .= ' ' . $attributes['className'];
81 }
82
83 $confirmation_attributes = array(
84 'slug' => $attributes['slug'],
85 'slug_sub' => 'validation',
86 'description' => $attributes['descriptionConfirmation'],
87 'placeholder' => $attributes['placeholderConfirmation'],
88 'default' => $attributes['defaultConfirmation'],
89 'hideDescription' => $attributes['hideDescription'],
90 );
91
92 ?>
93
94 <div class="<?php echo esc_attr( $class ); ?>">
95 <?php GhostKit_Form_Field_Label::get( $attributes ); ?>
96
97 <?php if ( $attributes['emailConfirmation'] ) : ?>
98 <div class="ghostkit-form-field-row">
99 <div class="ghostkit-form-field-email-primary">
100 <?php endif; ?>
101
102 <input type="email" <?php GhostKit_Form_Field_Attributes::get( $attributes ); ?> />
103
104 <?php GhostKit_Form_Field_Description::get( $attributes ); ?>
105
106 <?php if ( $attributes['emailConfirmation'] ) : ?>
107 </div>
108 <div class="ghostkit-form-field-email-confirm">
109 <input type="email" <?php GhostKit_Form_Field_Attributes::get( $confirmation_attributes ); ?> data-confirm-email="[name='<?php echo esc_attr( $attributes['slug'] ); ?>[value]']" />
110
111 <?php GhostKit_Form_Field_Description::get( $confirmation_attributes ); ?>
112 </div>
113 </div>
114 <?php endif; ?>
115 </div>
116
117 <?php
118
119 return ob_get_clean();
120 }
121 }
122 new GhostKit_Form_Field_Email_Block();
123