PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.16.1
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.16.1
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / assets / misc / gutenberg / enqueue-block-editor-assets.php

enqueue-block-editor-assets.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.16.1, at assets/misc/gutenberg/enqueue-block-editor-assets.php

168 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
5 add_action(
6 'enqueue_block_assets',
7 function () {
8
9 if ( !is_admin() ) {
10 return;
11 }
12
13 // Enqueue necessary assets for the Editor interface
14 wp_enqueue_style('wppb_block_stylesheet', WPPB_PLUGIN_URL . 'assets/misc/gutenberg/blocks/assets/css/gutenberg-blocks.css', PROFILE_BUILDER_VERSION);
15 wp_enqueue_style('wppb_stylesheet', WPPB_PLUGIN_URL . 'assets/css/style-front-end.css', array('wp-edit-blocks'), PROFILE_BUILDER_VERSION);
16
17 // load the corresponding Form Design stylesheets
18 $active_design = 'form-style-default';
19 if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR.'/features/form-designs/form-designs.php' ) )
20 $active_design = wppb_get_active_form_design();
21
22 if ( $active_design === 'form-style-default' ) {
23
24 // load stylesheet for the Default Form Style if the active WP Theme is a Block Theme (Block Themes were introduced in WordPress since the 5.9 release)
25 if ( version_compare( get_bloginfo( 'version' ), '5.9', '>=' ) && function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() )
26 wp_enqueue_style('wppb_block_themes_front_end_stylesheet', WPPB_PLUGIN_URL . 'assets/css/style-block-themes-front-end.css', array('wp-edit-blocks'), PROFILE_BUILDER_VERSION);
27
28 }
29 else { // if $active_design is other than 'form-style-default' the constants WPPB_PAID_PLUGIN_DIR and WPPB_PAID_PLUGIN_URL are defined (verified at line:14)
30
31 if ( file_exists( WPPB_PAID_PLUGIN_DIR . '/features/form-designs/css/' . $active_design . '/form-design-general-style.css' ) )
32 wp_enqueue_style( 'wppb_form_designs_general_style', WPPB_PAID_PLUGIN_URL . 'features/form-designs/css/' . $active_design . '/form-design-general-style.css', array('wp-edit-blocks'),PROFILE_BUILDER_VERSION );
33
34 if ( file_exists( WPPB_PAID_PLUGIN_DIR . '/features/form-designs/css/' . $active_design .'/extra-form-notifications-style.css' ) )
35 wp_enqueue_style( 'wppb_register_success_notification_style', WPPB_PAID_PLUGIN_URL . 'features/form-designs/css/' . $active_design .'/extra-form-notifications-style.css', array('wp-edit-blocks'),PROFILE_BUILDER_VERSION );
36 }
37
38 //Select
39 // Don't enqueue when JetEngine is active
40 if( !class_exists( 'Jet_Engine' ) ){
41 //Select2
42 wp_enqueue_script('wppb_select2_js', WPPB_PLUGIN_URL . 'assets/js/select2/select2.min.js', array('jquery'), PROFILE_BUILDER_VERSION);
43 wp_enqueue_style('wppb_select2_css', WPPB_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), PROFILE_BUILDER_VERSION);
44 }
45
46
47 //Upload
48 wp_enqueue_style('wppb-upload-css', WPPB_PLUGIN_URL . 'front-end/default-fields/upload/upload.css', false, PROFILE_BUILDER_VERSION);
49
50 if ( defined( 'WPPB_PAID_PLUGIN_URL' ) ) {
51 //Select CPT
52 wp_enqueue_style('wppb-select-cpt-style', WPPB_PAID_PLUGIN_URL . 'front-end/extra-fields/select-cpt/style-front-end.css', array(), PROFILE_BUILDER_VERSION);
53
54 //Select Taxonomy
55 wp_enqueue_style('wppb-select-taxonomy-style', WPPB_PAID_PLUGIN_URL . 'front-end/extra-fields/select-taxonomy/select-taxonomy-style.css', array(), PROFILE_BUILDER_VERSION);
56
57 //Multi-Step Forms compatibility
58 wp_enqueue_style('wppb-msf-style-frontend', WPPB_PAID_PLUGIN_URL . 'add-ons-advanced/multi-step-forms/assets/css/frontend-multi-step-forms.css', array(), PROFILE_BUILDER_VERSION);
59
60 //Social Connect
61 wp_enqueue_style('wppb-sc-frontend-style', WPPB_PAID_PLUGIN_URL . 'add-ons-advanced/social-connect/assets/css/wppb_sc_main_frontend.css', false, PROFILE_BUILDER_VERSION);
62
63 if ( in_array( PROFILE_BUILDER, ['Profile Builder Pro', 'Profile Builder Agency', 'Profile Builder Unlimited'] ) ) {
64 //Userlisting
65 wp_enqueue_script('wppb-userlisting-js', WPPB_PAID_PLUGIN_URL . 'add-ons/user-listing/userlisting.js', array('jquery', 'jquery-touch-punch'), PROFILE_BUILDER_VERSION, true);
66 wp_localize_script('wppb-userlisting-js', 'wppb_userlisting_obj', array('pageSlug' => wppb_get_users_pagination_slug()));
67 wp_enqueue_style('wppb-ul-slider-css', WPPB_PAID_PLUGIN_URL . 'add-ons/user-listing/jquery-ui-slider.min.css', array(), PROFILE_BUILDER_VERSION);
68 wp_enqueue_script('jquery-ui-slider');
69 }
70 }
71 }
72 );
73
74 add_action(
75 'enqueue_block_editor_assets',
76 function () {
77 global $content_restriction_activated;
78 global $wp_version;
79
80 global $pagenow;
81
82 $arrDeps = ($pagenow === 'widgets.php') ?
83 array( 'wp-blocks', 'wp-dom', 'wp-dom-ready', 'wp-edit-widgets' ) :
84 array( 'wp-blocks', 'wp-dom', 'wp-dom-ready', 'wp-edit-post' );
85
86
87 //Register the Block Content Restriction assets
88 if ( $content_restriction_activated == 'yes' && version_compare( $wp_version, "5.0.0", ">=" ) ) {
89 wp_register_script(
90 'wppb-block-editor-assets-content-restriction',
91 WPPB_PLUGIN_URL . 'assets/misc/gutenberg/block-content-restriction/build/index.js',
92 $arrDeps,
93 PROFILE_BUILDER_VERSION
94 );
95 wp_enqueue_script('wppb-block-editor-assets-content-restriction');
96
97 if (!function_exists('get_editable_roles')) {
98 require_once ABSPATH . 'wp-admin/includes/user.php';
99 }
100
101 $user_roles_initial = get_editable_roles();
102
103 foreach ($user_roles_initial as $key => $role) {
104 $user_roles[] = [
105 "slug" => $key,
106 "name" => $role['name'],
107 ];
108 }
109
110 $vars_array = array(
111 'userRoles' => json_encode($user_roles),
112 'content_restriction_activated' => json_encode($content_restriction_activated == 'yes'),
113 );
114
115 wp_localize_script('wppb-block-editor-assets-content-restriction', 'wppbBlockEditorData', $vars_array);
116 }
117
118 // Disable pointer events for our forms inside the Editing interface
119 $style = '.wppb-block-container{ pointer-events: none; }';
120 wp_add_inline_style( 'wp-block-library', $style );
121 }
122 );
123
124 add_action(
125 'init',
126 function () {
127 global $content_restriction_activated;
128 global $wp_version;
129
130 //Register the Content Restriction Start and Content Restriction End blocks
131 if ( $content_restriction_activated == 'yes' && version_compare( $wp_version, "5.0.0", ">=" ) ) {
132 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/build/content-restriction-start' ) )
133 register_block_type( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/build/content-restriction-start' );
134 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/build/content-restriction-end' ) )
135 register_block_type( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/build/content-restriction-end' );
136 }
137 //Register the shortcode blocks
138 if ( version_compare( $wp_version, "5.0.0", ">=" ) ) {
139 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/edit-profile.php' ) )
140 include_once WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/edit-profile.php' ;
141 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/login.php' ) )
142 include_once WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/login.php' ;
143 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/recover-password.php' ) )
144 include_once WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/recover-password.php' ;
145 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/register.php' ) )
146 include_once WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/register.php' ;
147 if( defined( 'WPPB_PAID_PLUGIN_URL' ) && wppb_check_if_add_on_is_active( 'wppb_userListing' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons/user-listing/assets/misc/gutenberg/blocks/user-listing.php' ) )
148 include_once( WPPB_PAID_PLUGIN_DIR . '/add-ons/user-listing/assets/misc/gutenberg/blocks/user-listing.php' );
149 }
150 }
151 );
152
153 function register_layout_category( $categories ) {
154
155 $categories[] = array(
156 'slug' => 'wppb-block',
157 'title' => 'Profile Builder'
158 );
159
160 return $categories;
161 }
162
163 if ( version_compare( get_bloginfo( 'version' ), '5.8', '>=' ) ) {
164 add_filter( 'block_categories_all', 'register_layout_category' );
165 } else {
166 add_filter( 'block_categories', 'register_layout_category' );
167 }
168