/
admin-comments.php
43 lines (36 loc) · 1.11 KB
/
admin-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
<?php
function jobman_comments( $iid, $editable = false ) {
if( $editable ) {
?>
<form action="" method="post">
<input type="hidden" name="interview" value="<?php echo $iid ?>" />
<textarea class="large-text code" name="comment"></textarea>
<input type="submit" name="submit" value="<?php _e( 'Comment', 'jobman' )?>" />
</form>
<?php
}
$comments = get_comments( "post_id=$iid" );
jobman_display_comments( $comments );
}
function jobman_display_comments( $comments ) {
if( empty( $comments ) ) {
echo '<p class="error">' . __( 'No comments found', 'jobman' ) . '</p>';
return;
}
foreach( $comments as $comment ) {
$author = get_userdata( $comment->user_id );
echo "<br/><strong>$comment->comment_date - $author->user_nicename</strong><br/>";
echo wpautop( $comment->comment_content );
}
}
function jobman_store_comment() {
global $current_user;
get_currentuserinfo();
$comment = array(
'comment_post_ID' => $_REQUEST['interview'],
'comment_content' => $_REQUEST['comment'],
'user_id' => $current_user->ID
);
wp_insert_comment( $comment );
}
?>