| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Profile Builder Divi Extension |
| 4 |
Plugin URI: https://wordpress.org/plugins/profile-builder/ |
| 5 |
Description: Profile Builder is the all in one user profile and user registration plugin for WordPress. |
| 6 |
Version: 1.0.0 |
| 7 |
Author: Cozmoslabs |
| 8 |
Author URI: https://www.cozmoslabs.com/ |
| 9 |
License: GPL2 |
| 10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 11 |
Text Domain: wppb-profile-builder-divi-extension |
| 12 |
Domain Path: /languages |
| 13 |
|
| 14 |
Profile Builder Divi Extension is free software: you can redistribute it and/or modify |
| 15 |
it under the terms of the GNU General Public License as published by |
| 16 |
the Free Software Foundation, either version 2 of the License, or |
| 17 |
any later version. |
| 18 |
|
| 19 |
Profile Builder Divi Extension is distributed in the hope that it will be useful, |
| 20 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
GNU General Public License for more details. |
| 23 |
|
| 24 |
You should have received a copy of the GNU General Public License |
| 25 |
along with Profile Builder Divi Extension. If not, see https://www.gnu.org/licenses/gpl-2.0.html. |
| 26 |
*/ |
| 27 |
|
| 28 |
|
| 29 |
if ( ! function_exists( 'wppb_initialize_extension' ) ): |
| 30 |
|
| 31 |
add_action( 'divi_extensions_init', 'wppb_divi_initialize_extension' ); |
| 32 |
|
| 33 |
/** |
| 34 |
* Creates the extension's main class instance. |
| 35 |
* |
| 36 |
* @since 1.0.0 |
| 37 |
*/ |
| 38 |
function wppb_divi_initialize_extension() { |
| 39 |
require_once plugin_dir_path( __FILE__ ) . 'includes/ProfileBuilderDiviExtension.php'; |
| 40 |
|
| 41 |
} |
| 42 |
|
| 43 |
add_action( 'wp_ajax_wppb_divi_extension_ajax', 'wppb_divi_extension_ajax' ); |
| 44 |
|
| 45 |
function wppb_divi_extension_ajax() { |
| 46 |
check_ajax_referer( 'pb_divi_render_form', 'pb_nonce' ); |
| 47 |
|
| 48 |
if( !current_user_can( 'manage_options' ) ) |
| 49 |
die(); |
| 50 |
|
| 51 |
|
| 52 |
if ( is_array( $_POST ) && array_key_exists( 'form_type', $_POST ) && $_POST['form_type'] !== '' ) { |
| 53 |
$output = ''; |
| 54 |
|
| 55 |
switch ($_POST['form_type']) { |
| 56 |
case 'rf': |
| 57 |
include_once(WPPB_PLUGIN_DIR . '/front-end/register.php'); |
| 58 |
include_once(WPPB_PLUGIN_DIR . '/front-end/class-formbuilder.php'); |
| 59 |
|
| 60 |
$form_name = 'unspecified'; |
| 61 |
if ( array_key_exists('form_name', $_POST)) { |
| 62 |
$form_name = sanitize_text_field($_POST['form_name']); |
| 63 |
if ($form_name === 'default') { |
| 64 |
$form_name = 'unspecified'; |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
$atts['role1'] = pb_divi_parse_role( $_POST['role'] ); |
| 69 |
|
| 70 |
if (!$form_name || $form_name === 'unspecified') { |
| 71 |
$atts = [ |
| 72 |
'role' => array_key_exists('role', $_POST) ? sanitize_text_field($_POST['role']) : '', |
| 73 |
'form_name' => '', |
| 74 |
'redirect_url' => array_key_exists('redirect_url', $_POST) && $_POST['redirect_url'] !== 'default' ? pb_divi_parse_url($_POST['redirect_url']) : '', |
| 75 |
'logout_redirect_url' => array_key_exists('logout_redirect_url', $_POST) && $_POST['logout_redirect_url'] !== 'default' ? pb_divi_parse_url($_POST['logout_redirect_url']) : '', |
| 76 |
'automatic_login' => array_key_exists('toggle_automatic_login', $_POST) && $_POST['toggle_automatic_login'] ? 'yes' : '', |
| 77 |
]; |
| 78 |
} else { |
| 79 |
$atts = [ |
| 80 |
'role' => '', |
| 81 |
'form_name' => $form_name, |
| 82 |
'redirect_url' => '', |
| 83 |
'logout_redirect_url' => array_key_exists('logout_redirect_url', $_POST) && $_POST['logout_redirect_url'] !== 'default' ? pb_divi_parse_url($_POST['logout_redirect_url']) : '', |
| 84 |
'automatic_login' => '', |
| 85 |
]; |
| 86 |
} |
| 87 |
|
| 88 |
$output = |
| 89 |
'<div class="wppb-divi-editor-container">' . |
| 90 |
wppb_front_end_register( $atts ) . |
| 91 |
'</div>'; |
| 92 |
|
| 93 |
break; |
| 94 |
|
| 95 |
case 'epf': |
| 96 |
include_once(WPPB_PLUGIN_DIR . '/front-end/edit-profile.php'); |
| 97 |
include_once(WPPB_PLUGIN_DIR . '/front-end/class-formbuilder.php'); |
| 98 |
|
| 99 |
$form_name = 'unspecified'; |
| 100 |
if ( array_key_exists('form_name', $_POST)) { |
| 101 |
$form_name = sanitize_text_field($_POST['form_name']); |
| 102 |
if ($form_name === 'default') { |
| 103 |
$form_name = 'unspecified'; |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
$atts = [ |
| 108 |
'form_name' => $form_name, |
| 109 |
'redirect_url' => array_key_exists('redirect_url', $_POST) && $_POST['redirect_url'] !== 'default' ? pb_divi_parse_url($_POST['redirect_url']) : '', |
| 110 |
]; |
| 111 |
|
| 112 |
$output = |
| 113 |
'<div class="wppb-divi-editor-container">' . |
| 114 |
wppb_front_end_profile_info( $atts ) . |
| 115 |
'</div>'; |
| 116 |
|
| 117 |
break; |
| 118 |
|
| 119 |
case 'l': |
| 120 |
include_once(WPPB_PLUGIN_DIR . '/front-end/login.php'); |
| 121 |
|
| 122 |
$atts = [ |
| 123 |
'register_url' => array_key_exists('register_url', $_POST) && $_POST['register_url'] !== 'default' ? pb_divi_parse_url($_POST['register_url']) : '', |
| 124 |
'lostpassword_url' => array_key_exists('lostpassword_url', $_POST) && $_POST['lostpassword_url'] !== 'default' ? pb_divi_parse_url($_POST['lostpassword_url']) : '', |
| 125 |
'redirect_url' => array_key_exists('redirect_url', $_POST) && $_POST['redirect_url'] !== 'default' ? pb_divi_parse_url($_POST['redirect_url']) : '', |
| 126 |
'logout_redirect_url' => array_key_exists('logout_redirect_url', $_POST) && $_POST['logout_redirect_url'] !== 'default' ? pb_divi_parse_url($_POST['logout_redirect_url']) : '', |
| 127 |
'show_2fa_field' => array_key_exists('toggle_auth_field', $_POST) && $_POST['toggle_auth_field'] === 'on' ? 'yes' : '', |
| 128 |
'block' => 'true', |
| 129 |
]; |
| 130 |
|
| 131 |
$output = |
| 132 |
'<div class="wppb-divi-editor-container">' . |
| 133 |
wppb_front_end_login( $atts ) . |
| 134 |
'</div>'; |
| 135 |
|
| 136 |
break; |
| 137 |
|
| 138 |
case 'rp': |
| 139 |
include_once(WPPB_PLUGIN_DIR . '/front-end/recover.php'); |
| 140 |
|
| 141 |
$atts = [ |
| 142 |
'block' => 'true', |
| 143 |
]; |
| 144 |
|
| 145 |
$output = |
| 146 |
'<div class="wppb-divi-editor-container">' . |
| 147 |
wppb_front_end_password_recovery( $atts ) . |
| 148 |
'</div>'; |
| 149 |
|
| 150 |
break; |
| 151 |
|
| 152 |
case 'ul': |
| 153 |
if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ) { |
| 154 |
include_once( WPPB_PAID_PLUGIN_DIR.'/add-ons/user-listing/userlisting.php' ); |
| 155 |
|
| 156 |
$atts = [ |
| 157 |
'name' => array_key_exists('userlisting_name', $_POST) ? sanitize_text_field($_POST['userlisting_name']) : '', |
| 158 |
'meta_value' => array_key_exists('field_name', $_POST) && array_key_exists('meta_value', $_POST) && $_POST['field_name'] !== 'default' ? ( $_POST['meta_value'] !== 'undefined' ? sanitize_text_field($_POST['meta_value']) : '' ) : '', |
| 159 |
'0' => array_key_exists('single', $_POST) && $_POST['single'] === 'on' ? 'single' : '', |
| 160 |
'id' => array_key_exists('id', $_POST) && $_POST['id'] !== 'undefined' ? absint($_POST['id']) : '', |
| 161 |
'meta_key' => array_key_exists('field_name', $_POST) && $_POST['field_name'] !== 'default' ? sanitize_text_field($_POST['field_name']) : '', |
| 162 |
'include' => array_key_exists('include', $_POST) && $_POST['include'] !== 'undefined' ? pb_divi_parse_ids($_POST['include']) : '', |
| 163 |
'exclude' => array_key_exists('exclude', $_POST) && $_POST['exclude'] !== 'undefined' ? pb_divi_parse_ids($_POST['exclude']) : '', |
| 164 |
]; |
| 165 |
|
| 166 |
if ( $atts['name'] === '' || $atts['name'] === 'default' ) { |
| 167 |
$output =wppb_form_notification_styling( |
| 168 |
'<div class="wppb-divi-editor-container"> |
| 169 |
<p class="wppb-alert"> |
| 170 |
Please select a User Listing! |
| 171 |
</p><!-- .wppb-alert--> |
| 172 |
</div>'); |
| 173 |
} else { |
| 174 |
$output = |
| 175 |
'<div class="wppb-divi-editor-container">' . |
| 176 |
wppb_user_listing_shortcode( $atts ) . |
| 177 |
'</div>'; |
| 178 |
} |
| 179 |
} |
| 180 |
|
| 181 |
break; |
| 182 |
} |
| 183 |
|
| 184 |
$output .= |
| 185 |
'<style type="text/css">' . |
| 186 |
file_get_contents( WPPB_PLUGIN_DIR . '/assets/css/style-front-end.css' ) . |
| 187 |
'</style>'; |
| 188 |
|
| 189 |
// load the corresponding Form Design stylesheets |
| 190 |
$active_design = 'form-style-default'; |
| 191 |
if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR.'/features/form-designs/form-designs.php' ) ) |
| 192 |
$active_design = wppb_get_active_form_design(); |
| 193 |
|
| 194 |
if ( $active_design === 'form-style-default' ) { |
| 195 |
|
| 196 |
// load stylesheet for the Default Form Style if the active WP Theme is a Block Theme (Block Themes were introduced in WordPress since the 5.9 release) |
| 197 |
if ( version_compare( get_bloginfo( 'version' ), '5.9', '>=' ) && function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) |
| 198 |
$output .= |
| 199 |
'<style type="text/css">' . |
| 200 |
file_get_contents( WPPB_PLUGIN_DIR . '/assets/css/style-block-themes-front-end.css' ) . |
| 201 |
'</style>'; |
| 202 |
|
| 203 |
} |
| 204 |
else { // if $active_design is other than 'form-style-default' the constants WPPB_PAID_PLUGIN_DIR and WPPB_PAID_PLUGIN_URL are defined (verified at line:14) |
| 205 |
|
| 206 |
if ( file_exists( WPPB_PAID_PLUGIN_DIR . '/features/form-designs/css/' . $active_design . '/form-design-general-style.css' ) ) |
| 207 |
$output .= |
| 208 |
'<style type="text/css">' . |
| 209 |
file_get_contents( WPPB_PLUGIN_DIR . '/features/form-designs/css/' . $active_design . '/form-design-general-style.css' ) . |
| 210 |
'</style>'; |
| 211 |
|
| 212 |
if ( file_exists( WPPB_PAID_PLUGIN_DIR . '/features/form-designs/css/' . $active_design .'/extra-form-notifications-style.css' ) ) |
| 213 |
$output .= |
| 214 |
'<style type="text/css">' . |
| 215 |
file_get_contents( WPPB_PLUGIN_DIR . '/features/form-designs/css/' . $active_design .'/extra-form-notifications-style.css' ) . |
| 216 |
'</style>'; |
| 217 |
} |
| 218 |
|
| 219 |
//Select |
| 220 |
// Don't enqueue when JetEngine is active |
| 221 |
if( !class_exists( 'Jet_Engine' ) ) { |
| 222 |
$output .= |
| 223 |
'<script type="text/javascript">' . |
| 224 |
file_get_contents( WPPB_PLUGIN_DIR . '/assets/js/select2/select2.min.js' ) . |
| 225 |
'</script>'; |
| 226 |
$output .= |
| 227 |
'<style type="text/css">' . |
| 228 |
file_get_contents( WPPB_PLUGIN_DIR . '/assets/css/select2/select2.min.css' ) . |
| 229 |
'</style>'; |
| 230 |
} |
| 231 |
|
| 232 |
if ( defined( 'WPPB_PAID_PLUGIN_URL' ) ) { |
| 233 |
//Select2 |
| 234 |
$output .= |
| 235 |
'<style type="text/css">' . |
| 236 |
file_get_contents( WPPB_PAID_PLUGIN_DIR . '/front-end/default-fields/select2/select2.css' ) . |
| 237 |
'</style>'; |
| 238 |
$output .= |
| 239 |
'<style type="text/css">' . |
| 240 |
file_get_contents( WPPB_PAID_PLUGIN_DIR . '/front-end/extra-fields/select-cpt/style-front-end.css' ) . |
| 241 |
'</style>'; |
| 242 |
|
| 243 |
//Upload |
| 244 |
$output .= |
| 245 |
'<style type="text/css">' . |
| 246 |
file_get_contents( WPPB_PAID_PLUGIN_DIR . '/front-end/extra-fields/upload/upload.css' ) . |
| 247 |
'</style>'; |
| 248 |
|
| 249 |
//Multi-Step Forms compatibility |
| 250 |
$output .= |
| 251 |
'<style type="text/css">' . |
| 252 |
file_get_contents( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/multi-step-forms/assets/css/frontend-multi-step-forms.css' ) . |
| 253 |
'</style>'; |
| 254 |
|
| 255 |
//Social Connect |
| 256 |
$output .= |
| 257 |
'<style type="text/css">' . |
| 258 |
file_get_contents( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/social-connect/assets/css/wppb_sc_main_frontend.css' ) . |
| 259 |
'</style>'; |
| 260 |
} |
| 261 |
|
| 262 |
echo json_encode( $output );// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 263 |
die(); |
| 264 |
} |
| 265 |
|
| 266 |
die(); |
| 267 |
} |
| 268 |
|
| 269 |
$wppb_generalSettings = get_option( 'wppb_general_settings', 'not_found' ); |
| 270 |
$wppb_content_restriction_settings = get_option( 'wppb_content_restriction_settings', 'not_found' ); |
| 271 |
if( $wppb_generalSettings != 'not_found' || $wppb_content_restriction_settings != 'not_found' ) { |
| 272 |
global $content_restriction_activated; |
| 273 |
$content_restriction_activated = 'no'; |
| 274 |
if( !empty( $wppb_content_restriction_settings['contentRestriction'] ) ){ |
| 275 |
$content_restriction_activated = $wppb_content_restriction_settings['contentRestriction']; |
| 276 |
} |
| 277 |
elseif( !empty( $wppb_generalSettings['contentRestriction'] ) ){ |
| 278 |
$content_restriction_activated = $wppb_generalSettings['contentRestriction']; |
| 279 |
} |
| 280 |
} |
| 281 |
global $wp_version; |
| 282 |
if ( isset( $content_restriction_activated ) && $content_restriction_activated == 'yes' && version_compare( $wp_version, "5.0.0", ">=" ) ) { |
| 283 |
add_filter( 'et_builder_get_parent_modules', 'wppb_divi_content_restriction_extend_modules' ); |
| 284 |
add_filter( 'et_module_shortcode_output', 'wppb_divi_content_restriction_render_section', 10, 3 ); |
| 285 |
} |
| 286 |
|
| 287 |
/** |
| 288 |
* Add the content restriction toggle and fields on all modules |
| 289 |
*/ |
| 290 |
function wppb_divi_content_restriction_extend_modules( $modules ) { |
| 291 |
|
| 292 |
static $is_applied = false; |
| 293 |
if ( $is_applied ) { |
| 294 |
return $modules; |
| 295 |
} |
| 296 |
|
| 297 |
if ( empty( $modules ) ) { |
| 298 |
return $modules; |
| 299 |
} |
| 300 |
|
| 301 |
foreach ( $modules as $module_slug => $module ) { |
| 302 |
if ( ! isset( $module->settings_modal_toggles ) || |
| 303 |
! isset( $module->fields_unprocessed ) || |
| 304 |
in_array( $module_slug, array( 'wppb_content_restriction_start', 'wppb_content_restriction_end' ) ) ) { |
| 305 |
continue; |
| 306 |
} |
| 307 |
|
| 308 |
$toggles_list = $module->settings_modal_toggles; |
| 309 |
// Add a 'PB Content Restriction' toggle on the 'Advanced' tab |
| 310 |
if ( isset( $toggles_list['custom_css'] ) && ! empty( $toggles_list['custom_css']['toggles'] ) ) { |
| 311 |
$toggles_list['custom_css']['toggles']['wppb_content_restriction_toggle'] = array( |
| 312 |
'title' => esc_html__( 'PB Content Restriction', 'profile-builder' ), |
| 313 |
'priority' => 220, |
| 314 |
); |
| 315 |
$module->settings_modal_toggles = $toggles_list; |
| 316 |
} |
| 317 |
|
| 318 |
$fields_list = $module->fields_unprocessed; |
| 319 |
// Add content restriction options in the toggle |
| 320 |
if ( ! empty( $fields_list ) ) { |
| 321 |
$module->fields_unprocessed = wppb_divi_content_restriction_get_fields_list ( $fields_list ); |
| 322 |
} |
| 323 |
} |
| 324 |
$is_applied = true; |
| 325 |
return $modules; |
| 326 |
} |
| 327 |
|
| 328 |
function wppb_divi_content_restriction_render_section( $output, $render_slug, $module ) { |
| 329 |
|
| 330 |
if ( is_array( $output ) ) { |
| 331 |
return $output; |
| 332 |
} |
| 333 |
|
| 334 |
if ('et_pb_column' === $render_slug) { |
| 335 |
return $output; |
| 336 |
} |
| 337 |
|
| 338 |
static $show_message = false; |
| 339 |
|
| 340 |
if ( !isset( $content_restriction_module_pair_active ) ) { |
| 341 |
static $content_restriction_module_pair_active = false; |
| 342 |
} |
| 343 |
if ( !isset( $content_restriction_module_pair_settings ) ) { |
| 344 |
static $content_restriction_module_pair_settings = array(); |
| 345 |
} |
| 346 |
|
| 347 |
if ( $render_slug === 'wppb_content_restriction_start' ) { |
| 348 |
$content_restriction_module_pair_active = true; |
| 349 |
$content_restriction_module_pair_settings = $module->get_attrs_unprocessed(); |
| 350 |
return; |
| 351 |
} |
| 352 |
if ( $render_slug === 'wppb_content_restriction_end' ) { |
| 353 |
if ( $content_restriction_module_pair_active ) { |
| 354 |
$content_restriction_module_pair_active = false; |
| 355 |
$aux = $content_restriction_module_pair_settings; |
| 356 |
$content_restriction_module_pair_settings = array(); |
| 357 |
return wppb_divi_content_restriction_process_shortcode( wppb_divi_content_restriction_get_attrs( $aux ), '', isset( $aux['wppb_toggle_message'] ) && $aux['wppb_toggle_message'] === 'on' ); |
| 358 |
} else { |
| 359 |
$content_restriction_module_pair_active = false; |
| 360 |
$content_restriction_module_pair_settings = array(); |
| 361 |
return; |
| 362 |
} |
| 363 |
} |
| 364 |
|
| 365 |
if ( $content_restriction_module_pair_active ) { |
| 366 |
return wppb_divi_content_restriction_process_shortcode( wppb_divi_content_restriction_get_attrs( $content_restriction_module_pair_settings ), $output, false ); |
| 367 |
} |
| 368 |
|
| 369 |
$attrs_unprocessed = $module->get_attrs_unprocessed(); |
| 370 |
|
| 371 |
if ( isset( $attrs_unprocessed['wppb_display_to'] ) && $attrs_unprocessed['wppb_display_to'] !== 'all' ) { |
| 372 |
return wppb_divi_content_restriction_process_shortcode( wppb_divi_content_restriction_get_attrs( $attrs_unprocessed ), $output, isset( $attrs_unprocessed['wppb_toggle_message'] ) && $attrs_unprocessed['wppb_toggle_message'] === 'on' ); |
| 373 |
} |
| 374 |
|
| 375 |
return $output; |
| 376 |
} |
| 377 |
|
| 378 |
function wppb_divi_content_restriction_process_shortcode ( $attrs, $output, $show_message = true ) { |
| 379 |
if ( $show_message ){ |
| 380 |
$output = wppb_content_restriction_shortcode( $attrs, $output ); |
| 381 |
} else { |
| 382 |
add_filter( 'wppb_content_restriction_shortcode_message', 'wppb_divi_content_restriction_filter_no_message'); |
| 383 |
$output = wppb_content_restriction_shortcode( $attrs, $output ); |
| 384 |
remove_filter( 'wppb_content_restriction_shortcode_message', 'wppb_divi_content_restriction_filter_no_message'); |
| 385 |
} |
| 386 |
return $output; |
| 387 |
} |
| 388 |
|
| 389 |
function wppb_divi_content_restriction_filter_no_message () { |
| 390 |
return; |
| 391 |
} |
| 392 |
|
| 393 |
function wppb_divi_content_restriction_get_attrs ( $attrs_unprocessed ) { |
| 394 |
return array( |
| 395 |
'user_roles' => isset( $attrs_unprocessed['wppb_user_roles'] ) ? $attrs_unprocessed['wppb_user_roles'] : array(), |
| 396 |
'display_to' => $attrs_unprocessed['wppb_display_to'] === 'logged_in' ? '' : $attrs_unprocessed['wppb_display_to'], |
| 397 |
'message' => isset( $attrs_unprocessed['wppb_toggle_custom_message'] ) && $attrs_unprocessed['wppb_toggle_custom_message'] === 'on' |
| 398 |
? ( $attrs_unprocessed['wppb_display_to'] === 'not_logged_in' ? $attrs_unprocessed['wppb_message_logged_out'] : $attrs_unprocessed['wppb_message_logged_in'] ) |
| 399 |
: '', |
| 400 |
'users_id' => $attrs_unprocessed['wppb_display_to'] === 'logged_in' ? ( isset( $attrs_unprocessed['wppb_users_ids'] ) ? $attrs_unprocessed['wppb_users_ids'] : '' ) : '', |
| 401 |
); |
| 402 |
} |
| 403 |
|
| 404 |
function wppb_divi_content_restriction_get_fields_list ( $fields_list = array() ) { |
| 405 |
if (!function_exists('get_editable_roles')) { |
| 406 |
require_once ABSPATH . 'wp-admin/includes/user.php'; |
| 407 |
} |
| 408 |
$user_roles ['default'] = esc_html__( 'All' , 'profile-builder' ); |
| 409 |
$editable_roles = get_editable_roles(); |
| 410 |
foreach ($editable_roles as $key => $role) { |
| 411 |
$user_roles [$key] = $role['name']; |
| 412 |
} |
| 413 |
|
| 414 |
$fields_list['wppb_display_to'] = array( |
| 415 |
'label' => esc_html__( 'Show content to', 'profile-builder' ), |
| 416 |
'description' => esc_html__( 'The users you wish to see the content.', 'profile-builder' ), |
| 417 |
'type' => 'select', |
| 418 |
'options' => array( |
| 419 |
'all' => esc_html__( 'All', 'profile-builder' ), |
| 420 |
'logged_in' => esc_html__( 'Logged in', 'profile-builder' ), |
| 421 |
'not_logged_in' => esc_html__( 'Not logged in', 'profile-builder' ), |
| 422 |
), |
| 423 |
'default' => 'all', |
| 424 |
'toggle_slug' => 'wppb_content_restriction_toggle', |
| 425 |
'tab_slug' => 'custom_css', |
| 426 |
); |
| 427 |
$fields_list['wppb_user_roles'] = array( |
| 428 |
'label' => esc_html__( 'User Roles', 'profile-builder' ), |
| 429 |
'description' => esc_html__( 'The desired valid user roles. Select none for all roles to be valid.', 'profile-builder' ), |
| 430 |
'type' => 'select', |
| 431 |
'options' => $user_roles, |
| 432 |
'default' => 'default', |
| 433 |
'toggle_slug' => 'wppb_content_restriction_toggle', |
| 434 |
'tab_slug' => 'custom_css', |
| 435 |
'show_if' => array( |
| 436 |
'wppb_display_to' => 'logged_in', |
| 437 |
), |
| 438 |
); |
| 439 |
$fields_list['wppb_users_ids'] = array( |
| 440 |
'label' => esc_html__( 'User IDs', 'profile-builder' ), |
| 441 |
'description' => esc_html__( 'A comma-separated list of user IDs.', 'profile-builder' ), |
| 442 |
'type' => 'text', |
| 443 |
'toggle_slug' => 'wppb_content_restriction_toggle', |
| 444 |
'tab_slug' => 'custom_css', |
| 445 |
'show_if' => array( |
| 446 |
'wppb_display_to' => 'logged_in', |
| 447 |
), |
| 448 |
); |
| 449 |
$fields_list['wppb_toggle_message'] = array( |
| 450 |
'label' => esc_html__( 'Enable Message', 'profile-builder' ), |
| 451 |
'description' => esc_html__( 'Show the Message defined in the Profile Builder Settings.', 'profile-builder' ), |
| 452 |
'type' => 'yes_no_button', |
| 453 |
'options' => array( |
| 454 |
'on' => esc_html__( 'Yes', 'profile-builder'), |
| 455 |
'off' => esc_html__( 'No', 'profile-builder'), |
| 456 |
), |
| 457 |
'toggle_slug' => 'wppb_content_restriction_toggle', |
| 458 |
'tab_slug' => 'custom_css', |
| 459 |
'show_if_not' => array( |
| 460 |
'wppb_display_to' => 'all', |
| 461 |
), |
| 462 |
); |
| 463 |
$fields_list['wppb_toggle_custom_message'] = array( |
| 464 |
'label' => esc_html__( 'Custom Message', 'profile-builder' ), |
| 465 |
'description' => esc_html__( 'Enable Custom Message.', 'profile-builder' ), |
| 466 |
'type' => 'yes_no_button', |
| 467 |
'options' => array( |
| 468 |
'on' => esc_html__( 'Yes', 'profile-builder'), |
| 469 |
'off' => esc_html__( 'No', 'profile-builder'), |
| 470 |
), |
| 471 |
'toggle_slug' => 'wppb_content_restriction_toggle', |
| 472 |
'tab_slug' => 'custom_css', |
| 473 |
'show_if_not' => array( |
| 474 |
'wppb_display_to' => 'all', |
| 475 |
), |
| 476 |
'show_if' => array( |
| 477 |
'wppb_toggle_message' => 'on', |
| 478 |
), |
| 479 |
); |
| 480 |
$fields_list['wppb_message_logged_in'] = array( |
| 481 |
'label' => esc_html__( 'Custom message', 'profile-builder' ), |
| 482 |
'description' => esc_html__( 'Enter the custom message you wish the restricted users to see.', 'profile-builder' ), |
| 483 |
'type' => 'text', |
| 484 |
'toggle_slug' => 'wppb_content_restriction_toggle', |
| 485 |
'tab_slug' => 'custom_css', |
| 486 |
'show_if' => array( |
| 487 |
'wppb_toggle_message' => 'on', |
| 488 |
'wppb_toggle_custom_message' => 'on', |
| 489 |
'wppb_display_to' => 'logged_in', |
| 490 |
), |
| 491 |
); |
| 492 |
$fields_list['wppb_message_logged_out'] = array( |
| 493 |
'label' => esc_html__( 'Custom message', 'profile-builder' ), |
| 494 |
'description' => esc_html__( 'Custom message for logged-out users.', 'profile-builder' ), |
| 495 |
'type' => 'text', |
| 496 |
'toggle_slug' => 'wppb_content_restriction_toggle', |
| 497 |
'tab_slug' => 'custom_css', |
| 498 |
'show_if' => array( |
| 499 |
'wppb_toggle_message' => 'on', |
| 500 |
'wppb_toggle_custom_message' => 'on', |
| 501 |
'wppb_display_to' => 'not_logged_in', |
| 502 |
), |
| 503 |
); |
| 504 |
return $fields_list; |
| 505 |
} |
| 506 |
|
| 507 |
function pb_divi_parse_role( $role ){ |
| 508 |
|
| 509 |
$roles = explode( ',', $roles ); |
| 510 |
|
| 511 |
if( empty( $roles ) ) |
| 512 |
return ''; |
| 513 |
|
| 514 |
$result = ''; |
| 515 |
|
| 516 |
foreach( $roles as $role ){ |
| 517 |
$result .= absint( $role ) . ','; |
| 518 |
} |
| 519 |
|
| 520 |
return rtrim( $result, ',' ); |
| 521 |
|
| 522 |
} |
| 523 |
|
| 524 |
function pb_divi_parse_ids( $attrs ){ |
| 525 |
|
| 526 |
$attrs = explode( ',', $attrs ); |
| 527 |
|
| 528 |
if( empty( $attrs ) ) |
| 529 |
return ''; |
| 530 |
|
| 531 |
$result = ''; |
| 532 |
|
| 533 |
foreach( $attrs as $attr ){ |
| 534 |
$result .= absint( $attr ) . ','; |
| 535 |
} |
| 536 |
|
| 537 |
return rtrim( $result, ',' ); |
| 538 |
|
| 539 |
} |
| 540 |
|
| 541 |
function pb_divi_parse_url( $redirect_url ){ |
| 542 |
|
| 543 |
if( $redirect_url === esc_url_raw( $redirect_url ) ) |
| 544 |
return esc_url_raw( $redirect_url ); |
| 545 |
|
| 546 |
return ''; |
| 547 |
|
| 548 |
} |
| 549 |
|
| 550 |
endif; |
| 551 |
|