PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 1.8.7
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v1.8.7
3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / includes / class-evf-form-block.php
everest-forms / includes Last commit date
abstracts 4 years ago admin 4 years ago elementor 4 years ago export 4 years ago fields 4 years ago interfaces 8 years ago libraries 7 years ago log-handlers 4 years ago shortcodes 4 years ago templates 5 years ago class-everest-forms.php 4 years ago class-evf-ajax.php 4 years ago class-evf-autoloader.php 7 years ago class-evf-background-updater.php 7 years ago class-evf-cache-helper.php 6 years ago class-evf-deprecated-action-hooks.php 6 years ago class-evf-deprecated-filter-hooks.php 5 years ago class-evf-emails.php 5 years ago class-evf-fields.php 6 years ago class-evf-form-block.php 4 years ago class-evf-form-handler.php 4 years ago class-evf-form-task.php 4 years ago class-evf-forms-features.php 4 years ago class-evf-frontend-scripts.php 4 years ago class-evf-install.php 5 years ago class-evf-integrations.php 7 years ago class-evf-log-levels.php 8 years ago class-evf-logger.php 5 years ago class-evf-post-types.php 5 years ago class-evf-privacy.php 6 years ago class-evf-session-handler.php 7 years ago class-evf-shortcodes.php 4 years ago class-evf-smart-tags.php 4 years ago class-evf-template-loader.php 4 years ago class-evf-validation.php 6 years ago evf-conditional-functions.php 6 years ago evf-core-functions.php 4 years ago evf-deprecated-functions.php 6 years ago evf-entry-functions.php 4 years ago evf-formatting-functions.php 4 years ago evf-notice-functions.php 4 years ago evf-template-functions.php 4 years ago evf-template-hooks.php 7 years ago evf-update-functions.php 5 years ago
class-evf-form-block.php
191 lines
1 <?php
2 /**
3 * EverestForm Gutenberg blocks
4 *
5 * @package EverstForms\Class
6 * @version 1.3.4
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * Guten Block Class.
13 */
14 class EVF_Form_Block {
15
16 /**
17 * Constructor.
18 */
19 public function __construct() {
20 add_action( 'init', array( $this, 'register_block' ) );
21 add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
22 }
23
24 /**
25 * Register the block and its scripts.
26 */
27 public function register_block() {
28 if ( ! function_exists( 'register_block_type' ) ) {
29 return;
30 }
31
32 register_block_type(
33 'everest-forms/form-selector',
34 array(
35 'attributes' => array(
36 'formId' => array(
37 'type' => 'string',
38 ),
39 'className' => array(
40 'type' => 'string',
41 ),
42 'displayTitle' => array(
43 'type' => 'boolean',
44 ),
45 'displayDescription' => array(
46 'type' => 'boolean',
47 ),
48 'displayPopup' => array(
49 'type' => 'boolean',
50 ),
51 'displayPopupType' => array(
52 'type' => 'string',
53 ),
54 'displayPopupText' => array(
55 'type' => 'string',
56 ),
57 'displayPopupSize' => array(
58 'type' => 'string',
59 ),
60 ),
61 'editor_style' => 'everest-forms-block-editor',
62 'editor_script' => 'everest-forms-block-editor',
63 'render_callback' => array( $this, 'get_form_html' ),
64 )
65 );
66 }
67
68 /**
69 * Load Gutenberg block scripts.
70 */
71 public function enqueue_block_editor_assets() {
72 wp_register_style(
73 'everest-forms-block-editor',
74 evf()->plugin_url() . '/assets/css/everest-forms.css',
75 array( 'wp-edit-blocks' ),
76 defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? filemtime( evf()->plugin_path() . '/assets/css/everest-forms.css' ) : EVF_VERSION
77 );
78
79 if ( defined( 'EFP_PLUGIN_FILE' ) ) {
80 wp_register_script(
81 'everest-forms-block-editor',
82 plugins_url( '/assets/js/admin/gutenberg/form-block.min.js', EFP_PLUGIN_FILE ),
83 array( 'wp-blocks', 'wp-element', 'wp-i18n', 'wp-components' ),
84 defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? filemtime( plugin_dir_path( EFP_PLUGIN_FILE ) . '/assets/js/admin/gutenberg/form-block.min.js' ) : EFP_VERSION,
85 true
86 );
87 } else {
88 wp_register_script(
89 'everest-forms-block-editor',
90 evf()->plugin_url() . '/assets/js/admin/gutenberg/form-block.min.js',
91 array( 'wp-blocks', 'wp-element', 'wp-i18n', 'wp-components' ),
92 defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? filemtime( evf()->plugin_path() . '/assets/js/admin/gutenberg/form-block.min.js' ) : EVF_VERSION,
93 true
94 );
95 }
96
97 $form_block_data = array(
98 'forms' => evf()->form->get_multiple( array( 'order' => 'DESC' ) ),
99 'i18n' => array(
100 'title' => esc_html__( 'Everest Forms', 'everest-forms' ),
101 'description' => esc_html__( 'Select and display one of your forms.', 'everest-forms' ),
102 'form_keywords' => array(
103 esc_html__( 'form', 'everest-forms' ),
104 esc_html__( 'contact', 'everest-forms' ),
105 esc_html__( 'survey', 'everest-forms' ),
106 ),
107 'form_select' => esc_html__( 'Select a Form', 'everest-forms' ),
108 'form_settings' => esc_html__( 'Form Settings', 'everest-forms' ),
109 'form_selected' => esc_html__( 'Form', 'everest-forms' ),
110 'show_title' => esc_html__( 'Show Title', 'everest-forms' ),
111 'show_description' => esc_html__( 'Show Description', 'everest-forms' ),
112 'show_Popup' => esc_html__( 'Show Popup', 'everest-forms' ),
113 'popup_type' => esc_html__( 'Popup Type', 'everest-forms' ),
114 'popup_size' => esc_html__( 'Popup Size', 'everest-forms' ),
115 ),
116 );
117 wp_localize_script( 'everest-forms-block-editor', 'evf_form_block_data', $form_block_data );
118 }
119
120 /**
121 * Get form HTML to display in a Gutenberg block.
122 *
123 * @param array $attr Attributes passed by Gutenberg block.
124 * @return string
125 */
126 public function get_form_html( $attr ) {
127 $form_id = ! empty( $attr['formId'] ) ? absint( $attr['formId'] ) : 0;
128
129 if ( empty( $form_id ) ) {
130 return '';
131 }
132
133 // Wrapper classes.
134 $classes = 'everest-forms';
135 if ( isset( $attr['className'] ) ) {
136 $classes .= ' ' . $attr['className'];
137 }
138
139 $is_gb_editor = defined( 'REST_REQUEST' ) && REST_REQUEST && ! empty( $_REQUEST['context'] ) && 'edit' === $_REQUEST['context']; // phpcs:ignore WordPress.Security.NonceVerification
140 $title = ! empty( $attr['displayTitle'] ) ? true : false;
141 $description = ! empty( $attr['displayDescription'] ) ? true : false;
142 $popup = ! empty( $attr['displayPopup'] ) ? true : false;
143 $popup_type = ! empty( $attr['displayPopupType'] ) ? $attr['displayPopupType'] : false;
144 $popup_text = ! empty( $attr['displayPopupText'] ) ? $attr['displayPopupText'] : 'View Form';
145 $popup_size = ! empty( $attr['displayPopupSize'] ) ? $attr['displayPopupSize'] : false;
146
147 // Disable form fields if called from the Gutenberg editor.
148 if ( $is_gb_editor ) {
149 add_filter(
150 'everest_forms_frontend_container_class',
151 function ( $classes ) {
152 $classes[] = 'evf-gutenberg-form-selector';
153 $classes[] = 'evf-container-full';
154 return $classes;
155 }
156 );
157 add_action(
158 'everest_forms_frontend_output',
159 function () {
160 echo '<fieldset disabled>';
161 },
162 3
163 );
164 add_action(
165 'everest_forms_frontend_output',
166 function () {
167 echo '</fieldset>';
168 },
169 30
170 );
171 }
172
173 return EVF_Shortcodes::shortcode_wrapper(
174 array( 'EVF_Shortcode_Form', 'output' ),
175 array(
176 'id' => $form_id,
177 'title' => $title,
178 'description' => $description,
179 'type' => $popup_type,
180 'text' => $popup_text,
181 'size' => $popup_size,
182 ),
183 array(
184 'class' => evf_sanitize_classes( $classes ),
185 )
186 );
187 }
188 }
189
190 new EVF_Form_Block();
191