From 9fff9597c9d6f70ff89e1a7ce43a6b007901fe39 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Fri, 20 Apr 2018 14:28:43 +0300 Subject: [PATCH 01/35] - password field initial commit; --- includes/core/class-fields.php | 10 +++++++--- includes/core/um-actions-profile.php | 14 ++++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 00ad82c6..bc8069e3 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -574,7 +574,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) { } elseif ( um_user( $key ) && $this->editing == true ) { - if ( strstr( $key, 'user_pass' ) ) { + //show empty value for password fields + if ( strstr( $key, 'user_pass' ) || $type == 'password' ) { return ''; } @@ -3432,9 +3433,12 @@ if ( ! class_exists( 'um\core\Fields' ) ) { if (isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group') return; - if ($visibility == 'edit') return; + if ( $visibility == 'edit' ) return; - if (in_array( $type, array( 'block', 'shortcode', 'spacing', 'divider', 'group' ) )) { + //invisible on profile page + if ( $type == 'password' ) return; + + if ( in_array( $type, array( 'block', 'shortcode', 'spacing', 'divider', 'group' ) ) ) { } else { diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php index 072e8901..a57a5255 100644 --- a/includes/core/um-actions-profile.php +++ b/includes/core/um-actions-profile.php @@ -218,6 +218,7 @@ function um_user_edit_profile( $args ) { // loop through fields if ( ! empty( $fields ) ) { + foreach ( $fields as $key => $array ) { if ( ! um_can_edit_field( $fields[ $key ] ) && isset( $fields[ $key ]['editable'] ) && ! $fields[ $key ]['editable'] ) @@ -236,10 +237,15 @@ function um_user_edit_profile( $args ) { } else { - if ( isset( $userinfo[ $key ] ) && $args['submitted'][ $key ] != $userinfo[ $key ] ) { - $to_update[ $key ] = $args['submitted'][ $key ]; - } elseif ( $args['submitted'][ $key ] ) { - $to_update[ $key ] = $args['submitted'][ $key ]; + if ( $array['type'] == 'password' ) { + $to_update[ $key ] = wp_hash_password( $args['submitted'][ $key ] ); + $args['submitted'][ $key ] = sprintf( __( 'Your choosed %s', 'ultimate-member' ), $array['title'] ); + } else { + if ( isset( $userinfo[ $key ] ) && $args['submitted'][ $key ] != $userinfo[ $key ] ) { + $to_update[ $key ] = $args['submitted'][ $key ]; + } elseif ( $args['submitted'][ $key ] ) { + $to_update[ $key ] = $args['submitted'][ $key ]; + } } } From 03c47ebc4531de870ba097cf9f501b7c8a8cbc16 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Thu, 3 May 2018 16:20:46 +0300 Subject: [PATCH 02/35] - fixed checkboxes with "'" symbols in label; - fixed User page restriction options; --- includes/core/class-access.php | 2 +- includes/core/class-fields.php | 7 ++++++- includes/core/um-actions-profile.php | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index c0d601ac..7f1c1fc5 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -532,7 +532,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { if ( ! empty( $post->post_type ) && $post->post_type == 'page' ) { if ( um_is_core_post( $post, 'login' ) || um_is_core_post( $post, 'register' ) || um_is_core_post( $post, 'account' ) || um_is_core_post( $post, 'logout' ) || - um_is_core_post( $post, 'password-reset' ) ) + um_is_core_post( $post, 'password-reset' ) || um_is_core_post( $post, 'user' ) ) return false; } diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 9cab1a87..2dc39756 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -798,6 +798,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) { return true; } + $stripslashed = array_map( 'stripslashes', UM()->form()->post_form[ $key ] ); + if ( in_array( $value, $stripslashed ) ) { + return true; + } + if ( in_array( html_entity_decode( $value ), UM()->form()->post_form[ $key ] ) ) { return true; } @@ -1578,7 +1583,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { if ($visibility == 'view' && $this->set_mode != 'register') return; - if (( $visibility == 'view' && $this->set_mode == 'register' ) || + if ( ( $visibility == 'view' && $this->set_mode == 'register' ) || ( isset( $data['editable'] ) && $data['editable'] == 0 && $this->set_mode == 'profile' ) ) { diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php index 803a3e88..912be967 100644 --- a/includes/core/um-actions-profile.php +++ b/includes/core/um-actions-profile.php @@ -220,6 +220,9 @@ function um_user_edit_profile( $args ) { if ( ! empty( $fields ) ) { foreach ( $fields as $key => $array ) { + /*if ( ! um_can_edit_field( $fields[ $key ] ) ) + continue;*/ + if ( ! um_can_edit_field( $fields[ $key ] ) && isset( $fields[ $key ]['editable'] ) && ! $fields[ $key ]['editable'] ) continue; From 0ba4a8e6b06c056cd9fbe824cdf1677c55dbf7be Mon Sep 17 00:00:00 2001 From: yura_nalivaiko Date: Mon, 7 May 2018 10:23:51 +0300 Subject: [PATCH 03/35] -changes for menu; --- includes/admin/core/packages/2.0-beta1/menus.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/admin/core/packages/2.0-beta1/menus.php b/includes/admin/core/packages/2.0-beta1/menus.php index a1ecb262..80f0ce2a 100644 --- a/includes/admin/core/packages/2.0-beta1/menus.php +++ b/includes/admin/core/packages/2.0-beta1/menus.php @@ -18,9 +18,15 @@ $menus = get_posts( array( foreach ( $menus as $menu ) { $menu_roles = get_post_meta( $menu->ID, 'menu-item-um_nav_roles', true ); - foreach ( $menu_roles as $i => $role_k ) { - $menu_roles[ $i ] = $roles_associations[ $role_k ]; + if( !is_array( $menu_roles ) ) { + $menu_roles = array(); } + foreach ( $menu_roles as $i => $role_k ) { + if( $role_k != '' && isset( $roles_associations[ $role_k ] ) ) { + $menu_roles[ $i ] = $roles_associations[ $role_k ]; + } + } + update_post_meta( $menu->ID, 'menu-item-um_nav_roles', $menu_roles ); } \ No newline at end of file From 7493d419014a3595d378d57bf6ab22de1b682a4b Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 8 May 2018 12:33:27 +0300 Subject: [PATCH 04/35] - GDPR extension added; - fixed some issues with dependencies pre2.0 extensions; --- includes/admin/core/class-admin-notices.php | 25 +++++++++++- includes/class-dependencies.php | 1 + includes/class-init.php | 42 +-------------------- 3 files changed, 26 insertions(+), 42 deletions(-) diff --git a/includes/admin/core/class-admin-notices.php b/includes/admin/core/class-admin-notices.php index ce698225..ac84e031 100644 --- a/includes/admin/core/class-admin-notices.php +++ b/includes/admin/core/class-admin-notices.php @@ -225,9 +225,32 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { function old_extensions_notice() { $show = false; + $old_extensions = array( + 'bbpress', + 'followers', + 'friends', + 'instagram', + 'mailchimp', + 'messaging', + 'mycred', + 'notices', + 'notifications', + 'online', + 'private-content', + 'profile-completeness', + 'recaptcha', + 'reviews', + 'social-activity', + 'social-login', + 'terms-conditions', + 'user-tags', + 'verified-users', + 'woocommerce', + ); + $slugs = array_map( function( $item ) { return 'um-' . $item . '/um-' . $item . '.php'; - }, array_keys( UM()->dependencies()->ext_required_version ) ); + }, $old_extensions ); $active_plugins = UM()->dependencies()->get_active_plugins(); foreach ( $slugs as $slug ) { diff --git a/includes/class-dependencies.php b/includes/class-dependencies.php index d25f1f9a..b0fe53b9 100644 --- a/includes/class-dependencies.php +++ b/includes/class-dependencies.php @@ -57,6 +57,7 @@ if ( ! class_exists( 'um\Dependencies' ) ) { 'woocommerce' => '2.0.1', 'restrict-content' => '2.0', 'beaver-builder' => '2.0', + 'gdpr' => '1.0.0', ); diff --git a/includes/class-init.php b/includes/class-init.php index 249a103e..bcd10906 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -30,6 +30,7 @@ if ( ! class_exists( 'UM' ) ) { * @method UM_Terms_Conditions_API Terms_Conditions_API() * @method UM_Private_Content_API Private_Content_API() * @method UM_User_Location_API User_Location_API() + * @method UM_GDPR_API GDPR_API() * */ final class UM extends UM_Functions { @@ -385,47 +386,6 @@ if ( ! class_exists( 'UM' ) ) { } - /** - * Show notice for customers with old extension's versions - */ - /*function old_extensions_notice() { - if ( ! is_admin() ) { - return; - } - - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { - return; - } - - $show = false; - - $slugs = array_map( function( $item ) { - return 'um-' . $item . '/um-' . $item . '.php'; - }, array_keys( $this->dependencies()->ext_required_version ) ); - - $active_plugins = $this->dependencies()->get_active_plugins(); - foreach ( $slugs as $slug ) { - if ( in_array( $slug, $active_plugins ) ) { - $plugin_data = get_plugin_data( um_path . '..' . DIRECTORY_SEPARATOR . $slug ); - if ( version_compare( '2.0', $plugin_data['Version'], '>' ) ) { - $show = true; - break; - } - } - } - - if ( ! $show ) { - return; - } - - /*global $um_woocommerce; - remove_action( 'init', array( $um_woocommerce, 'plugin_check' ), 1 ); - $um_woocommerce->plugin_inactive = true;* - - echo '

' . sprintf( __( '%s %s requires 2.0 extensions. You have pre 2.0 extensions installed on your site.
Please update %s extensions to latest versions. For more info see this doc.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, 'http://docs.ultimatemember.com/article/266-updating-to-2-0-versions-of-extensions' ) . '

'; - }*/ - - /** * Autoload UM classes handler * From 60637cc3a40800f24d08b0bb9fe865c720add3ca Mon Sep 17 00:00:00 2001 From: Denis Baranov Date: Wed, 9 May 2018 16:16:32 +0300 Subject: [PATCH 05/35] fix privacy tab content --- includes/core/class-account.php | 6 +++--- includes/core/class-fields.php | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/core/class-account.php b/includes/core/class-account.php index 1b7007af..4b617404 100644 --- a/includes/core/class-account.php +++ b/includes/core/class-account.php @@ -55,6 +55,7 @@ if ( ! class_exists( 'um\core\Account' ) ) { * @param $args */ function init_tabs( $args ) { + $this->tabs = $this->get_tabs(); ksort( $this->tabs ); @@ -75,7 +76,6 @@ if ( ! class_exists( 'um\core\Account' ) ) { } } - $this->tabs = $tabs_structed; } @@ -527,7 +527,7 @@ if ( ! class_exists( 'um\core\Account' ) ) { * ?> */ $args = apply_filters( 'um_account_tab_privacy_fields', $args, $shortcode_args ); - + $fields = UM()->builtin()->get_specific_fields( $args ); $fields = $this->account_secure_fields( $fields, $id ); $fields = $this->filter_fields_by_attrs( $fields, $shortcode_args ); @@ -535,7 +535,6 @@ if ( ! class_exists( 'um\core\Account' ) ) { foreach ( $fields as $key => $data ){ $output .= UM()->fields()->edit_field( $key, $data ); } - break; case 'delete': @@ -752,6 +751,7 @@ if ( ! class_exists( 'um\core\Account' ) ) { * ?> */ do_action( "um_after_account_{$tab_id}", $args ); +// var_dump($args); if ( ! isset( $tab_data['show_button'] ) || false !== $tab_data['show_button'] ) { ?> diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 9cab1a87..9a780c10 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -1619,6 +1619,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { // forbidden in edit mode? if (isset( $data['edit_forbidden'] )) return; + // required option if (isset( $data['required_opt'] )) { $opt = $data['required_opt']; From ad405dc038854f7f972b7e29b8128d1f09f7ff84 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Wed, 9 May 2018 18:02:10 +0300 Subject: [PATCH 06/35] - fixed required radio button is it has conditional logic; --- includes/core/um-filters-fields.php | 72 +++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/includes/core/um-filters-fields.php b/includes/core/um-filters-fields.php index e68498ce..7f55479e 100644 --- a/includes/core/um-filters-fields.php +++ b/includes/core/um-filters-fields.php @@ -367,18 +367,70 @@ add_filter( 'um_get_form_fields', 'um_get_form_fields', 99 ); */ function um_get_custom_field_array( $array, $fields ) { - if ( isset( $array['conditions'] ) ) { - for ( $a = 0; $a < count( $array['conditions'] ); $a++ ) { - if ( isset( $array['conditional_value'] ) || isset( $array['conditional_value' . $a] ) ) { - foreach ( $array['conditions'] as $key => $value ) { - $condition_metakey = $fields[ $value[1] ]['metakey']; + if ( ! empty( $array['conditions'] ) ) { + foreach ( $array['conditions'] as $key => $value ) { + $condition_metakey = $fields[ $value[1] ]['metakey']; + if ( isset( $_POST[ $condition_metakey ] ) ) { + $cond_value = ( $fields[ $value[1] ]['type'] == 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ]; + list( $visibility, $parent_key, $op, $parent_value ) = $value; - if ( isset( $_POST[ $condition_metakey ] ) ) { - $cond_value = ( $fields[ $value[1] ]['type'] == 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ]; - - if ( isset( $array['conditional_value'] ) && $cond_value !== $array['conditional_value'] ) { + if ( $visibility == 'hide' ) { + if ( $op == 'empty' ) { + if ( empty( $cond_value ) ) { $array['required'] = 0; - } elseif ( isset( $array['conditional_value'.$a] ) && $cond_value !== $array['conditional_value'.$a] ) { + } + } elseif ( $op == 'not empty' ) { + if ( ! empty( $cond_value ) ) { + $array['required'] = 0; + } + } elseif ( $op == 'equals to' ) { + if ( $cond_value == $parent_value ) { + $array['required'] = 0; + } + } elseif ( $op == 'not equals' ) { + if ( $cond_value != $parent_value ) { + $array['required'] = 0; + } + } elseif ( $op == 'greater than' ) { + if ( $cond_value > $op ) { + $array['required'] = 0; + } + } elseif ( $op == 'less than' ) { + if ( $cond_value < $op ) { + $array['required'] = 0; + } + } elseif ( $op == 'contains' ) { + if ( strstr( $cond_value, $parent_value ) ) { + $array['required'] = 0; + } + } + } elseif ( $visibility == 'show' ) { + if ( $op == 'empty' ) { + if ( ! empty( $cond_value ) ) { + $array['required'] = 0; + } + } elseif ( $op == 'not empty' ) { + if ( empty( $cond_value ) ) { + $array['required'] = 0; + } + } elseif ( $op == 'equals to' ) { + if ( $cond_value != $parent_value ) { + $array['required'] = 0; + } + } elseif ( $op == 'not equals' ) { + if ( $cond_value == $parent_value ) { + $array['required'] = 0; + } + } elseif ( $op == 'greater than' ) { + if ( $cond_value <= $op ) { + $array['required'] = 0; + } + } elseif ( $op == 'less than' ) { + if ( $cond_value >= $op ) { + $array['required'] = 0; + } + } elseif ( $op == 'contains' ) { + if ( ! strstr( $cond_value, $parent_value ) ) { $array['required'] = 0; } } From fc9b4865041efa56d7b15c330c1582d78f794963 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Thu, 10 May 2018 10:09:14 +0300 Subject: [PATCH 07/35] - removed Tracking notice; --- includes/admin/core/class-admin-notices.php | 2 +- includes/class-init.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/admin/core/class-admin-notices.php b/includes/admin/core/class-admin-notices.php index ac84e031..a26b409d 100644 --- a/includes/admin/core/class-admin-notices.php +++ b/includes/admin/core/class-admin-notices.php @@ -38,7 +38,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { $this->localize_note(); $this->show_update_messages(); $this->check_wrong_install_folder(); - $this->admin_notice_tracking(); + //$this->admin_notice_tracking(); $this->need_upgrade(); $this->check_wrong_licenses(); diff --git a/includes/class-init.php b/includes/class-init.php index bcd10906..10112ed0 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -522,7 +522,7 @@ if ( ! class_exists( 'UM' ) ) { $this->permalinks(); $this->modal(); $this->cron(); - $this->tracking(); + //$this->tracking(); $this->mobile(); $this->external_integrations(); } From 99a9ebde1f08b4dd33f49ce65cfddb6f386aae9a Mon Sep 17 00:00:00 2001 From: yura_nalivaiko Date: Fri, 11 May 2018 10:53:29 +0300 Subject: [PATCH 08/35] -fixes --- includes/core/um-actions-register.php | 4 ++-- includes/core/um-navmenu.php | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/core/um-actions-register.php b/includes/core/um-actions-register.php index 4dfab462..b086bb03 100644 --- a/includes/core/um-actions-register.php +++ b/includes/core/um-actions-register.php @@ -118,7 +118,7 @@ function um_send_registration_notification( $user_id, $args ) { $emails = um_multi_admin_email(); if ( ! empty( $emails ) ) { foreach ( $emails as $email ) { - if ( um_user( 'status' ) != 'pending' ) { + if ( um_user( 'account_status' ) != 'pending' ) { UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) ); } else { UM()->mail()->send( $email, 'notification_review', array( 'admin' => true ) ); @@ -136,7 +136,7 @@ add_action( 'um_registration_complete', 'um_send_registration_notification', 10, * @param $args */ function um_check_user_status( $user_id, $args ) { - $status = um_user( 'status' ); + $status = um_user( 'account_status' ); /** * UM hook diff --git a/includes/core/um-navmenu.php b/includes/core/um-navmenu.php index e46b3a4b..214e3258 100644 --- a/includes/core/um-navmenu.php +++ b/includes/core/um-navmenu.php @@ -47,7 +47,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) { if ( empty( $_POST['menu-item-db-id'] ) || ! in_array( $menu_item_db_id, $_POST['menu-item-db-id'] ) ) { return; } - + //var_dump($_POST['menu-item-um_nav_roles']); exit; foreach ( self::$fields as $_key => $label ) { $key = sprintf( 'menu-item-%s', $_key ); @@ -55,7 +55,8 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) { // Sanitize if ( ! empty( $_POST[ $key ][ $menu_item_db_id ] ) ) { // Do some checks here... - $value = $_POST[ $key ][ $menu_item_db_id ]; + $value = is_array( $_POST[ $key ][ $menu_item_db_id ] ) ? + array_keys( $_POST[ $key ][ $menu_item_db_id ] ) : $_POST[ $key ][ $menu_item_db_id ]; } else { $value = null; } @@ -165,7 +166,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) { $id_attr = ' id="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" '; $for_attr = ' for="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" '; $html .= ""; } From d17e15efb57fe7df8b112abb600187bbe72d8306 Mon Sep 17 00:00:00 2001 From: yura_nalivaiko Date: Fri, 11 May 2018 15:08:06 +0300 Subject: [PATCH 09/35] - added status save on user registration; --- includes/core/um-actions-register.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/core/um-actions-register.php b/includes/core/um-actions-register.php index 4dfab462..2e4404d0 100644 --- a/includes/core/um-actions-register.php +++ b/includes/core/um-actions-register.php @@ -54,8 +54,9 @@ function um_after_insert_user( $user_id, $args ) { //clear Users cached queue UM()->user()->remove_cached_queue(); + um_fetch_user( $user_id ); + UM()->user()->set_status( um_user('status') ); if ( ! empty( $args['submitted'] ) ) { - um_fetch_user( $user_id ); UM()->user()->set_registration_details( $args['submitted'] ); } @@ -103,7 +104,7 @@ function um_after_insert_user( $user_id, $args ) { */ do_action( 'um_registration_complete', $user_id, $args ); } -add_action( 'um_user_register', 'um_after_insert_user', 10, 2 ); +add_action( 'um_user_register', 'um_after_insert_user', 1, 2 ); /** From 9f6abd68fd639d5ba6a0acf2f3b5bce7d619e8a1 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Mon, 14 May 2018 11:09:27 +0300 Subject: [PATCH 10/35] - removed password from "Info" modal - add T&C date to modal "Info"; --- includes/core/class-user.php | 14 ++++++++ includes/um-short-functions.php | 60 ++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 23 deletions(-) diff --git a/includes/core/class-user.php b/includes/core/class-user.php index c58f0410..6a0a9aca 100644 --- a/includes/core/class-user.php +++ b/includes/core/class-user.php @@ -890,6 +890,20 @@ if ( ! class_exists( 'um\core\User' ) ) { unset( $submitted['confirm_user_password'] ); } + //remove all password field values from submitted details + $password_fields = array(); + foreach ( $submitted as $k => $v ) { + if ( UM()->fields()->get_field_type( $k ) == 'password' ) { + $password_fields[] = $k; + $password_fields[] = 'confirm_' . $k; + } + } + + foreach ( $password_fields as $pw_field ) { + unset( $submitted[ $pw_field ] ); + } + + /** * UM hook * diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index d15afc67..b0758afa 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -508,10 +508,11 @@ function um_user_submitted_registration( $style = false ) { $data = um_user( 'submitted' ); - if ($style) + if ( $style ) { $output .= '
'; + } - if (isset( $data ) && is_array( $data )) { + if ( isset( $data ) && is_array( $data ) ) { /** * UM hook @@ -535,38 +536,51 @@ function um_user_submitted_registration( $style = false ) { */ $data = apply_filters( 'um_email_registration_data', $data ); - foreach ($data as $k => $v) { + $pw_fields = array(); + foreach ( $data as $k => $v ) { - if (!is_array( $v ) && strstr( $v, 'ultimatemember/temp' )) { + if ( strstr( $k, 'user_pass' ) || in_array( $k, array( 'g-recaptcha-response', 'request', '_wpnonce', '_wp_http_referer' ) ) ) { + continue; + } + + if ( UM()->fields()->get_field_type( $k ) == 'password' ) { + $pw_fields[] = $k; + $pw_fields[] = 'confirm_' . $k; + continue; + } + + if ( ! empty( $pw_fields ) && in_array( $k, $pw_fields ) ) { + continue; + } + + if ( ! is_array( $v ) && strstr( $v, 'ultimatemember/temp' ) ) { $file = basename( $v ); $v = um_user_uploads_uri() . $file; } - if (!strstr( $k, 'user_pass' ) && !in_array( $k, array( 'g-recaptcha-response', 'request', '_wpnonce', '_wp_http_referer' ) )) { - - if (is_array( $v )) { - $v = implode( ',', $v ); - } - - if ($k == 'timestamp') { - $k = __( 'date submitted', 'ultimate-member' ); - $v = date( "d M Y H:i", $v ); - } - - if ($style) { - if (!$v) $v = __( '(empty)', 'ultimate-member' ); - $output .= "

$v

"; - } else { - $output .= "$k: $v" . "
"; - } - + if ( is_array( $v ) ) { + $v = implode( ',', $v ); } + if ( $k == 'timestamp' ) { + $k = __( 'date submitted', 'ultimate-member' ); + $v = date( "d M Y H:i", $v ); + } + + if ( $style ) { + if ( ! $v ) { + $v = __( '(empty)', 'ultimate-member' ); + } + $output .= "

$v

"; + } else { + $output .= "$k: $v" . "
"; + } } } - if ($style) + if ( $style ) { $output .= '
'; + } return $output; } From c1f12b6ee0456f9e7b54bb0dd851accadd1739e9 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Mon, 14 May 2018 17:55:47 +0300 Subject: [PATCH 11/35] - GDPR compatibility on delete user; --- includes/core/class-user.php | 123 +++++++++++++++++------------- includes/core/um-actions-core.php | 4 +- 2 files changed, 75 insertions(+), 52 deletions(-) diff --git a/includes/core/class-user.php b/includes/core/class-user.php index 6a0a9aca..a449366c 100644 --- a/includes/core/class-user.php +++ b/includes/core/class-user.php @@ -39,6 +39,7 @@ if ( ! class_exists( 'um\core\User' ) ) { add_action( 'init', array( &$this, 'set' ), 1 ); $this->preview = false; + $this->send_mail_on_delete = true; // a list of keys that should never be in wp_usermeta $this->update_user_keys = array( @@ -54,6 +55,8 @@ if ( ! class_exists( 'um\core\User' ) ) { // When the cache should be cleared add_action('um_delete_user_hook', array(&$this, 'remove_cached_queue') ); + add_action('um_delete_user', array( &$this, 'remove_cache' ), 10, 1 ); + add_action('um_after_user_status_is_changed_hook', array(&$this, 'remove_cached_queue') ); // When user cache should be cleared @@ -83,6 +86,73 @@ if ( ! class_exists( 'um\core\User' ) ) { add_action( 'wpmu_activate_user', array( &$this, 'add_um_role_wpmu_new_user' ), 10, 1 ); add_action( 'init', array( &$this, 'check_membership' ), 10 ); + + add_action( 'delete_user', array( &$this, 'delete_user_handler' ), 10, 1 ); + add_action( 'wpmu_delete_user', array( &$this, 'delete_user_handler' ), 10, 1 ); + } + + + /** + * @param $user_id + */ + function delete_user_handler( $user_id ) { + + um_fetch_user( $user_id ); + + /** + * UM hook + * + * @type action + * @title um_delete_user_hook + * @description On delete user + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_delete_user_hook', 'function_name', 10 ); + * @example + * + */ + do_action( 'um_delete_user_hook' ); + + /** + * UM hook + * + * @type action + * @title um_delete_user + * @description On delete user + * @input_vars + * [{"var":"$user_id","type":"int","desc":"User ID"}] + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_delete_user', 'function_name', 10, 1 ); + * @example + * + */ + do_action( 'um_delete_user', um_user( 'ID' ) ); + + // send email notifications + if ( $this->send_mail_on_delete ) { + UM()->mail()->send( um_user( 'user_email' ), 'deletion_email' ); + + $emails = um_multi_admin_email(); + if ( ! empty( $emails ) ) { + foreach ( $emails as $email ) { + UM()->mail()->send( $email, 'notification_deletion', array( 'admin' => true ) ); + } + } + } + + // remove uploads + UM()->files()->remove_dir( um_user_uploads_dir() ); } @@ -1288,59 +1358,10 @@ if ( ! class_exists( 'um\core\User' ) ) { * @param bool $send_mail */ function delete( $send_mail = true ) { - /** - * UM hook - * - * @type action - * @title um_delete_user_hook - * @description On delete user - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_delete_user_hook', 'function_name', 10 ); - * @example - * - */ - do_action( 'um_delete_user_hook' ); - /** - * UM hook - * - * @type action - * @title um_delete_user - * @description On delete user - * @input_vars - * [{"var":"$user_id","type":"int","desc":"User ID"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_delete_user', 'function_name', 10, 1 ); - * @example - * - */ - do_action( 'um_delete_user', um_user( 'ID' ) ); - // send email notifications - if ( $send_mail ) { - UM()->mail()->send( um_user( 'user_email' ), 'deletion_email' ); + $this->send_mail_on_delete = $send_mail; - $emails = um_multi_admin_email(); - if ( ! empty( $emails ) ) { - foreach ( $emails as $email ) { - UM()->mail()->send( $email, 'notification_deletion', array( 'admin' => true ) ); - } - } - } - - // remove uploads - UM()->files()->remove_dir( um_user_uploads_dir() ); + $this->delete_user_handler( um_user( 'ID' ) ); // remove user if ( is_multisite() ) { diff --git a/includes/core/um-actions-core.php b/includes/core/um-actions-core.php index 2c85e9cb..fdfabc43 100644 --- a/includes/core/um-actions-core.php +++ b/includes/core/um-actions-core.php @@ -108,7 +108,9 @@ function um_action_request_process() { break; case 'um_delete': - if ( ! UM()->roles()->um_current_user_can( 'delete', $uid ) ) wp_die( __('You do not have permission to delete this user.','ultimate-member') ); + if ( ! UM()->roles()->um_current_user_can( 'delete', $uid ) ) { + wp_die( __('You do not have permission to delete this user.','ultimate-member') ); + } um_fetch_user( $uid ); UM()->user()->delete(); exit( wp_redirect( UM()->permalinks()->get_current_url( true ) ) ); From e1bf14e9e0835a51595d7666d35247ea2eaceeec Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 15 May 2018 15:41:28 +0300 Subject: [PATCH 12/35] - deprecated time checking spam bot; --- includes/admin/core/class-admin-settings.php | 1 - includes/core/class-form.php | 13 ------------- includes/core/um-actions-password.php | 19 ------------------- 3 files changed, 33 deletions(-) diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index ba23548a..bea6bdc2 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -2181,7 +2181,6 @@ Cache User Profile: options()->get( 'um_profile_object_cache_s Generate Slugs on Directories: options()->get( 'um_generate_slug_in_directory' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?> Rewrite Rules: options()->get( 'um_flush_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?> Force UTF-8 Encoding: options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?> -Time Check Security: options()->get( 'enable_timebot' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?> JS/CSS Compression: Network Structure: options()->get( 'network_permalink_structure' ). "\n"; ?> diff --git a/includes/core/class-form.php b/includes/core/class-form.php index a5fc3c6e..9b5ff609 100644 --- a/includes/core/class-form.php +++ b/includes/core/class-form.php @@ -331,19 +331,6 @@ if ( ! class_exists( 'um\core\Form' ) ) { wp_die( 'Hello, spam bot!', 'ultimate-member' ); } - if ( ! in_array( $this->form_data['mode'], array( 'login' ) ) ) { - - $form_timestamp = trim($_POST['timestamp']); - $live_timestamp = current_time( 'timestamp' ); - - if ( $form_timestamp == '' && UM()->options()->get( 'enable_timebot' ) == 1 ) - wp_die( __('Hello, spam bot!','ultimate-member') ); - - if ( !current_user_can('manage_options') && $live_timestamp - $form_timestamp < 6 && UM()->options()->get( 'enable_timebot' ) == 1 ) - wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!','ultimate-member') ); - - } - /** * UM hook * diff --git a/includes/core/um-actions-password.php b/includes/core/um-actions-password.php index 876ca53c..041153e8 100644 --- a/includes/core/um-actions-password.php +++ b/includes/core/um-actions-password.php @@ -133,15 +133,6 @@ function um_reset_password_errors_hook( $args ) { if ( $_POST[ UM()->honeypot ] != '' ) wp_die('Hello, spam bot!','ultimate-member'); - $form_timestamp = trim($_POST['timestamp']); - $live_timestamp = current_time( 'timestamp' ); - - if ( $form_timestamp == '' && UM()->options()->get( 'enable_timebot' ) == 1 ) - wp_die( __('Hello, spam bot!','ultimate-member') ); - - if ( $live_timestamp - $form_timestamp < 3 && UM()->options()->get( 'enable_timebot' ) == 1 ) - wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!','ultimate-member') ); - $user = ""; foreach ( $_POST as $key => $val ) { @@ -197,16 +188,6 @@ function um_change_password_errors_hook( $args ) { wp_die('Hello, spam bot!','ultimate-member'); } - $form_timestamp = trim($_POST['timestamp']); - $live_timestamp = current_time( 'timestamp' ); - - if ( $form_timestamp == '' && UM()->options()->get( 'enable_timebot' ) == 1 ) - wp_die( __('Hello, spam bot!','ultimate-member') ); - - if ( $live_timestamp - $form_timestamp < 3 && UM()->options()->get( 'enable_timebot' ) == 1 ) { - wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!','ultimate-member') ); - } - $reset_pass_hash = ''; if( isset( $_REQUEST['act'] ) && $_REQUEST['act'] == 'reset_password' && um_is_core_page('password-reset') ){ From 9e25dc6302642a4c403215024933783e2f44803a Mon Sep 17 00:00:00 2001 From: dbaranov Date: Wed, 16 May 2018 16:02:34 +0300 Subject: [PATCH 13/35] Disable comments if user has not permission to access this post --- includes/core/class-access.php | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index 7f1c1fc5..a6008639 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -65,6 +65,10 @@ if ( ! class_exists( 'um\core\Access' ) ) { add_action( 'template_redirect', array( &$this, 'template_redirect' ), 1000 ); add_action( 'um_access_check_individual_term_settings', array( &$this, 'um_access_check_individual_term_settings' ) ); add_action( 'um_access_check_global_settings', array( &$this, 'um_access_check_global_settings' ) ); + + /* Disable comments if user has not permission to access current post */ + add_filter( 'comments_open', array( $this, 'disable_comments_open' ), 99, 2 ); + add_filter( 'get_comments_number', array( $this, 'disable_comments_open' ), 99, 2 ); } @@ -932,6 +936,41 @@ if ( ! class_exists( 'um\core\Access' ) ) { $content = $this->current_single_post->post_content; return $content; } + + /** + * Disable comments if user has not permission to access this post + * @param mixed $open + * @param int $post_id + * @return boolean + */ + public function disable_comments_open( $open, $post_id ) { + + static $cache = array(); + + if( isset($cache[$post_id]) ){ + return $cache[$post_id] ? $open : false; + } + + $restriction = get_post_meta( $post_id, 'um_content_restriction', true ); + + if ( $restriction ) { + if ( is_user_logged_in() ) { + if ( '1' == $restriction['_um_accessible'] && ! current_user_can( 'administrator' ) ) { + $open = false; + }else + if ( ! empty($restriction['_um_access_roles']) && ! $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] ) ) { + $open = false; + } + + } elseif ( '2' == $restriction['_um_accessible'] ) { + $open = false; + } + } + + $cache[$post_id] = $open; + + return $open; + } /** From 78a88675942601e102b0c6c9e0115c50bbbfe579 Mon Sep 17 00:00:00 2001 From: dbaranov Date: Thu, 17 May 2018 17:25:09 +0300 Subject: [PATCH 14/35] fix getting role default value --- includes/core/class-fields.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 9a82bd01..0de08f93 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -822,8 +822,13 @@ if ( ! class_exists( 'um\core\Fields' ) ) { if (in_array( $field_value, $role_keys )) { $field_value = 'um_' . $field_value; } - } - + } + elseif( $this->set_mode == 'register' ){ + $data['default'] = UM()->options()->get( 'register_role' ); + } + else{ + $data['default'] = get_option( 'default_role' ); + } } /** @@ -946,6 +951,12 @@ if ( ! class_exists( 'um\core\Fields' ) ) { $um_user_value = 'um_' . $um_user_value; } } + elseif( $this->set_mode == 'register' ){ + $data['default'] = UM()->options()->get( 'register_role' ); + } + else{ + $data['default'] = get_option( 'default_role' ); + } } if ($um_user_value == $value) { From d42a048bd36322f4b5028e92a29159e396419bb7 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Thu, 17 May 2018 17:38:42 +0300 Subject: [PATCH 15/35] - code review, added the code for the using UM own function; --- includes/core/class-access.php | 98 +++++++++++++++++++++------------- 1 file changed, 60 insertions(+), 38 deletions(-) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index a6008639..50938c9e 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -65,10 +65,10 @@ if ( ! class_exists( 'um\core\Access' ) ) { add_action( 'template_redirect', array( &$this, 'template_redirect' ), 1000 ); add_action( 'um_access_check_individual_term_settings', array( &$this, 'um_access_check_individual_term_settings' ) ); add_action( 'um_access_check_global_settings', array( &$this, 'um_access_check_global_settings' ) ); - - /* Disable comments if user has not permission to access current post */ - add_filter( 'comments_open', array( $this, 'disable_comments_open' ), 99, 2 ); - add_filter( 'get_comments_number', array( $this, 'disable_comments_open' ), 99, 2 ); + + /* Disable comments if user has not permission to access current post */ + add_filter( 'comments_open', array( $this, 'disable_comments_open' ), 99, 2 ); + add_filter( 'get_comments_number', array( $this, 'disable_comments_open' ), 99, 2 ); } @@ -936,41 +936,63 @@ if ( ! class_exists( 'um\core\Access' ) ) { $content = $this->current_single_post->post_content; return $content; } - - /** - * Disable comments if user has not permission to access this post - * @param mixed $open - * @param int $post_id - * @return boolean - */ - public function disable_comments_open( $open, $post_id ) { - - static $cache = array(); - - if( isset($cache[$post_id]) ){ - return $cache[$post_id] ? $open : false; - } - - $restriction = get_post_meta( $post_id, 'um_content_restriction', true ); - if ( $restriction ) { - if ( is_user_logged_in() ) { - if ( '1' == $restriction['_um_accessible'] && ! current_user_can( 'administrator' ) ) { - $open = false; - }else - if ( ! empty($restriction['_um_access_roles']) && ! $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] ) ) { - $open = false; - } - - } elseif ( '2' == $restriction['_um_accessible'] ) { - $open = false; - } - } - - $cache[$post_id] = $open; - - return $open; - } + + /** + * Disable comments if user has not permission to access this post + * @param mixed $open + * @param int $post_id + * @return boolean + */ + public function disable_comments_open( $open, $post_id ) { + + static $cache = array(); + + if ( isset( $cache[ $post_id ] ) ) { + return $cache[ $post_id ] ? $open : false; + } + + $post = get_post( $post_id ); + $restriction = $this->get_post_privacy_settings( $post ); + + if ( ! $restriction ) { + $cache[ $post_id ] = $open; + return $open; + } + + if ( '1' == $restriction['_um_accessible'] ) { + + if ( is_user_logged_in() ) { + if ( ! current_user_can( 'administrator' ) ) { + $open = false; + } + } + + } elseif ( '2' == $restriction['_um_accessible'] ) { + if ( ! is_user_logged_in() ) { + $open = false; + } else { + if ( ! current_user_can( 'administrator' ) ) { + $custom_restrict = $this->um_custom_restriction( $restriction ); + + if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) { + if ( ! $custom_restrict ) { + $open = false; + } + } else { + $user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] ); + + if ( ! isset( $user_can ) || ! $user_can || ! $custom_restrict ) { + $open = false; + } + } + } + } + } + + $cache[ $post_id ] = $open; + return $open; + } /** From bedc2d8fda0a4e4ebbe69456e57e3558c91efdd8 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Thu, 17 May 2018 17:46:38 +0300 Subject: [PATCH 16/35] - temporary commented code with role's fields; --- includes/core/class-fields.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 0de08f93..6ca16cce 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -814,21 +814,21 @@ if ( ! class_exists( 'um\core\Fields' ) ) { $field_value = um_user( $key ); - if ($key == 'role') { + if ( $key == 'role' ) { $role_keys = get_option( 'um_roles' ); - if (!empty( $role_keys )) { - if (in_array( $field_value, $role_keys )) { + if ( ! empty( $role_keys ) ) { + if ( in_array( $field_value, $role_keys ) ) { $field_value = 'um_' . $field_value; } - } - elseif( $this->set_mode == 'register' ){ + } + /*elseif( $this->set_mode == 'register' ){ $data['default'] = UM()->options()->get( 'register_role' ); } else{ $data['default'] = get_option( 'default_role' ); - } + }*/ } /** @@ -941,25 +941,25 @@ if ( ! class_exists( 'um\core\Fields' ) ) { $um_user_value = um_user( $key ); - if ($key == 'role') { + if ( $key == 'role' ) { $um_user_value = strtolower( $um_user_value ); $role_keys = get_option( 'um_roles' ); - if (!empty( $role_keys )) { - if (in_array( $um_user_value, $role_keys )) { + if ( ! empty( $role_keys ) ) { + if ( in_array( $um_user_value, $role_keys ) ) { $um_user_value = 'um_' . $um_user_value; } } - elseif( $this->set_mode == 'register' ){ - $data['default'] = UM()->options()->get( 'register_role' ); - } - else{ - $data['default'] = get_option( 'default_role' ); - } + /*elseif( $this->set_mode == 'register' ){ + $data['default'] = UM()->options()->get( 'register_role' ); + } + else{ + $data['default'] = get_option( 'default_role' ); + }*/ } - if ($um_user_value == $value) { + if ( $um_user_value == $value ) { return true; } From d6d3a0af07444ec2b10f1b9996cb13d745ef5697 Mon Sep 17 00:00:00 2001 From: yura_nalivaiko Date: Fri, 18 May 2018 10:20:21 +0300 Subject: [PATCH 17/35] - fixed problem with tabs; --- includes/core/class-profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/core/class-profile.php b/includes/core/class-profile.php index 0de83c6c..c650cbea 100644 --- a/includes/core/class-profile.php +++ b/includes/core/class-profile.php @@ -115,7 +115,7 @@ if ( ! class_exists( 'um\core\Profile' ) ) { 'icon' => 'um-faicon-comment' ) ) ); - + um_fetch_user(get_current_user_id()); // disable private tabs if ( ! is_admin() ) { foreach ( $tabs as $id => $tab ) { From 8414586f4561e38719aaef454abf73297acf48f1 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 22 May 2018 11:17:18 +0300 Subject: [PATCH 18/35] - fixed Install Info settings section on PHP7.1; - GDPR compatibility; - added support for GDPR Personal Data Exporter; - added support for GDPR Personal Data Eraser; - added feature: New privacy field to form builder for GDPR consent collection; - added GDPR privacy policy guide text; --- assets/js/um-gdpr.js | 22 ++ includes/admin/core/class-admin-gdpr.php | 316 ++++++++++++++++++ includes/admin/core/class-admin-settings.php | 7 +- .../admin/templates/form/register_gdpr.php | 71 ++++ includes/admin/templates/gdpr.php | 40 +++ includes/class-init.php | 45 +++ includes/core/class-builtin.php | 2 +- includes/core/class-enqueue.php | 2 + includes/core/class-gdpr.php | 86 +++++ templates/gdpr-register.php | 44 +++ ultimate-member.php | 2 +- 11 files changed, 633 insertions(+), 4 deletions(-) create mode 100644 assets/js/um-gdpr.js create mode 100644 includes/admin/core/class-admin-gdpr.php create mode 100644 includes/admin/templates/form/register_gdpr.php create mode 100644 includes/admin/templates/gdpr.php create mode 100644 includes/core/class-gdpr.php create mode 100644 templates/gdpr-register.php diff --git a/assets/js/um-gdpr.js b/assets/js/um-gdpr.js new file mode 100644 index 00000000..31c0fde9 --- /dev/null +++ b/assets/js/um-gdpr.js @@ -0,0 +1,22 @@ +(function( $ ) { + 'use strict'; + + $(document).on('click', "a.um-toggle-gdpr" ,function() { + + var me = jQuery(this); + + $( ".um-gdpr-content" ).toggle( "fast", function() { + if( $( ".um-gdpr-content" ).is(':visible') ){ + me.text( me.data('toggle-hide') ); + } + + if( $( ".um-gdpr-content" ).is(':hidden') ){ + me.text( me.data('toggle-show') ); + } + + }); + + }); + + +})( jQuery ); diff --git a/includes/admin/core/class-admin-gdpr.php b/includes/admin/core/class-admin-gdpr.php new file mode 100644 index 00000000..5a69dd2b --- /dev/null +++ b/includes/admin/core/class-admin-gdpr.php @@ -0,0 +1,316 @@ +metabox(), 'load_metabox_form' ), + 'um_form', + 'side', + 'default' + ); + } + + + /** + * + */ + function init_fields() { + $this->meta_associations = array( + + 'account_status' => __( 'Account Status', 'ultimate-member' ), + 'submitted' => __( 'Submitted data on Registration', 'ultimate-member' ), + 'form_id' => __( 'Registration Form ID', 'ultimate-member' ), + 'timestamp' => __( 'Registration Timestamp', 'ultimate-member' ), + 'request' => __( 'Registration Request', 'ultimate-member' ), + '_wpnonce' => __( 'Registration Nonce', 'ultimate-member' ), + '_wp_http_referer' => __( 'Registration HTTP referer', 'ultimate-member' ), + 'role' => __( 'Community Role', 'ultimate-member' ), + 'um_user_profile_url_slug_user_login' => __( 'Profile Slug "Username"', 'ultimate-member' ), + 'um_user_profile_url_slug_name' => __( 'Profile Slug "First and Last Name with \'.\'"', 'ultimate-member' ), + 'um_user_profile_url_slug_name_dash' => __( 'Profile Slug "First and Last Name with \'-\'"', 'ultimate-member' ), + 'um_user_profile_url_slug_name_plus' => __( 'Profile Slug "First and Last Name with \'+\'"', 'ultimate-member' ), + 'um_user_profile_url_slug_user_id' => __( 'Profile Slug "User ID"', 'ultimate-member' ), + '_um_last_login' => __( 'Last Login Timestamp', 'ultimate-member' ), + + //Private content extension + '_um_private_content_post_id' => __( 'Private Content Post ID', 'ultimate-member' ), + + //Verified Users extension + '_um_verified' => __( 'Verified Account', 'ultimate-member' ), + + //Terms & Conditions extension + 'use_terms_conditions_agreement' => __( 'Terms&Conditions Agreement', 'ultimate-member' ), + + //GDPR extension + 'use_gdpr_agreement' => __( 'Privacy Policy Agreement', 'ultimate-member' ), + + + ); + + $all_fields = UM()->builtin()->all_user_fields( null, true ); + unset( $all_fields[0] ); + + $all_fields = array_map( function( $value ) { + return $value['title']; + }, $all_fields ); + + $this->meta_associations = array_merge( $this->meta_associations, $all_fields ); + + /** + * UM hook + * + * @type filter + * @title um_gdpr_meta_associations + * @description Exclude taxonomies for UM + * @input_vars + * [{"var":"$meta_associations","type":"array","desc":"Meta Keys Titles"}] + * @change_log + * ["Since: 2.0.14"] + * @usage + * + * @example + * + */ + $this->meta_associations = apply_filters( 'um_gdpr_meta_associations', $this->meta_associations ); + } + + + /** + * Return the default suggested privacy policy content. + * + * @return string The default policy content. + */ + function plugin_get_default_privacy_content() { + ob_start(); + + include UM()->admin()->templates_path . 'gdpr.php'; + + return ob_get_clean(); + } + + + /** + * Add the suggested privacy policy text to the policy postbox. + */ + function plugin_add_suggested_privacy_content() { + $content = $this->plugin_get_default_privacy_content(); + wp_add_privacy_policy_content( ultimatemember_plugin_name, $content ); + } + + + /** + * Register exporter for Plugin user data. + * + * @see https://github.com/allendav/wp-privacy-requests/blob/master/EXPORT.md + * + * @param $exporters + * + * @return array + */ + function plugin_register_exporters( $exporters ) { + $exporters[] = array( + 'exporter_friendly_name' => ultimatemember_plugin_name, + 'callback' => array( &$this, 'data_exporter' ) + ); + return $exporters; + } + + + /** + * Get user metadata in key => value array + * + * + * @param $user_id + * + * @return array + */ + function get_metadata( $user_id ) { + global $wpdb; + + $metadata = $wpdb->get_results( $wpdb->prepare( + "SELECT meta_key, meta_value + FROM {$wpdb->usermeta} + WHERE user_id = %d", + $user_id + ), ARRAY_A ); + + $filtered = array(); + foreach ( $metadata as $data ) { + if ( in_array( $data['meta_key'], array_keys( $this->meta_associations ) ) ) { + $filtered[] = array( + 'key' => $data['meta_key'], + 'name' => $this->meta_associations[ $data['meta_key'] ], + //'value' => maybe_unserialize( $data['meta_value'] ), + 'value' => $data['meta_value'], + ); + } + } + + return $filtered; + } + + + /** + * Exporter for Plugin user data. + * + * @see https://github.com/allendav/wp-privacy-requests/blob/master/EXPORT.md + * + * @param $email_address + * @param int $page + * + * @return array + */ + function data_exporter( $email_address, $page = 1 ) { + $export_items = array(); + $user = get_user_by( 'email', $email_address ); + + if ( $user && $user->ID ) { + // Most item IDs should look like postType-postID + // If you don't have a post, comment or other ID to work with, + // use a unique value to avoid having this item's export + // combined in the final report with other items of the same id + $item_id = "ultimate-member-{$user->ID}"; + + // Core group IDs include 'comments', 'posts', etc. + // But you can add your own group IDs as needed + $group_id = 'ultimate-member'; + + // Optional group label. Core provides these for core groups. + // If you define your own group, the first exporter to + // include a label will be used as the group label in the + // final exported report + $group_label = ultimatemember_plugin_name; + + // Plugins can add as many items in the item data array as they want + //$data = array(); + + $data = $this->get_metadata( $user->ID ); + + if ( ! empty( $data ) ) { + // Add this group of items to the exporters data array. + $export_items[] = array( + 'group_id' => $group_id, + 'group_label' => $group_label, + 'item_id' => $item_id, + 'data' => $data, + ); + } + } + // Returns an array of exported items for this pass, but also a boolean whether this exporter is finished. + //If not it will be called again with $page increased by 1. + return array( + 'data' => $export_items, + 'done' => true, + ); + } + + + /** + * Register eraser for Plugin user data. + * + * @param array $erasers + * + * @return array + */ + function plugin_register_erasers( $erasers = array() ) { + $erasers[] = array( + 'eraser_friendly_name' => ultimatemember_plugin_name, + 'callback' => array( &$this, 'data_eraser' ) + ); + return $erasers; + } + + + /** + * Eraser for Plugin user data. + * + * @param $email_address + * @param int $page + * + * @return array + */ + function data_eraser( $email_address, $page = 1 ) { + if ( empty( $email_address ) ) { + return array( + 'items_removed' => false, + 'items_retained' => false, + 'messages' => array(), + 'done' => true, + ); + } + + $user = get_user_by( 'email', $email_address ); + $messages = array(); + $items_removed = false; + $items_retained = false; + + if ( $user && $user->ID ) { + $data = $this->get_metadata( $user->ID ); + + foreach ( $data as $metadata ) { + $deleted = delete_user_meta( $user->ID, $metadata['key'] ); + if ( $deleted ) { + $items_removed = true; + } else { + $messages[] = sprintf( __( 'Your %s was unable to be removed at this time.', 'ultimate-member' ), $metadata['name'] ); + $items_retained = true; + } + } + } + + // Returns an array of exported items for this pass, but also a boolean whether this exporter is finished. + //If not it will be called again with $page increased by 1. + return array( + 'items_removed' => $items_removed, + 'items_retained' => $items_retained, + 'messages' => $messages, + 'done' => true, + ); + } + + } + +} \ No newline at end of file diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index bea6bdc2..29ff98fc 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -1197,12 +1197,14 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" ); $section_fields = $this->get_section_fields( $current_tab, $current_subtab ); + $settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab ); /** * UM hook * * @type filter * @title um_settings_section_{$current_tab}_{$current_subtab}_content + * * @description Render settings section * @input_vars * [{"var":"$content","type":"string","desc":"Section content"}, @@ -1220,7 +1222,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { * ?> */ echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content', - $this->render_settings_section( $section_fields, $current_tab, $current_subtab ), + $settings_section, $section_fields ); @@ -1258,6 +1260,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" ); $section_fields = $this->get_section_fields( $current_tab, $current_subtab ); + $settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab ); /** * UM hook @@ -1281,7 +1284,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { * ?> */ echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content', - $this->render_settings_section( $section_fields, $current_tab, $current_subtab ), + $settings_section, $section_fields ); ?> diff --git a/includes/admin/templates/form/register_gdpr.php b/includes/admin/templates/form/register_gdpr.php new file mode 100644 index 00000000..0a226b11 --- /dev/null +++ b/includes/admin/templates/form/register_gdpr.php @@ -0,0 +1,71 @@ +
+ + __( 'Select page', 'ultimate-member' ) + ); + + $pages = get_pages(); + foreach ( $pages as $page ) { + $options[$page->ID] = $page->post_title; + } + + UM()->admin_forms( array( + 'class' => 'um-form-register-gdpr um-top-label', + 'prefix_id' => 'form', + 'fields' => array( + array( + 'id' => '_um_register_use_gdpr', + 'type' => 'select', + 'label' => __( 'Enable on this form', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr', null, '' ), + 'options' => array( + '0' => __( 'No', 'ultimate-member' ), + '1' => __( 'Yes', 'ultimate-member' ) + ), + ), + array( + 'id' => '_um_register_use_gdpr_content_id', + 'type' => 'select', + 'label' => __( 'Content', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_content_id', null, '' ), + 'options' => $options, + 'conditional' => array( '_um_register_use_gdpr', '=', '1' ) + ), + array( + 'id' => '_um_register_use_gdpr_toggle_show', + 'type' => 'text', + 'label' => __( 'Toggle Show text', 'ultimate-member' ), + 'placeholder' => __( 'Show privacy policy', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_toggle_show', null, __( 'Show privacy policy', 'ultimate-member' ) ), + 'conditional' => array( '_um_register_use_gdpr', '=', '1' ) + ), + array( + 'id' => '_um_register_use_gdpr_toggle_hide', + 'type' => 'text', + 'label' => __( 'Toggle Hide text', 'ultimate-member' ), + 'placeholder' => __( 'Hide privacy policy', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_toggle_hide', null, __( 'Hide privacy policy', 'ultimate-member' ) ), + 'conditional' => array( '_um_register_use_gdpr', '=', '1' ) + ), + array( + 'id' => '_um_register_use_gdpr_agreement', + 'type' => 'text', + 'label' => __( 'Checkbox agreement description', 'ultimate-member' ), + 'placeholder' => __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_agreement', null, __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ) ), + 'conditional' => array( '_um_register_use_gdpr', '=', '1' ) + ), + array( + 'id' => '_um_register_use_gdpr_error_text', + 'type' => 'text', + 'label' => __( 'Error Text', 'ultimate-member' ), + 'placeholder' => __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_error_text', null, __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ) ), + 'conditional' => array( '_um_register_use_gdpr', '=', '1' ) + ) + ) + ) )->render_form(); ?> + +
+
\ No newline at end of file diff --git a/includes/admin/templates/gdpr.php b/includes/admin/templates/gdpr.php new file mode 100644 index 00000000..da6334ed --- /dev/null +++ b/includes/admin/templates/gdpr.php @@ -0,0 +1,40 @@ + + +

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+ +

