Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix date check on dashboard.php for Enth3 inactive fanlistings
1) open dashboard.php, around line 130, find this:
$info = get_listing_info( $id );
$stats = get_listing_stats( $id );
// now check $lastupdated -- if more than 8 weeks ago, notify!
$weeks = 0;
2) under $weeks = 0;, add the following:
$lastupdated = new DateTime($stats['lastupdated']);
$currentdate = new DateTime();
3) a few lines below, find:
if( $stats['lastupdated'] == '' || // no last updated date
$weeks >= 8 ){
4) now replace:
$weeks >= 2 ){
with:
$lastupdated->diff($currentdate, true)->days > 55 ){
5) save and upload, check how many (almost) inactive fanlistings you have, yikes.
P.S.: in the end, your code block should look something like:
<?php
$owned = get_owned( 'current' );
$header = true;
foreach( $owned as $id ) {
$info = get_listing_info( $id );
$stats = get_listing_stats( $id );
// now check $lastupdated -- if more than 8 weeks ago, notify!
$weeks = 0;
$lastupdated = new DateTime($stats['lastupdated']);
$currentdate = new DateTime();
/* // OLD LEGACY CODE
if( $stats['lastupdated'] && date( 'Y' ) != date( 'Y', strtotime( $stats['lastupdated'] ) ) ) {
$weeks = ( 52 - date( 'W', strtotime( $stats['lastupdated'] ) ) ) + date( 'W' );
} else if( $stats['lastupdated'] ) {
$weeks = date( 'W' ) - date( 'W', strtotime( $stats['lastupdated'] ) );
}
*/
if( $stats['lastupdated'] == '' || // no last updated date
$lastupdated->diff($currentdate, true)->days > 55 ){
if( $header ) {
?>
<h2>Neglected Listings Notification</h2>
<p>The following listings have gone on two months without a
newly-approved member or a new/updated affiliate!</p>
<ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment