mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-14 04:06:36 +09:00
The general users setting "Avoid indexing profile by search engines" is added.
The user role setting "Avoid indexing profile by search engines" is changed.
This commit is contained in:
@@ -630,6 +630,17 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Require a strong password? (when user resets password only)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Enable or disable a strong password rules on password reset and change procedure', 'ultimate-member' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'profile_noindex',
|
||||
'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' ),
|
||||
'options' => [
|
||||
'1' => __( 'Yes', 'ultimate-member' ),
|
||||
'' => __( 'No', 'ultimate-member' )
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
@@ -43,11 +43,17 @@
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_noindex',
|
||||
'type' => 'checkbox',
|
||||
'type' => 'select',
|
||||
'size' => 'medium',
|
||||
'name' => '_um_profile_noindex',
|
||||
'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Hides the profile page for robots', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_profile_noindex'] ) ? $role['_um_profile_noindex'] : 0,
|
||||
'tooltip' => __( 'Hides the profile page for robots.', 'ultimate-member' ) . ' ' . __( 'The default value depends on the general users settings.', 'ultimate-member' ),
|
||||
'options' => [
|
||||
'' => __( 'Default', 'ultimate-member' ),
|
||||
'1' => __( 'Yes', 'ultimate-member' ),
|
||||
'2' => __( 'No', 'ultimate-member' )
|
||||
],
|
||||
'value' => ! empty( $role['_um_profile_noindex'] ) ? $role['_um_profile_noindex'] : '',
|
||||
)
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
|
||||
@@ -1686,6 +1686,52 @@ 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(); ?>
|
||||
*
|
||||
* @return boolean Is the profile indexing disabled?
|
||||
*/
|
||||
function is_profile_noindex(){
|
||||
$user_id = $this->id;
|
||||
|
||||
$profile_noindex = false;
|
||||
|
||||
if ( !get_option( 'blog_public' ) ){
|
||||
// Option "Search engine visibility" in [wp-admin > Settings > Reading]
|
||||
$profile_noindex = true;
|
||||
|
||||
} 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' ){
|
||||
// Setting "Avoid indexing my profile by search engines in [Account > Privacy]
|
||||
$profile_noindex = true;
|
||||
|
||||
}
|
||||
|
||||
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' ){
|
||||
// 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 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method checks if give user profile is private.
|
||||
*
|
||||
|
||||
@@ -680,33 +680,23 @@ function um_profile_dynamic_meta_desc() {
|
||||
|
||||
$user_id = um_get_requested_user();
|
||||
|
||||
$privacy = get_user_meta( $user_id, 'profile_privacy', true );
|
||||
if ( $privacy == __( 'Only me', 'ultimate-member' ) || $privacy == 'Only me' ) {
|
||||
echo '<meta name="robots" content="noindex, nofollow" />';
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see the user role setting "Avoid indexing profile by search engines"
|
||||
*/
|
||||
$role = UM()->roles()->get_priority_user_role( $user_id );
|
||||
$permissions = UM()->roles()->role_data( $role );
|
||||
if ( ! empty( $permissions['profile_noindex'] ) ) {
|
||||
echo '<meta name="robots" content="noindex, nofollow" />';
|
||||
return;
|
||||
if( $user_id !== um_user('ID') ){
|
||||
um_fetch_user( $user_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see the account setting "Avoid indexing my profile by search engines"
|
||||
* Settings by the priority:
|
||||
* "Search engine visibility" in [wp-admin > Settings > Reading]
|
||||
* "Profile Privacy" in [Account > Privacy]
|
||||
* "Avoid indexing my profile by search engines in [Account > Privacy]
|
||||
* "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]
|
||||
*/
|
||||
$noindex = get_user_meta( $user_id, 'profile_noindex', true );
|
||||
if ( ! empty( $noindex ) ) {
|
||||
if ( UM()->user()->is_profile_noindex() ) {
|
||||
echo '<meta name="robots" content="noindex, nofollow" />';
|
||||
return;
|
||||
}
|
||||
|
||||
um_fetch_user( $user_id );
|
||||
|
||||
$locale = get_user_locale( $user_id );
|
||||
$site_name = get_bloginfo( 'name' );
|
||||
$twitter_site = '@' . sanitize_title( $site_name );
|
||||
|
||||
Reference in New Issue
Block a user