Skip to content

Commit

Permalink
Add media view hook
Browse files Browse the repository at this point in the history
  • Loading branch information
raftaar1191 committed Dec 4, 2023
1 parent 4e98d71 commit 46c3f44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions admin/menu/class-view-analytics-settings-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ public function media_settings() {
),
array(
'type' => 'toggle',
'description' => __( 'Show Media View Count in Public', 'view-analytics' ),
'description' => __( 'Show Media View Count in Public.', 'view-analytics' ),
'id' => 'show_view_count',
'default' => true,
),
array(
'type' => 'toggle',
'description' => __( 'Show Media View User Lists when someone click on the views button', 'view-analytics' ),
'description' => __( 'Show Media View User Lists when someone click on the views button.', 'view-analytics' ),
'id' => 'show_view_user_list',
'default' => true,
),
Expand Down
23 changes: 10 additions & 13 deletions includes/media/class-view-analytics-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,22 @@ public function view_count_key() {
*/
public function view_count_show_user_list( $author_id ) {

$view = false;

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

if ( $this->get_view_setting_active( 'show_view_user_list' ) ) {

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

$view = apply_filters( $this->create_filter_key( 'show_view_user_list' ), $this->is_author( $author_id ) );
/**
* 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_user_list' ), $this->is_author( $author_id ) );
}

/**
Expand Down

0 comments on commit 46c3f44

Please sign in to comment.