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

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

90 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * SureDonation Url Markup Class.
4 *
5 * @package SureDonation
6 * @since 1.1.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 * Url Markup Class.
19 *
20 * @since 1.1.1
21 */
22 class Url_Markup extends Base {
23 /**
24 * Invalid URL error message.
25 *
26 * @var string
27 * @since 1.1.1
28 */
29 protected $invalid_url_msg = '';
30
31 /**
32 * Initialize the properties based on block attributes.
33 *
34 * @param array<string, mixed> $attributes Block attributes.
35 * @since 1.1.1
36 */
37 public function __construct( $attributes ) {
38 $this->slug = 'url';
39
40 $invalid_url_msg = isset( $attributes['invalidUrlMsg'] ) ? Helper::get_string_value( $attributes['invalidUrlMsg'] ) : '';
41 $this->invalid_url_msg = '' !== $invalid_url_msg ? $invalid_url_msg : __( 'Please enter a valid URL.', 'suredonation' );
42
43 $this->set_properties( $attributes );
44 $this->set_unique_slug();
45 $this->set_markup_properties();
46 }
47
48 /**
49 * Render url markup
50 *
51 * @since 1.1.1
52 * @return string
53 */
54 public function markup() {
55 $classes = $this->get_field_classes();
56 $aria_desc = $this->get_aria_describedby();
57
58 ob_start();
59 ?>
60 <div data-block-id="<?php echo esc_attr( $this->block_id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
61 <?php echo wp_kses_post( $this->label_markup ); ?>
62 <?php echo wp_kses_post( $this->help_markup ); ?>
63 <div class="sd-block-wrap">
64 <input
65 class="sd-input-common sd-input-<?php echo esc_attr( $this->slug ); ?>"
66 type="url"
67 name="<?php echo esc_attr( $this->field_name ); ?>"
68 id="<?php echo esc_attr( $this->unique_slug ); ?>"
69 data-slug="<?php echo esc_attr( $this->block_slug ? $this->block_slug : $this->unique_slug ); ?>"
70 <?php if ( ! empty( $aria_desc ) ) { ?>
71 aria-describedby="<?php echo esc_attr( $aria_desc ); ?>"
72 <?php } ?>
73 data-required="<?php echo esc_attr( $this->data_require_attr ); ?>"
74 aria-required="<?php echo esc_attr( $this->data_require_attr ); ?>"
75 data-invalid-url-msg="<?php echo esc_attr( $this->invalid_url_msg ); ?>"
76 <?php if ( '' !== $this->default ) { ?>
77 value="<?php echo esc_attr( $this->default ); ?>"
78 <?php } ?>
79 <?php if ( '' !== $this->placeholder ) { ?>
80 placeholder="<?php echo esc_attr( $this->placeholder ); ?>"
81 <?php } ?>
82 />
83 </div>
84 <div class="sd-error-wrap"><?php echo wp_kses_post( $this->error_msg_markup ); ?></div>
85 </div>
86 <?php
87 return (string) ob_get_clean();
88 }
89 }
90