get_results("show tables like '{$tp}term_taxonomy'");
if (count($wpv) > 0) {
$ver = 2.3;
}
$tp = $wpdb->prefix;
$the_cat = '';
$tmp_array = (array)explode(',', trim(get_option('ddps_cat'), ','));
if (count($tmp_array) > 0) {
$the_cat = '(' . trim(get_option('ddps_cat'), ',') . ')';
}
if ($the_cat == "") {
$oldest_post = $wpdb->get_var("
SELECT ID
FROM {$tp}posts
WHERE post_type = 'post'
AND post_status = 'publish'
GROUP BY post_date asc
");
} else {
if ($ver < 2.3) {
$oldest_post = $wpdb->get_var("
SELECT ID
FROM {$tp}posts, {$tp}post2cat
WHERE {$tp}post2cat.category_id IN " . $the_cat . "
AND post_type = 'post'
AND {$tp}posts.post_status = 'publish'
AND {$tp}post2cat.post_id = {$tp}posts.ID
GROUP BY post_date asc
");
} else { // post 2.3+
$oldest_post = $wpdb->get_var("
SELECT ID
FROM {$tp}posts, {$tp}term_relationships, {$tp}term_taxonomy
WHERE {$tp}term_taxonomy.term_id IN " . $the_cat . "
AND {$tp}term_taxonomy.term_taxonomy_id = {$tp}term_relationships.term_taxonomy_id
AND {$tp}term_relationships.object_id = {$tp}posts.ID
AND {$tp}posts.post_type = 'post'
AND {$tp}posts.post_status = 'publish'
GROUP BY post_date asc
");
}
}
$new_time = date('Y-m-d H:i:s');
$wpdb->query("UPDATE $wpdb->posts SET post_date = '$new_time' WHERE ID = '$oldest_post'");
}
function more_reccurences() {
return array(
'ddps_schedule' => array('interval' => ((int)get_option('ddps_delay') * 3600), 'display' => 'Post Shift Schedule')
);
}
add_filter('cron_schedules', 'more_reccurences');
?>