- reviewed No Index functionality;

This commit is contained in:
nikitasinelnikov
2021-03-03 15:21:18 +02:00
parent 8dc7d9f425
commit 7f7dae9979
8 changed files with 36 additions and 38 deletions
+3 -3
View File
@@ -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' ),
]
)
)
+4 -4
View File
@@ -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'] : '',
)
+2 -1
View File
@@ -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' );
+15 -15
View File
@@ -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 <?php UM()->user()->is_profile_noindex(); ?>
* @param int $user_id
*
* @since 2.1.16
* @usage <?php UM()->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 );
}
+2 -2
View File
@@ -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 '<meta name="robots" content="noindex, nofollow" />';
return;
}
+1 -1
View File
@@ -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
*/
+2 -8
View File
@@ -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() );
+7 -4
View File
@@ -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 =