PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 0.0.1
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v0.0.1
1.6.0 1.5.1 1.5.0 1.4.0 1.3.0 trunk 0.0.1 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0
suredonation / inc / fields / input-markup.php

input-markup.php in SureDonation – Donation Forms, Fundraising Campaigns & Donor Management 0.0.1, at inc/fields/input-markup.php

88 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * SureDonation Input Markup Class.
4 *
5 * @package SureDonation
6 * @since 0.0.1
7 */
8
9 namespace SureDonation\Inc\Fields;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 use SureDonation\Inc\Helper;
16
17 /**
18 * Input Markup Class.
19 *
20 * @since 0.0.1
21 */
22 class Input_Markup extends Base {
23 /**
24 * Maximum length of text allowed for an input field.
25 *
26 * @var int
27 * @since 0.0.1
28 */
29 protected $max_length = 100;
30
31 /**
32 * Initialize the properties based on block attributes.
33 *
34 * @param array<string, mixed> $attributes Block attributes.
35 * @since 0.0.1
36 */
37 public function __construct( $attributes ) {
38 $this->slug = 'input';
39 $this->max_length = isset( $attributes['maxLength'] ) ? absint( Helper::get_string_value( $attributes['maxLength'] ) ) : 100;
40
41 $this->set_properties( $attributes );
42 $this->set_unique_slug();
43 $this->set_markup_properties();
44 }
45
46 /**
47 * Render input markup
48 *
49 * @since 0.0.1
50 * @return string
51 */
52 public function markup() {
53 $classes = $this->get_field_classes();
54 $aria_desc = $this->get_aria_describedby();
55
56 ob_start();
57 ?>
58 <div data-block-id="<?php echo esc_attr( $this->block_id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
59 <?php echo wp_kses_post( $this->label_markup ); ?>
60 <?php echo wp_kses_post( $this->help_markup ); ?>
61 <div class="sd-block-wrap">
62 <input
63 class="sd-input-common sd-input-<?php echo esc_attr( $this->slug ); ?>"
64 type="text"
65 name="<?php echo esc_attr( $this->field_name ); ?>"
66 id="<?php echo esc_attr( $this->unique_slug ); ?>"
67 data-slug="<?php echo esc_attr( $this->block_slug ? $this->block_slug : $this->unique_slug ); ?>"
68 <?php if ( ! empty( $aria_desc ) ) { ?>
69 aria-describedby="<?php echo esc_attr( $aria_desc ); ?>"
70 <?php } ?>
71 data-required="<?php echo esc_attr( $this->data_require_attr ); ?>"
72 aria-required="<?php echo esc_attr( $this->data_require_attr ); ?>"
73 maxlength="<?php echo esc_attr( (string) $this->max_length ); ?>"
74 <?php if ( '' !== $this->default ) { ?>
75 value="<?php echo esc_attr( $this->default ); ?>"
76 <?php } ?>
77 <?php if ( '' !== $this->placeholder ) { ?>
78 placeholder="<?php echo esc_attr( $this->placeholder ); ?>"
79 <?php } ?>
80 />
81 </div>
82 <?php echo wp_kses_post( $this->error_msg_markup ); ?>
83 </div>
84 <?php
85 return (string) ob_get_clean();
86 }
87 }
88