base = $base; $this->admin = $base->admin; $this->referer = $this->admin->get_referer(); if ( '' != wp_get_original_referer() ) { $this->referer = wp_get_original_referer(); } $this->referer = remove_query_arg( array('approved', 'unapproved', 'spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids'), $this->referer ); global $action; wp_reset_vars(array('action')); if ( 'cdc' == $action ) { $action = 'delete'; } elseif ( 'mac' == $action ) { $action = 'approve'; } if ( isset( $_GET['dt'] ) ) { if ( 'spam' == $_GET['dt'] ) { $action = 'spam'; } elseif ( 'trash' == $_GET['dt'] ) { $action = 'trash'; } } switch($action) { case 'spam': case 'approve': case 'delete': case 'trash': $this->confirm($action); break; case 'editcomment': $this->edit_form(); break; case 'deletecomment': case 'trashcomment': case 'untrashcomment': case 'spamcomment': case 'unspamcomment': $this->delete_comment($action); exit(); case 'approvecomment': case 'unapprovecomment': $this->approve_comment($action); exit(); case 'editedcomment': $this->edited_comment(); exit(); default: break; } } // ================================================== private function edit_form() { global $user_ID, $title; $comment = intval($_GET['c']); if (! $comment = get_comment($comment)) { $this->base->ks_die(__('Oops, no comment with this ID.')); } if (! current_user_can('edit_post', $comment->comment_post_ID)) { $this->base->ks_die(__('You are not allowed to edit comments on this post.')); } $comment = get_comment_to_edit($comment); $title = sprintf(__('Editing Comment # %s'), $comment->comment_ID); include dirname(__FILE__) . '/admin-header.php'; $submitbutton_text = __('Edit Comment'); $form_action = 'editedcomment'; $form_extra = ''; ?>
admin->sid_field(); ks_fix_encoding_form(); wp_nonce_field('update-comment_' . $comment->comment_ID, "_wpnonce", false); ?>







