PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.13
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.13
2.12.7 2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 All 97 releases
sureforms / inc / blocks / sform / block.php

block.php in SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz 0.0.13, at inc/blocks/sform/block.php

51 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PHP render form Sureforms_Form Block.
4 *
5 * @package SureForms.
6 */
7
8 namespace SRFM\Inc\Blocks\Sform;
9
10 use WP_REST_Response;
11 use SRFM\Inc\Blocks\Base;
12 use SRFM\Inc\Generate_Form_Markup;
13 use SRFM\Inc\Helper;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * Sureforms_Form Block.
21 */
22 class Block extends Base {
23 /**
24 * Render the block.
25 *
26 * @param array<mixed> $attributes Block attributes.
27 * @param string $content Post content.
28 *
29 * @return string|false
30 */
31 public function render( $attributes, $content = '' ) {
32 $id = isset( $attributes['id'] ) ? Helper::get_integer_value( $attributes['id'] ) : '';
33
34 if ( empty( $id ) ) {
35 return '';
36 }
37
38 $sf_classname = isset( $attributes['className'] ) ? $attributes['className'] : '';
39 $show_title_current_page = isset( $attributes['showTitle'] ) ? $attributes['showTitle'] : true;
40
41 $form = get_post( $id );
42
43 if ( ! $form || SRFM_FORMS_POST_TYPE !== $form->post_type || 'publish' !== $form->post_status || ! empty( $form->post_password ) ) {
44 return '';
45 }
46
47 return Generate_Form_Markup::get_form_markup( $id, $show_title_current_page, $sf_classname );
48 }
49
50 }
51