diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index 34c27484..d053da94 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -636,10 +636,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'type' => 'select', 'size' => 'small', 'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ), - 'tooltip' => __( 'Hides the profile page for robots.', 'ultimate-member' ) . ' ' . __( 'This setting can be overridden by individual role settings.', 'ultimate-member' ), + 'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ), 'options' => [ - '1' => __( 'Yes', 'ultimate-member' ), - '' => __( 'No', 'ultimate-member' ) + '0' => __( 'No', 'ultimate-member' ), + '1' => __( 'Yes', 'ultimate-member' ), ] ) ) diff --git a/includes/admin/templates/role/profile.php b/includes/admin/templates/role/profile.php index 0b19c247..02aa0ae8 100644 --- a/includes/admin/templates/role/profile.php +++ b/includes/admin/templates/role/profile.php @@ -47,11 +47,11 @@ 'size' => 'medium', 'name' => '_um_profile_noindex', 'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ), - 'tooltip' => __( 'Hides the profile page for robots.', 'ultimate-member' ) . ' ' . __( 'The default value depends on the general users settings.', 'ultimate-member' ), + 'tooltip' => __( 'Hides the profile page for robots. The default value depends on the General > Users setting.', 'ultimate-member' ), 'options' => [ - '' => __( 'Default', 'ultimate-member' ), - '1' => __( 'Yes', 'ultimate-member' ), - '2' => __( 'No', 'ultimate-member' ) + '' => __( 'Default', 'ultimate-member' ), + '0' => __( 'No', 'ultimate-member' ), + '1' => __( 'Yes', 'ultimate-member' ), ], 'value' => ! empty( $role['_um_profile_noindex'] ) ? $role['_um_profile_noindex'] : '', ) diff --git a/includes/class-config.php b/includes/class-config.php index 1fa9b2cb..1f25edcc 100644 --- a/includes/class-config.php +++ b/includes/class-config.php @@ -574,8 +574,9 @@ if ( ! class_exists( 'um\Config' ) ) { 'custom_roles_increment' => 1, 'um_profile_object_cache_stop' => 0, 'rest_api_version' => '2.0', - 'member_directory_own_table' => 0, + 'member_directory_own_table' => 0, 'profile_show_html_bio' => 0, + 'profile_noindex' => 0, ); add_filter( 'um_get_tabs_from_config', '__return_true' ); diff --git a/includes/core/class-user.php b/includes/core/class-user.php index 30254a7f..dc44b886 100644 --- a/includes/core/class-user.php +++ b/includes/core/class-user.php @@ -1689,46 +1689,46 @@ if ( ! class_exists( 'um\core\User' ) ) { /** * This method checks if the profile indexing is disabled * - * @since 2.1.14 [2020-12-22] - * @usage user()->is_profile_noindex(); ?> + * @param int $user_id + * + * @since 2.1.16 + * @usage user()->is_profile_noindex( $user_id ); ?> * * @return boolean Is the profile indexing disabled? */ - function is_profile_noindex(){ - $user_id = $this->id; - + function is_profile_noindex( $user_id ) { $profile_noindex = false; - - if ( !get_option( 'blog_public' ) ){ + + if ( ! get_option( 'blog_public' ) ) { // Option "Search engine visibility" in [wp-admin > Settings > Reading] $profile_noindex = true; - } elseif ( $this->is_private_profile( $user_id ) ){ + } elseif ( $this->is_private_profile( $user_id ) ) { // Setting "Profile Privacy" in [Account > Privacy] $profile_noindex = true; - } elseif ( get_user_meta( $user_id, 'profile_noindex', true ) === '1' ){ + } elseif ( get_user_meta( $user_id, 'profile_noindex', true ) === '1' ) { // Setting "Avoid indexing my profile by search engines in [Account > Privacy] $profile_noindex = true; - + } - - if( ! $profile_noindex ){ + + if ( ! $profile_noindex ) { $role = UM()->roles()->get_priority_user_role( $user_id ); $permissions = UM()->roles()->role_data( $role ); - + if ( isset( $permissions['profile_noindex'] ) && $permissions['profile_noindex'] === '1' ) { // Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > User Roles > Edit Role] $profile_noindex = true; - } elseif ( empty( $permissions['profile_noindex'] ) && UM()->options()->get( 'profile_noindex' ) === '1' ){ + } elseif ( $permissions['profile_noindex'] === '' && UM()->options()->get( 'profile_noindex' ) === '1' ) { // Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > Settings > General > Users] $profile_noindex = true; } } - return apply_filters( 'um_user_is_profile_noindex', $profile_noindex, $this ); + return apply_filters( 'um_user_is_profile_noindex', $profile_noindex, $user_id, $this ); } diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php index 900b3de3..19afb128 100644 --- a/includes/core/um-actions-profile.php +++ b/includes/core/um-actions-profile.php @@ -680,7 +680,7 @@ function um_profile_dynamic_meta_desc() { $user_id = um_get_requested_user(); - if( $user_id !== um_user('ID') ){ + if ( $user_id !== um_user('ID') ) { um_fetch_user( $user_id ); } @@ -692,7 +692,7 @@ function um_profile_dynamic_meta_desc() { * "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > User Roles > Edit Role] * "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > Settings > General > Users] */ - if ( UM()->user()->is_profile_noindex() ) { + if ( UM()->user()->is_profile_noindex( $user_id ) ) { echo ''; return; } diff --git a/includes/core/um-filters-account.php b/includes/core/um-filters-account.php index 7b963c3a..d7c6613b 100644 --- a/includes/core/um-filters-account.php +++ b/includes/core/um-filters-account.php @@ -48,7 +48,7 @@ add_filter( 'um_account_pre_updating_profile_array', 'um_account_sanitize_data', /** * Fix for the account field "Avoid indexing my profile by search engines" - * @since 2.1.14 [2020-12-15] + * @since 2.1.16 * @param bool $value * @return int */ diff --git a/includes/core/um-filters-profile.php b/includes/core/um-filters-profile.php index dc3969a4..be4395b3 100644 --- a/includes/core/um-filters-profile.php +++ b/includes/core/um-filters-profile.php @@ -12,21 +12,15 @@ */ function um_dynamic_user_profile_pagetitle( $title, $sep = '' ) { - $profile_title = UM()->options()->get( 'profile_title' ); - if ( um_is_core_page( 'user' ) && um_get_requested_user() ) { $user_id = um_get_requested_user(); - $privacy = get_user_meta( $user_id, 'profile_privacy', true ); - if ( $privacy == __( 'Only me', 'ultimate-member' ) || $privacy == 'Only me' ) { + if ( UM()->user()->is_profile_noindex( $user_id ) ) { return $title; } - $noindex = get_user_meta( $user_id, 'profile_noindex', true ); - if ( ! empty( $noindex ) ) { - return $title; - } + $profile_title = UM()->options()->get( 'profile_title' ); um_fetch_user( um_get_requested_user() ); diff --git a/readme.txt b/readme.txt index c9d00e94..f26a6ca5 100644 --- a/readme.txt +++ b/readme.txt @@ -157,15 +157,18 @@ The plugin works with popular caching plugins by automatically excluding Ultimat = 2.1.16: March 9, 2021 = +* Enhancements: + - Added: General and role setting to avoid indexing users' profiles + * Bugfixes: - - Fixed PHP notices and warnings - - Fixed security vulnerability with User Account page and password field - - Fixed user creating without username but based on first+last name with not-ASCII symbols + - Fixed: PHP notices and warnings + - Fixed: Security vulnerability with User Account page and password field + - Fixed: User creating without username but based on first+last name with not-ASCII symbols = 2.1.15: December 24, 2020 = * Bugfixes: - - Fixed conditional logic for the form fields without metakeys + - Fixed: Conditional logic for the form fields without metakeys = 2.1.14: December 22, 2020 =