PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.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 4.0.3, at assets/misc/gutenberg/blocks/register.php

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