public static function edit_notification($commentID = 0, $postID = 0) { global $wpdb, $aecomments; //Check admin options and also if user editing is post author if ($aecomments->get_admin_option('email_edits') == "false") { return false; } //Get the comment and post $comment = get_comment($commentID, ARRAY_A); if (empty($comment)) { return false; } $query = "SELECT * FROM {$wpdb->posts} WHERE ID={$postID}"; $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE ID=%d", $postID), ARRAY_A); if (!$post) { return false; } if (AECCore::is_comment_owner($postID)) { return false; } //Make sure the comment is approved and not a trackback/pingback if ($comment['comment_approved'] == '1' && ($comment['comment_type'] != 'pingback' || $comment['comment_type'] != 'trackback')) { //Put together the e-mail message $message = sprintf(__("A comment has been edited on post %s", 'ajaxEdit') . ": \n%s\n\n", stripslashes($post['post_title']), get_permalink($comment['comment_post_ID'])); $message .= sprintf(__("Author: %s\n", 'ajaxEdit'), $comment['comment_author']); $message .= sprintf(__("Author URL: %s\n", 'ajaxEdit'), stripslashes($comment['comment_author_url'])); $message .= sprintf(__("Author E-mail: %s\n", 'ajaxEdit'), stripslashes($comment['comment_author_email'])); $message .= __("Comment:\n", 'ajaxEdit') . stripslashes($comment['comment_content']) . "\n\n"; $message .= __("See all comments on this post here:\n", 'ajaxEdit'); $message .= get_permalink($comment['comment_post_ID']) . "#comments\n\n"; $subject = sprintf(__('New Edited Comment On: %s', 'ajaxEdit'), stripslashes($post['post_title'])); $subject = '[' . get_bloginfo('name') . '] ' . $subject; $email = get_bloginfo('admin_email'); $site_name = str_replace('"', "'", get_bloginfo('name')); $charset = get_option('blog_charset'); $headers = "From: \"{$site_name}\" <{$email}>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: text/plain; charset=\"{$charset}\"\n"; //Send the e-mail return wp_mail($email, $subject, $message, $headers); } return false; }
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php AECCSS::output_interface_css(); AECJS::register_popups_js('move-comment'); wp_print_scripts(array('aec_popups', 'jquery-tools-tabs')); wp_print_styles(array('aeccommenteditor')); do_action('add_wp_ajax_comments_css_editor'); ?> <title>WP Ajax Edit Comments Move Comment</title> </head> <body class="hidden move"> <div id="comment-options"> <?php /* Admin nonce */ if (AECCore::is_comment_owner($postID)) { wp_nonce_field('wp-ajax-edit-comments_move-comment'); } ?> <div class="wrap"> <!-- the tabs --> <ul class="tabs" id="flowtabs"> <li><a href="#1" id="t1"><?php _e("Move by Post", 'ajaxEdit'); ?> </a></li> <li><a href="#2" id="t2" class=""><?php _e("Move by Title", 'ajaxEdit'); ?> </a></li>
public static function spam_comment($commentID = 0, $postID = 0) { if (AECCore::is_comment_owner($postID)) { $status = wp_set_comment_status($commentID, 'spam') ? "1" : 'comment_spam_failed'; return $status; } else { return 'comment_spam_failed_permission'; } }
public static function add_edit_links($content) { global $comment, $aecomments; if ($aecomments->skip) { $aecomments->skip = false; return $content; } if (empty($comment)) { return $content; } if (is_page() && $aecomments->get_admin_option('show_pages') != 'true') { return $content; } if (AECCore::can_edit_quickcheck($comment) != 1) { return $content; } //--ag if (AECCore::can_edit($comment->comment_ID, $comment->comment_post_ID) != 1) { return $content; } if ($aecomments->get_admin_option('comment_display_top') == 'true') { $aec_top = true; } $tempContent = $content; //temporary variable to store content $edit_admin = "edit-comment-admin-links"; $clearfix = $timer_class = ''; if ($aecomments->get_admin_option('icon_display') != 'classic' && $aecomments->get_admin_option('icon_display') != 'dropdown') { $edit_admin = "edit-comment-admin-links-no-icon"; $timer_class = "ajax-edit-time-left-no-icon"; } /*If you're wondering why the JS is inline, it's because people with 500+ comments were having their browsers lock up. With inline, the JS is run as needed. Not elegant, but the best solution.*/ if (!isset($aec_top)) { //Test to see if user wants interface on top or bottom $content = '<div class="edit-comment" id="edit-comment' . $comment->comment_ID . '" style="background: none">' . $content . '</div>'; $content .= "<div id='comment-undo-{$comment->comment_ID}' class='aec-undo' style='background: none'></div>"; } else { $content = ''; } if (!AECCore::is_comment_owner($comment->comment_post_ID)) { //For anonymous users $content .= "<div class='{$edit_admin} {$clearfix}' id='edit-comment-user-link-{$comment->comment_ID}' style='background:none'>"; $content .= AECCore::build_admin_links($comment->comment_ID, $comment->comment_post_ID); $content .= "</div>"; //Show custom content to users if (AECCore::show_affiliate_link()) { $message = do_shortcode(stripslashes($aecomments->get_admin_option('affiliate_text'))); $message = str_replace("[url]", "<a href='http://www.ajaxeditcomments.com/?affiliate_id=" . $aecomments->get_admin_option('affiliate_id') . "'>", $message); $message = str_replace("[/url]", "</a>", $message); $content .= "<div class='aec-custom-text'>{$message}</div><!--/aec-custom-text-->"; } //End for anonymous users } else { //Check if user is editor $role = AECUtility::get_user_role(); //todo change editor to capability if ($role == 'editor' && $aecomments->get_admin_option('allow_editing_editors') == 'false') { return $content; } if (is_admin() && $aecomments->get_admin_option('admin_editing') == "false") { //We're in the admin panel $content .= '<div class="' . $edit_admin . ' ' . $clearfix . '" id="edit-comment-admin-links' . $comment->comment_ID . '">'; $content .= AECCore::build_admin_links($comment->comment_ID, $comment->comment_post_ID); $content .= "</div>"; //End in the admin panel } elseif ($aecomments->get_user_option('comment_editing') == "true") { //We're in a post $content .= '<div class="' . $edit_admin . ' ' . $clearfix . '" id="edit-comment-admin-links' . $comment->comment_ID . '" style="background: none">'; $content .= AECCore::build_admin_links($comment->comment_ID, $comment->comment_post_ID); $content .= "</div>"; } } if (isset($aec_top)) { //Test to see if user wants interface on top or bottom $content .= "<div id='comment-undo-{$comment->comment_ID}' class='aec-undo' style='background: none'></div>"; $content .= '<div class="edit-comment" id="edit-comment' . $comment->comment_ID . '" style="background: none">' . $tempContent . '</div>'; } return $content; }
public static function check_spam($commentID = 0, $postID = 0) { global $aecomments; //Check to see if spam protection is enabled if ($aecomments->get_admin_option('spam_protection') == "none") { return false; } //Return if user is post author or can edit posts if (AECCore::is_comment_owner($postID)) { return false; } if (function_exists("akismet_check_db_comment") && $aecomments->get_admin_option('spam_protection') == 'akismet') { //Akismet //Check to see if there is a valid API key if (akismet_verify_key(get_option('wordpress_api_key')) != "failed") { //Akismet $response = akismet_check_db_comment($commentID); if ($response == "true") { //You have spam wp_set_comment_status($commentID, 'spam'); return true; } } } elseif ($aecomments->get_admin_option('spam_protection') == "defensio" && function_exists('defensio_post')) { //Defensio global $defensio_conf, $wpdb; $comment = get_comment($commentID, ARRAY_A); if (!$comment) { return true; } $comment['owner-url'] = $defensio_conf['blog']; $comment['user-ip'] = $comment['comment_author_IP']; $comment['article-date'] = strftime("%Y/%m/%d", strtotime($wpdb->get_var("SELECT post_date FROM {$wpdb->posts} WHERE ID=" . $comment['comment_post_ID']))); $comment['comment-author'] = $comment['comment_author']; $comment['comment-author-email'] = $comment['comment_author_email']; $comment['comment-author-url'] = $comment['comment_author_url']; $comment['comment-content'] = defensio_unescape_string($comment['comment_content']); if (!isset($comment['comment_type']) or empty($comment['comment_type'])) { $comment['comment-type'] = 'comment'; } else { $comment['comment-type'] = $comment['comment_type']; } if (defensio_reapply_wp_comment_preferences($comment) === "spam") { return true; } $results = defensio_post('audit-comment', $comment); $ar = Spyc::YAMLLoad($results); if (isset($ar['defensio-result'])) { if ($ar['defensio-result']['spam']) { wp_set_comment_status($commentID, 'spam'); return true; } } } return false; }
} ?> </tbody> </table> <table><tbody> <?php do_action('wp_ajax_comments_editor'); ?> </tbody></table> <?php } ?> <div id="edit_options"></div> <div class="form"><textarea cols="50" rows="8" name="comment" id="comment"> </textarea></div> <!--form--> <?php if (AECCore::is_comment_owner()) { ?> </div><!--content area 1--> <div> <div id="comment-options"> <?php // translators: Publish box date formt, see http://php.net/date $datef = __('M j, Y @ G:i'); $stamp = __('Submitted on: <b>%1$s</b>'); $date = date_i18n($datef, strtotime($comment->comment_date)); ?> <h3><?php _e('Adjust Comment Time', "ajaxEdit"); ?> </h3> <div><span id="timestamp"><?php