PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.5.2
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.5.2
3.5.2 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 / blocks / class-evf-blocks.php
everest-forms / includes / blocks Last commit date
block-types 1 year ago class-evf-blocks.php 2 years ago
class-evf-blocks.php
145 lines
1 <?php
2 /**
3 * Everest Forms blocks.
4 *
5 * @since 2.0.9
6 * @package everest-forms
7 */
8
9 defined( 'ABSPATH' ) || exit;
10 /**
11 * Everest Forms blocks class.
12 */
13 class EVF_Blocks {
14 /**
15 * Constructor.
16 */
17 public function __construct() {
18 $this->init_hooks();
19 }
20
21 /**
22 * Init hooks.
23 *
24 * @since 2.0.9
25 */
26 private function init_hooks() {
27 $this->includes();
28 add_filter( 'block_categories_all', array( $this, 'block_categories' ), PHP_INT_MAX, 2 );
29 add_action( 'init', array( $this, 'register_block_types' ) );
30 add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
31 }
32 /**
33 * Includes the block type files.
34 *
35 * @since 0
36 */
37 private function includes() {
38 include_once EVF_ABSPATH . 'includes/blocks/block-types/class-evf-blocks-abstract.php';
39 include_once EVF_ABSPATH . 'includes/blocks/block-types/class-evf-blocks-form-selector.php';
40 include_once EVF_ABSPATH . 'includes/blocks/block-types/class-evf-blocks-frontend-listing.php';
41 include_once EVF_ABSPATH . 'includes/blocks/block-types/class-evf-blocks-user-login.php';
42 }
43 /**
44 * Enqueue Block Editor Assets.
45 *
46 * @return void.
47 */
48 public function enqueue_block_editor_assets() {
49 wp_register_style(
50 'everest-forms-block-editor',
51 evf()->plugin_url() . '/assets/css/everest-forms.css',
52 array( 'wp-edit-blocks' ),
53 evf()->version
54 );
55 wp_enqueue_style( 'everest-forms-block-editor' );
56 $enqueue_script = array( 'wp-blocks', 'wp-element', 'wp-i18n', 'wp-editor', 'wp-components', 'react', 'react-dom' );
57 wp_register_script(
58 'everest-forms-block-editor',
59 evf()->plugin_url() . '/dist/blocks.min.js',
60 $enqueue_script,
61 evf()->version,
62 true
63 );
64 wp_register_script(
65 'everest-forms-shortcode-embed-form',
66 evf()->plugin_url() . '/assets/js/admin/shortcode-form-embed.js',
67 array( 'wp-blocks', 'wp-element', 'wp-i18n', 'wp-components', 'wp-dom-ready', 'wp-edit-post', 'jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'tooltipster', 'wp-color-picker', 'perfect-scrollbar' ),
68 defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? filemtime( evf()->plugin_path() . '/assets/js/admin/shortcode-form-embed.js' ) : EVF_VERSION,
69 true
70 );
71 $form_block_data = array(
72 'evfRestApiNonce' => wp_create_nonce( 'wp_rest' ),
73 'restURL' => rest_url(),
74 'forms' => evf()->form->get_multiple( array( 'order' => 'DESC' ) ),
75 'isPro' => defined( 'EFP_VERSION' ) && version_compare( EFP_VERSION, '1.7.3', '>=' ) ? true : false,
76 'isFrontendListingActive' => defined( 'EVF_FRONTEND_LISTING_VERSION' ) && version_compare( EVF_FRONTEND_LISTING_VERSION, '1.0.0', '>=' ) ? true : false,
77 'isUserRegistrationActive' => defined( 'EVF_USER_REGISTRATION_VERSION' ) && version_compare( EVF_USER_REGISTRATION_VERSION, '1.1.3', '>=' ) ? true : false,
78 );
79
80 wp_localize_script( 'everest-forms-block-editor', '_EVF_BLOCKS_', $form_block_data );
81 $action_page = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
82
83 if ( 'edit' === $action_page ) {
84 wp_enqueue_script( 'everest-forms-shortcode-embed-form' );
85 }
86 wp_enqueue_script( 'everest-forms-block-editor' );
87 }
88
89 /**
90 * Add "Everest Forms" category to the blocks listing in post edit screen.
91 *
92 * @param array $block_categories All registered block categories.
93 * @return array
94 * @since 2.0.9
95 */
96 public function block_categories( array $block_categories ) {
97
98 return array_merge(
99 array(
100 array(
101 'slug' => 'everest-forms',
102 'title' => esc_html__( 'Everest Forms', 'everest-forms' ),
103 ),
104 ),
105 $block_categories
106 );
107 }
108 /**
109 * Register block types.
110 *
111 * @return void
112 */
113 public function register_block_types() {
114 $block_types = $this->get_block_types();
115 foreach ( $block_types as $block_type ) {
116 new $block_type();
117 }
118 }
119
120 /**
121 * Get block types.
122 *
123 * @return AbstractBlock[]
124 */
125 private function get_block_types() {
126 $is_pro = defined( 'EFP_VERSION' ) && version_compare( EFP_VERSION, '1.7.3', '>=' ) ? true : false;
127 $is_frontendlisting_active = defined( 'EVF_FRONTEND_LISTING_VERSION' ) && version_compare( EVF_FRONTEND_LISTING_VERSION, '1.0.0', '>=' ) ? true : false;
128 $is_use_registration_active = defined( 'EVF_USER_REGISTRATION_VERSION' ) && version_compare( EVF_USER_REGISTRATION_VERSION, '1.1.3', '>=' ) ? true : false;
129 $class = array(
130 EVF_Blocks_Form_Selector::class, //phpcs:ignore;
131 );
132 if ( $is_pro && $is_frontendlisting_active ) {
133 $class[]= EVF_Blocks_Frontend_Listing::class; //phpcs:ignore;
134 }
135 if ( $is_pro && $is_use_registration_active ) {
136 $class[]= EVF_Blocks_User_Login::class; //phpcs:ignore;
137 }
138 return apply_filters(
139 'everest_forms_block_types',
140 $class
141 );
142 }
143 }
144 return new EVF_Blocks();
145