prefix . $tableName; return $wpdb->query('DELETE FROM ' . $wpTableName . ' WHERE hash="' . $hash . '"'); } return false; } /** * Delete all Rows from the Database which are older than the given timestamp and where the optin value matches as defined. * @param $timestamp * @param int $optin */ private function removeOlderThan($timestamp, $optin = 0) { global $wpdb; $tableName = 'f12_cf7_doubleoptin'; $wpTableName = $wpdb->prefix . $tableName; //$sql = 'DELETE FROM ' . $wpTableName . ' WHERE createtime < "' . $timestamp . '" AND doubleoptin="' . $optin . '"'; $wpdb->query('DELETE FROM ' . $wpTableName . ' WHERE createtime < "' . $timestamp . '" AND doubleoptin="' . $optin . '"'); } /** * Delete all DOI entries */ public function reset(){ global $wpdb; $tableName = 'f12_cf7_doubleoptin'; $wpTableName = $wpdb->prefix . $tableName; $wpdb->query('DELETE FROM ' . $wpTableName); } /** * Clear all unconfirmed database entries if the period selected * is reached. */ public function removeUnconfirmedOptins() { $Settings = CF7DoubleOptIn::getInstance()->getSettings(); if ($Settings['delete_unconfirmed'] == 0 || !is_numeric($Settings['delete_unconfirmed'])) { return; } $period = $Settings['delete_unconfirmed_period']; $timestamp = strtotime("- " . (int)$Settings['delete_unconfirmed'] . " ".$period, time()); $this->removeOlderThan($timestamp, 0); } /** * Clear all confimred database entries if the period selected * is reached. */ public function removeConfirmedOptins() { $Settings = CF7DoubleOptIn::getInstance()->getSettings(); if ($Settings['delete'] == 0 || !is_numeric($Settings['delete'])) { return; } $period = $Settings['delete_period']; $timestamp = strtotime("- " . (int)$Settings['delete'] . " ".$period, time()); $this->removeOlderThan($timestamp, 1); } } }