| 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-register', |
| 14 |
add_query_arg( [ 'action' => 'wppb-block-register.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/register/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/register/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>Register 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 |
'role' => $attributes['role'] !== '' ? ' role="' . esc_attr( $attributes['role'] ) . '"' : '', |
| 307 |
'form_name' => '', |
| 308 |
'redirect_url' => $attributes['redirect_url'] !== '' ? ' redirect_url="' . esc_url( $attributes['redirect_url'] ) . '"' : '', |
| 309 |
'logout_redirect_url' => $attributes['logout_redirect_url'] !== '' ? ' logout_redirect_url="' . esc_url( $attributes['logout_redirect_url'] ) . '"' : '', |
| 310 |
'automatic_login' => $attributes['automatic_login'] ? ' automatic_login="yes"' : '', |
| 311 |
]; |
| 312 |
} else { |
| 313 |
$atts = [ |
| 314 |
'role' => '', |
| 315 |
'form_name' => ' form_name="' . $form_name . '"', |
| 316 |
'redirect_url' => '', |
| 317 |
'logout_redirect_url' => $attributes['logout_redirect_url'] !== '' ? ' logout_redirect_url="' . esc_url( $attributes['logout_redirect_url'] ) . '"' : '', |
| 318 |
'automatic_login' => '', |
| 319 |
]; |
| 320 |
} |
| 321 |
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'] . ' ]' ) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 322 |
} |
| 323 |
}, |
| 324 |
10, |
| 325 |
2 |
| 326 |
); |
| 327 |
|
| 328 |
/** |
| 329 |
* Register: JavaScript. |
| 330 |
*/ |
| 331 |
add_action( |
| 332 |
'wp_ajax_wppb-block-register.js', |
| 333 |
function() { |
| 334 |
header( 'Content-Type: text/javascript' ); |
| 335 |
|
| 336 |
$args = array( |
| 337 |
'post_type' => 'page', |
| 338 |
'posts_per_page' => -1 |
| 339 |
); |
| 340 |
|
| 341 |
if( function_exists( 'wc_get_page_id' ) ) |
| 342 |
$args['exclude'] = wc_get_page_id( 'shop' ); |
| 343 |
|
| 344 |
$all_pages = get_posts( $args ); |
| 345 |
?> |
| 346 |
( function ( blocks, i18n, element, serverSideRender, blockEditor, components ) { |
| 347 |
var { __ } = i18n; |
| 348 |
var el = element.createElement; |
| 349 |
var PanelBody = components.PanelBody; |
| 350 |
var SelectControl = components.SelectControl; |
| 351 |
var ToggleControl = components.ToggleControl; |
| 352 |
var TextControl = components.TextControl; |
| 353 |
var Button = components.Button; |
| 354 |
var Text = components.__experimentalText; |
| 355 |
var InspectorControls = wp.editor.InspectorControls; |
| 356 |
|
| 357 |
blocks.registerBlockType( 'wppb/register', { |
| 358 |
icon: |
| 359 |
el('svg', {}, |
| 360 |
el( 'path', |
| 361 |
{ |
| 362 |
d: "m 6.060947,9.5388969 c -0.049,-0.058 -0.1159,-0.093 -0.1778,-0.1361 0,0 -0.2921,-0.215 -0.2921,-0.215 -0.271,-0.2089 -0.5275,-0.4398 -0.7608,-0.6903 -0.6133,-0.6582 -1.0671,-1.5116 -1.2277,-2.4003 -0.043,-0.2401 -0.081,-0.5187 -0.082,-0.762 0,0 -0.013,-0.2794 -0.013,-0.2794 0,0 0.012,-0.127 0.012,-0.127 0,0 0,-0.1651 0,-0.1651 0,0 0.012,-0.127 0.012,-0.127 0,0 0.049,-0.4318 0.049,-0.4318 0.1148,-0.7792 0.4319,-1.5308 0.9068,-2.159 0.5129,-0.6785 1.2601,-1.27849998 2.043,-1.61639998 0.5894,-0.2544 1.2241,-0.4081 1.8669,-0.4156 0,0 0.1651,-0.0130000022 0.1651,-0.0130000022 0,0 0.127,0.0120000021 0.127,0.0120000021 0,0 0.1651,0 0.1651,0 0,0 0.127,0.012 0.127,0.012 0.3658,0.025 0.729,0.096 1.0795,0.2041 1.3113,0.4033 2.4651,1.33699998 3.0701,2.57829998 0.6277,1.2874 0.7121,2.7812 0.1735,4.1148 -0.2399,0.5938 -0.5806,1.1109 -1.0063,1.5875 -0.2369,0.2653 -0.499,0.5094 -0.7768,0.7316 -0.089,0.072 -0.2831,0.2336 -0.381,0.2717 0,0 0,0.025 0,0.025 0,0 0.7112,0.2940999 0.7112,0.2940999 0.6331,0.2717002 1.0023,0.4378002 1.5621,0.8586002 0,0 0.3173,0.185 0.3173,0.185 0.213,0.1813 -0.071,0.4368 -0.203,0.5673 -0.041,0.041 -0.066,0.065 -0.1143,0.097 -0.05,0.034 -0.093,0.051 -0.1524,0.062 -0.1604,0.029 -0.3036,-0.053 -0.4318,-0.138 0,0 -0.381,-0.2499 -0.381,-0.2499 -0.5649,-0.3397 -1.0933,-0.5842 -1.7272,-0.7693 -0.7370002,-0.2153 -1.5072,-0.3063 -2.2733,-0.2975 0,0 -0.127,0.012 -0.127,0.012 0,0 -0.127,0 -0.127,0 0,0 -0.127,0.012 -0.127,0.012 0,0 -0.7366,0.087 -0.7366,0.087 -0.907,0.1512 -1.7832,0.4743 -2.5781,0.9356 -1.6257,0.9436 -2.9202,2.547 -3.4635,4.3507 -0.1191,0.3957 -0.1818,0.6592 -0.2501,1.0668 0,0 -0.0710001,0.6223 -0.0710001,0.6223 0,0.1503 0.042,0.3048 0.16490005,0.4015 0.1042,0.082 0.2529,0.1012 0.381,0.1071 0,0 0.254,0.012 0.254,0.012 0,0 0.2159,-0.013 0.2159,-0.013 0,0 5.4737,0 5.4737,0 0,0 2.4891998,0 2.4891998,0 0,0 0.1905002,-0.013 0.1905002,-0.013 0,0 0.9906,0 0.9906,0 0,0 0.1905,-0.013 0.1905,-0.013 0,0 0.5969,0 0.5969,0 0,0 0.1905,-0.013 0.1905,-0.013 0.2018,-2e-4 0.3568,0 0.5588,0.031 0.4647,0.078 0.8372,0.3136 1.2065,0.5931 0.096,0.073 0.3827,0.2873 0.4445,0.3666 0,0 -10.9728,0 -10.9728,0 0,0 -1.9431,0 -1.9431,0 0,0 -0.1524,-0.012 -0.1524,-0.012 -0.38190005,-0.027 -0.82500005,-0.1105 -1.05950005,-0.4457 -0.206,-0.2942 -0.189,-0.6494 -0.1851,-0.9906 0,0 0.071,-0.5842 0.071,-0.5842 0,0 0.1974,-0.9525 0.1974,-0.9525 0.3729,-1.4916 1.08010005,-2.8205 2.15750005,-3.9243 0,0 0.1776,-0.1656 0.1776,-0.1656 0.4393,-0.4201 0.9205,-0.7823 1.4351,-1.105 0.437,-0.2741 0.9107,-0.5223002 1.3843,-0.7268002 0.1284,-0.055 0.5215,-0.2298999 0.635,-0.2504999 z m 2.2987,-8.57070002 c 0,0 -0.2667,0.027 -0.2667,0.027 -0.2706,0.036 -0.5407,0.092 -0.8001,0.17870002 -1.0421,0.3475 -1.9575,1.1324 -2.4285,2.1291 -0.2717,0.5754 -0.4109,1.2057 -0.4036,1.8415 0,0 0.012,0.1397 0.012,0.1397 0.053,1.2058 0.6753,2.3521 1.6388,3.0748 0.3587,0.269 0.7435,0.4708 1.1684,0.6124 0.3321,0.1108 0.6673,0.1762 1.016,0.2002 0,0 0.127,0.012 0.127,0.012 0,0 0.2794,0 0.2794,0 0,0 0.1524,-0.012 0.1524,-0.012 0.5485,-0.038 1.0816998,-0.1768 1.5748,-0.4234 0.4468,-0.2234 0.8984,-0.5618 1.2284,-0.9367 0.3764,-0.4277 0.6455,-0.8846 0.833,-1.4224 0.1068,-0.3064 0.2114,-0.8199 0.2119,-1.143 0,0 0,-0.3683 0,-0.3683 0,-0.2176 -0.062,-0.561 -0.1159,-0.7747 -0.223,-0.8925 -0.7155,-1.6606 -1.4335,-2.2377 -0.3838,-0.3085 -0.8161,-0.5404 -1.2827002,-0.696 -0.3125998,-0.1042 -0.6365998,-0.1686 -0.9651998,-0.19160002 0,0 -0.1524,-0.01 -0.1524,-0.01 0,0 -0.3937,0 -0.3937,0 z m 7.4295,13.09190012 c 0,0 0,-2.8194 0,-2.8194 0,0 0,-0.7112 0,-0.7112 0,-0.1319 0.062,-0.1395 0.1778,-0.1397 0,0 0.635,0 0.635,0 0.123,0 0.1518,0.049 0.1524,0.1651 0,0 0,0.6858 0,0.6858 0,0 0,2.8194 0,2.8194 0,0 2.8194,0 2.8194,0 0,0 0.6985,0 0.6985,0 0.1339,0 0.1522,0.058 0.1524,0.1778 0,0 0,0.6477 0,0.6477 0,0.129 -0.05,0.1396 -0.1651,0.1397 0,0 -3.5052,0 -3.5052,0 0,0 0,2.8194 0,2.8194 0,0 0,0.7112 0,0.7112 0,0.129 -0.05,0.1396 -0.1651,0.1397 0,0 -0.6604,0 -0.6604,0 -0.1227,-8e-4 -0.1394,-0.037 -0.1397,-0.1524 0,0 0,-3.5179 0,-3.5179 0,0 -2.8194,0 -2.8194,0 0,0 -0.7112,0 -0.7112,0 -0.1299,-8e-4 -0.1395,-0.048 -0.1397,-0.1651 0,0 0,-0.6604 0,-0.6604 0,-0.113 0.043,-0.1381 0.1524,-0.1397 0,0 0.6985,0 0.6985,0 0,0 2.8194,0 2.8194,0 z" |
| 363 |
} |
| 364 |
) |
| 365 |
), |
| 366 |
attributes: { |
| 367 |
form_name : { |
| 368 |
type: 'string', |
| 369 |
default: '' |
| 370 |
}, |
| 371 |
role : { |
| 372 |
type: 'string', |
| 373 |
default: '' |
| 374 |
}, |
| 375 |
automatic_login : { |
| 376 |
type: 'boolean', |
| 377 |
default: false |
| 378 |
}, |
| 379 |
redirect_url : { |
| 380 |
type: 'string', |
| 381 |
default: '' |
| 382 |
}, |
| 383 |
logout_redirect_url : { |
| 384 |
type: 'string', |
| 385 |
default: '' |
| 386 |
}, |
| 387 |
is_preview : { |
| 388 |
type: 'boolean', |
| 389 |
default: false, |
| 390 |
}, |
| 391 |
}, |
| 392 |
|
| 393 |
edit: function ( props ) { |
| 394 |
return [ |
| 395 |
el( |
| 396 |
'div', |
| 397 |
Object.assign( blockEditor.useBlockProps(), { key: 'wppb/register/render' } ), |
| 398 |
el( serverSideRender, |
| 399 |
{ |
| 400 |
block: 'wppb/register', |
| 401 |
attributes: props.attributes, |
| 402 |
} |
| 403 |
) |
| 404 |
), |
| 405 |
el( InspectorControls, { key: 'wppb/register/inspector' }, |
| 406 |
[ |
| 407 |
el( PanelBody, |
| 408 |
{ |
| 409 |
title: __( 'Form Settings' , 'profile-builder' ), |
| 410 |
key: 'wppb/register/inspector/form_settings', |
| 411 |
}, |
| 412 |
[ |
| 413 |
el( SelectControl, |
| 414 |
{ |
| 415 |
label: __( 'Form' , 'profile-builder' ), |
| 416 |
key: 'wppb/register/inspector/form_settings/form_name', |
| 417 |
help: __( 'Select the desired Registration form' , 'profile-builder' ), |
| 418 |
value: props.attributes.form_name, |
| 419 |
options: [ |
| 420 |
{ |
| 421 |
label: __( 'Default' , 'profile-builder' ), |
| 422 |
value: '' |
| 423 |
}, |
| 424 |
<?php |
| 425 |
$wppb_module_settings = get_option( 'wppb_module_settings', 'not_found' ); |
| 426 |
|
| 427 |
if ( !( ( $wppb_module_settings !== 'not_found' && ( |
| 428 |
!isset( $wppb_module_settings['wppb_multipleRegistrationForms'] ) || |
| 429 |
$wppb_module_settings['wppb_multipleRegistrationForms'] !== 'show' |
| 430 |
) ) || |
| 431 |
$wppb_module_settings === 'not_found' ) ){ |
| 432 |
$args = array( |
| 433 |
'post_type' => 'wppb-rf-cpt', |
| 434 |
'posts_per_page' => -1 |
| 435 |
); |
| 436 |
|
| 437 |
$the_query = new WP_Query( $args ); |
| 438 |
|
| 439 |
if ( $the_query->have_posts() ) { |
| 440 |
foreach ( $the_query->posts as $post ) { |
| 441 |
?> |
| 442 |
{ |
| 443 |
label: '<?php echo esc_html( $post->post_title ); ?>', |
| 444 |
value: '<?php echo esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $post->post_title ) ); ?>' |
| 445 |
}, |
| 446 |
<?php |
| 447 |
} |
| 448 |
wp_reset_postdata(); |
| 449 |
} |
| 450 |
} |
| 451 |
?> |
| 452 |
], |
| 453 |
onChange: ( value ) => { props.setAttributes( { form_name: value } ); } |
| 454 |
} |
| 455 |
), |
| 456 |
props.attributes.form_name == '' ? |
| 457 |
el( SelectControl, |
| 458 |
{ |
| 459 |
label: __( 'Assigned Role' , 'profile-builder' ), |
| 460 |
key: 'wppb/register/inspector/form_settings/role', |
| 461 |
help: __( 'Select a Role to be assigned to users that register via this form' , 'profile-builder' ), |
| 462 |
value: props.attributes.role, |
| 463 |
options: [ |
| 464 |
{ |
| 465 |
label: __( 'Default' , 'profile-builder' ), |
| 466 |
value: '<?php echo esc_attr( get_option("default_role") ); ?>' |
| 467 |
}, |
| 468 |
<?php |
| 469 |
if (!function_exists('get_editable_roles')) { |
| 470 |
require_once ABSPATH . 'wp-admin/includes/user.php'; |
| 471 |
} |
| 472 |
|
| 473 |
$user_roles = get_editable_roles(); |
| 474 |
|
| 475 |
foreach ($user_roles as $key => $role) { |
| 476 |
$user_roles[$key] = $role['name']; |
| 477 |
?> |
| 478 |
{ |
| 479 |
label: '<?php echo esc_html( $role["name"] ); ?>', |
| 480 |
value: '<?php echo esc_attr( $key ); ?>' |
| 481 |
}, |
| 482 |
<?php |
| 483 |
} |
| 484 |
?> |
| 485 |
], |
| 486 |
onChange: ( value ) => { props.setAttributes( { role: value } ); } |
| 487 |
} |
| 488 |
) : |
| 489 |
'', |
| 490 |
props.attributes.form_name == '' ? |
| 491 |
el( ToggleControl, |
| 492 |
{ |
| 493 |
label: __( 'Automatic Login' , 'profile-builder' ), |
| 494 |
key: 'wppb/register/inspector/form_settings/automatic_login', |
| 495 |
help: __( 'Automatically log in users after they register' , 'profile-builder' ), |
| 496 |
checked: props.attributes.automatic_login, |
| 497 |
onChange: ( value ) => { props.setAttributes( { automatic_login: !props.attributes.automatic_login } ); } |
| 498 |
} |
| 499 |
) : |
| 500 |
'', |
| 501 |
props.attributes.form_name != '' ? |
| 502 |
el( Text, |
| 503 |
{ |
| 504 |
key: 'wppb/register/inspector/form_settings/notice' |
| 505 |
}, |
| 506 |
[ |
| 507 |
__( 'Edit the Settings for this form ' , 'profile-builder' ), |
| 508 |
el( Button, |
| 509 |
{ |
| 510 |
key: 'wppb/register/inspector/form_settings/notice_button', |
| 511 |
href: '<?php echo esc_url( admin_url( 'edit.php?post_type=wppb-rf-cpt' ) ); ?>', |
| 512 |
target: '_blank', |
| 513 |
text: __( 'here' , 'profile-builder' ), |
| 514 |
variant: 'link' |
| 515 |
}, |
| 516 |
) |
| 517 |
] |
| 518 |
) : |
| 519 |
'', |
| 520 |
] |
| 521 |
), |
| 522 |
el( PanelBody, |
| 523 |
{ |
| 524 |
title: __( 'Redirects' , 'profile-builder' ), |
| 525 |
key: 'wppb/register/inspector/redirects', |
| 526 |
}, |
| 527 |
[ |
| 528 |
props.attributes.form_name == '' ? |
| 529 |
el( SelectControl, |
| 530 |
{ |
| 531 |
label: __( 'After Registration' , 'profile-builder' ), |
| 532 |
key: 'wppb/register/inspector/redirects/redirect_url', |
| 533 |
help: __( 'Select a page for an After Registration Redirect' , 'profile-builder' ), |
| 534 |
value: props.attributes.redirect_url, |
| 535 |
options: [ |
| 536 |
{ |
| 537 |
label: __( '' , 'profile-builder' ), |
| 538 |
value: '' |
| 539 |
}, |
| 540 |
<?php |
| 541 |
if( !empty( $all_pages ) ){ |
| 542 |
foreach ( $all_pages as $page ){ |
| 543 |
?> |
| 544 |
{ |
| 545 |
label: '<?php echo esc_html( $page->post_title ) ?>', |
| 546 |
value: '<?php echo esc_url( get_page_link( $page->ID ) ) ?>' |
| 547 |
}, |
| 548 |
<?php |
| 549 |
} |
| 550 |
} |
| 551 |
?> |
| 552 |
], |
| 553 |
onChange: ( value ) => { props.setAttributes( { redirect_url: value } ); } |
| 554 |
} |
| 555 |
) : |
| 556 |
'', |
| 557 |
el( SelectControl, |
| 558 |
{ |
| 559 |
label: __( 'After Logout' , 'profile-builder' ), |
| 560 |
key: 'wppb/register/inspector/redirects/logout_redirect_url', |
| 561 |
help: __( 'Select a page for an After Logout Redirect' , 'profile-builder' ), |
| 562 |
value: props.attributes.logout_redirect_url, |
| 563 |
options: [ |
| 564 |
{ |
| 565 |
label: __( '' , 'profile-builder' ), |
| 566 |
value: '' |
| 567 |
}, |
| 568 |
<?php |
| 569 |
if( !empty( $all_pages ) ){ |
| 570 |
foreach ( $all_pages as $page ){ |
| 571 |
?> |
| 572 |
{ |
| 573 |
label: '<?php echo esc_html( $page->post_title ) ?>', |
| 574 |
value: '<?php echo esc_url( get_page_link( $page->ID ) ) ?>' |
| 575 |
}, |
| 576 |
<?php |
| 577 |
} |
| 578 |
} |
| 579 |
?> |
| 580 |
], |
| 581 |
onChange: ( value ) => { props.setAttributes( { logout_redirect_url: value } ); } |
| 582 |
} |
| 583 |
), |
| 584 |
] |
| 585 |
) |
| 586 |
] |
| 587 |
), |
| 588 |
el( blockEditor.InspectorAdvancedControls, { key: 'wppb/register/inspector_advanced' }, |
| 589 |
[ |
| 590 |
props.attributes.form_name == '' ? |
| 591 |
el( TextControl, |
| 592 |
{ |
| 593 |
label: __( 'After Registration' , 'profile-builder' ), |
| 594 |
key: 'wppb/register/inspector_advanced/redirects/redirect_url', |
| 595 |
help: __( 'Manually type in an After Registration Redirect URL' , 'profile-builder' ), |
| 596 |
value: props.attributes.redirect_url, |
| 597 |
onChange: ( value ) => { props.setAttributes( { redirect_url: value } ); } |
| 598 |
} |
| 599 |
) : |
| 600 |
'', |
| 601 |
el( TextControl, |
| 602 |
{ |
| 603 |
label: __( 'After Logout' , 'profile-builder' ), |
| 604 |
key: 'wppb/register/inspector_advanced/redirects/logout_redirect_url', |
| 605 |
help: __( 'Manually type in an After Logout Redirect URL' , 'profile-builder' ), |
| 606 |
value: props.attributes.logout_redirect_url, |
| 607 |
onChange: ( value ) => { props.setAttributes( { logout_redirect_url: value } ); } |
| 608 |
} |
| 609 |
) |
| 610 |
] |
| 611 |
) |
| 612 |
]; |
| 613 |
} |
| 614 |
} ); |
| 615 |
} )( |
| 616 |
window.wp.blocks, |
| 617 |
window.wp.i18n, |
| 618 |
window.wp.element, |
| 619 |
window.wp.serverSideRender, |
| 620 |
window.wp.blockEditor, |
| 621 |
window.wp.components |
| 622 |
); |
| 623 |
<?php |
| 624 |
exit; |
| 625 |
} |
| 626 |
); |
| 627 |
|