Skip to content

Commit

Permalink
Fix code for Profile view
Browse files Browse the repository at this point in the history
  • Loading branch information
raftaar1191 committed Dec 4, 2023
1 parent 46c3f44 commit 1e381cc
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 33 deletions.
31 changes: 21 additions & 10 deletions includes/class-view-analytics-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,33 @@ public function view_count_enable() {
return $this->get_view_setting_active( 'main' );
}


/**
* Return the View Analytics Avatar show the user view count
* Return the View Analytics show count
*/
public function view_count_show_view_count() {

$view = false;
public function view_count_show_view_count( $author_id = 0 ) {

if ( ! $this->view_count_enable() ) {
return $view;

if ( empty( $author_id ) ) {
return false;
}

if ( $this->get_view_setting_active( 'show_view_count' ) ) {
$view = apply_filters( $this->create_filter_key( 'show_view_count' ), true );

if( ! $this->view_count_enable() ) {
return false;
}

if ( ! $this->get_view_setting_active( 'show_view_count' ) ) {
return false;
}

/**
* if the user is the admin then return true
*/
if( $this->is_admin() ) {
return true;
}

return $view;
return apply_filters( $this->create_filter_key( 'show_view_count' ), $this->is_author( $author_id ) );
}

/**
Expand Down
19 changes: 19 additions & 0 deletions includes/media/class-view-analytics-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ public function view_count_key() {
return '_view_analytics_media_table_count_enable';
}

/**
* Return the View Analytics show count
* Overwrite this for Media View Count
*/
public function view_count_show_view_count( $author_id = false ) {

$view = false;

if ( ! $this->view_count_enable() ) {
return $view;
}

if ( $this->get_view_setting_active( 'show_view_count' ) ) {
$view = apply_filters( $this->create_filter_key( 'show_view_count' ), true );
}

return $view;
}

/**
* Return the View Analytics Media show the user view list
*/
Expand Down
1 change: 1 addition & 0 deletions includes/profile/class-view-analytics-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public static function instance() {
public function view_count_key() {
return '_view_analytics_profile_table_count_enable';
}


/**
* Check if the current user is allow to view the Profile View List
Expand Down
14 changes: 2 additions & 12 deletions public/partials/avatar/view-analytics-public-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ public function profile_navigation() {
/**
* Check if the curret user has access to view the Profile View Tab
*/
if (
$this->common->view_count_show_view_count()
&&
$this->common->can_current_user_view_list_current_user()
) {
if ( $this->common->view_count_show_view_count() ) {
bp_core_new_nav_item(
array(
'name' => __( 'Profile Avatar Update', 'view-analytics' ),
Expand Down Expand Up @@ -113,13 +109,7 @@ public function group_navigation() {
/**
* Check if the curret user has access to view the Profile View Tab
*/
if (
! empty( $current_group )
&&
$this->common->view_count_show_view_count()
&&
$this->common->can_current_user_view_list( $current_group->id )
) {
if ( ! empty( $current_group ) && $this->common->view_count_show_view_count() ) {

$group_link = bp_get_group_permalink( $current_group );

Expand Down
6 changes: 1 addition & 5 deletions public/partials/group/view-analytics-public-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ public function navigation() {
/**
* Check if the curret user has access to view the Profile View Tab
*/
if (
! empty( $current_group )
&& $this->common->view_count_show_view_count()
&& $this->common->can_current_user_view_list( $current_group->id )
) {
if ( ! empty( $current_group ) && $this->common->view_count_show_view_count() ) {

$group_link = bp_get_group_permalink( $current_group );

Expand Down
9 changes: 3 additions & 6 deletions public/partials/profile/view-analytics-public-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,8 @@ public function navigation() {
/**
* Check if the curret user has access to view the Profile View Tab
*/
if (
$this->common->view_count_show_view_count()
&&
$this->common->can_current_user_view_list()
) {
$displayed_user_id = bp_displayed_user_id();
if ( ! empty( $displayed_user_id ) && $this->common->view_count_show_view_count( $displayed_user_id ) ) {
bp_core_new_nav_item(
array(
'name' => __( 'Profile View', 'view-analytics' ),
Expand All @@ -98,7 +95,7 @@ public function view_manage() {
}

function content() {
$author_id = get_current_user_id();
$author_id = bp_displayed_user_id();
$view_details = $this->common->table->get_details( $author_id );
if ( empty( $view_details ) ) {
echo __( 'No one has view your Profile', 'view-analytics' );
Expand Down

0 comments on commit 1e381cc

Please sign in to comment.