← All changes
|
includes/blocks/class-convertkit-block-form-builder-field.php
+7
-4
3.3.3
→
3.4.6
View file →
| @@ -50,9 +50,9 @@ | ||
| 50 | 50 | * @since 3.0.0 |
| 51 | 51 | * |
| 52 | 52 | * @var bool |
| 53 | 53 | */ |
| 54 | - private $field_required = false; | |
| 54 | + public $field_required = false; | |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * Constructor |
| 58 | 58 | * |
| @@ -293,14 +293,17 @@ | ||
| 293 | 293 | |
| 294 | 294 | // Determine if the field is required. |
| 295 | 295 | $field_required = $this->field_required ? true : ( $atts['required'] ? true : false ); |
| 296 | 296 | |
| 297 | + // Prefix the field's ID, so it doesn't clash with other elements on the page. | |
| 298 | + $id = 'kit-form-builder-' . sanitize_title( $this->field_id ); | |
| 299 | + | |
| 297 | 300 | // Build input / textarea. |
| 298 | 301 | switch ( $this->field_type ) { |
| 299 | 302 | case 'textarea': |
| 300 | 303 | $field = sprintf( |
| 301 | 304 | '<textarea id="%s" name="convertkit[%s]" %s></textarea>', |
| 302 | - esc_attr( sanitize_title( $this->field_id ) ), | |
| 305 | + esc_attr( $id ), | |
| 303 | 306 | esc_attr( $this->field_name ), |
| 304 | 307 | $field_required ? ' required' : '' |
| 305 | 308 | ); |
| 306 | 309 | break; |
| @@ -307,9 +310,9 @@ | ||
| 307 | 310 | default: |
| 308 | 311 | $field = sprintf( |
| 309 | 312 | '<input type="%s" id="%s" name="convertkit[%s]" %s />', |
| 310 | 313 | esc_attr( $this->field_type ), |
| 311 | - esc_attr( sanitize_title( $this->field_id ) ), | |
| 314 | + esc_attr( $id ), | |
| 312 | 315 | esc_attr( $this->field_name ), |
| 313 | 316 | $field_required ? ' required' : '' |
| 314 | 317 | ); |
| 315 | 318 | break; |
| @@ -319,9 +322,9 @@ | ||
| 319 | 322 | $html = sprintf( |
| 320 | 323 | '<div class="%s" style="%s"><label for="%s">%s%s</label>%s</div>', |
| 321 | 324 | implode( ' ', map_deep( $css_classes, 'sanitize_html_class' ) ), |
| 322 | 325 | implode( ';', map_deep( $css_styles, 'esc_attr' ) ), |
| 323 | - esc_attr( sanitize_title( $this->field_id ) ), | |
| 326 | + esc_attr( $id ), | |
| 324 | 327 | esc_html( $atts['label'] ), |
| 325 | 328 | ( $field_required ? ' <span class="convertkit-form-builder-field-required">*</span>' : '' ), |
| 326 | 329 | $field |
| 327 | 330 | ); |