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

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

79 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 Textarea block.
4 *
5 * @package ghostkit
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 /**
13 * Class GhostKit_Form_Field_Textarea_Block
14 */
15 class GhostKit_Form_Field_Textarea_Block {
16 /**
17 * GhostKit_Form_Field_Textarea_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__( 'Textarea', 'ghostkit' ),
35 ),
36 )
37 ),
38 )
39 );
40 }
41
42 /**
43 * Register gutenberg block output
44 *
45 * @param array $attributes - block attributes.
46 *
47 * @return string
48 */
49 public function block_render( $attributes ) {
50 ob_start();
51
52 $class = 'ghostkit-form-field ghostkit-form-field-textarea';
53
54 if ( isset( $attributes['className'] ) ) {
55 $class .= ' ' . $attributes['className'];
56 }
57
58 $attrs_without_default = $attributes;
59 unset( $attrs_without_default['default'] );
60
61 $default = isset( $attributes['default'] ) ? $attributes['default'] : '';
62
63 ?>
64
65 <div class="<?php echo esc_attr( $class ); ?>">
66 <?php GhostKit_Form_Field_Label::get( $attributes ); ?>
67
68 <textarea <?php GhostKit_Form_Field_Attributes::get( $attributes ); ?>><?php echo esc_html( $default ); ?></textarea>
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_Textarea_Block();
79