admin->the_editor($comment->comment_content, 6, 4); $id = $this->base->ktai->read_term_id($comment); if (count($id)) { if ($id[0]) { echo '·' . sprintf(__('Term ID: %s', 'ktai_style'), esc_attr($id[0])) . '
'; } if ($id[1]) { echo '·' . sprintf(__('USIM ID: %s', 'ktai_style'), esc_attr($id[1])) . '
'; } if ($id[2]) { echo '·' . sprintf(__('Sub ID: %s', 'ktai_style'), esc_attr($id[2])) . '
'; } } ?>
comment_approved, '1'); ?> /> Approved', 'ktai_style'), 'green'); ?> comment_approved, '0'); ?> /> Pending', 'ktai_style'), '#ff9900'); ?> comment_approved, 'spam'); ?> /> Spam', 'ktai_style'), 'red'); ?>
base->strip_host($this->referer); if ($referer) { printf(__('Cancel Edit', 'ktai_style'), esc_attr($referer) ); ?>
comment_ID, $orig_referer ); $delete_url = wp_nonce_url($delete_url, 'delete-comment_' . $comment->comment_ID); } else { $button = __('Delete Comment'); $delete_url = sprintf('comment.php?action=deletecomment&c=%d%s', $comment->comment_ID, $orig_referer ); } ?>
base->ks_die(__('Oops, no comment with this ID.') . sprintf(' ' . __('Go back') . '', 'edit-comments.php' ), '', false); } if (! current_user_can('edit_post', $comment->comment_post_ID)) { $this->base->ks_die('delete' == $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.')); } include dirname(__FILE__) . '/admin-header.php'; switch ($action) { case 'spam': $message = __('You are about to mark the following comment as spam:'); break; case 'trash': $message = __('You are about to move the following comment to the Trash:', 'ktai_style'); break; case 'delete': $message = __('You are about to delete the following comment:'); break; default: $message = __('You are about to approve the following comment:'); break; } echo '

' . $message . '
' . __('Are you sure you want to do this?') . '

'; ?>
admin->sid_field(); ?>
admin->sid_field(); wp_nonce_field($nonce_action); ?>
[<?php comment_type(__('Comment', 'ktai_style'), __('Trackback'), __('Pingback')); ?>]  @
comment_author_email) { ?>
comment_author_url && 'http://' != $comment->comment_author_url) { ?>
base->ks_die(__('Oops, no comment with this ID.') . sprintf(' '.__('Go back').'!', 'edit-comments.php'), '', false); //exit; } if (! current_user_can('edit_post', $comment->comment_post_ID) ) { $this->base->ks_die(__('You are not allowed to edit comments on this post.')); } $redir = $this->referer; if ( empty($redir) || $noredir || false !== strpos($redir, 'comment.php')) { $redir = 'edit-comments.php'; } switch ( $action ) { case 'deletecomment': wp_delete_comment($comment_id); $redir = add_query_arg( array( 'deleted' => 1 ), $redir ); break; case 'trashcomment': if (function_exists('wp_trash_comment')) { wp_trash_comment($comment_id); $redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir ); } break; case 'untrashcomment': if (function_exists('wp_untrash_comment')) { wp_untrash_comment($comment_id); $redir = add_query_arg( array('untrashed' => '1'), $redir ); } break; case 'spamcomment': if (function_exists('wp_spam_comment')) { wp_spam_comment($comment_id); } else { wp_set_comment_status($comment_id, 'spam'); } $redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir ); break; case 'unspamcomment': if (function_exists('wp_spam_comment')) { wp_unspam_comment($comment_id); $redir = add_query_arg( array('unspammed' => '1'), $redir ); } break; } $this->admin->redirect($redir); exit; } // ================================================== private function approve_comment($action) { $comment_id = intval($_GET['c']); check_admin_referer('approve-comment_' . $comment_id); $noredir = isset($_GET['noredir']); if ( !$comment = get_comment($comment_id) ) { $this->base->ks_die(__('Oops, no comment with this ID.') . sprintf(' '.__('Go back').'!', 'edit-comments.php'), '', false); } if ( !current_user_can('edit_post', $comment->comment_post_ID) ) { if ( 'approvecomment' == $action ) { $this->base->ks_die(__('You are not allowed to edit comments on this post, so you cannot approve this comment.')); } else { $this->base->ks_die(__('You are not allowed to edit comments on this post, so you cannot disapprove this comment.')); } // exit; } $redir = $this->referer; if ( empty($redir) || $noredir ) { $redir = 'edit-comments.php?p=' . intval($comment->comment_post_ID); } if ( 'approvecomment' == $action ) { wp_set_comment_status($comment_id, 'approve'); $redir = add_query_arg( array( 'approved' => 1 ), $redir ); } else { wp_set_comment_status($comment_id, 'hold'); $redir = add_query_arg( array( 'unapproved' => 1 ), $redir ); } if ( get_option('comments_notify')) { wp_notify_postauthor($comment->comment_ID); } $this->admin->redirect($redir); exit; } // ================================================== private function edited_comment() { $comment_ID = intval($_POST['comment_ID']); $comment_post_ID = intval($_POST['comment_post_ID']); check_admin_referer('update-comment_' . $comment_ID); $this->edit_comment($comment_ID, $comment_post_ID); $location = ( empty($_POST['referredby']) ? "edit-comments.php?p=$comment_post_ID" : $_POST['referredby'] ); $location = apply_filters('comment_edit_redirect', $location, $comment_ID); $this->admin->redirect($location); } /* ================================================== * @param none * @return none * based on edit_post() at wp-admin/includes/post.php of WP 2.3 */ private function edit_comment($comment_ID, $comment_post_ID) { if (! current_user_can('edit_post', $comment_post_ID)) { $this->base->ks_die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.')); } $charset = ks_detect_encoding(); if ( !$this->base->get('encoding_converted') ) { foreach ( array('newcomment_author','content') as $f) { $_POST[$f] = $this->base->decode_from_ktai($_POST[$f], $charset); } } $comment_data = array(); $comment_data['comment_author'] = trim(strip_tags($_POST['newcomment_author'])); $comment_data['comment_author_email'] = trim(strip_tags($_POST['newcomment_author_email'])); $comment_data['comment_author_url'] = trim(strip_tags($_POST['newcomment_author_url'])); $comment_data['comment_approved'] = trim(strip_tags($_POST['comment_status'])); $comment_data['comment_content'] = trim( $_POST['content']); $comment_data['comment_ID'] = intval($_POST['comment_ID']); wp_update_comment($comment_data); } // ===== End of class ==================== } ?>