PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.16.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.16.3
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.3, at assets/misc/gutenberg/enqueue-block-editor-assets.php

167 lines 8.4 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 if ( wppb_should_load_block_theme_stylesheet() )
25 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);
26
27 }
28 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)
29
30 if ( file_exists( WPPB_PAID_PLUGIN_DIR . '/features/form-designs/css/' . $active_design . '/form-design-general-style.css' ) )
31 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 );
32
33 if ( file_exists( WPPB_PAID_PLUGIN_DIR . '/features/form-designs/css/' . $active_design .'/extra-form-notifications-style.css' ) )
34 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 );
35 }
36
37 //Select
38 // Don't enqueue when JetEngine is active
39 if( !class_exists( 'Jet_Engine' ) ){
40 //Select2
41 wp_enqueue_script('wppb_select2_js', WPPB_PLUGIN_URL . 'assets/js/select2/select2.min.js', array('jquery'), PROFILE_BUILDER_VERSION);
42 wp_enqueue_style('wppb_select2_css', WPPB_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), PROFILE_BUILDER_VERSION);
43 }
44
45
46 //Upload
47 wp_enqueue_style('wppb-upload-css', WPPB_PLUGIN_URL . 'front-end/default-fields/upload/upload.css', false, PROFILE_BUILDER_VERSION);
48
49 if ( defined( 'WPPB_PAID_PLUGIN_URL' ) ) {
50 //Select CPT
51 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);
52
53 //Select Taxonomy
54 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);
55
56 //Multi-Step Forms compatibility
57 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);
58
59 //Social Connect
60 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);
61
62 if ( in_array( PROFILE_BUILDER, ['Profile Builder Pro', 'Profile Builder Agency', 'Profile Builder Unlimited'] ) ) {
63 //Userlisting
64 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);
65 wp_localize_script('wppb-userlisting-js', 'wppb_userlisting_obj', array('pageSlug' => wppb_get_users_pagination_slug()));
66 wp_enqueue_style('wppb-ul-slider-css', WPPB_PAID_PLUGIN_URL . 'add-ons/user-listing/jquery-ui-slider.min.css', array(), PROFILE_BUILDER_VERSION);
67 wp_enqueue_script('jquery-ui-slider');
68 }
69 }
70 }
71 );
72
73 add_action(
74 'enqueue_block_editor_assets',
75 function () {
76 global $content_restriction_activated;
77 global $wp_version;
78
79 global $pagenow;
80
81 $arrDeps = ($pagenow === 'widgets.php') ?
82 array( 'wp-blocks', 'wp-dom', 'wp-dom-ready', 'wp-edit-widgets' ) :
83 array( 'wp-blocks', 'wp-dom', 'wp-dom-ready', 'wp-edit-post' );
84
85
86 //Register the Block Content Restriction assets
87 if ( $content_restriction_activated == 'yes' && version_compare( $wp_version, "5.0.0", ">=" ) ) {
88 wp_register_script(
89 'wppb-block-editor-assets-content-restriction',
90 WPPB_PLUGIN_URL . 'assets/misc/gutenberg/block-content-restriction/build/index.js',
91 $arrDeps,
92 PROFILE_BUILDER_VERSION
93 );
94 wp_enqueue_script('wppb-block-editor-assets-content-restriction');
95
96 if (!function_exists('get_editable_roles')) {
97 require_once ABSPATH . 'wp-admin/includes/user.php';
98 }
99
100 $user_roles_initial = get_editable_roles();
101
102 foreach ($user_roles_initial as $key => $role) {
103 $user_roles[] = [
104 "slug" => $key,
105 "name" => $role['name'],
106 ];
107 }
108
109 $vars_array = array(
110 'userRoles' => json_encode($user_roles),
111 'content_restriction_activated' => json_encode($content_restriction_activated == 'yes'),
112 );
113
114 wp_localize_script('wppb-block-editor-assets-content-restriction', 'wppbBlockEditorData', $vars_array);
115 }
116
117 // Disable pointer events for our forms inside the Editing interface
118 $style = '.wppb-block-container{ pointer-events: none; }';
119 wp_add_inline_style( 'wp-block-library', $style );
120 }
121 );
122
123 add_action(
124 'init',
125 function () {
126 global $content_restriction_activated;
127 global $wp_version;
128
129 //Register the Content Restriction Start and Content Restriction End blocks
130 if ( $content_restriction_activated == 'yes' && version_compare( $wp_version, "5.0.0", ">=" ) ) {
131 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/build/content-restriction-start' ) )
132 register_block_type( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/build/content-restriction-start' );
133 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/build/content-restriction-end' ) )
134 register_block_type( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/build/content-restriction-end' );
135 }
136 //Register the shortcode blocks
137 if ( version_compare( $wp_version, "5.0.0", ">=" ) ) {
138 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/edit-profile.php' ) )
139 include_once WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/edit-profile.php' ;
140 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/login.php' ) )
141 include_once WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/login.php' ;
142 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/recover-password.php' ) )
143 include_once WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/recover-password.php' ;
144 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/register.php' ) )
145 include_once WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/blocks/register.php' ;
146 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' ) )
147 include_once( WPPB_PAID_PLUGIN_DIR . '/add-ons/user-listing/assets/misc/gutenberg/blocks/user-listing.php' );
148 }
149 }
150 );
151
152 function register_layout_category( $categories ) {
153
154 $categories[] = array(
155 'slug' => 'wppb-block',
156 'title' => 'Profile Builder'
157 );
158
159 return $categories;
160 }
161
162 if ( version_compare( get_bloginfo( 'version' ), '5.8', '>=' ) ) {
163 add_filter( 'block_categories_all', 'register_layout_category' );
164 } else {
165 add_filter( 'block_categories', 'register_layout_category' );
166 }
167