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 / edit-profile.php

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

367 lines 15.0 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/edit-profile',
14 [
15 'render_callback' => function( $attributes, $content ) {
16 ob_start();
17 do_action( 'wppb/edit_profile/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_multipleEditProfileForms'] ) ||
32 $wppb_module_settings['wppb_multipleEditProfileForms'] !== 'show'
33 ) ) ||
34 $wppb_module_settings === 'not_found' ) ){
35 $args = array(
36 'post_type' => 'wppb-epf-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 $args = array(
52 'post_type' => 'page',
53 'posts_per_page' => -1
54 );
55
56 if( function_exists( 'wc_get_page_id' ) )
57 $args['exclude'] = wc_get_page_id( 'shop' );
58
59 $all_pages = get_posts( $args );
60
61 $url_options[] = [ "label" => "", "value" => "" ];
62 if( !empty( $all_pages ) ) {
63 foreach ( $all_pages as $page ) {
64 $url_options[] = [ "label" => esc_html( $page->post_title ) , "value" => esc_url( get_page_link( $page->ID ) ) ];
65 }
66 }
67
68 // Add pre-loaded data for my-namespace/my-block
69 wp_add_inline_script('wppb-register-editor-script', 'window.wppbEditProfileBlockConfig = ' . json_encode(array(
70 'wppb_paid' => defined( 'WPPB_PAID_PLUGIN_DIR' ),
71 'edit_profile_form_options' => $registration_form_options,
72 'button' => esc_url( admin_url( 'edit.php?post_type=wppb-epf-cpt' ) ),
73 'url_options' => $url_options,
74 )), 'before');
75 }
76 );
77
78 /**
79 * Render: PHP.
80 *
81 * @param array $attributes Optional. Block attributes. Default empty array.
82 * @param string $content Optional. Block content. Default empty string.
83 */
84 add_action(
85 'wppb/edit_profile/render_callback',
86 function( $attributes, $content ) {
87 if ( isset($attributes['is_preview']) && $attributes['is_preview'] === 'true' ) {
88 echo '
89 <svg
90 xmlns="http://www.w3.org/2000/svg"
91 fill="none"
92 viewBox="0 0 230 430"
93 style="width: "100%";"
94 >
95 <title>Edit Profile Block Preview</title>
96 <rect
97 width="44.373241"
98 height="15"
99 x="27.955204"
100 y="27.950914"
101 rx="3.5329013"
102 id="rect6"
103 style="fill:#a0a5aa;stroke-width:0.84058326" />
104 <rect
105 width="6.177"
106 height="6.177"
107 x="27.955204"
108 y="388.05646"
109 rx="3"
110 id="rect38"
111 style="fill:#a0a5aa" />
112 <rect
113 width="35.717747"
114 height="15"
115 x="27.955204"
116 y="406.9473"
117 rx="2.8437696"
118 id="rect6-7"
119 style="fill:#a0a5aa;stroke-width:0.75415772" />
120 <rect
121 width="121.18815"
122 height="9.191123"
123 x="80.097206"
124 y="101.45288"
125 rx="6.5996327"
126 id="rect4-3-5"
127 style="fill:#a0a5aa;stroke-width:2.13954115" />
128 <rect
129 width="169.35583"
130 height="4.6558123"
131 x="27.955204"
132 y="56.672096"
133 rx="9.2227373"
134 id="rect4-3-5-9"
135 style="fill:#a0a5aa;stroke-width:1.80013108" />
136 <rect
137 width="22.35239"
138 height="11.730559"
139 x="27.955204"
140 y="79.031174"
141 rx="1.2172608"
142 id="rect4-3-1"
143 style="fill:#a0a5aa;stroke-width:1.03807247" />
144 <rect
145 width="58.980843"
146 height="2.9058123"
147 x="80.097206"
148 y="112.6096"
149 rx="3.2119634"
150 id="rect4-3-5-2"
151 style="fill:#a0a5aa;stroke-width:0.83925813" />
152 <rect
153 width="121.18815"
154 height="9.191123"
155 x="80.097206"
156 y="121.21694"
157 rx="6.5996327"
158 id="rect4-3-5-7"
159 style="fill:#a0a5aa;stroke-width:2.13954115" />
160 <rect
161 width="121.18815"
162 height="9.191123"
163 x="80.097206"
164 y="134.21693"
165 rx="6.5996327"
166 id="rect4-3-5-0"
167 style="fill:#a0a5aa;stroke-width:2.13954115" />
168 <rect
169 width="121.18815"
170 height="9.191123"
171 x="80.097206"
172 y="147.15443"
173 rx="6.5996327"
174 id="rect4-3-5-93"
175 style="fill:#a0a5aa;stroke-width:2.13954115" />
176 <rect
177 width="121.18815"
178 height="9.191123"
179 x="80.097206"
180 y="202.06604"
181 rx="6.5996327"
182 id="rect4-3-5-6"
183 style="fill:#a0a5aa;stroke-width:2.13954115" />
184 <rect
185 width="121.18815"
186 height="9.191123"
187 x="80.097206"
188 y="215.05089"
189 rx="6.5996327"
190 id="rect4-3-5-06"
191 style="fill:#a0a5aa;stroke-width:2.13954115" />
192 <rect
193 width="121.18815"
194 height="47.81683"
195 x="80.097206"
196 y="266.19736"
197 rx="6.5996327"
198 id="rect4-3-5-26"
199 style="fill:#a0a5aa;stroke-width:4.88007784" />
200 <rect
201 width="121.18815"
202 height="9.191123"
203 x="80.097206"
204 y="331.47766"
205 rx="6.5996327"
206 id="rect4-3-5-1"
207 style="fill:#a0a5aa;stroke-width:2.13954115" />
208 <rect
209 width="121.18815"
210 height="9.191123"
211 x="80.097206"
212 y="351.15445"
213 rx="6.5996327"
214 id="rect4-3-5-8"
215 style="fill:#a0a5aa;stroke-width:2.13954115" />
216 <rect
217 width="116.34488"
218 height="2.9058123"
219 x="80.097206"
220 y="316.20871"
221 rx="6.3358793"
222 id="rect4-3-5-2-7"
223 style="fill:#a0a5aa;stroke-width:1.17872834" />
224 <rect
225 width="52.793659"
226 height="2.9058123"
227 x="80.097206"
228 y="322.88547"
229 rx="2.8750234"
230 id="rect4-3-5-2-9"
231 style="fill:#a0a5aa;stroke-width:0.7940191" />
232 <rect
233 width="39.270241"
234 height="2.9058123"
235 x="80.097206"
236 y="342.66321"
237 rx="2.1385686"
238 id="rect4-3-5-2-2"
239 style="fill:#a0a5aa;stroke-width:0.68481278" />
240 <rect
241 width="51.114281"
242 height="2.9058123"
243 x="80.097206"
244 y="362.35513"
245 rx="2.7835681"
246 id="rect4-3-5-2-0"
247 style="fill:#a0a5aa;stroke-width:0.78128809" />
248 <rect
249 width="28.901199"
250 height="9.191123"
251 x="27.955204"
252 y="101.45288"
253 rx="1.573894"
254 id="rect4-3-5-5"
255 style="fill:#a0a5aa;stroke-width:1.04483688" />
256 <rect
257 width="27.651199"
258 height="9.191123"
259 x="27.955204"
260 y="121.21694"
261 rx="1.5058219"
262 id="rect4-3-5-5-9"
263 style="fill:#a0a5aa;stroke-width:1.02199209" />
264 <rect
265 width="26.151199"
266 height="9.191123"
267 x="27.955204"
268 y="134.21693"
269 rx="1.4241353"
270 id="rect4-3-5-5-2"
271 style="fill:#a0a5aa;stroke-width:0.99388552" />
272 <rect
273 width="29.151199"
274 height="9.191123"
275 x="27.955204"
276 y="147.15443"
277 rx="1.5875086"
278 id="rect4-3-5-5-28"
279 style="fill:#a0a5aa;stroke-width:1.04934609" />
280 <rect
281 width="19.901199"
282 height="9.191123"
283 x="27.955204"
284 y="202.06604"
285 rx="1.0837744"
286 id="rect4-3-5-5-97"
287 style="fill:#a0a5aa;stroke-width:0.8670221" />
288 <rect
289 width="20.026199"
290 height="9.191123"
291 x="27.955204"
292 y="215.05089"
293 rx="1.0905817"
294 id="rect4-3-5-5-3"
295 style="fill:#a0a5aa;stroke-width:0.86974072" />
296 <rect
297 width="42.526199"
298 height="9.191123"
299 x="27.955204"
300 y="266.19736"
301 rx="2.3158808"
302 id="rect4-3-5-5-6"
303 style="fill:#a0a5aa;stroke-width:1.26741493" />
304 <rect
305 width="27.526199"
306 height="9.191123"
307 x="27.955204"
308 y="331.47766"
309 rx="1.4990147"
310 id="rect4-3-5-5-1"
311 style="fill:#a0a5aa;stroke-width:1.01967943" />
312 <rect
313 width="45.901199"
314 height="9.191123"
315 x="27.955204"
316 y="351.15445"
317 rx="2.4996758"
318 id="rect4-3-5-5-29"
319 style="fill:#a0a5aa;stroke-width:1.31674767" />
320 <rect
321 width="37.85239"
322 height="11.730559"
323 x="27.955204"
324 y="180.14156"
325 rx="2.0613558"
326 id="rect4-3-1-31"
327 style="fill:#a0a5aa;stroke-width:1.3508662" />
328 <rect
329 width="46.10239"
330 height="11.730559"
331 x="27.955204"
332 y="244.31151"
333 rx="2.5106323"
334 id="rect4-3-1-9"
335 style="fill:#a0a5aa;stroke-width:1.49082756" />
336 <rect
337 width="79.401199"
338 height="9.191123"
339 x="35.0494"
340 y="386.54941"
341 rx="4.3240104"
342 id="rect4-3-5-5-29-4"
343 style="fill:#a0a5aa;stroke-width:1.73182523" />
344 </svg>';
345 } else {
346 $form_name = '';
347 if ( array_key_exists( 'form_name', $attributes ) ) {
348 $form_name = $attributes['form_name'];
349 }
350 if ( !$form_name || $form_name === '' ) {
351 $atts = [
352 'form_name' => '',
353 'redirect_url' => $attributes['redirect_url'] !== '' ? ' redirect_url="' . esc_url( $attributes['redirect_url'] ) . '"' : '',
354 'ajax' => $attributes['ajax'] ? ' ajax="true"' : '',
355 ];
356 } else {
357 $atts = [
358 'form_name' => ' form_name="' . esc_attr( $form_name ) . '"',
359 'redirect_url' => '',
360 'ajax' => ' ajax="multiple-register-form"',
361 ];
362 }
363 echo '<div class="wppb-block-container">' . do_shortcode( '[wppb-edit-profile' . $atts['form_name'] . $atts['redirect_url'] . $atts['ajax'] . ' ]' ) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
364 }
365 }
366 , 10, 2 );
367