PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 1.1.0
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v1.1.0
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 / checkbox-markup.php

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

77 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * SureDonation Checkbox 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 /**
16 * Checkbox Markup Class.
17 *
18 * @since 0.0.1
19 */
20 class Checkbox_Markup extends Base {
21 /**
22 * Initialize the properties based on block attributes.
23 *
24 * @param array<string, mixed> $attributes Block attributes.
25 * @since 0.0.1
26 */
27 public function __construct( $attributes ) {
28 $this->slug = 'checkbox';
29
30 $this->set_properties( $attributes );
31 $this->set_unique_slug();
32 $this->set_markup_properties();
33 }
34
35 /**
36 * Render checkbox markup
37 *
38 * @since 0.0.1
39 * @return string
40 */
41 public function markup() {
42 $classes = $this->get_field_classes();
43 $aria_desc = $this->get_aria_describedby();
44 $required_mark = $this->required ? '<span class="sd-required" aria-hidden="true">*</span>' : '';
45
46 ob_start();
47 ?>
48 <div data-block-id="<?php echo esc_attr( $this->block_id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
49 <div class="sd-block-wrap sd-checkbox-wrap">
50 <label class="sd-checkbox-label" for="<?php echo esc_attr( $this->unique_slug ); ?>">
51 <input
52 class="sd-input-checkbox"
53 type="checkbox"
54 name="<?php echo esc_attr( $this->field_name ); ?>"
55 id="<?php echo esc_attr( $this->unique_slug ); ?>"
56 value="1"
57 <?php if ( ! empty( $aria_desc ) ) { ?>
58 aria-describedby="<?php echo esc_attr( $aria_desc ); ?>"
59 <?php } ?>
60 data-required="<?php echo esc_attr( $this->data_require_attr ); ?>"
61 aria-required="<?php echo esc_attr( $this->data_require_attr ); ?>"
62 <?php echo esc_attr( $this->checked_attr ); ?>
63 />
64 <span class="sd-checkbox-text">
65 <?php echo wp_kses_post( $this->label ); ?>
66 <?php echo wp_kses_post( $required_mark ); ?>
67 </span>
68 </label>
69 </div>
70 <?php echo wp_kses_post( $this->help_markup ); ?>
71 <div class="sd-error-wrap"><?php echo wp_kses_post( $this->error_msg_markup ); ?></div>
72 </div>
73 <?php
74 return (string) ob_get_clean();
75 }
76 }
77