-
Notifications
You must be signed in to change notification settings - Fork 0
/
wap-comments.php
53 lines (47 loc) · 2.52 KB
/
wap-comments.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
### Tells WordPress to load the WordPress theme and output it.
define( 'WP_USE_THEMES', false );
### Loads the WordPress Environment and Template
require( './wp-blog-header.php' );
### Remove WordPress Footer
remove_all_actions( 'wp_footer' );
remove_all_actions( 'loop_end' );
### Set Header To WML
header( 'Content-Type: text/vnd.wap.wml;charset=utf-8' );
### Get Post ID
$id = intval($_GET['id']);
### If $p Is Not Empty
if ($id > 0) {
$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_content, comment_post_ID, $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments LEFT JOIN $wpdb->posts ON comment_post_ID = ID WHERE comment_post_ID = '$id' AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish' AND post_date < '".current_time('mysql')."' ORDER BY comment_date");
$post = $wpdb->get_row("SELECT post_title, comment_status FROM $wpdb->posts WHERE ID = '$id' AND post_date < post_date < '".current_time('mysql')."' AND post_status = 'publish'");
### Else Display Last 10 Comments
} else {
$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_content, comment_post_ID, $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->comments.comment_approved = '1' AND post_date < '".current_time('mysql')."' ORDER BY comment_date DESC LIMIT 10");
$post = $wpdb->get_row("SELECT post_title, comment_status FROM $wpdb->posts WHERE post_date < '".current_time('mysql')."' AND post_status = 'publish' ORDER BY post_date DESC");
}
### Echo XML
echo '<?xml version="1.0" encoding="utf-8"?'.'>';
?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD WML 2.0//EN" "http://www.wapforum.org/dtd/wml20.dtd">
<wml>
<card id="WordPress" title="<?php bloginfo_rss('name'); ?>">
<p>Comments On <?php the_title_rss(); ?></p>
<br />
<?php if ($comments) : ?>
<?php foreach ($comments as $comment) : ?>
<p>> <?php comment_author_rss() ?></p>
<p>> <?php comment_time(get_option('date_format').' ('.get_option('time_format').')'); ?></p>
<p><?php comment_text_rss() ?></p>
<br />
<?php endforeach; ?>
<?php else : ?>
<?php if ('open' === $post->comment_status) : ?>
<p>No Comments Are Posted Yet.</p>
<?php else : ?>
<p>Comments Are Closed.</p>
<?php endif; ?>
<?php endif; ?>
<br />
<p><a href="wap.php"><< <?php bloginfo_rss('name'); ?></a></p>
</card>
</wml>