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
← All changes | features/functions.php +369 -93 3.9.84.0.3 View file →
@@ -9,9 +9,9 @@
9 9 // whitelist options, you can add more register_settings changing the second parameter
10 10 function wppb_register_settings() {
11 11 register_setting( 'wppb_option_group', 'wppb_default_settings' );
12 12 register_setting( 'wppb_general_settings', 'wppb_general_settings', 'wppb_general_settings_sanitize' );
13 - register_setting( 'wppb_display_admin_settings', 'wppb_display_admin_settings' );
13 +// register_setting( 'wppb_display_admin_settings', 'wppb_display_admin_settings' );
14 14 register_setting( 'wppb_profile_builder_pro_serial', 'wppb_profile_builder_pro_serial' );
15 15 register_setting( 'wppb_profile_builder_hobbyist_serial', 'wppb_profile_builder_hobbyist_serial' );
16 16 register_setting( 'wppb_module_settings', 'wppb_module_settings' );
17 17 register_setting( 'wppb_module_settings_description', 'wppb_module_settings_description' );
@@ -55,8 +55,24 @@
55 55 }
56 56 }
57 57
58 58
59 +/**
60 + * Whether Profile Builder should load style-block-themes-front-end.css.
61 + */
62 +function wppb_should_load_block_theme_stylesheet() {
63 + $is_block_theme_context = version_compare( get_bloginfo( 'version' ), '5.9', '>=' )
64 + && function_exists( 'wp_is_block_theme' )
65 + && wp_is_block_theme();
66 +
67 + /**
68 + * Filter whether to load the block theme front-end stylesheet.
69 + *
70 + * @param bool $load_block_theme_stylesheet True when WordPress is 5.9+ and the active theme is a block theme.
71 + */
72 + return (bool) apply_filters( 'wppb_load_block_theme_stylesheet', $is_block_theme_context );
73 +}
74 +
59 75 function wppb_add_plugin_stylesheet() {
60 76 $wppb_generalSettings = get_option( 'wppb_general_settings' );
61 77
62 78 if ( ( file_exists( WPPB_PLUGIN_DIR . '/assets/css/style-front-end.css' ) ) && ( isset( $wppb_generalSettings['extraFieldsLayout'] ) && ( $wppb_generalSettings['extraFieldsLayout'] == 'default' ) ) ){
@@ -62,8 +78,9 @@
62 78 if ( ( file_exists( WPPB_PLUGIN_DIR . '/assets/css/style-front-end.css' ) ) && ( isset( $wppb_generalSettings['extraFieldsLayout'] ) && ( $wppb_generalSettings['extraFieldsLayout'] == 'default' ) ) ){
63 79 wp_register_style( 'wppb_stylesheet', WPPB_PLUGIN_URL . 'assets/css/style-front-end.css', array(), PROFILE_BUILDER_VERSION );
64 80 wp_enqueue_style( 'wppb_stylesheet' );
65 81 }
82 +
66 83 if( is_rtl() ) {
67 84 if ( ( file_exists( WPPB_PLUGIN_DIR . '/assets/css/rtl.css' ) ) && ( isset( $wppb_generalSettings['extraFieldsLayout'] ) && ( $wppb_generalSettings['extraFieldsLayout'] == 'default' ) ) ){
68 85 wp_register_style( 'wppb_stylesheet_rtl', WPPB_PLUGIN_URL . 'assets/css/rtl.css', array(), PROFILE_BUILDER_VERSION );
69 86 wp_enqueue_style( 'wppb_stylesheet_rtl' );
@@ -68,33 +85,85 @@
68 85 wp_register_style( 'wppb_stylesheet_rtl', WPPB_PLUGIN_URL . 'assets/css/rtl.css', array(), PROFILE_BUILDER_VERSION );
69 86 wp_enqueue_style( 'wppb_stylesheet_rtl' );
70 87 }
71 88 }
89 +
90 + if ( wppb_should_load_block_theme_stylesheet() ) {
91 + $active_design = function_exists( 'wppb_get_active_form_design' ) ? wppb_get_active_form_design() : 'form-style-default';
92 +
93 + if ( $active_design === 'form-style-default' && file_exists( WPPB_PLUGIN_DIR . 'assets/css/style-block-themes-front-end.css' ) ) {
94 + wp_register_style( 'wppb_block_themes_front_end_stylesheet', WPPB_PLUGIN_URL . 'assets/css/style-block-themes-front-end.css', array(), PROFILE_BUILDER_VERSION );
95 + wp_enqueue_style( 'wppb_block_themes_front_end_stylesheet' );
96 + }
97 + }
72 98 }
73 99
74 100
75 101 function wppb_show_admin_bar($content){
76 - global $current_user;
102 + global $current_user;
77 103
78 - $adminSettingsPresent = get_option('wppb_display_admin_settings','not_found');
79 - $show = null;
104 + $general_settings = get_option( 'wppb_general_settings' );
105 + $selected_roles = isset( $general_settings['hide_admin_bar_for'] ) ? $general_settings['hide_admin_bar_for'] : '';
80 106
81 - if ($adminSettingsPresent != 'not_found' && $current_user->ID)
82 - foreach ($current_user->roles as $role_key) {
83 - if (empty($GLOBALS['wp_roles']->roles[$role_key]))
84 - continue;
85 - $role = $GLOBALS['wp_roles']->roles[$role_key];
86 - if (isset($adminSettingsPresent[$role['name']])) {
87 - if ($adminSettingsPresent[$role['name']] == 'show')
88 - $show = true;
89 - if ($adminSettingsPresent[$role['name']] == 'hide' && $show === null)
90 - $show = false;
91 - }
92 - }
93 - return $show === null ? $content : $show;
107 + $show = null;
108 +
109 + if ( $general_settings != 'not_found' && $current_user->ID && !empty( $selected_roles ) )
110 + foreach ( $current_user->roles as $role_key ) {
111 + if( $role_key == 'administrator' && current_user_can( 'manage_options' ) && !in_array( 'allUserRoles', $selected_roles ) )
112 + break;
113 + else if ( empty( $GLOBALS['wp_roles']->roles[$role_key] ) )
114 + continue;
115 +
116 + $role = $GLOBALS['wp_roles']->roles[$role_key];
117 +
118 + if ( !empty( $selected_roles ) && ( in_array( $role['name'], $selected_roles ) || in_array( 'allUserRoles', $selected_roles ) || in_array( 'allUserRolesExceptAdmin', $selected_roles ) ) && $show === null )
119 + $show = false;
120 + }
121 + return $show === null ? $content : $show;
94 122 }
95 123
124 +function wppb_has_international_tel_input_field() {
125 + $manage_fields = get_option( 'wppb_manage_fields', array() );
96 126
127 + if ( ! is_array( $manage_fields ) ) {
128 + return false;
129 + }
130 +
131 + foreach ( $manage_fields as $field ) {
132 + if ( ! empty( $field['field'] ) && $field['field'] === 'International Telephone Input' ) {
133 + return true;
134 + }
135 + }
136 +
137 + return false;
138 +}
139 +
140 +function wppb_maybe_add_international_tel_input_notice() {
141 + if ( ! class_exists( 'WPPB_Plugin_Notifications' ) ) {
142 + return;
143 + }
144 +
145 + if ( ! wppb_has_international_tel_input_field() ) {
146 + return;
147 + }
148 +
149 + if ( function_exists( 'wppb_international_tel_input_handler' ) ) {
150 + return;
151 + }
152 +
153 + $notification_id = 'wppb_intl_tel_input_paid_update_notice';
154 + $message = '<p>';
155 + $message .= __( 'The <strong>International Telephone Input</strong> field is currently used on this site, but it now requires the <strong>paid Profile Builder plugin</strong> to be updated as well.', 'profile-builder' );
156 + $message .= ' ';
157 + $message .= __( 'Please update the paid plugin to the latest version so this field can continue to load and validate correctly.', 'profile-builder' );
158 + $message .= '</p>';
159 + $message .= '<a href="' . wp_nonce_url( add_query_arg( array( 'wppb_dismiss_admin_notification' => $notification_id ) ), 'wppb_plugin_notice_dismiss' ) . '" type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'profile-builder' ) . '</span></a>';
160 +
161 + WPPB_Plugin_Notifications::get_instance()->add_notification( $notification_id, $message, 'wppb-notice notice notice-warning is-dismissible', false, array(), true );
162 +}
163 +
164 +add_action( 'admin_init', 'wppb_maybe_add_international_tel_input_notice' );
165 +
97 166 if(!function_exists('wppb_curpageurl')){
98 167 function wppb_curpageurl(){
99 168 $req_uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( $_SERVER['REQUEST_URI'] ) : '';
100 169
@@ -292,12 +361,12 @@
292 361 $activation_landing_page_id = ( ( isset( $wppb_generalSettings['activationLandingPage'] ) && ( trim( $wppb_generalSettings['activationLandingPage'] ) != '' ) ) ? $wppb_generalSettings['activationLandingPage'] : 'not_set' );
293 362
294 363 if ( $activation_landing_page_id != 'not_set' ){
295 364 //an activation page was selected, but we still need to check if the current page doesn't already have the registration shortcode
296 - if ( strpos( $post->post_content, '[wppb-register' ) === false )
365 + if ( strpos( $post->post_content, '[wppb-register' ) === false && !has_block( 'wppb/register', $post->post_content ) )
297 366 add_filter( 'the_content', 'wppb_add_activation_message' );
298 367
299 - }elseif ( strpos( $post->post_content, '[wppb-register' ) === false ){
368 + }elseif ( strpos( $post->post_content, '[wppb-register' ) === false && !has_block( 'wppb/register', $post->post_content ) ){
300 369 //no activation page was selected, and the sent link pointed to the home url
301 370 nocache_headers();
302 371 wp_redirect( apply_filters( 'wppb_activatate_account_redirect_url', WPPB_PLUGIN_URL.'assets/misc/fallback-page.php?activation_key='.urlencode( $activation_key ).'&site_name='.urlencode( get_bloginfo( 'name' ) ).'&message='.urlencode( $activation_message = wppb_activate_signup( $activation_key ) ), $activation_key, $activation_message ) );
303 372 exit;
@@ -323,9 +392,9 @@
323 392 'menu_slug' => 'profile-builder',
324 393 'page_type' => 'menu_page',
325 394 'position' => '70.69',
326 395 'priority' => 1,
327 - 'icon_url' => WPPB_PLUGIN_URL . 'assets/images/pb-menu-icon.png'
396 + 'icon_url' => WPPB_PLUGIN_URL . 'assets/images/pb-menu-icon.svg'
328 397 );
329 398 new WCK_Page_Creator_PB( $args );
330 399
331 400 /**
@@ -358,9 +427,9 @@
358 427 wp_enqueue_script( 'wppb-select2', WPPB_PLUGIN_URL . 'assets/js/select2/select2.min.js', array(), PROFILE_BUILDER_VERSION, true );
359 428 wp_enqueue_style( 'wppb-select2-style', WPPB_PLUGIN_URL . 'assets/css/select2/select2.min.css', false, PROFILE_BUILDER_VERSION );
360 429 }
361 430
362 - if ( $hook == 'admin_page_profile-builder-private-website' ){
431 + if ( $hook == 'profile-builder_page_profile-builder-private-website' ){
363 432 wp_enqueue_script( 'wppb-select2', WPPB_PLUGIN_URL . 'assets/js/select2/select2.min.js', array(), PROFILE_BUILDER_VERSION, true );
364 433 wp_enqueue_script( 'wppb-select2-compat', WPPB_PLUGIN_URL . 'assets/js/select2-compat.js', array(), PROFILE_BUILDER_VERSION, true );
365 434 wp_enqueue_style( 'wppb-select2-style', WPPB_PLUGIN_URL . 'assets/css/select2/select2.min.css', false, PROFILE_BUILDER_VERSION );
366 435 }
@@ -382,11 +451,10 @@
382 451 ( $hook == 'profile-builder_page_user-email-customizer') ||
383 452 ( $hook == 'profile-builder_page_profile-builder-content_restriction' ) ||
384 453 ( strpos( $hook, 'profile-builder_page_' ) === 0 ) ||
385 454 ( $hook == 'edit.php' && ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'wppb-roles-editor' ) ) ||
386 - ( $hook == 'admin_page_profile-builder-pms-promo') ||
387 455 ( $hook == 'toplevel_page_profile-builder-register') || //multisite register version page
388 - ( $hook == 'admin_page_profile-builder-private-website') ) {
456 + ( $hook == 'admin_page_profile-builder-pms-promo') ) {
389 457 wp_enqueue_style( 'wppb-back-end-style', WPPB_PLUGIN_URL . 'assets/css/style-back-end.css', false, PROFILE_BUILDER_VERSION );
390 458 }
391 459
392 460 if ( $hook == 'profile-builder_page_profile-builder-general-settings' )
@@ -398,8 +466,11 @@
398 466 wp_enqueue_style( 'thickbox' );
399 467 wp_enqueue_script( 'thickbox' );
400 468 }
401 469
470 + if ( $hook == 'profile-builder_page_profile-builder-dashboard' )
471 + wp_enqueue_script( 'jquery-pb-dashboard', WPPB_PLUGIN_URL . 'assets/js/jquery-pb-dashboard.js', array(), PROFILE_BUILDER_VERSION, true );
472 +
402 473 if ( isset( $_GET['post_type'] ) || isset( $_GET['post'] ) ){
403 474 if ( isset( $_GET['post_type'] ) )
404 475 $post_type = sanitize_text_field( $_GET['post_type'] );
405 476
@@ -407,16 +478,30 @@
407 478 $post_type = get_post_type( absint( $_GET['post'] ) );
408 479
409 480 if ( ( 'wppb-epf-cpt' == $post_type ) || ( 'wppb-rf-cpt' == $post_type ) || ( 'wppb-ul-cpt' == $post_type ) ){
410 481 wp_enqueue_style( 'wppb-back-end-style', WPPB_PLUGIN_URL . 'assets/css/style-back-end.css', false, PROFILE_BUILDER_VERSION );
411 - wp_enqueue_script( 'wppb-epf-rf', WPPB_PLUGIN_URL . 'assets/js/jquery-epf-rf.js', array(), PROFILE_BUILDER_VERSION, true );
482 + wp_enqueue_script( 'wppb-epf-rf', WPPB_PLUGIN_URL . 'assets/js/jquery-epf-rf.js', array(), PROFILE_BUILDER_VERSION, true );
483 + wp_localize_script( 'wppb-epf-rf', 'wppbEpfRf', array( 'nonce' => wp_create_nonce( 'wppb-epf-rf-id-change' ) ) );
412 484 }
413 485 else if( 'wppb-roles-editor' == $post_type ){
414 486 wp_enqueue_style( 'wppb-back-end-style', WPPB_PLUGIN_URL . 'assets/css/style-back-end.css', array(), PROFILE_BUILDER_VERSION );
415 487 }
416 488 }
489 + else if ( isset( $_GET['page'] ) ) {
490 + wp_enqueue_style( 'wppb-back-end-style', WPPB_PLUGIN_URL . 'assets/css/style-back-end.css', array(), PROFILE_BUILDER_VERSION );
491 + }
417 492
493 + if ( $hook == 'user-edit.php' ) {
494 + wp_enqueue_style( 'wppb-back-end-edit-user-style', WPPB_PLUGIN_URL . 'assets/css/style-back-end-edit-user.css', array(), PROFILE_BUILDER_VERSION );
495 + }
496 +
418 497 wp_enqueue_script( 'wppb-sitewide', WPPB_PLUGIN_URL . 'assets/js/jquery-pb-sitewide.js', array(), PROFILE_BUILDER_VERSION, true );
498 + wp_localize_script( 'wppb-sitewide', 'wppbDeactivationData', array(
499 + 'deactivationReasonNonce' => wp_create_nonce( 'wppb_deactivation_reason' ),
500 + 'deactivationReasonRequired' => __( 'Please select a reason before deactivating.', 'profile-builder' ),
501 + 'deactivationReasonInput' => __( 'Please complete the required field before deactivating.', 'profile-builder' ),
502 + 'deactivationReasonSaveError' => __( 'We could not save your feedback. Please try again.', 'profile-builder' ),
503 + ) );
419 504
420 505 wp_enqueue_style( 'wppb-serial-notice-css', WPPB_PLUGIN_URL . 'assets/css/serial-notice.css', false, PROFILE_BUILDER_VERSION );
421 506 }
422 507 add_action( 'admin_enqueue_scripts', 'wppb_print_cpt_script', 9 );
@@ -424,12 +509,11 @@
424 509 /**
425 510 * Highlight the settings page under Profile Builder in the admin menu for these pages
426 511 */
427 512 //add add_action( "admin_footer-$hook", "wppb_make_setting_menu_item_highlighted" ); for other pages that don't have a parent
428 -add_action( "admin_footer-admin_page_profile-builder-private-website", "wppb_make_setting_menu_item_highlighted" );
513 +add_action( "admin_footer-profile-builder_page_profile-builder-private-website", "wppb_make_setting_menu_item_highlighted" );
429 514 add_action( "admin_footer-profile-builder_page_profile-builder-admin-bar-settings", "wppb_make_setting_menu_item_highlighted" );
430 515 add_action( "admin_footer-profile-builder_page_profile-builder-content_restriction", "wppb_make_setting_menu_item_highlighted" );
431 -add_action( "admin_footer-profile-builder_page_profile-builder-content_restriction", "wppb_make_setting_menu_item_highlighted" );
432 516 add_action( "admin_footer-profile-builder_page_admin-email-customizer", "wppb_make_setting_menu_item_highlighted" );
433 517 add_action( "admin_footer-profile-builder_page_user-email-customizer", "wppb_make_setting_menu_item_highlighted" );
434 518 add_action( "admin_footer-profile-builder_page_profile-builder-toolbox-settings", "wppb_make_setting_menu_item_highlighted" );
435 519 add_action( "admin_footer-profile-builder_page_profile-builder-two-factor-authentication", "wppb_make_setting_menu_item_highlighted" );
@@ -708,18 +792,29 @@
708 792 // add a hook to delete the user from the _signups table if either the email confirmation is activated, or it is a wpmu installation
709 793 function wppb_delete_user_from_signups_table($user_id) {
710 794 global $wpdb;
711 795
712 - $userLogin = $wpdb->get_var( $wpdb->prepare( "SELECT user_login, user_email FROM " . $wpdb->users . " WHERE ID = %d LIMIT 1", $user_id ) );
713 - if ( is_multisite() )
714 - $delete = $wpdb->delete( $wpdb->signups, array( 'user_login' => $userLogin ) );
715 - else {
716 - $table_name = $wpdb->prefix . 'signups';
717 - $val = $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) );
718 - if ( $val ){
719 - $delete = $wpdb->delete($wpdb->prefix . 'signups', array('user_login' => $userLogin));
720 - }
721 - }
796 + $user = get_userdata( $user_id );
797 +
798 + if ( empty( $user ) ) {
799 + return;
800 + }
801 +
802 + // Delete signup rows by both email and login so activated entries do not remain orphaned in the signups table
803 + // - the signup row can preserve the originally submitted username, while the actual WP user_login may be regenerated from the submitted email address on activation
804 + // - the signup row can also preserve the email address used at registration time, while the actual WP user_email may later change after activation
805 + // - deleting by both keys covers both mismatch cases and keeps stale signups rows from blocking future registrations or other flows
806 + if ( is_multisite() ) {
807 + $wpdb->delete( $wpdb->signups, array( 'user_email' => $user->user_email ), array( '%s' ) );
808 + $wpdb->delete( $wpdb->signups, array( 'user_login' => $user->user_login ), array( '%s' ) );
809 + } else {
810 + $table_name = $wpdb->prefix . 'signups';
811 + $val = $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) );
812 + if ( $val ) {
813 + $wpdb->delete( $table_name, array( 'user_email' => $user->user_email ), array( '%s' ) );
814 + $wpdb->delete( $table_name, array( 'user_login' => $user->user_login ), array( '%s' ) );
815 + }
816 + }
722 817 }
723 818
724 819 $wppb_generalSettings = get_option( 'wppb_general_settings' );
725 820 if ( !empty( $wppb_generalSettings['emailConfirmation'] ) && ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) ) {
@@ -745,8 +840,22 @@
745 840 return apply_filters( 'wppb_user_meta_exists_meta_name', $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $id, $meta_name ) ), $id, $meta_name );
746 841 }
747 842
748 843
844 +/**
845 + * Sanitize a URL from request input. Non-string values (e.g. arrays from bracket notation) return ''.
846 + *
847 + * @param mixed $url Candidate URL.
848 + * @return string
849 + */
850 +function wppb_sanitize_request_url( $url ) {
851 + if ( ! is_string( $url ) || $url === '' ) {
852 + return '';
853 + }
854 +
855 + return esc_url_raw( wp_unslash( $url ) );
856 +}
857 +
749 858 // function to check if there is a need to add the http:// prefix
750 859 function wppb_check_missing_http( $redirectLink ) {
751 860 return preg_match( '#^(?:[a-z\d]+(?:-+[a-z\d]+)*\.)+[a-z]+(?::\d+)?(?:/|$)#i', $redirectLink );
752 861 }
@@ -791,9 +900,9 @@
791 900
792 901 //function to check password strength
793 902 function wppb_check_password_strength(){
794 903 $wppb_generalSettings = get_option( 'wppb_general_settings' );
795 - if( isset( $_POST['wppb_password_strength'] ) && !empty( $wppb_generalSettings['minimum_password_strength'] ) ){
904 + if( isset( $_POST['wppb_password_strength'] ) && sanitize_text_field( $_POST['wppb_password_strength'] ) != '' && !empty( $wppb_generalSettings['minimum_password_strength'] ) ){
796 905 $wppb_password_strength = sanitize_text_field( $_POST['wppb_password_strength'] );
797 906 $password_strength_array = array( 'short' => 0, 'bad' => 1, 'good' => 2, 'strong' => 3 );
798 907 $password_strength_text = array( 'short' => __( 'Very Weak', 'profile-builder' ), 'bad' => __( 'Weak', 'profile-builder' ), 'good' => __( 'Medium', 'profile-builder' ), 'strong' => __( 'Strong', 'profile-builder' ) );
799 908 if( $password_strength_array[$wppb_password_strength] < $password_strength_array[$wppb_generalSettings['minimum_password_strength']] ){
@@ -830,8 +939,9 @@
830 939
831 940 /**
832 941 * Include password strength check scripts on frontend where we have shortcodes present
833 942 */
943 +add_action( 'elementor/frontend/after_enqueue_scripts', 'wppb_enqueue_password_strength_check' );
834 944 add_action( 'wp_footer', 'wppb_enqueue_password_strength_check' );
835 945 function wppb_enqueue_password_strength_check() {
836 946 global $wppb_shortcode_on_front;
837 947 if( $wppb_shortcode_on_front ){
@@ -848,14 +958,16 @@
848 958 $wppb_generalSettings = get_option( 'wppb_general_settings' );
849 959 if( !empty( $wppb_generalSettings['minimum_password_strength'] ) ){
850 960 ?>
851 961 <script type="text/javascript">
852 - function check_pass_strength() {
853 - var pass1 = jQuery('#passw1').val(), pass2 = jQuery('#passw2').val(), strength;
962 + function check_pass_strength(form) {
963 + var pass1 = jQuery(form).find('#passw1').val(),
964 + pass2 = jQuery(form).find('#passw2').val(),
965 + strength;
854 966
855 - jQuery('#pass-strength-result').removeClass('short bad good strong');
856 - if ( ! pass1 ) {
857 - jQuery('#pass-strength-result').html( pwsL10n.empty );
967 + jQuery(form).find('#pass-strength-result').removeClass('short bad good strong');
968 + if (!pass1) {
969 + jQuery(form).find('#pass-strength-result').html(pwsL10n.empty);
858 970 return;
859 971 }
860 972 <?php
861 973 global $wp_version;
@@ -872,33 +984,37 @@
872 984 }
873 985 ?>
874 986 switch ( strength ) {
875 987 case 2:
876 - jQuery('#pass-strength-result').addClass('bad').html( pwsL10n.bad );
877 - jQuery('#wppb_password_strength').val('bad');
988 + jQuery(form).find('#pass-strength-result').addClass('bad').html( pwsL10n.bad );
989 + jQuery(form).find('#wppb_password_strength').val('bad');
878 990 break;
879 991 case 3:
880 - jQuery('#pass-strength-result').addClass('good').html( pwsL10n.good );
881 - jQuery('#wppb_password_strength').val('good');
992 + jQuery(form).find('#pass-strength-result').addClass('good').html( pwsL10n.good );
993 + jQuery(form).find('#wppb_password_strength').val('good');
882 994 break;
883 995 case 4:
884 - jQuery('#pass-strength-result').addClass('strong').html( pwsL10n.strong );
885 - jQuery('#wppb_password_strength').val('strong');
996 + jQuery(form).find('#pass-strength-result').addClass('strong').html( pwsL10n.strong );
997 + jQuery(form).find('#wppb_password_strength').val('strong');
886 998 break;
887 999 case 5:
888 - jQuery('#pass-strength-result').addClass('short').html( pwsL10n.mismatch );
889 - jQuery('#wppb_password_strength').val('short');
1000 + jQuery(form).find('#pass-strength-result').addClass('short').html( pwsL10n.mismatch );
1001 + jQuery(form).find('#wppb_password_strength').val('short');
890 1002 break;
891 1003 default:
892 - jQuery('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
893 - jQuery('#wppb_password_strength').val('short');
1004 + jQuery(form).find('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
1005 + jQuery(form).find('#wppb_password_strength').val('short');
894 1006 }
895 1007 }
896 1008 jQuery( document ).ready( function() {
897 1009 // Binding to trigger checkPasswordStrength
898 - jQuery('#passw1').val('').on( 'keyup', check_pass_strength );
899 - jQuery('#passw2').val('').on( 'keyup', check_pass_strength );
900 - jQuery('#pass-strength-result').show();
1010 + jQuery('.wppb-user-forms').each(function() {
1011 + var form = this;
1012 + jQuery(form).find('#passw1, #passw2').val('').on('keyup change', function() {
1013 + check_pass_strength(form);
1014 + });
1015 + jQuery(form).find('#pass-strength-result').show();
1016 + });
901 1017 });
902 1018 </script>
903 1019 <?php
904 1020 }
@@ -911,9 +1027,9 @@
911 1027 function wppb_password_visibility_toggle_html(){
912 1028 if( apply_filters( 'wppb_show_password_visibility_toggle', false ) ){
913 1029 return '
914 1030 <button type="button" class="wppb-toggle-pw wppb-show-pw hide-if-no-js" data-toggle="0" aria-label="Show password" tabindex="-1">
915 - <img src="'.WPPB_PLUGIN_URL.'/assets/images/eye-outline.svg" width="20px" height="20px" />
1031 + <img src="'.WPPB_PLUGIN_URL.'/assets/images/eye-outline.svg" title="'. esc_html__( 'Show password', 'profile-builder' ) .'" width="20px" height="20px" />
916 1032 </button>';
917 1033 }
918 1034 return '';
919 1035 }
@@ -920,12 +1036,14 @@
920 1036
921 1037 /**
922 1038 * Include toggle password visibility script on frontend where we have shortcodes present
923 1039 */
1040 +add_action( 'elementor/frontend/after_enqueue_scripts', 'wppb_enqueue_password_visibility_toggle' );
924 1041 add_action( 'wp_footer', 'wppb_enqueue_password_visibility_toggle' );
925 1042 function wppb_enqueue_password_visibility_toggle() {
926 1043 global $wppb_shortcode_on_front;
927 - if( $wppb_shortcode_on_front && apply_filters( 'wppb_show_password_visibility_toggle', false ) ){
1044 + static $enqueued = false;
1045 + if( $wppb_shortcode_on_front && apply_filters( 'wppb_show_password_visibility_toggle', false ) && !$enqueued ){
928 1046
929 1047 //load jQuery if needed
930 1048 if( !wp_script_is('jquery', 'done') ){
931 1049 wp_print_scripts('jquery');
@@ -950,32 +1068,32 @@
950 1068 })
951 1069
952 1070 });
953 1071 function wppb_password_visibility_toggle() {
954 - var target_form_id = "#" + jQuery(this).closest('form').attr("id") + " ";
1072 + var button = jQuery( this );
1073 + var container = button.closest( '.wppb-password-field-container' );
1074 + var input = container.find( 'input' ).first();
1075 + var icon = button.find( 'img' );
955 1076
956 - var password_inputs = [ ".login-password input#user_pass", "input#passw1", "input#passw2" ]
1077 + if ( ! input.length ) {
1078 + return;
1079 + }
957 1080
958 - for ( var password_input of password_inputs ){
959 - var input = jQuery( target_form_id + password_input );
960 - var button = jQuery( target_form_id + "button.wppb-toggle-pw" );
961 - var icon = jQuery( target_form_id + "button.wppb-toggle-pw img" );
962 -
963 - if ( input.length ) {
964 - if ("password" === input.attr("type")) {
965 - input.attr("type", "text");
966 - button.toggleClass("wppb-show-pw").toggleClass("wppb-hide-pw");
967 - icon.attr("src", "<?php echo esc_attr( WPPB_PLUGIN_URL ); ?>/assets/images/eye-off-outline.svg");
968 - } else {
969 - input.attr("type", "password");
970 - button.toggleClass("wppb-show-pw").toggleClass("wppb-hide-pw");
971 - icon.attr("src", "<?php echo esc_attr( WPPB_PLUGIN_URL ); ?>/assets/images/eye-outline.svg");
972 - }
973 - }
1081 + if ( "password" === input.attr( "type" ) ) {
1082 + input.attr( "type", "text" );
1083 + button.removeClass( "wppb-show-pw" ).addClass( "wppb-hide-pw" );
1084 + icon.attr( "src", "<?php echo esc_attr( WPPB_PLUGIN_URL ); ?>/assets/images/eye-off-outline.svg" );
1085 + icon.attr( "title", "<?php esc_html_e( 'Hide password', 'profile-builder' ); ?>" );
1086 + } else {
1087 + input.attr( "type", "password" );
1088 + button.removeClass( "wppb-hide-pw" ).addClass( "wppb-show-pw" );
1089 + icon.attr( "src", "<?php echo esc_attr( WPPB_PLUGIN_URL ); ?>/assets/images/eye-outline.svg" );
1090 + icon.attr( "title", "<?php esc_html_e( 'Show password', 'profile-builder' ); ?>" );
974 1091 }
975 1092 }
976 1093 </script>
977 1094 <?php
1095 + $enqueued = true;
978 1096 }
979 1097 }
980 1098
981 1099 /**
@@ -1017,12 +1135,63 @@
1017 1135 return '';
1018 1136 }
1019 1137
1020 1138
1139 +/**
1140 + * Returns the AJAX actions that check the login/checkout credentials before the real form submission is sent.
1141 + *
1142 + * Those requests run the whole authentication stack, so our CAPTCHA check runs too and the token gets spent
1143 + * with the CAPTCHA provider, but they never log the user in - the browser still submits the form afterwards
1144 + * with the very same token. CAPTCHA tokens are single use, so verifying one a second time comes back as a
1145 + * duplicate and the login fails. For these actions we remember the successful verification and reuse it once,
1146 + * when the actual form submission arrives.
1147 + */
1148 +function wppb_get_captcha_prevalidation_actions() {
1149 + return apply_filters( 'wppb_captcha_prevalidation_actions', array(
1150 + 'pms_validate_checkout', // Paid Member Subscriptions checkout validation
1151 + 'wordfence_ls_authenticate', // Wordfence Login Security login pre-flight, used to decide if it needs to ask for a 2FA code
1152 + ) );
1153 +}
1154 +
1155 +/* Whether the current request is one of the CAPTCHA pre-validation AJAX calls above */
1156 +function wppb_is_captcha_prevalidation_request() {
1157 + if ( ! wp_doing_ajax() || empty( $_POST['action'] ) || ! is_string( $_POST['action'] ) ) /* phpcs:ignore WordPress.Security.NonceVerification.Missing */
1158 + return false;
1159 +
1160 + return in_array( sanitize_text_field( $_POST['action'] ), wppb_get_captcha_prevalidation_actions(), true ); /* phpcs:ignore WordPress.Security.NonceVerification.Missing */
1161 +}
1162 +
1163 +/**
1164 + * Drops pre-validated CAPTCHA tokens that were never claimed by a form submission.
1165 + *
1166 + * A pre-validation that is not followed by a submission (wrong password, abandoned login, bots) leaves its
1167 + * entry behind, so without this the option would keep growing on sites where every login is pre-validated.
1168 + */
1169 +function wppb_prune_captcha_prevalidations( $saved ) {
1170 + if ( ! is_array( $saved ) )
1171 + return array();
1172 +
1173 + $lifetime = apply_filters( 'wppb_captcha_prevalidation_lifetime', 15 * MINUTE_IN_SECONDS );
1174 +
1175 + foreach ( $saved as $token => $validated_at ) {
1176 + if ( ! is_int( $validated_at ) || ( time() - $validated_at ) > $lifetime )
1177 + unset( $saved[ $token ] );
1178 + }
1179 +
1180 + return $saved;
1181 +}
1182 +
1021 1183 /* Function for displaying reCAPTCHA error on Login and Recover Password forms */
1022 1184 function wppb_recaptcha_field_error($field_title='') {
1023 - $recaptcha_error = apply_filters('wppb_recaptcha_error' , __('Please enter a (valid) reCAPTCHA value','profile-builder') , $field_title);
1024 1185
1186 + $recaptcha_field = wppb_get_recaptcha_field();
1187 +
1188 + if( $recaptcha_field['recaptcha-type'] === 'v2' ) {
1189 + $recaptcha_error = apply_filters('wppb_recaptcha_error' , __('Please enter a (valid) reCAPTCHA value','profile-builder') , $field_title);
1190 + } else {
1191 + $recaptcha_error = apply_filters('wppb_recaptcha_error' , __('reCaptcha could not be verified. Please try again.','profile-builder') , $field_title);
1192 + }
1193 +
1025 1194 return $recaptcha_error;
1026 1195
1027 1196 }
1028 1197 /* Function for displaying phone field error */
@@ -1355,9 +1524,9 @@
1355 1524 }
1356 1525 }
1357 1526
1358 1527 if( ! empty( $redirect_url ) ) {
1359 - $redirect_url = ( wppb_check_missing_http( $redirect_url ) ? 'http://'. $redirect_url : $redirect_url );
1528 + $redirect_url = ( wppb_check_missing_http( $redirect_url ) ? wppb_add_missing_http( $redirect_url ) : $redirect_url );
1360 1529 }
1361 1530
1362 1531 return $redirect_url;
1363 1532 }
@@ -1362,8 +1531,87 @@
1362 1531 return $redirect_url;
1363 1532 }
1364 1533
1365 1534 /**
1535 + * Bind an autologin nonce to a user ID server-side (one-time use).
1536 + *
1537 + * @param int $user_id User ID to log in.
1538 + * @param string $nonce Autologin nonce.
1539 + */
1540 +function wppb_store_autologin_user( $user_id, $nonce ) {
1541 + $user_id = absint( $user_id );
1542 +
1543 + if ( ! $user_id || empty( $nonce ) ) {
1544 + return;
1545 + }
1546 +
1547 + set_transient( 'wppb_autologin_' . md5( $nonce ), $user_id, 2 * MINUTE_IN_SECONDS );
1548 +}
1549 +
1550 +/**
1551 + * Resolve the user bound to an autologin nonce.
1552 + *
1553 + * @param string $nonce Autologin nonce.
1554 + * @param bool $consume Whether to delete the stored mapping.
1555 + *
1556 + * @return int User ID, or 0 when not found.
1557 + */
1558 +function wppb_get_autologin_user_id( $nonce, $consume = true ) {
1559 + if ( empty( $nonce ) ) {
1560 + return 0;
1561 + }
1562 +
1563 + $key = 'wppb_autologin_' . md5( $nonce );
1564 + $user_id = absint( get_transient( $key ) );
1565 +
1566 + if ( $user_id && $consume ) {
1567 + delete_transient( $key );
1568 + }
1569 +
1570 + return $user_id;
1571 +}
1572 +
1573 +/**
1574 + * Build autologin query args for a user.
1575 + *
1576 + * @param int $user_id User ID to log in.
1577 + *
1578 + * @return array Query args for add_query_arg().
1579 + */
1580 +function wppb_get_autologin_query_args( $user_id ) {
1581 + $user_id = absint( $user_id );
1582 + $nonce = wp_create_nonce( 'autologin-' . $user_id . '-' . (int) ( time() / 60 ) );
1583 +
1584 + wppb_store_autologin_user( $user_id, $nonce );
1585 +
1586 + return array(
1587 + 'autologin' => 'true',
1588 + '_wpnonce' => $nonce,
1589 + );
1590 +}
1591 +
1592 +/**
1593 + * Verify an autologin nonce for the given user ID.
1594 + *
1595 + * @param string $nonce Autologin nonce.
1596 + * @param int $user_id User ID bound to the nonce.
1597 + *
1598 + * @return bool
1599 + */
1600 +function wppb_verify_autologin_nonce( $nonce, $user_id ) {
1601 + $user_id = absint( $user_id );
1602 +
1603 + if ( ! $user_id || empty( $nonce ) ) {
1604 + return false;
1605 + }
1606 +
1607 + $nonce_action = 'autologin-' . $user_id . '-';
1608 +
1609 + return wp_verify_nonce( $nonce, $nonce_action . (int) ( time() / 60 ) )
1610 + || wp_verify_nonce( $nonce, $nonce_action . (int) ( time() / 60 - 1 ) );
1611 +}
1612 +
1613 +/**
1366 1614 * Function that builds the redirect
1367 1615 *
1368 1616 * @param string $redirect_url - redirect URL
1369 1617 * @param int $redirect_delay - redirect delay in seconds
@@ -1379,14 +1627,14 @@
1379 1627
1380 1628 $redirect_message = '';
1381 1629
1382 1630 if( ! empty( $redirect_url ) ) {
1383 - $redirect_url = ( wppb_check_missing_http( $redirect_url ) ? 'http://'. $redirect_url : $redirect_url );
1631 + $redirect_url = ( wppb_check_missing_http( $redirect_url ) ? wppb_add_missing_http( $redirect_url ) : $redirect_url );
1384 1632
1385 1633 if( $redirect_delay == 0 ) {
1386 1634 $redirect_message = '<meta http-equiv="Refresh" content="'. $redirect_delay .';url='. $redirect_url .'" />';
1387 1635 } else {
1388 - $redirect_url_href = apply_filters( 'wppb_redirect_url', '<a href="'. $redirect_url .'">'. __( 'here', 'profile-builder' ) .'</a>', $redirect_url, $redirect_type, $form_args );
1636 + $redirect_url_href = apply_filters( 'wppb_redirect_url', '<a href="'. esc_url( $redirect_url ) .'">'. __( 'here', 'profile-builder' ) .'</a>', $redirect_url, $redirect_type, $form_args );
1389 1637 $redirect_message = apply_filters( 'wppb_redirect_message_before_returning', '<p class="redirect_message">'. sprintf( wp_slash( __( 'You will soon be redirected automatically. If you see this page for more than %1$d seconds, please click %2$s.%3$s', 'profile-builder' ) ), $redirect_delay, $redirect_url_href, '<meta http-equiv="Refresh" content="'. $redirect_delay .';url='. $redirect_url .'" />' ) .'</p>', $redirect_url, $redirect_delay, $redirect_url_href, $redirect_type, $form_args );
1390 1638 }
1391 1639 }
1392 1640
@@ -1450,20 +1698,24 @@
1450 1698 add_action( 'login_init', 'wppb_private_website_functionality', 1 );
1451 1699 function wppb_private_website_functionality(){
1452 1700 $wppb_private_website_settings = get_option( 'wppb_private_website_settings', 'not_found' );
1453 1701 if( $wppb_private_website_settings != 'not_found' ){
1454 - if( $wppb_private_website_settings['private_website'] == 'yes' ){
1702 + if( !empty( $wppb_private_website_settings['private_website'] ) && $wppb_private_website_settings['private_website'] == 'yes' ){
1455 1703 if( !is_user_logged_in() ){
1456 1704
1457 - if(is_404())
1705 + if( is_404() )
1458 1706 return;
1459 1707
1460 - //force wp-login.php if you accidentally get locked out
1708 + // force wp-login.php if you accidentally get locked out
1461 1709 global $pagenow;
1462 - if( $pagenow === 'wp-login.php' && isset( $_GET['wppb_force_wp_login'] ) )
1710 + if( $pagenow === 'wp-login.php' && ( isset( $_GET['wppb_force_wp_login'] ) || ( isset( $_SERVER['HTTP_REFERER'] ) && strpos( esc_url_raw( $_SERVER['HTTP_REFERER'] ), 'wppb_force_wp_login=true' ) !== false ) || ( isset($_REQUEST['redirect_to']) && strpos( sanitize_text_field( $_REQUEST['redirect_to'] ), 'wppb_force_wp_login=true' ) !== false ) ) )
1463 1711 return;
1464 1712
1465 - //go through paths first if they are set
1713 + // bypass requests that enter the password of a password protected post
1714 + if( $pagenow === 'wp-login.php' && isset( $_GET['action'] ) && $_GET['action'] == 'postpass' && isset( $_POST['post_password'] ) )
1715 + return;
1716 +
1717 + // go through paths first if they are set
1466 1718 if( isset( $wppb_private_website_settings['allowed_paths'] ) && !empty( $wppb_private_website_settings['allowed_paths'] ) ){
1467 1719 $allowed_paths = explode( "\r\n", $wppb_private_website_settings['allowed_paths'] );
1468 1720 $parsed_url = wp_parse_url( wppb_curpageurl() );
1469 1721 if( !empty( $parsed_url['path'] ) ) {
@@ -1482,8 +1734,23 @@
1482 1734 }
1483 1735 }
1484 1736 }
1485 1737
1738 + if( isset( $wppb_private_website_settings['allowed_query_strings'] ) && !empty( $wppb_private_website_settings['allowed_query_strings'] ) ){
1739 + $allowed_query_strings = explode( "\r\n", $wppb_private_website_settings['allowed_query_strings'] );
1740 + $parsed_url_parameters = wp_parse_url( wppb_curpageurl() );
1741 +
1742 + if( !empty( $parsed_url_parameters['query'] ) ) {
1743 + parse_str( $parsed_url_parameters['query'], $query_params );
1744 +
1745 + foreach ( $allowed_query_strings as $allowed_query ) {
1746 + if ( array_key_exists( $allowed_query, $query_params ) ) {
1747 + return;
1748 + }
1749 + }
1750 + }
1751 + }
1752 +
1486 1753 if( isset( $wppb_private_website_settings['allowed_pages'] ) )
1487 1754 $allowed_pages = $wppb_private_website_settings['allowed_pages'];
1488 1755 else{
1489 1756 $allowed_pages = array();
@@ -1536,12 +1803,12 @@
1536 1803 add_filter( 'body_class', 'wppb_private_website_body_classes' );
1537 1804 function wppb_private_website_body_classes( $classes ){
1538 1805 $wppb_private_website_settings = get_option( 'wppb_private_website_settings', 'not_found' );
1539 1806 if( $wppb_private_website_settings != 'not_found' ) {
1540 - if ($wppb_private_website_settings['private_website'] == 'yes') {
1807 + if ( !empty( $wppb_private_website_settings['private_website'] ) && $wppb_private_website_settings['private_website'] == 'yes' ) {
1541 1808 if (!is_user_logged_in()) {
1542 1809 $classes[] = 'wppb-private-website';
1543 - if ($wppb_private_website_settings['hide_menus'] == 'yes') {
1810 + if ( !empty( $wppb_private_website_settings['hide_menus'] ) && $wppb_private_website_settings['hide_menus'] == 'yes' ) {
1544 1811 $classes[] = 'wppb-private-website-hide-menus';
1545 1812 }
1546 1813 }
1547 1814 }
@@ -1563,9 +1830,9 @@
1563 1830 add_action('do_feed_atom_comments', 'wppb_disable_feed', 1);
1564 1831 function wppb_disable_feed() {
1565 1832 $wppb_private_website_settings = get_option( 'wppb_private_website_settings', 'not_found' );
1566 1833 if( $wppb_private_website_settings != 'not_found' ) {
1567 - if ($wppb_private_website_settings['private_website'] == 'yes') {
1834 + if ( !empty( $wppb_private_website_settings['private_website'] ) && $wppb_private_website_settings['private_website'] == 'yes' ) {
1568 1835 if (!is_user_logged_in()) {
1569 1836 wp_die( wp_kses_post( sprintf( __('No feed available,please visit our <a href="%s">homepage</a>!', 'profile-builder' ), get_bloginfo('url') ) ) );
1570 1837 }
1571 1838 }
@@ -1580,10 +1847,10 @@
1580 1847 add_filter('rest_jsonp_enabled', 'wppb_disable_rest');
1581 1848 function wppb_disable_rest( $bool ){
1582 1849 $wppb_private_website_settings = get_option( 'wppb_private_website_settings', 'not_found' );
1583 1850 if( $wppb_private_website_settings != 'not_found' ) {
1584 - if ($wppb_private_website_settings['private_website'] == 'yes') {
1585 - if ( isset( $wppb_private_website_settings[ 'disable_rest_api' ] ) && $wppb_private_website_settings[ 'disable_rest_api' ] == 'no' ) {
1851 + if ( !empty( $wppb_private_website_settings['private_website'] ) && $wppb_private_website_settings['private_website'] == 'yes' ) {
1852 + if ( !isset( $wppb_private_website_settings[ 'disable_rest_api' ] ) || $wppb_private_website_settings[ 'disable_rest_api' ] !== 'yes' ) {
1586 1853 return $bool;
1587 1854 }
1588 1855 if (!is_user_logged_in()) {
1589 1856 return false;
@@ -1601,12 +1868,21 @@
1601 1868 }
1602 1869
1603 1870 $wppb_private_website_settings = get_option( 'wppb_private_website_settings', 'not_found' );
1604 1871 if( $wppb_private_website_settings != 'not_found' ) {
1605 - if ($wppb_private_website_settings['private_website'] == 'yes') {
1606 - if ( isset( $wppb_private_website_settings[ 'disable_rest_api' ] ) && $wppb_private_website_settings[ 'disable_rest_api' ] == 'no' ) {
1872 + if ( !empty( $wppb_private_website_settings['private_website'] ) && $wppb_private_website_settings['private_website'] == 'yes' ) {
1873 + if ( !isset( $wppb_private_website_settings[ 'disable_rest_api' ] ) || $wppb_private_website_settings[ 'disable_rest_api' ] !== 'yes' ) {
1607 1874 return $result;
1608 1875 }
1876 +
1877 + // THE EVENTS CALENDAR EXCEPTION
1878 + // They do some rest API calls in the front-end for their event view but due to their usage, they are breaking the authenticated user
1879 + // and WordPress thinks the user is not authenticated (is_user_logged_in() == false)
1880 + // This makes things break for logged in users whe the Private Website + Rest API functionality is enabled
1881 + // We are going to ignore requests that contain their nonces so we can exlude them from our restrictions
1882 + if( isset( $_REQUEST['_tec_view_rest_nonce_primary'] ) || isset( $_REQUEST['_tec_view_rest_nonce_secondary'] ) )
1883 + return $result;
1884 +
1609 1885 if (!is_user_logged_in() && isset( $_SERVER['REQUEST_URI'] ) && $_SERVER['REQUEST_URI'] !== "/wp-json/jwt-auth/v1/token" && $_SERVER['REQUEST_URI'] !== "/wp-json/jwt-auth/v1/token/validate") {
1610 1886 return new WP_Error('rest_not_logged_in', __( 'You are not currently logged in.', 'profile-builder' ), array('status' => 401));
1611 1887 }
1612 1888 }
@@ -1622,9 +1898,9 @@
1622 1898 add_filter('wp_page_menu', 'wppb_hide_menus');
1623 1899 function wppb_hide_menus( $menu ){
1624 1900 $wppb_private_website_settings = get_option( 'wppb_private_website_settings', 'not_found' );
1625 1901 if( $wppb_private_website_settings != 'not_found' ) {
1626 - if ($wppb_private_website_settings['private_website'] == 'yes') {
1902 + if ( !empty( $wppb_private_website_settings['private_website'] ) && $wppb_private_website_settings['private_website'] == 'yes' ) {
1627 1903 if ( !is_user_logged_in() && ( !empty($wppb_private_website_settings['hide_menus']) && $wppb_private_website_settings['hide_menus'] == 'yes' ) ) {
1628 1904 return '';
1629 1905 }
1630 1906 }
@@ -1787,9 +2063,9 @@
1787 2063 global $wp_embed;
1788 2064 if(empty($atts['width']) || empty($atts['height'])){
1789 2065 $content = $wp_embed->run_shortcode('[embed]'.$content.'[/embed]');
1790 2066 } else {
1791 - $content = $wp_embed->run_shortcode('[embed width="'.$atts['width'].'" height="'.$atts['height'].'"]'.$content.'[/embed]');
2067 + $content = $wp_embed->run_shortcode('[embed width="'.esc_attr($atts['width']).'" height="'.esc_attr($atts['height']).'"]'.$content.'[/embed]');
1792 2068 }
1793 2069
1794 2070 return $content;
1795 2071 }