edit-profile.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.9.8, at assets/misc/gutenberg-blocks/edit-profile/edit-profile.php
| 1 | <?php |
| 2 | |
| 3 | // Exit if accessed directly |
| 4 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 5 | |
| 6 | /** |
| 7 | * Register: PHP. |
| 8 | */ |
| 9 | add_action( |
| 10 | 'init', |
| 11 | function() { |
| 12 | wp_register_script( |
| 13 | 'wppb-block-edit-profile', |
| 14 | add_query_arg( [ 'action' => 'wppb-block-edit-profile.js', ], admin_url( 'admin-ajax.php' ) ), |
| 15 | [ 'wp-blocks', 'wp-element', 'wp-editor' ], |
| 16 | microtime(), |
| 17 | true |
| 18 | ); |
| 19 | register_block_type( |
| 20 | __DIR__, |
| 21 | [ |
| 22 | 'render_callback' => function( $attributes, $content ) { |
| 23 | ob_start(); |
| 24 | do_action( 'wppb/edit-profile/render_callback', $attributes, $content ); |
| 25 | return ob_get_clean(); |
| 26 | }, |
| 27 | ] |
| 28 | ); |
| 29 | } |
| 30 | ); |
| 31 | |
| 32 | /** |
| 33 | * Render: PHP. |
| 34 | * |
| 35 | * @param array $attributes Optional. Block attributes. Default empty array. |
| 36 | * @param string $content Optional. Block content. Default empty string. |
| 37 | */ |
| 38 | add_action( |
| 39 | 'wppb/edit-profile/render_callback', |
| 40 | function( $attributes, $content ) { |
| 41 | if ( $attributes['is_preview'] ) { |
| 42 | echo ' |
| 43 | <svg |
| 44 | xmlns="http://www.w3.org/2000/svg" |
| 45 | fill="none" |
| 46 | viewBox="0 0 230 430" |
| 47 | style="width: "100%";" |
| 48 | > |
| 49 | <title>Edit Profile Block Preview</title> |
| 50 | <rect |
| 51 | width="44.373241" |
| 52 | height="15" |
| 53 | x="27.955204" |
| 54 | y="27.950914" |
| 55 | rx="3.5329013" |
| 56 | id="rect6" |
| 57 | style="fill:#a0a5aa;stroke-width:0.84058326" /> |
| 58 | <rect |
| 59 | width="6.177" |
| 60 | height="6.177" |
| 61 | x="27.955204" |
| 62 | y="388.05646" |
| 63 | rx="3" |
| 64 | id="rect38" |
| 65 | style="fill:#a0a5aa" /> |
| 66 | <rect |
| 67 | width="35.717747" |
| 68 | height="15" |
| 69 | x="27.955204" |
| 70 | y="406.9473" |
| 71 | rx="2.8437696" |
| 72 | id="rect6-7" |
| 73 | style="fill:#a0a5aa;stroke-width:0.75415772" /> |
| 74 | <rect |
| 75 | width="121.18815" |
| 76 | height="9.191123" |
| 77 | x="80.097206" |
| 78 | y="101.45288" |
| 79 | rx="6.5996327" |
| 80 | id="rect4-3-5" |
| 81 | style="fill:#a0a5aa;stroke-width:2.13954115" /> |
| 82 | <rect |
| 83 | width="169.35583" |
| 84 | height="4.6558123" |
| 85 | x="27.955204" |
| 86 | y="56.672096" |
| 87 | rx="9.2227373" |
| 88 | id="rect4-3-5-9" |
| 89 | style="fill:#a0a5aa;stroke-width:1.80013108" /> |
| 90 | <rect |
| 91 | width="22.35239" |
| 92 | height="11.730559" |
| 93 | x="27.955204" |
| 94 | y="79.031174" |
| 95 | rx="1.2172608" |
| 96 | id="rect4-3-1" |
| 97 | style="fill:#a0a5aa;stroke-width:1.03807247" /> |
| 98 | <rect |
| 99 | width="58.980843" |
| 100 | height="2.9058123" |
| 101 | x="80.097206" |
| 102 | y="112.6096" |
| 103 | rx="3.2119634" |
| 104 | id="rect4-3-5-2" |
| 105 | style="fill:#a0a5aa;stroke-width:0.83925813" /> |
| 106 | <rect |
| 107 | width="121.18815" |
| 108 | height="9.191123" |
| 109 | x="80.097206" |
| 110 | y="121.21694" |
| 111 | rx="6.5996327" |
| 112 | id="rect4-3-5-7" |
| 113 | style="fill:#a0a5aa;stroke-width:2.13954115" /> |
| 114 | <rect |
| 115 | width="121.18815" |
| 116 | height="9.191123" |
| 117 | x="80.097206" |
| 118 | y="134.21693" |
| 119 | rx="6.5996327" |
| 120 | id="rect4-3-5-0" |
| 121 | style="fill:#a0a5aa;stroke-width:2.13954115" /> |
| 122 | <rect |
| 123 | width="121.18815" |
| 124 | height="9.191123" |
| 125 | x="80.097206" |
| 126 | y="147.15443" |
| 127 | rx="6.5996327" |
| 128 | id="rect4-3-5-93" |
| 129 | style="fill:#a0a5aa;stroke-width:2.13954115" /> |
| 130 | <rect |
| 131 | width="121.18815" |
| 132 | height="9.191123" |
| 133 | x="80.097206" |
| 134 | y="202.06604" |
| 135 | rx="6.5996327" |
| 136 | id="rect4-3-5-6" |
| 137 | style="fill:#a0a5aa;stroke-width:2.13954115" /> |
| 138 | <rect |
| 139 | width="121.18815" |
| 140 | height="9.191123" |
| 141 | x="80.097206" |
| 142 | y="215.05089" |
| 143 | rx="6.5996327" |
| 144 | id="rect4-3-5-06" |
| 145 | style="fill:#a0a5aa;stroke-width:2.13954115" /> |
| 146 | <rect |
| 147 | width="121.18815" |
| 148 | height="47.81683" |
| 149 | x="80.097206" |
| 150 | y="266.19736" |
| 151 | rx="6.5996327" |
| 152 | id="rect4-3-5-26" |
| 153 | style="fill:#a0a5aa;stroke-width:4.88007784" /> |
| 154 | <rect |
| 155 | width="121.18815" |
| 156 | height="9.191123" |
| 157 | x="80.097206" |
| 158 | y="331.47766" |
| 159 | rx="6.5996327" |
| 160 | id="rect4-3-5-1" |
| 161 | style="fill:#a0a5aa;stroke-width:2.13954115" /> |
| 162 | <rect |
| 163 | width="121.18815" |
| 164 | height="9.191123" |
| 165 | x="80.097206" |
| 166 | y="351.15445" |
| 167 | rx="6.5996327" |
| 168 | id="rect4-3-5-8" |
| 169 | style="fill:#a0a5aa;stroke-width:2.13954115" /> |
| 170 | <rect |
| 171 | width="116.34488" |
| 172 | height="2.9058123" |
| 173 | x="80.097206" |
| 174 | y="316.20871" |
| 175 | rx="6.3358793" |
| 176 | id="rect4-3-5-2-7" |
| 177 | style="fill:#a0a5aa;stroke-width:1.17872834" /> |
| 178 | <rect |
| 179 | width="52.793659" |
| 180 | height="2.9058123" |
| 181 | x="80.097206" |
| 182 | y="322.88547" |
| 183 | rx="2.8750234" |
| 184 | id="rect4-3-5-2-9" |
| 185 | style="fill:#a0a5aa;stroke-width:0.7940191" /> |
| 186 | <rect |
| 187 | width="39.270241" |
| 188 | height="2.9058123" |
| 189 | x="80.097206" |
| 190 | y="342.66321" |
| 191 | rx="2.1385686" |
| 192 | id="rect4-3-5-2-2" |
| 193 | style="fill:#a0a5aa;stroke-width:0.68481278" /> |
| 194 | <rect |
| 195 | width="51.114281" |
| 196 | height="2.9058123" |
| 197 | x="80.097206" |
| 198 | y="362.35513" |
| 199 | rx="2.7835681" |
| 200 | id="rect4-3-5-2-0" |
| 201 | style="fill:#a0a5aa;stroke-width:0.78128809" /> |
| 202 | <rect |
| 203 | width="28.901199" |
| 204 | height="9.191123" |
| 205 | x="27.955204" |
| 206 | y="101.45288" |
| 207 | rx="1.573894" |
| 208 | id="rect4-3-5-5" |
| 209 | style="fill:#a0a5aa;stroke-width:1.04483688" /> |
| 210 | <rect |
| 211 | width="27.651199" |
| 212 | height="9.191123" |
| 213 | x="27.955204" |
| 214 | y="121.21694" |
| 215 | rx="1.5058219" |
| 216 | id="rect4-3-5-5-9" |
| 217 | style="fill:#a0a5aa;stroke-width:1.02199209" /> |
| 218 | <rect |
| 219 | width="26.151199" |
| 220 | height="9.191123" |
| 221 | x="27.955204" |
| 222 | y="134.21693" |
| 223 | rx="1.4241353" |
| 224 | id="rect4-3-5-5-2" |
| 225 | style="fill:#a0a5aa;stroke-width:0.99388552" /> |
| 226 | <rect |
| 227 | width="29.151199" |
| 228 | height="9.191123" |
| 229 | x="27.955204" |
| 230 | y="147.15443" |
| 231 | rx="1.5875086" |
| 232 | id="rect4-3-5-5-28" |
| 233 | style="fill:#a0a5aa;stroke-width:1.04934609" /> |
| 234 | <rect |
| 235 | width="19.901199" |
| 236 | height="9.191123" |
| 237 | x="27.955204" |
| 238 | y="202.06604" |
| 239 | rx="1.0837744" |
| 240 | id="rect4-3-5-5-97" |
| 241 | style="fill:#a0a5aa;stroke-width:0.8670221" /> |
| 242 | <rect |
| 243 | width="20.026199" |
| 244 | height="9.191123" |
| 245 | x="27.955204" |
| 246 | y="215.05089" |
| 247 | rx="1.0905817" |
| 248 | id="rect4-3-5-5-3" |
| 249 | style="fill:#a0a5aa;stroke-width:0.86974072" /> |
| 250 | <rect |
| 251 | width="42.526199" |
| 252 | height="9.191123" |
| 253 | x="27.955204" |
| 254 | y="266.19736" |
| 255 | rx="2.3158808" |
| 256 | id="rect4-3-5-5-6" |
| 257 | style="fill:#a0a5aa;stroke-width:1.26741493" /> |
| 258 | <rect |
| 259 | width="27.526199" |
| 260 | height="9.191123" |
| 261 | x="27.955204" |
| 262 | y="331.47766" |
| 263 | rx="1.4990147" |
| 264 | id="rect4-3-5-5-1" |
| 265 | style="fill:#a0a5aa;stroke-width:1.01967943" /> |
| 266 | <rect |
| 267 | width="45.901199" |
| 268 | height="9.191123" |
| 269 | x="27.955204" |
| 270 | y="351.15445" |
| 271 | rx="2.4996758" |
| 272 | id="rect4-3-5-5-29" |
| 273 | style="fill:#a0a5aa;stroke-width:1.31674767" /> |
| 274 | <rect |
| 275 | width="37.85239" |
| 276 | height="11.730559" |
| 277 | x="27.955204" |
| 278 | y="180.14156" |
| 279 | rx="2.0613558" |
| 280 | id="rect4-3-1-31" |
| 281 | style="fill:#a0a5aa;stroke-width:1.3508662" /> |
| 282 | <rect |
| 283 | width="46.10239" |
| 284 | height="11.730559" |
| 285 | x="27.955204" |
| 286 | y="244.31151" |
| 287 | rx="2.5106323" |
| 288 | id="rect4-3-1-9" |
| 289 | style="fill:#a0a5aa;stroke-width:1.49082756" /> |
| 290 | <rect |
| 291 | width="79.401199" |
| 292 | height="9.191123" |
| 293 | x="35.0494" |
| 294 | y="386.54941" |
| 295 | rx="4.3240104" |
| 296 | id="rect4-3-5-5-29-4" |
| 297 | style="fill:#a0a5aa;stroke-width:1.73182523" /> |
| 298 | </svg>'; |
| 299 | } else { |
| 300 | $form_name = ''; |
| 301 | if ( array_key_exists( 'form_name', $attributes ) ) { |
| 302 | $form_name = $attributes['form_name']; |
| 303 | } |
| 304 | if ( !$form_name || $form_name === '' ) { |
| 305 | $atts = [ |
| 306 | 'form_name' => '', |
| 307 | 'redirect_url' => $attributes['redirect_url'] !== '' ? ' redirect_url="' . esc_url( $attributes['redirect_url'] ) . '"' : '', |
| 308 | ]; |
| 309 | } else { |
| 310 | $atts = [ |
| 311 | 'form_name' => ' form_name="' . $form_name . '"', |
| 312 | 'redirect_url' => '', |
| 313 | ]; |
| 314 | } |
| 315 | echo '<div class="wppb-block-container">' . do_shortcode( '[wppb-edit-profile' . $atts['form_name'] . $atts['redirect_url'] . ' ]' ) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 316 | } |
| 317 | }, |
| 318 | 10, |
| 319 | 2 |
| 320 | ); |
| 321 | |
| 322 | /** |
| 323 | * Register: JavaScript. |
| 324 | */ |
| 325 | add_action( |
| 326 | 'wp_ajax_wppb-block-edit-profile.js', |
| 327 | function() { |
| 328 | header( 'Content-Type: text/javascript' ); |
| 329 | |
| 330 | $args = array( |
| 331 | 'post_type' => 'page', |
| 332 | 'posts_per_page' => -1 |
| 333 | ); |
| 334 | |
| 335 | if( function_exists( 'wc_get_page_id' ) ) |
| 336 | $args['exclude'] = wc_get_page_id( 'shop' ); |
| 337 | |
| 338 | $all_pages = get_posts( $args ); |
| 339 | ?> |
| 340 | ( function ( blocks, i18n, element, serverSideRender, blockEditor, components ) { |
| 341 | var { __ } = i18n; |
| 342 | var el = element.createElement; |
| 343 | var PanelBody = components.PanelBody; |
| 344 | var SelectControl = components.SelectControl; |
| 345 | var TextControl = components.TextControl; |
| 346 | var Button = components.Button; |
| 347 | var Text = components.__experimentalText; |
| 348 | var InspectorControls = wp.editor.InspectorControls; |
| 349 | |
| 350 | blocks.registerBlockType( 'wppb/edit-profile', { |
| 351 | icon: |
| 352 | el('svg', {}, |
| 353 | el( 'path', |
| 354 | { |
| 355 | d: "m 6.0748388,9.5111184 c -0.099,-0.038 -0.3519,-0.2294 -0.4445,-0.3021 -0.2808,-0.2202 -0.5499,-0.4486 -0.7896,-0.7139 -0.3274,-0.3624 -0.6189,-0.7523 -0.8327,-1.1938 -0.2727,-0.563 -0.4316,-1.1673 -0.4744,-1.7907 0,0 -0.011,-0.1397 -0.011,-0.1397 0,0 0,-0.5715 0,-0.5715 0,0 0.011,-0.127 0.011,-0.127 0.041,-0.5995 0.1724,-1.1913 0.4242,-1.7399 0.5843,-1.2728 1.7588,-2.28950004 3.0949,-2.70480004 0.5504,-0.1709 1.0894,-0.2356 1.6637,-0.2289 0,0 0.1397,0.012 0.1397,0.012 1.1751002,0.051 2.3266002,0.5475 3.1877002,1.34560004 0,0 0.2027,0.1916 0.2027,0.1916 0.5567,0.5821 0.9719,1.2857 1.2034,2.0574 0.089,0.2952 0.1506,0.5954 0.1834,0.9017 0,0 0.023,0.2413 0.023,0.2413 0,0 0.013,0.2667 0.013,0.2667 0,0 -0.013,0.3683 -0.013,0.3683 0,0.2138 -0.075,0.6249 -0.1255,0.8382 -0.3294,1.3871 -1.2433,2.4909 -2.3891,3.302 0.6849,0.2905 1.494,0.5944996 2.0955,1.0250996 0,0 0.2413,0.177 0.2413,0.177 0.1102,0.065 0.3181,0.1248 0.3358,0.2711 0.014,0.1159 -0.085,0.2251 -0.1545,0.3048 -0.1628,0.1872 -0.3068,0.3483 -0.575,0.2835 -0.051,-0.012 -0.093,-0.034 -0.1397,-0.058 0,0 -0.5588,-0.3592 -0.5588,-0.3592 -0.3912,-0.2347 -0.8643,-0.4613 -1.2954,-0.611 -2.1439002,-0.7439996 -4.5605002,-0.4705 -6.4897002,0.7249 -1.6213,1.0045 -2.8241,2.5675 -3.3528,4.401501 0,0 -0.097,0.3683 -0.097,0.3683 -0.063,0.2544 -0.1152,0.5525 -0.1463,0.8128 0,0 -0.034,0.3683 -0.034,0.3683 0.01,0.1204 0.027,0.2455 0.10599999,0.3424 0.1026,0.1269 0.3208,0.1654 0.4759,0.1656 0,0 4.9911,0 4.9911,0 0,0 2.7686,0 2.7686,0 0,0 0.1905,-0.013 0.1905,-0.013 0,0 1.3208002,0 1.3208002,0 0,0 0.1905,-0.013 0.1905,-0.013 0,0 0.6477,0 0.6477,0 0,0 0.2159,-0.013 0.2159,-0.013 0.2658,-3e-4 0.552,-0.016 0.8128,0.031 0.4383,0.079 0.8052,0.3029 1.1557,0.5678 0,0 0.3175,0.2498 0.3175,0.2498 0.053,0.042 0.119,0.083 0.1524,0.1422 0,0 -10.9855002,0 -10.9855002,0 0,0 -1.8669,0 -1.8669,0 0,0 -0.1397,-0.012 -0.1397,-0.012 -0.40049999,-0.027 -0.86169999,-0.085 -1.12069999,-0.433 -0.2141002,-0.2879 -0.20410019896,-0.6506 -0.2001002,-0.9906 0,-0.1616 0.055,-0.4918 0.084,-0.6604 0.06,-0.3549 0.1319,-0.7072 0.2284,-1.0541 0.1803,-0.6484 0.4123,-1.286301 0.73319999,-1.879601 0.5931,-1.0966 1.3661,-1.9912 2.371,-2.732 0.4948,-0.3647 1.1427,-0.7539 1.7018,-1.0104996 0,0 0.635,-0.278 0.635,-0.278 0,0 0.3175,-0.1324 0.3175,-0.1324 z m 2.2225,-8.54580004 c 0,0 -0.2413,0.028 -0.2413,0.028 -0.3083,0.042 -0.6099,0.11870004 -0.9017,0.22570004 -0.9628,0.353 -1.7756,1.0837 -2.2446,1.9932 -0.2473,0.4795 -0.4289,1.1231 -0.4351,1.6637 0,0 -0.013,0.2032 -0.013,0.2032 0,0 0.013,0.2286 0.013,0.2286 0,0.1545 0.04,0.3921 0.071,0.5461 0.095,0.4748 0.2701,0.9329 0.5234,1.3462 0.3003,0.4903 0.678,0.8906 1.1454,1.2246 0.3045,0.2177 0.6732,0.4094 1.0287,0.528 0.3581,0.1195 0.6406,0.1781 1.016,0.2154 0,0 0.127,0 0.127,0 0,0 0.127,0.013 0.127,0.013 0,0 0.3429,-0.013 0.3429,-0.013 0.1312,0 0.3877,-0.042 0.5207,-0.068 0.3128,-0.062 0.6662002,-0.1686 0.9525002,-0.3094 0,0 0.4191,-0.2243 0.4191,-0.2243 0.8838,-0.5502 1.5388,-1.4014 1.8142,-2.4077 0.066,-0.2429 0.1412,-0.6399 0.1416,-0.889 0,0 0,-0.4191 0,-0.4191 0,0 -0.012,-0.127 -0.012,-0.127 -0.016,-0.2261 -0.056,-0.4407 -0.1107,-0.6604 -0.3201,-1.2801 -1.3029,-2.3887 -2.5447,-2.8441 -0.3424002,-0.1255 -0.8554002,-0.25420004 -1.2192002,-0.25340004 0,0 -0.4572,0 -0.4572,0 0,0 -0.063,0 -0.063,0 z M 21.124339,6.8514184 c 0.13,-0.023 0.169,0.047 0.254,0.1324 0,0 0.3937,0.3937 0.3937,0.3937 0,0 1.7653,1.7653 1.7653,1.7653 0,0 0.4826,0.4826 0.4826,0.4826 0.065,0.065 0.1575,0.1366 0.1176,0.2413 -0.02,0.053 -0.1364,0.1584996 -0.1811,0.2031996 0,0 -0.3175,0.317 -0.3175,0.317 0,0 -0.127,0.115 -0.127,0.115 0,0 -1.5113,1.5111 -1.5113,1.5111 0,0 -2.3241,2.3241 -2.3241,2.3241 0,0 -0.4313,0.431801 -0.4313,0.431801 0,0 -0.2926,0.3048 -0.2926,0.3048 -0.095,0.095 -0.2788,0.2909 -0.381,0.3564 -0.089,0.057 -0.1807,0.081 -0.2794,0.1135 0,0 -0.4191,0.1397 -0.4191,0.1397 0,0 -1.3462,0.453 -1.3462,0.453 0,0 -0.8382,0.2794 -0.8382,0.2794 -0.3029,0.101 -0.5243,0.1858 -0.8509,0.182 -0.1179,0 -0.2656,-0.06 -0.381,-0.094 -0.057,-0.017 -0.1162,-0.032 -0.1343,-0.097 -0.022,-0.078 0.03,-0.1904 0.053,-0.2665 0,0 0.2001,-0.6477 0.2001,-0.6477 0,0 0.6986,-2.260601 0.6986,-2.260601 0,0 0.1777,-0.5715 0.1777,-0.5715 0.019,-0.057 0.056,-0.1991 0.083,-0.2413 0.026,-0.041 0.1157,-0.1263 0.1545,-0.1651 0,0 0.3048,-0.3048 0.3048,-0.3048 0,0 0.9525,-0.9525 0.9525,-0.9525 0,0 2.5781,-2.5780996 2.5781,-2.5780996 0,0 1.1049,-1.1049 1.1049,-1.1049 0,0 0.3048,-0.3048 0.3048,-0.3048 0.058,-0.058 0.1125,-0.1273 0.1905,-0.1578 z m 1.6891,2.9518 c 0,0 -1.2192,-1.2192 -1.2192,-1.2192 0,0 -0.3048,-0.3048 -0.3048,-0.3048 -0.027,-0.026 -0.089,-0.099 -0.127,-0.099 -0.032,0 -0.068,0.04 -0.089,0.061 0,0 -0.1905,0.1905 -0.1905,0.1905 0,0 -0.7747,0.7747 -0.7747,0.7747 0,0 -2.1463,2.1462996 -2.1463,2.1462996 0,0 -0.6858,0.6858 -0.6858,0.6858 -0.086,0.086 -0.3089,0.298 -0.3683,0.381 0,0 1.2192,1.2192 1.2192,1.2192 0,0 0.3048,0.3048 0.3048,0.3048 0.026,0.027 0.089,0.099 0.127,0.099 0.032,0 0.068,-0.04 0.089,-0.061 0,0 0.1905,-0.1905 0.1905,-0.1905 0,0 0.7747,-0.7747 0.7747,-0.7747 0,0 2.1463,-2.1463 2.1463,-2.1463 0,0 0.6858,-0.6858 0.6858,-0.6858 0.086,-0.086 0.3088,-0.2978996 0.3683,-0.3809996 z m -6.4897,3.3908996 c -0.051,0.059 -0.061,0.1437 -0.085,0.2159 0,0 -0.1493,0.4826 -0.1493,0.4826 0,0 -0.334,1.079501 -0.334,1.079501 0,0 -0.1305,0.4318 -0.1305,0.4318 0,0 0.381,-0.1228 0.381,-0.1228 0,0 0.6858,-0.2286 0.6858,-0.2286 0,0 0.7112,-0.237 0.7112,-0.237 0,0 0.3937,-0.135501 0.3937,-0.135501 0,0 -0.4953,-0.508 -0.4953,-0.508 0,0 -0.9779,-0.9779 -0.9779,-0.9779 z" |
| 356 | } |
| 357 | ) |
| 358 | ), |
| 359 | attributes: { |
| 360 | form_name : { |
| 361 | type: 'string', |
| 362 | default: '' |
| 363 | }, |
| 364 | redirect_url : { |
| 365 | type: 'string', |
| 366 | default: '', |
| 367 | }, |
| 368 | is_preview : { |
| 369 | type: 'boolean', |
| 370 | default: false, |
| 371 | }, |
| 372 | }, |
| 373 | |
| 374 | edit: function ( props ) { |
| 375 | return [ |
| 376 | el( |
| 377 | 'div', |
| 378 | Object.assign( blockEditor.useBlockProps(), { key: 'wppb/edit-profile/render' } ), |
| 379 | el( serverSideRender, |
| 380 | { |
| 381 | block: 'wppb/edit-profile', |
| 382 | attributes: props.attributes, |
| 383 | } |
| 384 | ) |
| 385 | ), |
| 386 | el( InspectorControls, { key: 'wppb/edit-profile/inspector' }, |
| 387 | [ |
| 388 | el( PanelBody, |
| 389 | { |
| 390 | title: __( 'Form Settings' , 'profile-builder' ), |
| 391 | key: 'wppb/edit-profile/inspector/form-settings' |
| 392 | }, |
| 393 | [ |
| 394 | el( SelectControl, |
| 395 | { |
| 396 | label: __( 'Form' , 'profile-builder' ), |
| 397 | key: 'wppb/edit-profile/inspector/form_settings/form_name', |
| 398 | help: __( 'Select the desired Edit Profile form' , 'profile-builder' ), |
| 399 | value: props.attributes.form_name, |
| 400 | options: [ |
| 401 | { |
| 402 | label: __( 'Default' , 'profile-builder' ), |
| 403 | value: '' |
| 404 | }, |
| 405 | <?php |
| 406 | $wppb_module_settings = get_option( 'wppb_module_settings', 'not_found' ); |
| 407 | |
| 408 | if ( !( ( $wppb_module_settings !== 'not_found' && ( |
| 409 | !isset( $wppb_module_settings['wppb_multipleEditProfileForms'] ) || |
| 410 | $wppb_module_settings['wppb_multipleEditProfileForms'] !== 'show' |
| 411 | ) ) || |
| 412 | $wppb_module_settings === 'not_found' ) ){ |
| 413 | $args = array( |
| 414 | 'post_type' => 'wppb-epf-cpt', |
| 415 | 'posts_per_page' => -1 |
| 416 | ); |
| 417 | |
| 418 | $the_query = new WP_Query( $args ); |
| 419 | |
| 420 | if ( $the_query->have_posts() ) { |
| 421 | foreach ( $the_query->posts as $post ) { |
| 422 | ?> |
| 423 | { |
| 424 | label: '<?php echo esc_html( $post->post_title ); ?>', |
| 425 | value: '<?php echo esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $post->post_title ) ); ?>' |
| 426 | }, |
| 427 | <?php |
| 428 | } |
| 429 | wp_reset_postdata(); |
| 430 | } |
| 431 | } |
| 432 | ?> |
| 433 | ], |
| 434 | onChange: ( value ) => { props.setAttributes( { form_name: value } ); } |
| 435 | } |
| 436 | ), |
| 437 | props.attributes.form_name != '' ? |
| 438 | el( Text, |
| 439 | { |
| 440 | key: 'wppb/edit-profile/inspector/form_settings/notice' |
| 441 | }, |
| 442 | [ |
| 443 | __( 'Edit the Settings for this form ' , 'profile-builder' ), |
| 444 | el( Button, |
| 445 | { |
| 446 | key: 'wppb/edit-profile/inspector/form_settings/notice_button', |
| 447 | href: '<?php echo esc_url( admin_url( 'edit.php?post_type=wppb-epf-cpt' ) ); ?>', |
| 448 | target: '_blank', |
| 449 | text: __( 'here' , 'profile-builder' ), |
| 450 | variant: 'link' |
| 451 | } |
| 452 | ) |
| 453 | ] |
| 454 | ) : |
| 455 | '', |
| 456 | ] |
| 457 | ), |
| 458 | props.attributes.form_name == '' ? |
| 459 | el( PanelBody, |
| 460 | { |
| 461 | title: __( 'Redirect' , 'profile-builder' ), |
| 462 | key: 'wppb/edit-profile/inspector/redirect' |
| 463 | }, |
| 464 | el( SelectControl, |
| 465 | { |
| 466 | label: __( 'After Edit Profile' , 'profile-builder' ), |
| 467 | key: 'wppb/edit-profile/inspector/redirect/redirect_url', |
| 468 | help: __( 'Select a page for an After Edit Profile Redirect' , 'profile-builder' ), |
| 469 | value: props.attributes.redirect_url, |
| 470 | options: [ |
| 471 | { |
| 472 | label: __( '' , 'profile-builder' ), |
| 473 | value: '' |
| 474 | }, |
| 475 | <?php |
| 476 | if( !empty( $all_pages ) ){ |
| 477 | foreach ( $all_pages as $page ){ |
| 478 | ?> |
| 479 | { |
| 480 | label: '<?php echo esc_html( $page->post_title ) ?>', |
| 481 | value: '<?php echo esc_url( get_page_link( $page->ID ) ) ?>' |
| 482 | }, |
| 483 | <?php |
| 484 | } |
| 485 | } |
| 486 | ?> |
| 487 | ], |
| 488 | onChange: ( value ) => { props.setAttributes( { redirect_url: value } ); } |
| 489 | } |
| 490 | ) |
| 491 | ) : |
| 492 | '', |
| 493 | ] |
| 494 | ), |
| 495 | el( blockEditor.InspectorAdvancedControls, { key: 'wppb/edit-profile/inspector_advanced' }, |
| 496 | [ |
| 497 | props.attributes.form_name == '' ? |
| 498 | el( TextControl, |
| 499 | { |
| 500 | label: __( 'After Edit Profile' , 'profile-builder' ), |
| 501 | key: 'wppb/edit-profile/inspector_advanced/redirect/redirect_url', |
| 502 | help: __( 'Manually type in an After Edit Profile Redirect URL' , 'profile-builder' ), |
| 503 | value: props.attributes.redirect_url, |
| 504 | onChange: ( value ) => { props.setAttributes( { redirect_url: value } ); } |
| 505 | } |
| 506 | ) : |
| 507 | '' |
| 508 | ] |
| 509 | ) |
| 510 | ]; |
| 511 | } |
| 512 | } ); |
| 513 | } )( |
| 514 | window.wp.blocks, |
| 515 | window.wp.i18n, |
| 516 | window.wp.element, |
| 517 | window.wp.serverSideRender, |
| 518 | window.wp.blockEditor, |
| 519 | window.wp.components |
| 520 | ); |
| 521 | <?php |
| 522 | exit; |
| 523 | } |
| 524 | ); |
| 525 |