| @@ -87,14 +87,25 @@ | ||
| 87 | 87 | * |
| 88 | 88 | * Shared by the donation form embed block and the campaign display blocks, |
| 89 | 89 | * both of which expose it on the `suredonationCampaignBlocks` JS global. |
| 90 | 90 | * |
| 91 | + * `currentPostType` lets a block scope its editor registration to a single | |
| 92 | + * post type (the Campaign Donate Button registers only on the campaign | |
| 93 | + * editor). It is read from the current screen, so it is only populated for | |
| 94 | + * the caller that runs on `enqueue_block_editor_assets` (the campaign editor | |
| 95 | + * assets); the embed-block caller runs on `init`, where there is no screen, | |
| 96 | + * so it receives an empty string. That is harmless — the embed block only | |
| 97 | + * consumes `logoUrl`. | |
| 98 | + * | |
| 91 | 99 | * @return array<string, string> |
| 92 | 100 | * @since 1.0.0 |
| 93 | 101 | */ |
| 94 | 102 | public function get_campaign_blocks_data() { |
| 103 | + $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; | |
| 104 | + | |
| 95 | 105 | return [ |
| 96 | - 'logoUrl' => esc_url_raw( SUREDONATION_URL . 'images/suredonation-logo.svg' ), | |
| 106 | + 'logoUrl' => esc_url_raw( SUREDONATION_URL . 'images/suredonation-logo.svg' ), | |
| 107 | + 'currentPostType' => $screen ? (string) $screen->post_type : '', | |
| 97 | 108 | ]; |
| 98 | 109 | } |
| 99 | 110 | |
| 100 | 111 | /** |
| @@ -304,11 +315,12 @@ | ||
| 304 | 315 | wp_localize_script( |
| 305 | 316 | 'suredonation-blocks', |
| 306 | 317 | 'suredonation_admin', |
| 307 | 318 | [ |
| 308 | - 'payments' => [ | |
| 319 | + 'payments' => [ | |
| 309 | 320 | 'stripe_connected' => Stripe_Helper::is_stripe_connected(), |
| 310 | 321 | 'stripe_connect_url' => Stripe_Helper::get_stripe_connect_url(), |
| 322 | + 'settings_url' => admin_url( 'admin.php?page=suredonation#/settings?tab=payments' ), | |
| 311 | 323 | 'offline_enabled' => Offline_Helper::is_offline_enabled(), |
| 312 | 324 | 'gateways' => apply_filters( |
| 313 | 325 | 'suredonation_editor_payment_gateways', |
| 314 | 326 | [ |
| @@ -324,11 +336,14 @@ | ||
| 324 | 336 | ], |
| 325 | 337 | ] |
| 326 | 338 | ), |
| 327 | 339 | ], |
| 328 | - 'fee_recovery' => Payment_Helper::get_fee_recovery_settings(), | |
| 329 | - 'currency' => $global_currency, | |
| 330 | - 'currencySymbol' => Payment_Helper::get_currency_symbol( $global_currency ), | |
| 340 | + 'fee_recovery' => Payment_Helper::get_fee_recovery_settings(), | |
| 341 | + 'currency' => $global_currency, | |
| 342 | + 'currencySymbol' => Payment_Helper::get_currency_symbol( $global_currency ), | |
| 343 | + // Resolved default validation messages so the editor can show | |
| 344 | + // them as placeholders on each field's Error Message control. | |
| 345 | + 'validationMessages' => \SureDonation\Inc\Field_Validation::get_resolved_validation_messages(), | |
| 331 | 346 | ] |
| 332 | 347 | ); |
| 333 | 348 | } |
| 334 | 349 | |