Esempio n. 1
0
/**
 * @since 3.0.2
 */
function awpcp_clean_up_non_verified_ads($listings, $settings)
{
    global $wpdb;
    if (!$settings->get_option('enable-email-verification')) {
        return;
    }
    $resend_email_threshold = $settings->get_option('email-verification-first-threshold');
    $delete_ads_threshold = $settings->get_option('email-verification-second-threshold');
    // delete Ads that have been in a non-verified state for more than M days
    $conditions = AWPCP_Ad::get_where_conditions_for_successfully_paid_listings(array('verified = 0', $wpdb->prepare('ad_postdate < ADDDATE( NOW(), INTERVAL -%d DAY )', $delete_ads_threshold)));
    foreach (AWPCP_Ad::find(join(' AND ', $conditions)) as $ad) {
        $ad->delete();
    }
    // re-send verificaiton email for Ads that have been in a non-verified state for more than N days
    $conditions = AWPCP_Ad::get_where_conditions_for_successfully_paid_listings(array('verified = 0', $wpdb->prepare('ad_postdate < ADDDATE( NOW(), INTERVAL -%d DAY )', $resend_email_threshold)));
    foreach (AWPCP_Ad::find(join(' AND ', $conditions)) as $ad) {
        if (intval(awpcp_get_ad_meta($ad->ad_id, 'verification_emails_sent', true)) <= 1) {
            $listings->send_verification_email($ad);
        }
    }
}