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 / blocks / register.php

register.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.16.3, at assets/misc/gutenberg/blocks/register.php

388 lines 16.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly.
4 }
5
6 /**
7 * Registers the block using the metadata loaded from the `block.json` file.
8 * Behind the scenes, it registers also all assets so they can be enqueued
9 * through the block editor in the corresponding context.
10 *
11 * @see https://developer.wordpress.org/reference/functions/register_block_type/
12 */
13 register_block_type( __DIR__ . '/build/register',
14 [
15 'render_callback' => function( $attributes, $content ) {
16 ob_start();
17 do_action( 'wppb/register/render_callback', $attributes, $content );
18 return ob_get_clean();
19 },
20 ]
21 );
22
23 add_action(
24 'admin_enqueue_scripts',
25 function () {
26 $wppb_module_settings = get_option( 'wppb_module_settings', 'not_found' );
27
28 $registration_form_options[] = [ "label" => __( 'Default' , 'profile-builder' ), "value" => "" ];
29
30 if ( !( ( $wppb_module_settings !== 'not_found' && (
31 !isset( $wppb_module_settings['wppb_multipleRegistrationForms'] ) ||
32 $wppb_module_settings['wppb_multipleRegistrationForms'] !== 'show'
33 ) ) ||
34 $wppb_module_settings === 'not_found' ) ){
35 $args = array(
36 'post_type' => 'wppb-rf-cpt',
37 'posts_per_page' => -1
38 );
39
40 $the_query = new WP_Query( $args );
41
42 if ( $the_query->have_posts() ) {
43 foreach ( $the_query->posts as $post ) {
44
45 $registration_form_options[] = [ "label" => esc_html( $post->post_title ) , "value" => esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $post->post_title ) ) ];
46 }
47 wp_reset_postdata();
48 }
49 }
50
51 if (!function_exists('get_editable_roles')) {
52 require_once ABSPATH . 'wp-admin/includes/user.php';
53 }
54
55 $user_roles = get_editable_roles();
56
57 $role_options[] = [ "label" => __( 'Default' , 'profile-builder' ), "value" => esc_attr( get_option("default_role") ) ];
58
59 foreach ($user_roles as $key => $role) {
60 $user_roles[$key] = $role['name'];
61 $role_options[] = [ "label" => esc_html( $role["name"] ) , "value" => esc_attr( $key ) ];
62 }
63
64 $args = array(
65 'post_type' => 'page',
66 'posts_per_page' => -1
67 );
68
69 if( function_exists( 'wc_get_page_id' ) )
70 $args['exclude'] = wc_get_page_id( 'shop' );
71
72 $all_pages = get_posts( $args );
73
74 $url_options[] = [ "label" => "", "value" => "" ];
75 if( !empty( $all_pages ) ) {
76 foreach ( $all_pages as $page ) {
77 $url_options[] = [ "label" => esc_html( $page->post_title ) , "value" => esc_url( get_page_link( $page->ID ) ) ];
78 }
79 }
80
81
82 // Add pre-loaded data for my-namespace/my-block
83 wp_add_inline_script('wppb-register-editor-script', 'window.wppbRegisterBlockConfig = ' . json_encode(array(
84 'wppb_paid' => defined( 'WPPB_PAID_PLUGIN_DIR' ),
85 'registration_form_options' => $registration_form_options,
86 'role_options' => $role_options,
87 'button' => esc_url( admin_url( 'edit.php?post_type=wppb-rf-cpt' ) ),
88 'url_options' => $url_options,
89 )), 'before');
90 }
91 );
92
93 /**
94 * Render: PHP.
95 *
96 * @param array $attributes Optional. Block attributes. Default empty array.
97 * @param string $content Optional. Block content. Default empty string.
98 */
99 add_action(
100 'wppb/register/render_callback',
101 function( $attributes, $content ) {
102 if ( isset($attributes['is_preview']) && $attributes['is_preview'] === 'true' ) {
103 echo '
104 <svg
105 xmlns="http://www.w3.org/2000/svg"
106 fill="none"
107 viewBox="0 0 230 430"
108 style="width: "100%";"
109 >
110 <title>Register Block Preview</title>
111 <rect
112 width="44.373241"
113 height="15"
114 x="27.955204"
115 y="27.950914"
116 rx="3.5329013"
117 id="rect6"
118 style="fill:#a0a5aa;stroke-width:0.84058326" />
119 <rect
120 width="6.177"
121 height="6.177"
122 x="27.955204"
123 y="388.05646"
124 rx="3"
125 id="rect38"
126 style="fill:#a0a5aa" />
127 <rect
128 width="35.717747"
129 height="15"
130 x="27.955204"
131 y="406.9473"
132 rx="2.8437696"
133 id="rect6-7"
134 style="fill:#a0a5aa;stroke-width:0.75415772" />
135 <rect
136 width="121.18815"
137 height="9.191123"
138 x="80.097206"
139 y="101.45288"
140 rx="6.5996327"
141 id="rect4-3-5"
142 style="fill:#a0a5aa;stroke-width:2.13954115" />
143 <rect
144 width="169.35583"
145 height="4.6558123"
146 x="27.955204"
147 y="56.672096"
148 rx="9.2227373"
149 id="rect4-3-5-9"
150 style="fill:#a0a5aa;stroke-width:1.80013108" />
151 <rect
152 width="22.35239"
153 height="11.730559"
154 x="27.955204"
155 y="79.031174"
156 rx="1.2172608"
157 id="rect4-3-1"
158 style="fill:#a0a5aa;stroke-width:1.03807247" />
159 <rect
160 width="58.980843"
161 height="2.9058123"
162 x="80.097206"
163 y="112.6096"
164 rx="3.2119634"
165 id="rect4-3-5-2"
166 style="fill:#a0a5aa;stroke-width:0.83925813" />
167 <rect
168 width="121.18815"
169 height="9.191123"
170 x="80.097206"
171 y="121.21694"
172 rx="6.5996327"
173 id="rect4-3-5-7"
174 style="fill:#a0a5aa;stroke-width:2.13954115" />
175 <rect
176 width="121.18815"
177 height="9.191123"
178 x="80.097206"
179 y="134.21693"
180 rx="6.5996327"
181 id="rect4-3-5-0"
182 style="fill:#a0a5aa;stroke-width:2.13954115" />
183 <rect
184 width="121.18815"
185 height="9.191123"
186 x="80.097206"
187 y="147.15443"
188 rx="6.5996327"
189 id="rect4-3-5-93"
190 style="fill:#a0a5aa;stroke-width:2.13954115" />
191 <rect
192 width="121.18815"
193 height="9.191123"
194 x="80.097206"
195 y="202.06604"
196 rx="6.5996327"
197 id="rect4-3-5-6"
198 style="fill:#a0a5aa;stroke-width:2.13954115" />
199 <rect
200 width="121.18815"
201 height="9.191123"
202 x="80.097206"
203 y="215.05089"
204 rx="6.5996327"
205 id="rect4-3-5-06"
206 style="fill:#a0a5aa;stroke-width:2.13954115" />
207 <rect
208 width="121.18815"
209 height="47.81683"
210 x="80.097206"
211 y="266.19736"
212 rx="6.5996327"
213 id="rect4-3-5-26"
214 style="fill:#a0a5aa;stroke-width:4.88007784" />
215 <rect
216 width="121.18815"
217 height="9.191123"
218 x="80.097206"
219 y="331.47766"
220 rx="6.5996327"
221 id="rect4-3-5-1"
222 style="fill:#a0a5aa;stroke-width:2.13954115" />
223 <rect
224 width="121.18815"
225 height="9.191123"
226 x="80.097206"
227 y="351.15445"
228 rx="6.5996327"
229 id="rect4-3-5-8"
230 style="fill:#a0a5aa;stroke-width:2.13954115" />
231 <rect
232 width="116.34488"
233 height="2.9058123"
234 x="80.097206"
235 y="316.20871"
236 rx="6.3358793"
237 id="rect4-3-5-2-7"
238 style="fill:#a0a5aa;stroke-width:1.17872834" />
239 <rect
240 width="52.793659"
241 height="2.9058123"
242 x="80.097206"
243 y="322.88547"
244 rx="2.8750234"
245 id="rect4-3-5-2-9"
246 style="fill:#a0a5aa;stroke-width:0.7940191" />
247 <rect
248 width="39.270241"
249 height="2.9058123"
250 x="80.097206"
251 y="342.66321"
252 rx="2.1385686"
253 id="rect4-3-5-2-2"
254 style="fill:#a0a5aa;stroke-width:0.68481278" />
255 <rect
256 width="51.114281"
257 height="2.9058123"
258 x="80.097206"
259 y="362.35513"
260 rx="2.7835681"
261 id="rect4-3-5-2-0"
262 style="fill:#a0a5aa;stroke-width:0.78128809" />
263 <rect
264 width="28.901199"
265 height="9.191123"
266 x="27.955204"
267 y="101.45288"
268 rx="1.573894"
269 id="rect4-3-5-5"
270 style="fill:#a0a5aa;stroke-width:1.04483688" />
271 <rect
272 width="27.651199"
273 height="9.191123"
274 x="27.955204"
275 y="121.21694"
276 rx="1.5058219"
277 id="rect4-3-5-5-9"
278 style="fill:#a0a5aa;stroke-width:1.02199209" />
279 <rect
280 width="26.151199"
281 height="9.191123"
282 x="27.955204"
283 y="134.21693"
284 rx="1.4241353"
285 id="rect4-3-5-5-2"
286 style="fill:#a0a5aa;stroke-width:0.99388552" />
287 <rect
288 width="29.151199"
289 height="9.191123"
290 x="27.955204"
291 y="147.15443"
292 rx="1.5875086"
293 id="rect4-3-5-5-28"
294 style="fill:#a0a5aa;stroke-width:1.04934609" />
295 <rect
296 width="19.901199"
297 height="9.191123"
298 x="27.955204"
299 y="202.06604"
300 rx="1.0837744"
301 id="rect4-3-5-5-97"
302 style="fill:#a0a5aa;stroke-width:0.8670221" />
303 <rect
304 width="20.026199"
305 height="9.191123"
306 x="27.955204"
307 y="215.05089"
308 rx="1.0905817"
309 id="rect4-3-5-5-3"
310 style="fill:#a0a5aa;stroke-width:0.86974072" />
311 <rect
312 width="42.526199"
313 height="9.191123"
314 x="27.955204"
315 y="266.19736"
316 rx="2.3158808"
317 id="rect4-3-5-5-6"
318 style="fill:#a0a5aa;stroke-width:1.26741493" />
319 <rect
320 width="27.526199"
321 height="9.191123"
322 x="27.955204"
323 y="331.47766"
324 rx="1.4990147"
325 id="rect4-3-5-5-1"
326 style="fill:#a0a5aa;stroke-width:1.01967943" />
327 <rect
328 width="45.901199"
329 height="9.191123"
330 x="27.955204"
331 y="351.15445"
332 rx="2.4996758"
333 id="rect4-3-5-5-29"
334 style="fill:#a0a5aa;stroke-width:1.31674767" />
335 <rect
336 width="37.85239"
337 height="11.730559"
338 x="27.955204"
339 y="180.14156"
340 rx="2.0613558"
341 id="rect4-3-1-31"
342 style="fill:#a0a5aa;stroke-width:1.3508662" />
343 <rect
344 width="46.10239"
345 height="11.730559"
346 x="27.955204"
347 y="244.31151"
348 rx="2.5106323"
349 id="rect4-3-1-9"
350 style="fill:#a0a5aa;stroke-width:1.49082756" />
351 <rect
352 width="79.401199"
353 height="9.191123"
354 x="35.0494"
355 y="386.54941"
356 rx="4.3240104"
357 id="rect4-3-5-5-29-4"
358 style="fill:#a0a5aa;stroke-width:1.73182523" />
359 </svg>';
360 } else {
361 $form_name = '';
362 if ( array_key_exists( 'form_name', $attributes ) ) {
363 $form_name = $attributes['form_name'];
364 }
365 if ( !$form_name || $form_name === '' ) {
366 $atts = [
367 'role' => $attributes['role'] !== '' ? ' role="' . esc_attr( $attributes['role'] ) . '"' : '',
368 'form_name' => '',
369 'redirect_url' => $attributes['redirect_url'] !== '' ? ' redirect_url="' . esc_url( $attributes['redirect_url'] ) . '"' : '',
370 'logout_redirect_url' => $attributes['logout_redirect_url'] !== '' ? ' logout_redirect_url="' . esc_url( $attributes['logout_redirect_url'] ) . '"' : '',
371 'automatic_login' => $attributes['automatic_login'] ? ' automatic_login="yes"' : '',
372 'ajax' => $attributes['ajax'] ? ' ajax="true"' : '',
373 ];
374 } else {
375 $atts = [
376 'role' => '',
377 'form_name' => ' form_name="' . esc_attr( $form_name ) . '"',
378 'redirect_url' => '',
379 'logout_redirect_url' => $attributes['logout_redirect_url'] !== '' ? ' logout_redirect_url="' . esc_url( $attributes['logout_redirect_url'] ) . '"' : '',
380 'automatic_login' => '',
381 'ajax' => ' ajax="multiple-register-form"',
382 ];
383 }
384 echo '<div class="wppb-block-container">' . do_shortcode( '[wppb-register' . $atts['role'] . $atts['form_name'] . $atts['redirect_url'] . $atts['logout_redirect_url'] . $atts['automatic_login'] . $atts['ajax'] . ' ]' ) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
385 }
386 }
387 , 10, 2 );
388