Skip to content

Commit

Permalink
Add media setting
Browse files Browse the repository at this point in the history
  • Loading branch information
raftaar1191 committed Nov 30, 2023
1 parent 666b56f commit 824f96a
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 79 deletions.
12 changes: 12 additions & 0 deletions admin/menu/class-view-analytics-settings-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ public function media_settings() {
'id' => 'main',
'default' => true,
),
array(
'type' => 'toggle',
'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' ),
'id' => 'show_view_user_list',
'default' => true,
),
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion assets/dist/css/frontend-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
margin-bottom: 0px;
}

#view_list.view-analytics-media-views span {
.view-analytics-media-views span {
background: #f2f2f2;
border-radius: 10px;
padding: 5px 10px;
Expand Down
42 changes: 0 additions & 42 deletions assets/dist/js/backend-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,6 @@
var __webpack_exports__ = {};
jQuery(function($) {


/**
* For all Media Type
*/
const all_media_type = document.getElementById('all-media-type');

new Chart(all_media_type, {
type: 'bar',
data: {
labels: view_analytics_media_view.all_media_type.media_label,
datasets: [{
label: view_analytics_media_view.all_media_type.label,
data: view_analytics_media_view.all_media_type.count,
backgroundColor: [
'rgb(255, 99, 132)',
'rgb(54, 162, 235)',
'rgb(255, 205, 86)'
],
}],
hoverOffset: 4,
options: {
legend: {
display: false
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
},
onClick: function (e) {
debugger;
var activePointLabel = this.getElementsAtEvent(e)[0]._model.label;
alert(activePointLabel);
}
}
}
});



/**
* For all Media View Type
*/
Expand Down
2 changes: 1 addition & 1 deletion assets/src/frontend/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}
}

#view_list.view-analytics-media-views {
.view-analytics-media-views {
span{
background: #f2f2f2;
border-radius: 10px;
Expand Down
41 changes: 40 additions & 1 deletion includes/media/class-view-analytics-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,47 @@ public function view_count_key() {
/**
* Return the View Analytics Media Count Key
*/
public function get_view_setting() {
return get_option( $this->view_count_key(), false );
}

/**
* Return the View Analytics Media Count Key
*/
public function get_view_setting_active( $key ) {
$settings = $this->get_view_setting();
return empty( $settings[ $key ] ) ? false : $settings[ $key ];
}

/**
* Return the View Analytics Media Count Key
*/
public function view_count_enable() {
return get_option( $this->view_count_key(), true );
return $this->get_view_setting_active( 'main' );
}

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

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

return $this->get_view_setting_active( 'show_view_count' );
}

/**
* Return the View Analytics Media show the user view list
*/
public function view_count_show_user_list() {

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

return $this->get_view_setting_active( 'show_view_user_list' );
}

/**
Expand Down
5 changes: 4 additions & 1 deletion includes/media/class-view-analytics-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ public function permissions_check( $request ) {


$this->common = View_Analytics_Media_Common::instance();
if( ! empty( $this->common->can_current_user_view_list( $key_id ) ) ) {
if(
! empty( $this->common->view_count_show_user_list() )
&& ! empty( $this->common->can_current_user_view_list( $key_id ) )
) {
return true;
}

Expand Down
70 changes: 41 additions & 29 deletions languages/view-analytics.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2023-11-26 04:29+0000\n"
"POT-Creation-Date: 2023-11-30 17:58+0000\n"
"Report-Msgid-Bugs-To: https://github.com/acrosswp/view-analytics/issues\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
Expand All @@ -15,55 +15,67 @@ msgstr ""
"X-Poedit-SourceCharset: UTF-8\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: admin/class-view-analytics-admin.php:129, admin/menu/class-view-analytics-settings-menu.php:110, admin/menu/class-view-analytics-settings-menu.php:111
#: admin/class-view-analytics-admin.php:136, admin/menu/class-view-analytics-settings-menu.php:212, admin/menu/class-view-analytics-settings-menu.php:213
msgid "Settings"
msgstr ""

#: admin/class-view-analytics-admin.php:130
#: admin/class-view-analytics-admin.php:137
msgid "About"
msgstr ""

#: admin/menu/class-view-analytics-main-menu.php:64, admin/menu/class-view-analytics-main-menu.php:65, admin/menu/class-view-analytics-settings-menu.php:117
#: admin/menu/class-view-analytics-main-menu.php:76
msgid "Abouts"
msgstr ""

#: admin/menu/class-view-analytics-main-menu.php:77
msgid "View Analytics"
msgstr ""

#: admin/menu/class-view-analytics-media-menu.php:76, admin/menu/class-view-analytics-media-menu.php:77
msgid "Media Analytics"
#: admin/menu/class-view-analytics-settings-menu.php:103, admin/menu/class-view-analytics-settings-menu.php:220
msgid "View Media Analytics"
msgstr ""

#: admin/menu/class-view-analytics-settings-menu.php:118
#: admin/menu/class-view-analytics-settings-menu.php:104
msgid "Enable Media View Count"
msgstr ""

#: admin/menu/class-view-analytics-settings-menu.php:123
#: admin/menu/class-view-analytics-settings-menu.php:110
msgid "Show Media View Count in Public"
msgstr ""

#: admin/menu/class-view-analytics-settings-menu.php:116
msgid "Show Media View User Lists when someone click on the views button"
msgstr ""

#: admin/menu/class-view-analytics-settings-menu.php:133, admin/menu/class-view-analytics-settings-menu.php:226
msgid "View Profile Count"
msgstr ""

#: admin/menu/class-view-analytics-settings-menu.php:124
#: admin/menu/class-view-analytics-settings-menu.php:134
msgid "Enable Profile View Count"
msgstr ""

#: admin/menu/class-view-analytics-settings-menu.php:129
#: admin/menu/class-view-analytics-settings-menu.php:151, admin/menu/class-view-analytics-settings-menu.php:232
msgid "View Group Count"
msgstr ""

#: admin/menu/class-view-analytics-settings-menu.php:130
#: admin/menu/class-view-analytics-settings-menu.php:152
msgid "Enable Group View Count"
msgstr ""

#: admin/menu/class-view-analytics-settings-menu.php:135
#: admin/menu/class-view-analytics-settings-menu.php:169, admin/menu/class-view-analytics-settings-menu.php:238
msgid "View Avatar Count"
msgstr ""

#: admin/menu/class-view-analytics-settings-menu.php:136
#: admin/menu/class-view-analytics-settings-menu.php:170
msgid "Enable Avatar View Count"
msgstr ""

#: admin/menu/class-view-analytics-settings-menu.php:141
#: admin/menu/class-view-analytics-settings-menu.php:187, admin/menu/class-view-analytics-settings-menu.php:244
msgid "View Forum/Topic/Reply Count"
msgstr ""

#: admin/menu/class-view-analytics-settings-menu.php:142
#: admin/menu/class-view-analytics-settings-menu.php:188
msgid "Enable Forum/Topic/Reply View Count"
msgstr ""

Expand Down Expand Up @@ -93,15 +105,15 @@ msgstr ""
msgid "%s saw your profile %s %s."
msgstr ""

#: includes/media/class-view-analytics-common.php:257
#: includes/media/class-view-analytics-common.php:296
msgid "viewed this %s ago."
msgstr ""

#: includes/media/class-view-analytics-common.php:288
#: includes/media/class-view-analytics-common.php:327
msgid "All Media View Type"
msgstr ""

#: includes/media/class-view-analytics-common.php:326, includes/media/class-view-analytics-common.php:364
#: includes/media/class-view-analytics-common.php:365, includes/media/class-view-analytics-common.php:403
msgid "All Media Type"
msgstr ""

Expand All @@ -113,49 +125,49 @@ msgstr ""
msgid "Invalid Attachment ID."
msgstr ""

#: includes/media/class-view-analytics-rest-api.php:235
#: includes/media/class-view-analytics-rest-api.php:252
msgid "Unique identifier for the object."
msgstr ""

#: includes/media/class-view-analytics-rest-api.php:239
#: includes/media/class-view-analytics-rest-api.php:256
msgid "The id of the user object"
msgstr ""

#: includes/media/class-view-analytics-rest-api.php:243, includes/media/class-view-analytics-rest-api.php:251
#: includes/media/class-view-analytics-rest-api.php:260, includes/media/class-view-analytics-rest-api.php:268
msgid "Unique identifier for the attachment."
msgstr ""

#: includes/media/class-view-analytics-rest-api.php:247
#: includes/media/class-view-analytics-rest-api.php:264
msgid "Unique identifier for the BB media."
msgstr ""

#: includes/media/class-view-analytics-rest-api.php:255
#: includes/media/class-view-analytics-rest-api.php:272
msgid "The Link of the User Profile Picture."
msgstr ""

#: includes/media/class-view-analytics-rest-api.php:259
#: includes/media/class-view-analytics-rest-api.php:276
msgid "The Link of the User Profile."
msgstr ""

#: includes/media/class-view-analytics-rest-api.php:263
#: includes/media/class-view-analytics-rest-api.php:280
msgid "The display name of the users."
msgstr ""

#: includes/media/class-view-analytics-rest-api.php:267
#: includes/media/class-view-analytics-rest-api.php:284
msgid "The message that need to be diplay."
msgstr ""

#: includes/media/class-view-analytics-rest-api.php:271
#: includes/media/class-view-analytics-rest-api.php:288
msgid "The date on which the user view the Media"
msgstr ""

#: public/class-view-analytics-public.php:204
#: public/class-view-analytics-public.php:203
msgid "View"
msgid_plural "Views"
msgstr[0] ""
msgstr[1] ""

#: public/class-view-analytics-public.php:225, public/class-view-analytics-public.php:240
#: public/class-view-analytics-public.php:228, public/class-view-analytics-public.php:243
msgid "People Who viewed This"
msgstr ""

Expand Down
12 changes: 8 additions & 4 deletions public/class-view-analytics-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function buddypress_show_view_count() {
*/
public function buddyboss_show_view_count() {

if ( $this->media_common->view_count_enable() ) {
if ( $this->media_common->view_count_show_view_count() ) {

$ajax_action = $this->media_common->is_lightbox_ajax();

Expand Down Expand Up @@ -203,10 +203,14 @@ public function show_view_count( $key_id ) {
$view = _n( 'View', 'Views', $counts, 'view-analytics' );
$counts = apply_filters( 'view_analytics_view_count_content', array( 'count' => $counts, 'text' => $view ), $key_id );

if( $this->media_common->can_current_user_view_list( $key_id ) ) {
echo "<div id='view_list' class='view-analytics-media-views'><span current-media-view='". $key_id ."'>" . implode( ' ', $counts ) . '</span> </div>';
} else {
if(
! $this->media_common->view_count_show_user_list()
||
! $this->media_common->can_current_user_view_list( $key_id )
) {
echo "<div class='view-analytics-media-views'><span>" . implode( ' ', $counts ) . '</span></div>';
} else {
echo "<div id='view_list' class='view-analytics-media-views'><span current-media-view='". $key_id ."'>" . implode( ' ', $counts ) . '</span> </div>';
}
}

Expand Down

0 comments on commit 824f96a

Please sign in to comment.