| @@ -116,4 +116,25 @@ | ||
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | return $result; |
| 119 | 119 | } |
| 120 | + | |
| 121 | +/** | |
| 122 | + * Additional data to expose to the view script module in the Form block. | |
| 123 | + * | |
| 124 | + * @return array The script module data. | |
| 125 | + */ | |
| 126 | +function gutenberg_block_core_form_view_script_module( $data ) { | |
| 127 | + if ( ! gutenberg_is_experiment_enabled( 'gutenberg-form-blocks' ) ) { | |
| 128 | + return $data; | |
| 129 | + } | |
| 130 | + | |
| 131 | + $data['nonce'] = wp_create_nonce( 'wp-block-form' ); | |
| 132 | + $data['ajaxUrl'] = admin_url( 'admin-ajax.php' ); | |
| 133 | + $data['action'] = 'wp_block_form_email_submit'; | |
| 134 | + | |
| 135 | + return $data; | |
| 136 | +} | |
| 137 | +add_filter( | |
| 138 | + 'script_module_data_@wordpress/block-library/form/view', | |
| 139 | + 'gutenberg_block_core_form_view_script_module' | |
| 140 | +); | |