| @@ -17,9 +17,8 @@ | ||
| 17 | 17 | * |
| 18 | 18 | * @since 0.0.1 |
| 19 | 19 | */ |
| 20 | 20 | class Address_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. |
| @@ -36,28 +35,76 @@ | ||
| 36 | 35 | * Render the sureforms address classic styling |
| 37 | 36 | * |
| 38 | 37 | * @param string $content inner block content. |
| 39 | 38 | * @since 0.0.2 |
| 40 | - * @return string|boolean | |
| 39 | + * @return string|bool | |
| 41 | 40 | */ |
| 42 | 41 | public function markup( $content = '' ) { |
| 42 | + /** | |
| 43 | + * Filter extra CSS classes for the address field wrapper. | |
| 44 | + * | |
| 45 | + * @param array<string> $extra_classes Extra CSS classes. | |
| 46 | + * @param array<mixed> $attributes Block attributes. | |
| 47 | + * @since 2.8.0 | |
| 48 | + */ | |
| 49 | + $extra_classes = apply_filters( 'srfm_address_field_classes', [], $this->attributes ); | |
| 50 | + | |
| 51 | + $this->class_name = $this->get_field_classes( $extra_classes ); | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * Filter additional HTML attributes for the address block wrapper div. | |
| 55 | + * | |
| 56 | + * IMPORTANT: Callbacks MUST escape all values with esc_attr() before | |
| 57 | + * returning. The output is echoed directly into a <div> tag. | |
| 58 | + * | |
| 59 | + * @param string $extra_attrs Additional HTML attributes string (pre-escaped). | |
| 60 | + * @param array<mixed> $attributes Block attributes. | |
| 61 | + * @since 2.8.0 | |
| 62 | + */ | |
| 63 | + $extra_attrs = apply_filters( 'srfm_address_block_attributes', '', $this->attributes ); | |
| 64 | + | |
| 43 | 65 | ob_start(); ?> |
| 44 | - <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 ); ?>"> | |
| 66 | + <div data-block-id="<?php echo esc_attr( $this->block_id ); ?>" class="<?php echo esc_attr( $this->class_name ); ?>" data-slug="<?php echo esc_attr( $this->block_slug ); ?>" | |
| 67 | + <?php | |
| 68 | + echo $extra_attrs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped by the filter callback. | |
| 69 | + ?> | |
| 70 | + > | |
| 45 | 71 | <fieldset> |
| 46 | - <legend> | |
| 72 | + <legend class="srfm-block-legend"> | |
| 47 | 73 | <?php echo wp_kses_post( $this->label_markup ); ?> |
| 48 | - <?php echo wp_kses_post( $this->help_markup ); ?> | |
| 49 | 74 | </legend> |
| 75 | + <?php echo wp_kses_post( $this->help_markup ); ?> | |
| 76 | + <?php | |
| 77 | + /** | |
| 78 | + * Fires after the address field legend, before the inner block content. | |
| 79 | + * Used by pro to render the autocomplete search input. | |
| 80 | + * | |
| 81 | + * @param array<mixed> $attributes Block attributes. | |
| 82 | + * @param string $block_id Block ID. | |
| 83 | + * @since 2.8.0 | |
| 84 | + */ | |
| 85 | + do_action( 'srfm_address_before_fields', $this->attributes, $this->block_id ); | |
| 86 | + ?> | |
| 50 | 87 | <div class="srfm-block-wrap"> |
| 51 | 88 | <?php |
| 52 | - // phpcs:ignore | |
| 53 | - echo $content; | |
| 54 | - // phpcs:ignoreEnd | |
| 89 | + // phpcs:ignore | |
| 90 | + echo $content; | |
| 91 | + // phpcs:ignoreEnd | |
| 55 | 92 | ?> |
| 56 | 93 | </div> |
| 94 | + <?php | |
| 95 | + /** | |
| 96 | + * Fires after the inner block content, before the closing fieldset. | |
| 97 | + * Used by pro to render hidden fields and map container. | |
| 98 | + * | |
| 99 | + * @param array<mixed> $attributes Block attributes. | |
| 100 | + * @param string $block_id Block ID. | |
| 101 | + * @since 2.8.0 | |
| 102 | + */ | |
| 103 | + do_action( 'srfm_address_after_fields', $this->attributes, $this->block_id ); | |
| 104 | + ?> | |
| 57 | 105 | </fieldset> |
| 58 | 106 | </div> |
| 59 | 107 | <?php |
| 60 | - | |
| 61 | 108 | return ob_get_clean(); |
| 62 | 109 | } |
| 63 | 110 | } |