get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}mce WHERE import_date >= FROM_UNIXTIME(%s) AND import_date <= FROM_UNIXTIME(%s) ORDER BY comment_date " . ($mce_options['digest_order'] == 1 ? "DESC" : "ASC") . ($mce_options['digest_max_comments'] ? " LIMIT " . $mce_options['digest_max_comments'] : ""), $start_time, $end_time)); if (empty($comments)) { return; } else if (count($comments) < $mce_options['digest_min_comments']) { if (empty($mce_options['digest_start_time'])) { $mce_options['digest_start_time'] = $start_time; update_option('mce_options', $mce_options); } return; } $date_format = get_option('date_format'); $time_format = get_option('time_format'); $content = ''; foreach ($comments as $comment) { $comment->comment_date = strtotime($comment->comment_date_gmt) + $gmt_offset; $content .= '
' . ($comment->post_title ? $comment->post_title : 'No title') . ''; if ($mce_options['date_format']) { $content .= '' . date($date_format, $comment->comment_date) . ' at ' . date($time_format, $comment->comment_date) . ''; } $content .= '
' . $comment->comment_content . '
'; if ($mce_options['include_action_links']) { $content .= '

' . $reply . ' | | ' . $tweet . '

'; } $content .= '
'; } if ($mce_options['itw_link'] || $mce_options['service_link'] || $mce_options['rss_feed']) { $content .= '

'; if ($mce_options['itw_link']) { $content .= 'Plugin by Improving The Web'; if ($mce_options['service_link'] || $mce_options['rss_feed']) { $content .= ' - '; } } if ($mce_options['service_link']) { if ($mce_options['type'] == 'backtype') { $content .= 'Powered by Backtype'; } else { $content .= 'Powered by CoComment'; } if ($mce_options['rss_feed']) { $content .= ' - '; } } if ($mce_options['rss_feed']) { $content .= 'Subscribe'; } $content .= '

'; } $title_search = array('[day]', '[week]', '[month]', '[year]', '[date]'); $title_replace = array(date('D', $start_time), date('jS F', $start_time) . ' - ' . date('jS F', $end_time), date('M', $start_time), date('Y', $start_time), date('F jS, Y', $start_time)); $post = array(); $post['post_content'] = $content; $post['post_title'] = str_replace($title_search, $title_replace, $mce_options['digest_title']); $post['post_date'] = date('Y-m-d h:i:s', time()); //date('Y-m-d 23:59:59') $post['post_date_gmt'] = get_gmt_from_date($post['post_date']); $post['comment_status'] = 'open'; $post['ping_status'] = 'open'; $post['post_status'] = 'publish'; $post['post_author'] = $wpdb->get_var("SELECT user_id from $wpdb->usermeta WHERE meta_key = 'wp_capabilities' and meta_value LIKE '%administrator%' order by user_id asc limit 1"); if ($mce_options['digest_tags']) { $post['tags_input'] = $mce_options['digest_tags']; } wp_insert_post($post); if (!empty($mce_options['digest_start_time'])) { unset($mce_options['digest_start_time']); update_option('mce_options', $mce_options); } } ?>