PluginProbe
Gutenberg / 23.3.0
Gutenberg v23.3.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / scripts / block-library / form-submission-notification.php

form-submission-notification.php in Gutenberg 23.3.0, at build/scripts/block-library/form-submission-notification.php

49 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Server-side rendering of the `core/form-submission-notification` block.
4 *
5 * @package WordPress
6 */
7
8 /**
9 * Renders the `core/form-submission-notification` block on server.
10 *
11 * @param array $attributes The block attributes.
12 * @param string $content The saved content.
13 *
14 * @return string The content of the block being rendered.
15 */
16 function gutenberg_render_block_core_form_submission_notification( $attributes, $content ) {
17 $show = isset( $_GET['wp-form-result'] ) && sanitize_text_field( wp_unslash( $_GET['wp-form-result'] ) ) === $attributes['type'];
18 /**
19 * Filters whether to show the form submission notification block.
20 *
21 * @param bool $show Whether to show the form submission notification block.
22 * @param array $attributes The block attributes.
23 * @param string $content The saved content.
24 *
25 * @return bool Whether to show the form submission notification block.
26 */
27 $show = apply_filters( 'show_form_submission_notification_block', $show, $attributes, $content );
28 if ( ! $show ) {
29 return '';
30 }
31 return $content;
32 }
33
34 /**
35 * Registers the `core/form-submission-notification` block on server.
36 */
37 function gutenberg_register_block_core_form_submission_notification() {
38 if ( ! gutenberg_is_experiment_enabled( 'gutenberg-form-blocks' ) ) {
39 return;
40 }
41 register_block_type_from_metadata(
42 __DIR__ . '/form-submission-notification',
43 array(
44 'render_callback' => 'gutenberg_render_block_core_form_submission_notification',
45 )
46 );
47 }
48 add_action( 'init', 'gutenberg_register_block_core_form_submission_notification', 20 );
49