604800, 'display' => __('Once Weekly')); return $schedule; } function mce_import_cron() { require MCE_DIR . '/import.php'; mce_import(); } function mce_digest_cron() { require MCE_DIR . '/digest.php'; mce_digest(); } function mce_head() { if (!is_admin()) { echo '' . "\n"; } } function mce_tweet() { global $wpdb; $comment = $wpdb->get_row($wpdb->prepare("SELECT comment_url, blog_url FROM {$wpdb->prefix}my_comments WHERE comment_ID = %d", $_GET['mce_tweet'])); if ($comment) { require MCE_DIR . '/import.php'; $result = mce_url_open('http://tinyurl.com/api-create.php?url=' . $comment->comment_url); wp_redirect('http://twitter.com/home?status=' . urlencode('Check this comment out ' . $result['body'] . ($comment->blog_url ? ' at ' . $comment->blog_url : ''))); die(); } else { wp_die('Invalid comment.'); } } function mce_list_comments($atts) { global $wpdb, $post, $mce_options; if (empty($mce_options)) { $mce_options = get_option('mce_options'); } if (!is_page()) { return '
' . __('You should add the shortcode to a page, not a post.', 'mce') . '
'; } $post->comment_status = 'closed'; $post->ping_status = 'closed'; if ($post->comment_count > 0) { $post->comment_count = 0; add_filter('comments_array', 'array'); //is this correct? } $mce_options['comments_per_page'] = (int) $mce_options['comments_per_page']; if (empty($mce_options['comments_per_page'])) { $mce_options['comments_per_page'] = get_option('comments_per_page'); } if ($mce_options['comments_per_page'] < 0) { $mce_options['comments_per_page'] = absint($mce_options['comments_per_page']); } if (empty($mce_options['page_url']) || $mce_options['page_url'] != get_permalink()) { $mce_options['page_url'] = get_permalink(); update_option('mce_options', $mce_options); } if (isset($_GET['cp'])) { $page = absint($_GET['cp']); if ($page <= 1 || $page != $_GET['cp']) { wp_redirect(get_permalink()); die(); } } else { $_GET['cp'] = 1; $page = 1; } $permalink = get_permalink(); $qs = (strpos($permalink, '?') !== false ? '&' : '?'); $comments = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}my_comments ORDER BY comment_date DESC LIMIT " . (($page-1) * $mce_options['comments_per_page']) . ", " . $mce_options['comments_per_page']); $content = ''; if (empty($comments)) { status_header(404); if ($page > 1) { $content .= '' . __('Page not found.', 'mce') . '
'; } else { $content .= '' . __('No comments yet.', 'mce') . '
'; } } else { $reply = __('Reply', 'mce'); $share = __('Share', 'mce'); $tweet = __('Tweet', 'mce'); $reply_to_this_comment = __('Reply to this comment', 'mce'); $read_this_comment = __('Read this comment', 'mce'); $email_this_comment = __('Email this comment', 'mce'); $post_on_twitter = __('Post on Twitter', 'mce'); $no_follow = (!$mce_options['dofollow_links'] ? ' rel="nofollow"' : ''); $new_window = ($mce_options['open_links_in_new_window'] ? ' target="_blank"' : ''); $gmt_offset = get_option('gmt_offset') * 3600; if ($mce_options['date_format']) { $date_format = get_option('date_format'); $time_format = get_option('time_format'); } foreach ($comments as $comment) { $comment->comment_date = strtotime($comment->comment_date_gmt) + $gmt_offset; $content .= '' . mce_mce_pagination() . '
'; 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 .= '
'; } } return $content; } function mce_mce_pagination() { global $mce_options; if (empty($mce_options)) { $mce_options = get_option('mce_options'); } $nr_pages = ceil($mce_options['comments_count'] / $mce_options['comments_per_page']); if ($nr_pages <= 1) { return; } $permalink = get_permalink(); if (strpos($permalink, '?') !== false) { $paged_permalink = $permalink . '&cp='; } else { $paged_permalink = $permalink . '?cp='; } $permalink = clean_url($permalink); $paged_permalink = clean_url($paged_permalink); $page = $_GET['cp']; $output = ''; if ($page > 1) { $before = $page - 4; $before = $before < 1 ? 1 : $before; $output .= '« ' . __('first', 'mce') . ' '; $output .= '‹ ' . __('previous', 'mce') . ' '; if ($before > 1) { $output .= ' … '; } for ($i=$before; $i<$page; $i++) { $output .= '' . $i . ' '; } } $output .= '' . $page . ' '; if ($page < $nr_pages) { $after = $page + 4; $after = $after > $nr_pages ? $nr_pages : $after; for ($i=$page+1; $i<=$after; $i++) { $output .= '' . $i . ' '; } } if ($page < $nr_pages) { if ($after < $nr_pages) { $output .= ' … '; } $output .= '' . __('next', 'mce') . ' › '; $output .= '' . __('last', 'mce') . ' » '; } return $output; } function mce_widget_init() { if (!function_exists('register_sidebar_widget')) { return; } function mce_widget($args) { extract($args); global $mce_options; if (empty($mce_options)) { $mce_options = get_option('mce_options'); } if (empty($mce_options['widget_title'])) { $mce_options['widget_title'] = __('My Comments', 'mce'); } if (empty($mce_options['widget_cache'])) { global $wpdb; $mce_options['widget_cache'] = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}my_comments ORDER BY comment_date DESC LIMIT %d", $mce_options['widget_max_comments'])); update_option('mce_options', $mce_options); } echo $before_widget; echo $before_title . $mce_options['widget_title'] . $after_title; echo '
' . $reply . ' | ' . $share . ' | ' . $tweet . '
'; } $content .= '