From 02fde13b39dd99229d895b0b7c82a0f5d12e02ba Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Fri, 19 Jun 2020 13:07:04 +0300 Subject: [PATCH] - added profile privacy setting for the avoiding profile indexation; --- includes/core/class-account.php | 2 +- includes/core/class-builtin.php | 43 ++++++++++++++++++++-------- includes/core/um-actions-profile.php | 26 +++++++++++++---- includes/core/um-filters-profile.php | 12 ++++++++ includes/um-short-functions.php | 2 +- readme.txt | 2 +- templates/modal/um_view_photo.php | 5 +++- 7 files changed, 70 insertions(+), 22 deletions(-) diff --git a/includes/core/class-account.php b/includes/core/class-account.php index bebfcf4e..fea95b00 100644 --- a/includes/core/class-account.php +++ b/includes/core/class-account.php @@ -590,7 +590,7 @@ if ( ! class_exists( 'um\core\Account' ) ) { case 'privacy': - $args = 'profile_privacy,hide_in_members'; + $args = 'profile_privacy,profile_noindex,hide_in_members'; /** * UM hook * diff --git a/includes/core/class-builtin.php b/includes/core/class-builtin.php index 6443d942..a002b05a 100644 --- a/includes/core/class-builtin.php +++ b/includes/core/class-builtin.php @@ -1115,18 +1115,37 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { // account page use ( not public ) 'profile_privacy' => array( - 'title' => __('Profile Privacy','ultimate-member'), - 'metakey' => 'profile_privacy', - 'type' => 'select', - 'label' => __('Profile Privacy','ultimate-member'), - 'help' => __('Who can see your public profile?','ultimate-member'), - 'required' => 0, - 'public' => 1, - 'editable' => 1, - 'default' => 'Everyone', - 'options' => $profile_privacy, - 'allowclear' => 0, - 'account_only' => true, + 'title' => __( 'Profile Privacy', 'ultimate-member' ), + 'metakey' => 'profile_privacy', + 'type' => 'select', + 'label' => __( 'Profile Privacy', 'ultimate-member' ), + 'help' => __( 'Who can see your public profile?', 'ultimate-member' ), + 'required' => 0, + 'public' => 1, + 'editable' => 1, + 'default' => 'Everyone', + 'options' => $profile_privacy, + 'allowclear' => 0, + 'account_only' => true, + 'required_perm' => 'can_make_private_profile', + ), + + 'profile_noindex' => array( + 'title' => __( 'Avoid my profile indexing', 'ultimate-member' ), + 'metakey' => 'profile_noindex', + 'type' => 'select', + 'label' => __( 'Avoid my profile indexing', 'ultimate-member' ), + 'help' => __( 'Hide my profile for robots?', 'ultimate-member' ), + 'required' => 0, + 'public' => 1, + 'editable' => 1, + 'default' => '0', + 'options' => array( + '0' => __( 'No', 'ultimate-member' ), + '1' => __( 'Yes', 'ultimate-member' ), + ), + 'allowclear' => 0, + 'account_only' => true, 'required_perm' => 'can_make_private_profile', ), diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php index a4309a70..429a13fb 100644 --- a/includes/core/um-actions-profile.php +++ b/includes/core/um-actions-profile.php @@ -629,6 +629,20 @@ function um_profile_dynamic_meta_desc() { 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' ) { + return; + } + + $noindex = get_user_meta( $user_id, 'profile_noindex', true ); + if ( ! empty( $noindex ) ) { ?> + + + + "http://schema.org", - "@type" => "Person", - "name" => esc_attr( $title ), - "description" => esc_attr( $description ), - "image" => esc_url( $image ), - "url" => esc_url( $url ) + "@context" => "http://schema.org", + "@type" => "Person", + "name" => esc_attr( $title ), + "description" => esc_attr( $description ), + "image" => esc_url( $image ), + "url" => esc_url( $url ), ); um_reset_user(); diff --git a/includes/core/um-filters-profile.php b/includes/core/um-filters-profile.php index 847a592d..c7277f78 100644 --- a/includes/core/um-filters-profile.php +++ b/includes/core/um-filters-profile.php @@ -16,6 +16,18 @@ function um_dynamic_user_profile_pagetitle( $title, $sep = '' ) { 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' ) { + return $title; + } + + $noindex = get_user_meta( $user_id, 'profile_noindex', true ); + if ( ! empty( $noindex ) ) { + return $title; + } + um_fetch_user( um_get_requested_user() ); $profile_title = um_convert_tags( $profile_title ); diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index fa007096..59f9f0ae 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -2053,7 +2053,7 @@ function um_get_cover_uri( $image, $attrs ) { function um_get_avatar_url( $get_avatar ) { preg_match( '/src="(.*?)"/i', $get_avatar, $matches ); - return $matches[1]; + return isset( $matches[1] ) ? $matches[1] : ''; } diff --git a/readme.txt b/readme.txt index d5aada35..416b0fad 100644 --- a/readme.txt +++ b/readme.txt @@ -142,7 +142,7 @@ The plugin works with popular caching plugins by automatically excluding Ultimat = Important: = -* To learn more about version 2.1 please see this [topic](https://wordpress.org/support/topic/version-2-1-4/) +* To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0) * UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin = 2.1.6: June 1, 2020 = diff --git a/templates/modal/um_view_photo.php b/templates/modal/um_view_photo.php index 9e7f0116..d24dbc23 100644 --- a/templates/modal/um_view_photo.php +++ b/templates/modal/um_view_photo.php @@ -2,7 +2,10 @@