← All changes
|
includes/blocks/class-convertkit-block-form-builder.php
+20
-9
3.3.7
→
3.4.3
View file →
| @@ -516,19 +516,29 @@ | ||
| 516 | 516 | * @return bool|array |
| 517 | 517 | */ |
| 518 | 518 | public function get_fields() { |
| 519 | 519 | |
| 520 | - // Get Kit Forms. | |
| 521 | - $forms = new ConvertKit_Resource_Forms( 'block_form_builder' ); | |
| 522 | - $forms_options = array(); | |
| 520 | + // Get Kit Forms. Non-legacy forms populate the sidebar dropdown; | |
| 521 | + // legacy forms are exposed separately as a fallback so the sidebar can | |
| 522 | + // keep displaying a previously-saved legacy form as the current | |
| 523 | + // selection without offering other legacy forms as new choices. | |
| 524 | + $forms = new ConvertKit_Resource_Forms( 'block_form_builder' ); | |
| 525 | + $forms_options = array(); | |
| 526 | + $forms_legacy_options = array(); | |
| 523 | 527 | if ( $forms->exist() ) { |
| 524 | 528 | foreach ( $forms->get() as $form ) { |
| 525 | - // Legacy forms don't include a `format` key, so define them as inline. | |
| 526 | - $forms_options[ $form['id'] ] = sprintf( | |
| 529 | + $label = sprintf( | |
| 527 | 530 | '%s [%s]', |
| 528 | 531 | sanitize_text_field( $form['name'] ), |
| 532 | + // Legacy forms don't include a `format` key, so define them as inline. | |
| 529 | 533 | ( ! empty( $form['format'] ) ? sanitize_text_field( $form['format'] ) : 'inline' ) |
| 530 | 534 | ); |
| 535 | + | |
| 536 | + if ( ! empty( $form['format'] ) ) { | |
| 537 | + $forms_options[ $form['id'] ] = $label; | |
| 538 | + } else { | |
| 539 | + $forms_legacy_options[ $form['id'] ] = $label; | |
| 540 | + } | |
| 531 | 541 | } |
| 532 | 542 | } |
| 533 | 543 | |
| 534 | 544 | // Get Kit Tags. |
| @@ -574,12 +584,13 @@ | ||
| 574 | 584 | 'value' => 0, |
| 575 | 585 | ), |
| 576 | 586 | ), |
| 577 | 587 | 'form_id' => array( |
| 578 | - 'label' => __( 'Form', 'convertkit' ), | |
| 579 | - 'type' => 'select', | |
| 580 | - 'description' => __( 'The Kit form to add the subscriber to. Useful if you want to send an incentive email.', 'convertkit' ), | |
| 581 | - 'values' => $forms_options, | |
| 588 | + 'label' => __( 'Form', 'convertkit' ), | |
| 589 | + 'type' => 'select', | |
| 590 | + 'description' => __( 'The Kit form to add the subscriber to. Useful if you want to send an incentive email.', 'convertkit' ), | |
| 591 | + 'values' => $forms_options, | |
| 592 | + 'legacy_values' => $forms_legacy_options, | |
| 582 | 593 | ), |
| 583 | 594 | 'tag_id' => array( |
| 584 | 595 | 'label' => __( 'Tag', 'convertkit' ), |
| 585 | 596 | 'type' => 'select', |