| @@ -17,9 +17,8 @@ | ||
| 17 | 17 | * |
| 18 | 18 | * @since 0.0.1 |
| 19 | 19 | */ |
| 20 | 20 | class Checkbox_Markup extends Base { |
| 21 | - | |
| 22 | 21 | /** |
| 23 | 22 | * Initialize the properties based on block attributes. |
| 24 | 23 | * |
| 25 | 24 | * @param array<mixed> $attributes Block attributes. |
| @@ -29,9 +28,8 @@ | ||
| 29 | 28 | $this->set_properties( $attributes ); |
| 30 | 29 | $this->set_input_label( __( 'Checkbox', 'sureforms' ) ); |
| 31 | 30 | $this->set_error_msg( $attributes, 'srfm_checkbox_block_required_text' ); |
| 32 | 31 | $this->slug = 'checkbox'; |
| 33 | - $this->help = isset( $attributes['checkboxHelpText'] ) ? $attributes['checkboxHelpText'] : ''; | |
| 34 | 32 | $this->set_markup_properties(); |
| 35 | 33 | $this->set_aria_described_by(); |
| 36 | 34 | } |
| 37 | 35 | |
| @@ -38,9 +36,9 @@ | ||
| 38 | 36 | /** |
| 39 | 37 | * Render the sureforms checkbox classic styling |
| 40 | 38 | * |
| 41 | 39 | * @since 0.0.2 |
| 42 | - * @return string|boolean | |
| 40 | + * @return string|bool | |
| 43 | 41 | */ |
| 44 | 42 | public function markup() { |
| 45 | 43 | |
| 46 | 44 | $label_random_id = 'srfm-' . $this->slug . '-' . wp_rand(); |
| @@ -48,23 +46,23 @@ | ||
| 48 | 46 | ob_start(); ?> |
| 49 | 47 | <div data-block-id="<?php echo esc_attr( $this->block_id ); ?>" class="srfm-block-single srfm-block srfm-<?php echo esc_attr( $this->slug ); ?>-block srf-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-block<?php echo esc_attr( $this->block_width ); ?><?php echo esc_attr( $this->class_name ); ?> <?php echo esc_attr( $this->conditional_class ); ?>"> |
| 50 | 48 | <div class="srfm-block-wrap"> |
| 51 | 49 | <input class="srfm-input-common screen-reader-text srfm-input-<?php echo esc_attr( $this->slug ); ?>" id="<?php echo esc_attr( $label_random_id ); ?>" |
| 52 | - <?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?> | |
| 53 | - name="srfm-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?><?php echo esc_attr( $this->field_name ); ?>" aria-required="<?php echo esc_attr( $this->aria_require_attr ); ?>" type="checkbox" <?php echo esc_attr( $this->checked_attr ); ?>/> | |
| 50 | + <?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?> | |
| 51 | + name="srfm-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?><?php echo esc_attr( $this->field_name ); ?>" data-required="<?php echo esc_attr( $this->data_require_attr ); ?>" aria-required="<?php echo esc_attr( $this->data_require_attr ); ?>" type="checkbox" <?php echo esc_attr( $this->checked_attr ); ?>/> | |
| 54 | 52 | <label class="srfm-cbx" for="<?php echo esc_attr( $label_random_id ); ?>"> |
| 55 | 53 | <span class="srfm-span-wrap"> |
| 56 | - <svg class="srfm-check-icon" width="12px" height="10px"> | |
| 54 | + <svg class="srfm-check-icon" width="12px" height="10px" aria-hidden="true"> | |
| 57 | 55 | <use xlink:href="#srfm-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-check"></use> |
| 58 | 56 | </svg> |
| 59 | 57 | </span> |
| 60 | 58 | <span class="srfm-span-wrap srfm-block-label"><?php echo wp_kses( $this->label, $this->allowed_tags ); ?> |
| 61 | 59 | <?php if ( $this->required ) { ?> |
| 62 | - <span class="srfm-required"> *</span> | |
| 60 | + <span class="srfm-required" aria-hidden="true"> *</span> | |
| 63 | 61 | <?php } ?> |
| 64 | 62 | </span> |
| 65 | 63 | </label> |
| 66 | - <svg class="srfm-inline-svg"> | |
| 64 | + <svg class="srfm-inline-svg" aria-hidden="true"> | |
| 67 | 65 | <symbol id="srfm-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-check" viewbox="0 0 12 10"> |
| 68 | 66 | <polyline points="1.5 6 4.5 9 10.5 1"></polyline> |
| 69 | 67 | </symbol> |
| 70 | 68 | </svg> |
| @@ -74,10 +72,19 @@ | ||
| 74 | 72 | <?php echo wp_kses_post( $this->error_msg_markup ); ?> |
| 75 | 73 | </div> |
| 76 | 74 | </div> |
| 77 | 75 | <?php |
| 76 | + $markup = ob_get_clean(); | |
| 78 | 77 | |
| 79 | - return ob_get_clean(); | |
| 80 | - | |
| 78 | + return apply_filters( | |
| 79 | + 'srfm_block_field_markup', | |
| 80 | + $markup, | |
| 81 | + [ | |
| 82 | + 'slug' => $this->slug, | |
| 83 | + 'is_editing' => $this->is_editing, | |
| 84 | + 'field_name' => $this->field_name, | |
| 85 | + 'attributes' => $this->attributes, | |
| 86 | + ] | |
| 87 | + ); | |
| 81 | 88 | } |
| 82 | 89 | |
| 83 | 90 | } |