-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
3,410 additions
and
3,371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* global dokanPageViewsParams */ | ||
|
||
jQuery( document ).ready( function( $ ) { | ||
if( ! localStorage ) { | ||
return; | ||
} | ||
|
||
if ( ! window.dokanPageViewsParams ) { | ||
return; | ||
} | ||
|
||
// Get today's date in the format of YYYY-MM-DD | ||
let newDate = new Date().toISOString().slice(0, 10); | ||
let dokanPageViewCount = JSON.parse(localStorage.getItem("dokan_pageview_count")); | ||
|
||
// If there is no data in local storage or today's date is not same as the date in local storage. | ||
if ( dokanPageViewCount === null || ( dokanPageViewCount.today && dokanPageViewCount.today !== newDate ) ) { | ||
dokanPageViewCount = { "today": newDate, "post_ids": [] }; | ||
} | ||
|
||
// If the post id is not in the local storage, then send the ajax request. | ||
if ( ! dokanPageViewCount.post_ids.includes( window.dokanPageViewsParams.post_id ) ) { | ||
$.post( window.dokanPageViewsParams.ajax_url, { | ||
action: "dokan_pageview", | ||
_ajax_nonce: window.dokanPageViewsParams.nonce, | ||
post_id: window.dokanPageViewsParams.post_id, | ||
} ); | ||
|
||
// Add the post id to the local storage. | ||
dokanPageViewCount.post_ids.push( window.dokanPageViewsParams.post_id ); | ||
localStorage.setItem( "dokan_pageview_count", JSON.stringify( dokanPageViewCount ) ); | ||
} | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.