+ +

+

+ +

+

+ +

+

+ +

+ +

+ +

+

+ +

+

+ +

\ No newline at end of file diff --git a/includes/class-init.php b/includes/class-init.php index 10112ed0..0e9f1fc3 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -485,6 +485,7 @@ if ( ! class_exists( 'UM' ) ) { $this->ajax_init(); $this->metabox(); $this->admin_upgrade()->init_packages_ajax_handlers(); + $this->admin_gdpr(); } elseif ( $this->is_request( 'admin' ) ) { $this->admin(); $this->admin_menu(); @@ -497,6 +498,7 @@ if ( ! class_exists( 'UM' ) ) { $this->users(); $this->dragdrop(); $this->plugin_updater(); + $this->admin_gdpr(); } elseif ( $this->is_request( 'frontend' ) ) { $this->enqueue(); $this->account(); @@ -525,6 +527,7 @@ if ( ! class_exists( 'UM' ) ) { //$this->tracking(); $this->mobile(); $this->external_integrations(); + $this->gdpr(); } @@ -640,6 +643,48 @@ if ( ! class_exists( 'UM' ) ) { } + /** + * GDPR privacy policy + * + * @since 2.0.14 + * + * @return bool|um\admin\core\Admin_GDPR() + */ + function admin_gdpr() { + global $wp_version; + + if ( version_compare( $wp_version, '4.9.6', '<' ) ) { + return false; + } + + if ( empty( $this->classes['admin_gdpr'] ) ) { + $this->classes['admin_gdpr'] = new um\admin\core\Admin_GDPR(); + } + return $this->classes['admin_gdpr']; + } + + + /** + * GDPR privacy policy + * + * @since 2.0.14 + * + * @return bool|um\core\GDPR() + */ + function gdpr() { + global $wp_version; + + if ( version_compare( $wp_version, '4.9.6', '<' ) ) { + return false; + } + + if ( empty( $this->classes['gdpr'] ) ) { + $this->classes['gdpr'] = new um\core\GDPR(); + } + return $this->classes['gdpr']; + } + + /** * @since 2.0 * diff --git a/includes/core/class-builtin.php b/includes/core/class-builtin.php index 2242e55b..c076c7a3 100644 --- a/includes/core/class-builtin.php +++ b/includes/core/class-builtin.php @@ -1252,7 +1252,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { */ $fields_without_metakey = apply_filters( 'um_fields_without_metakey', $fields_without_metakey ); - if ( !$show_all ) { + if ( ! $show_all ) { $this->fields_dropdown = array('image','file','password','rating'); $this->fields_dropdown = array_merge( $this->fields_dropdown, $fields_without_metakey ); } else { diff --git a/includes/core/class-enqueue.php b/includes/core/class-enqueue.php index 4365b686..b723b213 100644 --- a/includes/core/class-enqueue.php +++ b/includes/core/class-enqueue.php @@ -319,6 +319,8 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) { wp_register_script('um_functions', um_url . 'assets/js/um-functions' . $this->suffix . '.js', array('jquery', 'jquery-masonry') ); wp_enqueue_script('um_functions'); + wp_enqueue_script( 'um-gdpr', um_url . 'assets/js/um-gdpr' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, false ); + } diff --git a/includes/core/class-gdpr.php b/includes/core/class-gdpr.php new file mode 100644 index 00000000..82ec76e7 --- /dev/null +++ b/includes/core/class-gdpr.php @@ -0,0 +1,86 @@ +form()->add_error( 'use_gdpr_agreement', isset( $args['use_gdpr_error_text'] ) ? $args['use_gdpr_error_text'] : '' ); + } + } + + + /** + * @param $submitted + * + * @return mixed + */ + function add_agreement_date( $submitted ) { + if ( isset( $submitted['use_gdpr_agreement'] ) ) { + $submitted['use_gdpr_agreement'] = time(); + } + + return $submitted; + } + + + /** + * @param $submitted + * + * @return mixed + */ + function email_registration_data( $submitted ) { + + $timestamp = ! empty( $submitted['timestamp'] ) ? $submitted['timestamp'] : $submitted['use_gdpr_agreement']; + + if ( ! empty( $submitted['use_gdpr_agreement'] ) ) { + $submitted['GDPR Applied'] = date( "d M Y H:i", $timestamp ); + unset( $submitted['use_gdpr_agreement'] ); + } + + return $submitted; + } + + } + +} \ No newline at end of file diff --git a/templates/gdpr-register.php b/templates/gdpr-register.php new file mode 100644 index 00000000..714c6e84 --- /dev/null +++ b/templates/gdpr-register.php @@ -0,0 +1,44 @@ + + + +
+
+ + + + +
+
+ + +
+ + form()->errors; + + if ( isset( $errors['use_gdpr_agreement'] ) ) { + + $error_message = ! empty( $args['use_gdpr_error_text'] ) ? $args['use_gdpr_error_text'] : __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ); + + echo '

' . $error_message . '


'; + } ?> + +
+
+
\ No newline at end of file diff --git a/ultimate-member.php b/ultimate-member.php index bd87426e..e66af51a 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.0.13 +Version: 2.0.14 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member From 53b342eedd4b3a7ea40f0d59be3f690dff5cc335 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 22 May 2018 16:39:51 +0300 Subject: [PATCH 19/35] - changed readme; --- README.md | 4 ++-- readme.txt | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d4f28e78..3f9a2aed 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Ultimate Member is the #1 user profile & membership plugin for WordPress. The pl | Latest Version |Requires at least|Stable Tag| | :------------: |:------------:|:------------:| -| 2.0.12 | WordPress 4.9 or higher| 2.0.12 | +| 2.0.14 | WordPress 4.9 or higher| 2.0.14 | Features of the plugin include: @@ -48,7 +48,7 @@ GNU Version 2 or Any Later Version Releases ==================== -[Official Release Version: 2.0.12](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.12). +[Official Release Version: 2.0.14](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.14). [Official Release Version: 1.3.88](https://github.com/ultimatemember/ultimatemember/releases). diff --git a/readme.txt b/readme.txt index 847b4fee..ed23f690 100644 --- a/readme.txt +++ b/readme.txt @@ -6,7 +6,7 @@ Donate link: Tags: community, member, membership, user-profile, user-registration Requires at least: 4.1 Tested up to: 4.9 -Stable tag: 2.0.13 +Stable tag: 2.0.14 License: GNU Version 2 or Any Later Version License URI: http://www.gnu.org/licenses/gpl-3.0.txt @@ -131,6 +131,25 @@ The plugin works with popular caching plugins by automatically excluding Ultimat = Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin = += 2.0.14: May 22, 2018 = + +* Enhancements: + - Added support for GDPR Personal Data Exporter + - Added support for GDPR Personal Data Eraser + - Added new privacy field to form builder for GDPR consent collection + - Added GDPR privacy policy guide text + - Added GDPR compatibility on delete user process + - Added security to Restricted posts comments + - Added security to custom field type `Password` + - Deprecated time checking spam bot + +* Bugfixes: + - Fixed settings tabs for PHP7.1 + - Fixed issues with Profile Tabs + - Fixed User Avatars + - Fixed set user status on Registration process + - Fixed Account Privacy tab content + = 2.0.13: May 2, 2018 = * Bugfixes: From a63d1de7787b955ed67a1e2631a94194077d7b61 Mon Sep 17 00:00:00 2001 From: Champ Camba Date: Tue, 22 May 2018 23:47:48 +0800 Subject: [PATCH 20/35] Update minified script --- assets/js/um-gdpr.min.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 assets/js/um-gdpr.min.js diff --git a/assets/js/um-gdpr.min.js b/assets/js/um-gdpr.min.js new file mode 100644 index 00000000..b861cc4a --- /dev/null +++ b/assets/js/um-gdpr.min.js @@ -0,0 +1 @@ +!function(t){"use strict";t(document).on("click","a.um-toggle-gdpr",function(){var e=jQuery(this);t(".um-gdpr-content").toggle("fast",function(){t(".um-gdpr-content").is(":visible")&&e.text(e.data("toggle-hide")),t(".um-gdpr-content").is(":hidden")&&e.text(e.data("toggle-show"))})})}(jQuery); \ No newline at end of file From 1c091a2dcaf8639f4a51f29098fc4af939948ee0 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 22 May 2018 20:13:42 +0300 Subject: [PATCH 21/35] - fixed gdpr.min.js --- README.md | 4 ++-- readme.txt | 7 ++++++- ultimate-member.php | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3f9a2aed..86c2f833 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Ultimate Member is the #1 user profile & membership plugin for WordPress. The pl | Latest Version |Requires at least|Stable Tag| | :------------: |:------------:|:------------:| -| 2.0.14 | WordPress 4.9 or higher| 2.0.14 | +| 2.0.15 | WordPress 4.9 or higher| 2.0.15 | Features of the plugin include: @@ -48,7 +48,7 @@ GNU Version 2 or Any Later Version Releases ==================== -[Official Release Version: 2.0.14](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.14). +[Official Release Version: 2.0.15](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.15). [Official Release Version: 1.3.88](https://github.com/ultimatemember/ultimatemember/releases). diff --git a/readme.txt b/readme.txt index ed23f690..fa7ddfb2 100644 --- a/readme.txt +++ b/readme.txt @@ -6,7 +6,7 @@ Donate link: Tags: community, member, membership, user-profile, user-registration Requires at least: 4.1 Tested up to: 4.9 -Stable tag: 2.0.14 +Stable tag: 2.0.15 License: GNU Version 2 or Any Later Version License URI: http://www.gnu.org/licenses/gpl-3.0.txt @@ -131,6 +131,11 @@ The plugin works with popular caching plugins by automatically excluding Ultimat = Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin = += 2.0.15: May 22, 2018 = + +* Bugfixes: + - Fixed GDPR min.js script + = 2.0.14: May 22, 2018 = * Enhancements: diff --git a/ultimate-member.php b/ultimate-member.php index e66af51a..0af207cf 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.0.14 +Version: 2.0.15 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member From 7aed3486f148ea468e4c58d3b8259c253322436b Mon Sep 17 00:00:00 2001 From: yura_nalivaiko Date: Wed, 23 May 2018 09:54:54 +0300 Subject: [PATCH 22/35] - fixed fetch user in tabs; --- includes/core/class-profile.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/includes/core/class-profile.php b/includes/core/class-profile.php index c650cbea..a857654a 100644 --- a/includes/core/class-profile.php +++ b/includes/core/class-profile.php @@ -115,14 +115,21 @@ if ( ! class_exists( 'um\core\Profile' ) ) { 'icon' => 'um-faicon-comment' ) ) ); - um_fetch_user(get_current_user_id()); + // disable private tabs if ( ! is_admin() ) { + if( is_user_logged_in() ) { + $user_id = um_user('ID'); + um_fetch_user( get_current_user_id() ); + } foreach ( $tabs as $id => $tab ) { if ( ! $this->can_view_tab( $id ) ) { unset( $tabs[$id] ); } } + if( is_user_logged_in() ) { + um_fetch_user( $user_id ); + } } return $tabs; From f764353faa5ced9e656e2550780b3f7af7c85d74 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Wed, 23 May 2018 10:00:36 +0300 Subject: [PATCH 23/35] - changed readme; --- README.md | 4 ++-- readme.txt | 5 +++++ ultimate-member.php | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 86c2f833..bd1584de 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Ultimate Member is the #1 user profile & membership plugin for WordPress. The pl | Latest Version |Requires at least|Stable Tag| | :------------: |:------------:|:------------:| -| 2.0.15 | WordPress 4.9 or higher| 2.0.15 | +| 2.0.16 | WordPress 4.9 or higher| 2.0.16 | Features of the plugin include: @@ -48,7 +48,7 @@ GNU Version 2 or Any Later Version Releases ==================== -[Official Release Version: 2.0.15](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.15). +[Official Release Version: 2.0.16](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.16). [Official Release Version: 1.3.88](https://github.com/ultimatemember/ultimatemember/releases). diff --git a/readme.txt b/readme.txt index fa7ddfb2..632d11ff 100644 --- a/readme.txt +++ b/readme.txt @@ -131,6 +131,11 @@ The plugin works with popular caching plugins by automatically excluding Ultimat = Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin = += 2.0.16: May 23, 2018 = + +* Bugfixes: + - Fixed Profile Tabs issues + = 2.0.15: May 22, 2018 = * Bugfixes: diff --git a/ultimate-member.php b/ultimate-member.php index 0af207cf..62721747 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.0.15 +Version: 2.0.16 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member From 4c14d33fee469b5ec6c641d0ca836bf09ea94488 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Thu, 24 May 2018 14:28:22 +0300 Subject: [PATCH 24/35] - fixed user's profile restriction when user isn't logged in; --- includes/core/class-access.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index 50938c9e..6223c552 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -536,7 +536,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { if ( ! empty( $post->post_type ) && $post->post_type == 'page' ) { if ( um_is_core_post( $post, 'login' ) || um_is_core_post( $post, 'register' ) || um_is_core_post( $post, 'account' ) || um_is_core_post( $post, 'logout' ) || - um_is_core_post( $post, 'password-reset' ) || um_is_core_post( $post, 'user' ) ) + um_is_core_post( $post, 'password-reset' ) || ( is_user_logged_in() && um_is_core_post( $post, 'user' ) ) ) return false; } From 2ce01fcd4c1452169134bb00127bedc9b4e6ce26 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Thu, 24 May 2018 16:55:06 +0300 Subject: [PATCH 25/35] - upgrades request manual; --- includes/admin/class-admin.php | 20 +++++++++++++++++++ includes/admin/core/class-admin-menu.php | 15 ++++++++++++++ includes/admin/core/class-admin-notices.php | 8 ++++++++ .../templates/dashboard/upgrade-request.php | 6 ++++++ 4 files changed, 49 insertions(+) create mode 100644 includes/admin/templates/dashboard/upgrade-request.php diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index 9eed2865..56267f35 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -35,6 +35,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) ); add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) ); + add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) ); add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) ); add_action( 'um_admin_do_action__um_language_downloader', array( &$this, 'um_language_downloader' ) ); add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) ); @@ -48,6 +49,25 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { } + function manual_upgrades_request() { + if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) { + die(); + } + + $last_request = get_option( 'um_last_manual_upgrades_request', false ); + + if ( empty( $last_request ) || time() > $last_request + DAY_IN_SECONDS ) { + UM()->plugin_updater()->um_checklicenses(); + + update_option( 'um_last_manual_upgrades_request', time() ); + + $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'got_updates' ), admin_url( 'admin.php' ) ); + } else { + $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'often_updates' ), admin_url( 'admin.php' ) ); + } + exit( wp_redirect( $url ) ); + } + /** * Clear all users cache diff --git a/includes/admin/core/class-admin-menu.php b/includes/admin/core/class-admin-menu.php index f42ad023..cbb68cfd 100644 --- a/includes/admin/core/class-admin-menu.php +++ b/includes/admin/core/class-admin-menu.php @@ -206,6 +206,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { add_meta_box( 'um-metaboxes-mainbox-1', __( 'Latest from our blog', 'ultimate-member' ), array( &$this, 'um_news' ), $this->pagehook, 'normal', 'core' ); add_meta_box( 'um-metaboxes-sidebox-1', __( 'Purge Temp Files', 'ultimate-member' ), array( &$this, 'purge_temp' ), $this->pagehook, 'side', 'core' ); + add_meta_box( 'um-metaboxes-sidebox-2', __( 'User Cache', 'ultimate-member' ), array( &$this, 'user_cache' ), $this->pagehook, 'side', 'core' ); if ( $this->language_avaialable_not_installed() ) { @@ -215,6 +216,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { } else if ( $this->language_not_available() ) { add_meta_box( 'um-metaboxes-sidebox-2', __( 'Language', 'ultimate-member' ), array( &$this, 'ct_language' ), $this->pagehook, 'side', 'core' ); } + + //If there are active and licensed extensions - show metabox for upgrade it + $exts = UM()->plugin_updater()->um_get_active_plugins(); + if ( 0 < count( $exts ) ) { + add_meta_box( 'um-metaboxes-sidebox-3', __( 'Upgrade\'s Manual Request', 'ultimate-member' ), array( &$this, 'upgrade_request' ), $this->pagehook, 'side', 'core' ); + } } @@ -269,6 +276,14 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { } + /** + * + */ + function upgrade_request() { + include_once UM()->admin()->templates_path . 'dashboard/upgrade-request.php'; + } + + /** * */ diff --git a/includes/admin/core/class-admin-notices.php b/includes/admin/core/class-admin-notices.php index a26b409d..70b82f31 100644 --- a/includes/admin/core/class-admin-notices.php +++ b/includes/admin/core/class-admin-notices.php @@ -420,6 +420,14 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { $messages[0]['content'] = __( 'Your user cache is now removed.', 'ultimate-member' ); break; + case 'got_updates': + $messages[0]['content'] = __( 'You got the latest upgrades.', 'ultimate-member' ); + break; + + case 'often_updates': + $messages[0]['err_content'] = __( 'Try again later. You can run this action once daily.', 'ultimate-member' ); + break; + case 'form_duplicated': $messages[0]['content'] = __( 'The form has been duplicated successfully.', 'ultimate-member' ); break; diff --git a/includes/admin/templates/dashboard/upgrade-request.php b/includes/admin/templates/dashboard/upgrade-request.php new file mode 100644 index 00000000..f7c5bfcc --- /dev/null +++ b/includes/admin/templates/dashboard/upgrade-request.php @@ -0,0 +1,6 @@ +

+

+ + + +

\ No newline at end of file From 79ae9a91856993fb13cdda7f91629551b180a67d Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Fri, 25 May 2018 10:34:53 +0300 Subject: [PATCH 26/35] - fixed refresh of transient plugin upgrade options --- includes/admin/class-admin.php | 4 ++++ includes/admin/templates/dashboard/upgrade-request.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index 56267f35..9ec0de53 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -57,6 +57,10 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { $last_request = get_option( 'um_last_manual_upgrades_request', false ); if ( empty( $last_request ) || time() > $last_request + DAY_IN_SECONDS ) { + + delete_transient( 'update_plugins' ); + delete_site_transient( 'update_plugins' ); + UM()->plugin_updater()->um_checklicenses(); update_option( 'um_last_manual_upgrades_request', time() ); diff --git a/includes/admin/templates/dashboard/upgrade-request.php b/includes/admin/templates/dashboard/upgrade-request.php index f7c5bfcc..b1af5c84 100644 --- a/includes/admin/templates/dashboard/upgrade-request.php +++ b/includes/admin/templates/dashboard/upgrade-request.php @@ -1,6 +1,6 @@

- +

\ No newline at end of file From 4000dca515ae065ef7dd807f1425dea00ad82a9a Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Fri, 25 May 2018 15:05:14 +0300 Subject: [PATCH 27/35] - fixed wp_mail text/plain and text/html headers; - fixed profile tabs without icons at mobile devices; --- assets/css/um-profile.css | 2 +- includes/core/class-account.php | 1 - includes/core/class-fields.php | 2 +- includes/core/class-mail.php | 24 ++++++------------------ includes/core/um-actions-register.php | 16 +++++++++++++++- includes/core/um-navmenu.php | 2 +- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/assets/css/um-profile.css b/assets/css/um-profile.css index 00a07b6a..1a316863 100644 --- a/assets/css/um-profile.css +++ b/assets/css/um-profile.css @@ -394,7 +394,7 @@ font-weight: normal; } .um-profile-nav-item.without-icon a {padding-left: 10px} -.um-profile-nav-item.without-icon span.title {padding-left: 0} +.um-profile-nav-item.without-icon span.title {display: inline;padding-left: 0;} .um-profile-nav-item.without-icon i {display: none} .um-profile-nav-item a:hover {background: #555} diff --git a/includes/core/class-account.php b/includes/core/class-account.php index 4b617404..a6fc0c67 100644 --- a/includes/core/class-account.php +++ b/includes/core/class-account.php @@ -751,7 +751,6 @@ if ( ! class_exists( 'um\core\Account' ) ) { * ?> */ do_action( "um_after_account_{$tab_id}", $args ); -// var_dump($args); if ( ! isset( $tab_data['show_button'] ) || false !== $tab_data['show_button'] ) { ?> diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index a146a9b7..40c2cb9e 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -2890,7 +2890,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { $um_field_checkbox_item_title = $v; $option_value = $v; - if (!is_numeric( $k ) && in_array( $form_key, array( 'role' ) )) { + if ( ! is_numeric( $k ) && in_array( $form_key, array( 'role', 'role_radio' ) ) ) { $um_field_checkbox_item_title = $v; $option_value = $k; } diff --git a/includes/core/class-mail.php b/includes/core/class-mail.php index 330c8290..e92a208f 100644 --- a/includes/core/class-mail.php +++ b/includes/core/class-mail.php @@ -124,10 +124,14 @@ if ( ! class_exists( 'um\core\Mail' ) ) { $this->message = $this->prepare_template( $template, $args ); - add_filter( 'wp_mail_content_type', array( &$this, 'set_content_type' ) ); + if ( UM()->options()->get( 'email_html' ) ) { + $this->headers .= "Content-Type: text/html\r\n"; + } else { + $this->headers .= "Content-Type: text/plain\r\n"; + } + // Send mail wp_mail( $email, $this->subject, $this->message, $this->headers, $this->attachments ); - remove_filter( 'wp_mail_content_type', array( &$this, 'set_content_type' ) ); } @@ -481,22 +485,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) { } - /** - * Set email content type - * - * - * @param $content_type - * @return string - */ - function set_content_type( $content_type ) { - if ( UM()->options()->get( 'email_html' ) ) { - return 'text/html'; - } else { - return 'text/plain'; - } - } - - /** * Ajax copy template to the theme * diff --git a/includes/core/um-actions-register.php b/includes/core/um-actions-register.php index 3abc44ed..e59f6040 100644 --- a/includes/core/um-actions-register.php +++ b/includes/core/um-actions-register.php @@ -726,4 +726,18 @@ function um_registration_set_profile_full_name( $user_id, $args ) { */ do_action( 'um_update_profile_full_name', $user_id, $args ); } -add_action( 'um_registration_set_extra_data', 'um_registration_set_profile_full_name', 10, 2 ); \ No newline at end of file +add_action( 'um_registration_set_extra_data', 'um_registration_set_profile_full_name', 10, 2 ); + + +/** + * Redirect from default registration to UM registration page + */ +function um_form_register_redirect() { + $page_id = UM()->options()->get( UM()->options()->get_core_page_id( 'register' ) ); + $register_post = get_post( $page_id ); + if ( ! empty( $register_post ) ) { + wp_safe_redirect( get_permalink( $page_id ) ); + exit(); + } +} +add_action( 'login_form_register', 'um_form_register_redirect', 10 ); \ No newline at end of file diff --git a/includes/core/um-navmenu.php b/includes/core/um-navmenu.php index 214e3258..00b4a8a1 100644 --- a/includes/core/um-navmenu.php +++ b/includes/core/um-navmenu.php @@ -47,7 +47,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) { if ( empty( $_POST['menu-item-db-id'] ) || ! in_array( $menu_item_db_id, $_POST['menu-item-db-id'] ) ) { return; } - //var_dump($_POST['menu-item-um_nav_roles']); exit; + foreach ( self::$fields as $_key => $label ) { $key = sprintf( 'menu-item-%s', $_key ); From 224b869541ed7bff3e452c85b5437399d2001599 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Fri, 25 May 2018 18:22:38 +0300 Subject: [PATCH 28/35] - fixed user status setup on registration process; --- includes/core/class-form.php | 3 ++- includes/core/class-user.php | 30 ++++++++++++++++----------- includes/core/um-actions-register.php | 28 +++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/includes/core/class-form.php b/includes/core/class-form.php index 9b5ff609..7c0c1db6 100644 --- a/includes/core/class-form.php +++ b/includes/core/class-form.php @@ -465,8 +465,9 @@ if ( ! class_exists( 'um\core\Form' ) ) { $global_role = get_option( 'default_role' ); // WP Global settings $um_global_role = UM()->options()->get( 'register_role' ); // UM Settings Global settings - if ( ! empty( $um_global_role ) ) + if ( ! empty( $um_global_role ) ) { $global_role = $um_global_role; // Form Global settings + } $mode = $this->form_type( $post_id ); diff --git a/includes/core/class-user.php b/includes/core/class-user.php index a449366c..28cff8f4 100644 --- a/includes/core/class-user.php +++ b/includes/core/class-user.php @@ -1661,23 +1661,29 @@ if ( ! class_exists( 'um\core\User' ) ) { } } + + // update user if ( count( $args ) > 1 ) { - global $wp_roles; - $um_roles = get_option( 'um_roles' ); - if ( ! empty( $um_roles ) ) { - $role_keys = array_map( function( $item ) { - return 'um_' . $item; - }, get_option( 'um_roles' ) ); - } else { - $role_keys = array(); - } + //if isset roles argument validate role to properly for security reasons + if ( isset( $args['role'] ) ) { + global $wp_roles; + $um_roles = get_option( 'um_roles' ); - $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) ); + if ( ! empty( $um_roles ) ) { + $role_keys = array_map( function( $item ) { + return 'um_' . $item; + }, get_option( 'um_roles' ) ); + } else { + $role_keys = array(); + } - if ( isset( $args['role'] ) && in_array( $args['role'], $exclude_roles ) ) { - unset( $args['role'] ); + $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) ); + + if ( in_array( $args['role'], $exclude_roles ) ) { + unset( $args['role'] ); + } } wp_update_user( $args ); diff --git a/includes/core/um-actions-register.php b/includes/core/um-actions-register.php index e59f6040..addab9b4 100644 --- a/includes/core/um-actions-register.php +++ b/includes/core/um-actions-register.php @@ -55,7 +55,7 @@ function um_after_insert_user( $user_id, $args ) { UM()->user()->remove_cached_queue(); um_fetch_user( $user_id ); - UM()->user()->set_status( um_user('status') ); + UM()->user()->set_status( um_user( 'status' ) ); if ( ! empty( $args['submitted'] ) ) { UM()->user()->set_registration_details( $args['submitted'] ); } @@ -369,6 +369,30 @@ function um_submit_form_register( $args ) { $args['submitted'] = array_merge( $args['submitted'], $credentials ); $args = array_merge( $args, $credentials ); + //get user role from global or form's settings + $user_role = UM()->form()->assigned_role( UM()->form()->form_id ); + + //get user role from field Role dropdown or radio + if ( isset( $args['role'] ) ) { + global $wp_roles; + $um_roles = get_option( 'um_roles' ); + + if ( ! empty( $um_roles ) ) { + $role_keys = array_map( function( $item ) { + return 'um_' . $item; + }, get_option( 'um_roles' ) ); + } else { + $role_keys = array(); + } + + $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) ); + + //if role is properly set it + if ( ! in_array( $args['role'], $exclude_roles ) ) { + $user_role = $args['role']; + } + } + /** * UM hook * @@ -391,7 +415,7 @@ function um_submit_form_register( $args ) { * } * ?> */ - $user_role = apply_filters( 'um_registration_user_role', UM()->form()->assigned_role( UM()->form()->form_id ), $args ); + $user_role = apply_filters( 'um_registration_user_role', $user_role, $args ); $userdata = array( 'user_login' => $user_login, From 2864426fbce44d5e0829c715506767d0fa7f4eb1 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Fri, 25 May 2018 18:23:22 +0300 Subject: [PATCH 29/35] - changed version; --- ultimate-member.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ultimate-member.php b/ultimate-member.php index 62721747..2197a574 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.0.16 +Version: 2.0.17-alpha1 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member From c503c05a43b288c160755b17891756da6d3c3970 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Mon, 28 May 2018 14:41:15 +0300 Subject: [PATCH 30/35] - fixed PHP memory limit error after upgrade; --- includes/admin/core/class-admin-upgrade.php | 40 ++++++++++++++++--- .../packages/2.0-beta1/email_templates.php | 4 +- includes/class-init.php | 3 +- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/includes/admin/core/class-admin-upgrade.php b/includes/admin/core/class-admin-upgrade.php index e48cb7c9..406431c8 100644 --- a/includes/admin/core/class-admin-upgrade.php +++ b/includes/admin/core/class-admin-upgrade.php @@ -17,6 +17,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) { class Admin_Upgrade { + /** + * @var null + */ + protected static $instance = null; + + /** * @var */ @@ -31,6 +37,25 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) { var $packages_dir; + /** + * Main Admin_Upgrade Instance + * + * Ensures only one instance of UM is loaded or can be loaded. + * + * @since 1.0 + * @static + * @see UM() + * @return Admin_Upgrade - Main instance + */ + static public function instance() { + if ( is_null( self::$instance ) ) { + self::$instance = new self(); + } + + return self::$instance; + } + + /** * Admin_Upgrade constructor. */ @@ -39,11 +64,14 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) { $this->necessary_packages = $this->need_run_upgrades(); if ( ! empty( $this->necessary_packages ) ) { - $this->init_packages_ajax(); add_action( 'admin_menu', array( $this, 'admin_menu' ), 0 ); - add_action( 'wp_ajax_um_run_package', array( $this, 'ajax_run_package' ) ); - add_action( 'wp_ajax_um_get_packages', array( $this, 'ajax_get_packages' ) ); + if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { + $this->init_packages_ajax(); + + add_action( 'wp_ajax_um_run_package', array( $this, 'ajax_run_package' ) ); + add_action( 'wp_ajax_um_get_packages', array( $this, 'ajax_get_packages' ) ); + } } //add_action( 'in_plugin_update_message-' . um_plugin, array( $this, 'in_plugin_update_message' ) ); @@ -143,7 +171,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) { foreach ( $this->necessary_packages as $package ) { $hooks_file = $this->packages_dir . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR . 'hooks.php'; if ( file_exists( $hooks_file ) ) { - $pack_ajax_hooks = include $hooks_file; + $pack_ajax_hooks = include_once $hooks_file; foreach ( $pack_ajax_hooks as $action => $function ) { add_action( 'wp_ajax_um_' . $action, "um_upgrade_$function" ); @@ -160,7 +188,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) { foreach ( $this->necessary_packages as $package ) { $handlers_file = $this->packages_dir . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR . 'functions.php'; if ( file_exists( $handlers_file ) ) { - include $handlers_file; + include_once $handlers_file; } } } @@ -290,7 +318,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) { exit(''); } else { ob_start(); - include $this->packages_dir . DIRECTORY_SEPARATOR . $_POST['pack'] . DIRECTORY_SEPARATOR . 'init.php'; + include_once $this->packages_dir . DIRECTORY_SEPARATOR . $_POST['pack'] . DIRECTORY_SEPARATOR . 'init.php'; ob_get_flush(); exit; } diff --git a/includes/admin/core/packages/2.0-beta1/email_templates.php b/includes/admin/core/packages/2.0-beta1/email_templates.php index 264c32dd..d30a3182 100644 --- a/includes/admin/core/packages/2.0-beta1/email_templates.php +++ b/includes/admin/core/packages/2.0-beta1/email_templates.php @@ -25,8 +25,8 @@ foreach ( $emails as $email_key => $value ) { } else { $setting_value = UM()->options()->get( $email_key ); - $fp = fopen( $theme_template_path, "w" ); - $result = fputs( $fp, $setting_value ); + $fp = @fopen( $theme_template_path, "w" ); + $result = @fputs( $fp, $setting_value ); fclose( $fp ); } } else { diff --git a/includes/class-init.php b/includes/class-init.php index 0e9f1fc3..0cc6f25d 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -637,7 +637,8 @@ if ( ! class_exists( 'UM' ) ) { */ function admin_upgrade() { if ( empty( $this->classes['admin_upgrade'] ) ) { - $this->classes['admin_upgrade'] = new um\admin\core\Admin_Upgrade(); + $this->classes['admin_upgrade'] = um\admin\core\Admin_Upgrade::instance(); + //$this->classes['admin_upgrade'] = new um\admin\core\Admin_Upgrade(); } return $this->classes['admin_upgrade']; } From efe91cff2aafe9ffa0ae1142cf4514227c8664a2 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 29 May 2018 22:24:37 +0300 Subject: [PATCH 31/35] - fixed profile tabs displaying on desktop/mobile; --- assets/css/um-profile.css | 30 +++++++++++++++++++----- includes/core/um-actions-profile.php | 34 ++++++++++++++++------------ 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/assets/css/um-profile.css b/assets/css/um-profile.css index 1a316863..e14b2721 100644 --- a/assets/css/um-profile.css +++ b/assets/css/um-profile.css @@ -393,13 +393,31 @@ font-weight: normal; border-bottom: 0 !important; } -.um-profile-nav-item.without-icon a {padding-left: 10px} -.um-profile-nav-item.without-icon span.title {display: inline;padding-left: 0;} -.um-profile-nav-item.without-icon i {display: none} +.um-profile-nav-item.without-icon a { + padding-left: 10px; +} +.um-profile-nav-item.without-icon span.title { + padding-left: 0; +} +.um-profile-nav-item.without-icon i { + display: none; +} -.um-profile-nav-item a:hover {background: #555} -.um-profile-nav-item i {font-size: 18px;height: 18px;line-height: 18px;position: absolute;display: block;top: 8px;left: 10px} -.um-profile-nav-item span.title {padding-left: 5px} +.um-profile-nav-item a:hover { + background: #555; +} +.um-profile-nav-item i { + font-size: 18px; + height: 18px; + line-height: 18px; + position: absolute; + display: block; + top: 8px; + left: 10px; +} +.um-profile-nav-item span.title { + padding-left: 5px; +} .um-profile-nav-item span.count { font-size: 12px; font-weight: 300; diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php index 8d064021..4e035551 100644 --- a/includes/core/um-actions-profile.php +++ b/includes/core/um-actions-profile.php @@ -1377,40 +1377,46 @@ function um_profile_menu( $args ) { From 7a032a02d490632351fa4c83743767f9544ae76c Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 29 May 2018 22:35:57 +0300 Subject: [PATCH 32/35] - fixed issue https://wordpress.org/support/topic/corrections-for-core-um-actions-forms-php-um-v2-0-11/ --- includes/core/um-actions-form.php | 11 ++++++----- includes/core/um-filters-fields.php | 8 ++++---- ultimate-member.php | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/includes/core/um-actions-form.php b/includes/core/um-actions-form.php index 8050be80..5cf15388 100644 --- a/includes/core/um-actions-form.php +++ b/includes/core/um-actions-form.php @@ -314,8 +314,9 @@ function um_submit_form_errors_hook_( $args ) { foreach ( $array['conditions'] as $condition ) { list( $visibility, $parent_key, $op, $parent_value ) = $condition; - if ( ! isset( $args[ $parent_key ] ) ) + if ( ! isset( $args[ $parent_key ] ) ) { continue; + } $cond_value = ( $fields[ $parent_key ]['type'] == 'radio' ) ? $args[ $parent_key ][0] : $args[ $parent_key ]; @@ -337,11 +338,11 @@ function um_submit_form_errors_hook_( $args ) { continue 2; } } elseif ( $op == 'greater than' ) { - if ( $cond_value > $op ) { + if ( $cond_value > $parent_value ) { continue 2; } } elseif ( $op == 'less than' ) { - if ( $cond_value < $op ) { + if ( $cond_value < $parent_value ) { continue 2; } } elseif ( $op == 'contains' ) { @@ -367,11 +368,11 @@ function um_submit_form_errors_hook_( $args ) { continue 2; } } elseif ( $op == 'greater than' ) { - if ( $cond_value <= $op ) { + if ( $cond_value <= $parent_value ) { continue 2; } } elseif ( $op == 'less than' ) { - if ( $cond_value >= $op ) { + if ( $cond_value >= $parent_value ) { continue 2; } } elseif ( $op == 'contains' ) { diff --git a/includes/core/um-filters-fields.php b/includes/core/um-filters-fields.php index 7f55479e..4a2f59bf 100644 --- a/includes/core/um-filters-fields.php +++ b/includes/core/um-filters-fields.php @@ -392,11 +392,11 @@ function um_get_custom_field_array( $array, $fields ) { $array['required'] = 0; } } elseif ( $op == 'greater than' ) { - if ( $cond_value > $op ) { + if ( $cond_value > $parent_value ) { $array['required'] = 0; } } elseif ( $op == 'less than' ) { - if ( $cond_value < $op ) { + if ( $cond_value < $parent_value ) { $array['required'] = 0; } } elseif ( $op == 'contains' ) { @@ -422,11 +422,11 @@ function um_get_custom_field_array( $array, $fields ) { $array['required'] = 0; } } elseif ( $op == 'greater than' ) { - if ( $cond_value <= $op ) { + if ( $cond_value <= $parent_value ) { $array['required'] = 0; } } elseif ( $op == 'less than' ) { - if ( $cond_value >= $op ) { + if ( $cond_value >= $parent_value ) { $array['required'] = 0; } } elseif ( $op == 'contains' ) { diff --git a/ultimate-member.php b/ultimate-member.php index 2197a574..66dd3889 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.0.17-alpha1 +Version: 2.0.17-alpha2 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member From e855cf6f50b1cc89597153ebdea13200d27da370 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Wed, 30 May 2018 11:24:43 +0300 Subject: [PATCH 33/35] - 2.0.17 release --- README.md | 4 ++-- readme.txt | 14 +++++++++++++- ultimate-member.php | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bd1584de..2084e86e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Ultimate Member is the #1 user profile & membership plugin for WordPress. The pl | Latest Version |Requires at least|Stable Tag| | :------------: |:------------:|:------------:| -| 2.0.16 | WordPress 4.9 or higher| 2.0.16 | +| 2.0.17 | WordPress 4.9 or higher| 2.0.17 | Features of the plugin include: @@ -48,7 +48,7 @@ GNU Version 2 or Any Later Version Releases ==================== -[Official Release Version: 2.0.16](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.16). +[Official Release Version: 2.0.17](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.17). [Official Release Version: 1.3.88](https://github.com/ultimatemember/ultimatemember/releases). diff --git a/readme.txt b/readme.txt index 632d11ff..dd56c229 100644 --- a/readme.txt +++ b/readme.txt @@ -6,7 +6,7 @@ Donate link: Tags: community, member, membership, user-profile, user-registration Requires at least: 4.1 Tested up to: 4.9 -Stable tag: 2.0.15 +Stable tag: 2.0.17 License: GNU Version 2 or Any Later Version License URI: http://www.gnu.org/licenses/gpl-3.0.txt @@ -131,6 +131,18 @@ The plugin works with popular caching plugins by automatically excluding Ultimat = Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin = += 2.0.17: May 30, 2018 = + +* Enhancements: + - Added UM dashboard widget for getting latest extension's upgrades + +* Bugfixes: + - Fixed User Profile restriction when user isn't logged in + - Fixed Profile Tabs dispalying on desktop/mobile + - Fixed set user status after registration on some installs + - Fixed PHP memory limit issue on some installs with small PHP memory limit + - Fixed PHP validation on submit UM Forms with conditional fields logic + = 2.0.16: May 23, 2018 = * Bugfixes: diff --git a/ultimate-member.php b/ultimate-member.php index 66dd3889..eb040a25 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.0.17-alpha2 +Version: 2.0.17 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member From c31aae6e735c68bd30c008281a2fd8bbe50d4b5b Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Wed, 30 May 2018 12:37:42 +0300 Subject: [PATCH 34/35] + --- readme.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index dd56c229..9eb1d6fd 100644 --- a/readme.txt +++ b/readme.txt @@ -137,8 +137,8 @@ The plugin works with popular caching plugins by automatically excluding Ultimat - Added UM dashboard widget for getting latest extension's upgrades * Bugfixes: - - Fixed User Profile restriction when user isn't logged in - - Fixed Profile Tabs dispalying on desktop/mobile + - Fixed User Profile restriction when the user isn't logged in + - Fixed Profile Tabs displaying on desktop/mobile - Fixed set user status after registration on some installs - Fixed PHP memory limit issue on some installs with small PHP memory limit - Fixed PHP validation on submit UM Forms with conditional fields logic From d4188290d3d0b4dcab98ee3a606b6499a81fff5a Mon Sep 17 00:00:00 2001 From: yura_nalivaiko Date: Wed, 30 May 2018 12:50:38 +0300 Subject: [PATCH 35/35] fixed user_query --- includes/core/um-filters-members.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/core/um-filters-members.php b/includes/core/um-filters-members.php index 3f780466..e4ea86df 100644 --- a/includes/core/um-filters-members.php +++ b/includes/core/um-filters-members.php @@ -211,7 +211,7 @@ function um_add_search_to_query( $query_args, $args ){ */ $query_args = apply_filters( 'um_query_args_filter', $query_args ); - if ( count( $query_args['meta_query'] ) == 1 ) + if ( isset( $query_args['meta_query'] ) && count( $query_args['meta_query'] ) == 1 ) unset( $query_args['meta_query'] ); return $query_args;