Commit bb4b2134 authored by Art4's avatar Art4
Browse files

Unterstützung für WordPress Post-Status 'future'

parent beb80057
......@@ -237,7 +237,6 @@ function scrd_create_digest($preview=false) {
$content = '';
$posts = array();
$time_of_newest_item = 0;
......@@ -278,11 +277,10 @@ function scrd_create_digest($preview=false) {
$post_tags = '';
$post_format = 'link';
}
$content .= "\n\n" . scrd_theme_digest_post_content($item);
$title = $item->get_title();
$posts[] = array(
'post_content' => trim($content),
'post_title' => $wpdb->escape(html_entity_decode( $title, ENT_QUOTES ) ),
......@@ -295,95 +293,39 @@ function scrd_create_digest($preview=false) {
'post_format' => $post_format,
);
}
}
if(empty($posts))
if ( ! empty($posts) and get_option('scrd_post_status', SCRD_DEFAULT_STATUS) == 'future' )
{
$post_time = time();
$post_add_time = (int) floor(3600/count($posts));
for( $i = 0; $i < count($posts); $i++ )
{
$post_date = $post_time + mt_rand(60, $post_add_time);
$posts[$i]['post_date'] = date('Y-m-d H:i:s', $post_date);
$post_time += $post_add_time;
}
}
if ( empty($posts) )
{
scrd_debug_log('No new items for digest');
}
if ($preview)
{
return $posts;
return $posts;
}
else
{
scrd_set_last_item_time($feed_url, $time_of_newest_item);
scrd_debug_log("Created digest of " . count($posts) . " items");
scrd_debug_log("Created digest of " . count($posts) . " items");
}
return $posts;
//echo '<pre>'.print_r($subpattern, TRUE).'</pre>';
//*
// by default simple pie sorts reverse chronologically; first item is newest
$item = $rss->get_item();
$time_of_newest_item = $item->get_date('U');
scrd_debug_log("Fetched $max_items items");
if ($time_of_newest_item <= $feed_last_item_time) {
scrd_debug_log('No new items for digest');
$content = '<div>No new items for digest.</div>';
$title = '';
} else {
for ($item_index = 1; $item_index < $max_items; $item_index++) {
if ($item->get_date('U') <= $feed_last_item_time) {
break;
}
$content .= scrd_theme_digest_item($item);
$item = $rss->get_item($item_index);
}
$num_items_in_digest = $item_index;
if ($num_items_in_digest >= get_option('scrd_min_items', SCRD_MIN_ITEMS)) {
$content = scrd_theme_digest_list($content);
$content = scrd_add_header_footer($content);
$title = scrd_post_title();
} else {
$num_items_in_digest = 0;
scrd_debug_log('Not enough new items for digest');
$content = '<div>Not enough new items for digest.</div>';
$title = '';
}
}
if ($preview) {
return array(
'post_content' => $content,
'post_title' => $title,
);
}
if ($num_items_in_digest == 0) {
return array();
}
if (get_option('scrd_give_credit', 1) == 1) {
$content .= '<p class="scrd_credit">Digest powered by <a href="http://www.rssdigestpro.com">TTRSS-to-WP</a></p>'."\n";
if (SCRD_DEFAULT_ADD_CSS_CLEAR == 1) {
$content .= '<div style="clear:both"></div>'."\n";
}
}
$post_data = array(
'post_content' => $wpdb->escape($content),
'post_title' => $title,
'post_date' => date('Y-m-d H:i:s'),
'post_category' => array(get_option('scrd_post_category', SCRD_DEFAULT_CATEGORY)),
'post_status' => get_option('scrd_post_status', SCRD_DEFAULT_STATUS),
'post_author' => get_option('scrd_post_author', SCRD_DEFAULT_AUTHOR),
'tags_input' => get_option('scrd_post_tags',''),
);
scrd_set_last_item_time($feed_url, $time_of_newest_item);
scrd_debug_log("Created digest of $num_items_in_digest items");
return $post_data;
//*/
return $posts;
}
function scrd_post_title() {
......@@ -506,7 +448,7 @@ function scrd_options_tab() {
$cat_options .= "\n\t<option value='$cat_id' $selected>$cat_name</option>";
}
$statuses = array('draft','publish','pending');
$statuses = array('draft', 'publish', 'pending', 'future');
$status_options = '';
foreach ($statuses as $status) {
if ($status == get_option('scrd_post_status', SCRD_DEFAULT_STATUS)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment