public static function get_main_css($echo = false) { global $aecomments; $return_content = ''; $iconsize = AECCore::get_icon_size(); $iconset = $aecomments->get_admin_option('icon_set'); $rtl = $aecomments->get_admin_option('use_rtl'); $icondisplay = $aecomments->get_admin_option('icon_display'); if ($iconsize == 16) { $fontSize = 12; $paddingLeft = 5; } else { $fontSize = 16; $paddingLeft = 15; } if ($rtl == 'true') { $rtl_float = "right"; $icon_margin = "left"; } else { $rtl_float = "left"; $icon_margin = "right"; } $plugins_url = $aecomments->get_plugin_url('images'); //Left justified for formatting $return_content .= "\n.edit-comment-admin-links, .edit-comment-user-link {\n\n\tdisplay: none;\n\n}\n"; if ($icondisplay != "noicons") { $return_content .= ".edit-comment-admin-links a, .ajax-edit-time-left, .aec-dropdown-container a{\n\n\tdisplay: block;\n\n\theight: {$iconsize}px;\n\n\tfont-size: {$fontSize}px;\n\n\tpadding: 4px 0px;\n\n\tpadding-{$rtl_float}: {$paddingLeft}px;\n\n\tfloat: {$rtl_float};\n\n\tmargin-{$rtl_float}: 10px;\n\n\tfont-weight: bold;\n\n}\n\n.aec-icons {\n\n\tdisplay: block;\n\n\tclear: left;\n\n\tfloat: {$rtl_float};\n\n\twidth: {$iconsize}px;\n\n\theight: {$iconsize}px;\n\n\tmargin-{$icon_margin}: 4px;\n\n\tmargin-bottom: 5px;\n\n}\n\n.aec_link_text, .aec_anon_text {\n\n\tdisplay: block;\n\n\tfloat: {$rtl_float};\n\n\tmargin-{$icon_margin}: 6px;\n\n}\n\n.aec-icons {\n\n\tmargin-{$icon_margin}: 10px;\n\n}\n"; } //end if noicons if ($icondisplay == "iconsonly") { $return_content .= ".aec_link_text {\n\n\tdisplay:none;\n\n}\n\n.aec-icons {\n\n\tclear: none;\n\n}\n"; } //end if iconsonly $return_content .= "\n.affiliate_message {\n\n\tclear: {$rtl_float};\n\n}\n\n.affiliate_message a {\n\n\tdisplay:inline;\n\n\tfont:inherit;\n\n\tpadding:0;\n\n\tfloat:none;\n\n\tmargin:0;\n\n}\n\n.edit-comment-admin-links-no-icon a, .ajax-edit-time-left-no-icon{\n\n\tdisplay: inline;\n\n\tfloat: none;\n\n\tfont-size: 12px;\n\n\tpadding: 2px 0px;\n\n}\n\n.ajax-edit-time-left {\n\n\tpadding-left: 0;\n\n}\n"; if ($icondisplay != "noicons") { $return_content .= "\n.row-actions {\n\n\tclear: both;\n\n}\n\n.clearfix:after { /* from http://blue-anvil.com/archives/experiments-with-floats-whats-the-best-method-of-clearance*/ \n\n\tcontent: \".\";\n\n\tdisplay: block;\n\n\theight: 0;\n\n\tclear: both;\n\n\tvisibility: hidden;\n\n}\n\n/* Begin dropdown */ \n\n.aec-dropdownarrow { \n\n\tposition: relative;\n\n}\n\n.aec-dropdown { display: none; padding-bottom:10px;}\n\n.aec-dropdown-container {\n\n\tposition: absolute;\n\n\tdisplay: none;\n\n\tbackground-color: #FFF;\n\n\tpadding: 5px;\n\n\tborder: 1px solid #CCCCCC;\n\n\ttext-align: left;\n\n\tz-index: 10;\n\n}\n\n.wp-admin .aec-dropdown-container {\n\n\tbackground: #EEE;\n\n}\n\n.aec-dropdown-container a {\n\n\tfloat: none;\n\n\tmargin-left: 2px;\n\n}\n\n/* end dropdown */ \n\n/* Begin Images */ \n\n.aec-dropdownarrow span.aec-icons{\n\n\tbackground:url({$plugins_url}/themes/{$iconset}/sprite.png) " . $iconsize * -2 . "px 0px no-repeat;\n\n}\n\n.aec-dropdownlink-less span.aec-icons{\n\n\tbackground:url({$plugins_url}/themes/{$iconset}/sprite.png) " . $iconsize * -3 . "px 0px no-repeat;\n\n}\n\nspan.blacklist-comment{\n\n\tbackground:url({$plugins_url}/themes/{$iconset}/sprite.png) " . $iconsize * -12 . "px 0px no-repeat;\n}\nspan.email-comment{\n\n\tbackground:url({$plugins_url}/themes/{$iconset}/sprite.png) " . $iconsize * -8 . "px 0px no-repeat;\n\n}\n\nspan.edit-comment{\n\n\tbackground:url({$plugins_url}/themes/{$iconset}/sprite.png) " . $iconsize * -4 . "px 0px no-repeat;\n\n}\n\nspan.move-comment{\n\n\tbackground:url({$plugins_url}/themes/{$iconset}/sprite.png) " . $iconsize * -9 . "px 0px no-repeat;\n\n}\n\nspan.moderate-comment{\n\n\tbackground:url({$plugins_url}/themes/{$iconset}/sprite.png) " . $iconsize * -11 . "px 0px no-repeat;\n\n}\n\nspan.approve-comment{\n\n\tbackground:url({$plugins_url}/themes/{$iconset}/sprite.png) " . $iconsize * -5 . "px 0px no-repeat;\n\n}\n\nspan.delete-comment{\n\n\tbackground:url({$plugins_url}/themes/{$iconset}/sprite.png) " . $iconsize * -6 . "px 0px no-repeat;\n\n}\n\nspan.spam-comment{\n\n\tbackground:url({$plugins_url}/themes/{$iconset}/sprite.png) " . $iconsize * -10 . "px 0px no-repeat;\n\n}\n\nspan.delink-comment{\n\n\tbackground:url({$plugins_url}/themes/{$iconset}/sprite.png) " . $iconsize * -7 . "px 0px no-repeat;\n\n}\n\nspan.request-deletion-comment{\n\n\tbackground:url({$plugins_url}/themes/{$iconset}/sprite.png) " . $iconsize * -6 . "px 0px no-repeat;\n\n}\n\n.edit-comment-admin-links a, .edit-comment-user-link a, .edit-comment-admin-links-no-icon a, .aec-dropdown-container a {\n\n\ttext-decoration: none;\n\n}\n"; } //End no icons /* Errors */ $return_content .= "\nli.ajax-delete, div.ajax-delete { background: #F33; } /* todo Doesn't work for .alt comments */ \n\nli.ajax-approve, div.ajax-approve { background: #04cd33; } \n\nli.ajax-unapprove, div.ajax-unapprove { background: #F96; } \n"; ob_start(); //After the deadline if ($aecomments->get_admin_option('after_deadline_posts') == "true") { include $aecomments->get_plugin_dir('/css/atd/atd.css'); } include $aecomments->get_plugin_dir('/css/frontend.css'); $return_content .= str_replace('images', $aecomments->get_plugin_url('/css/images'), ob_get_clean()); //convert relative paths //Return content //Return content if ($echo) { echo "<!--Ajax Edit Comments Styles-->\n"; echo "<style type='text/css'>\n"; echo $return_content; echo "\n</style>\n"; } else { return $return_content; } }
public static function add_admin_pages() { global $aecomments; $capabilities = 'administrator'; if (AECCore::is_multisite()) { $capabilities = 'manage_network'; } $admin_hooks = array(); $admin_hooks[] = add_menu_page('Ajax Edit Comments', 'AEC', $capabilities, 'wpaec', array("AECAdmin", 'print_admin_page_behavior'), $aecomments->get_plugin_url('images/menu-icon.png')); $admin_hooks[] = add_submenu_page('wpaec', __('Behavior', 'ajaxEdit'), __('Behavior', 'ajaxEdit'), $capabilities, 'wpaec', array('AECAdmin', 'print_admin_page_behavior')); $admin_hooks[] = add_submenu_page('wpaec', __('Appearance', 'ajaxEdit'), __('Appearance', 'ajaxEdit'), $capabilities, 'aecappearance', array('AECAdmin', 'print_admin_page_appearance')); $admin_hooks[] = add_submenu_page('wpaec', __('Permissions', 'ajaxEdit'), __('Permissions', 'ajaxEdit'), $capabilities, 'aecpermissions', array('AECAdmin', 'print_admin_page_permissions')); $admin_hooks[] = add_submenu_page('wpaec', __('Cleanup', 'ajaxEdit'), __('Cleanup', 'ajaxEdit'), $capabilities, 'aeccleanup', array('AECAdmin', 'print_admin_page_cleanup')); foreach ($admin_hooks as $hook) { add_action('admin_print_styles-' . $hook, array('AECDependencies', 'add_admin_panel_css'), 1000); add_action('admin_print_scripts-' . $hook, array('AECDependencies', 'add_admin_scripts'), 1000); } do_action('aec-addon-menus'); }
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 get_js_vars() { global $aecomments; //todo - add esc_js where appropriate return array('AEC_BlogUrl' => admin_url('admin-ajax.php'), 'AEC_CanScroll' => AECCore::can_scroll(), 'AEC_Minutes' => __('minutes', 'ajaxEdit'), 'AEC_Minute' => __('minute', 'ajaxEdit'), 'AEC_And' => __('and', 'ajaxEdit'), 'AEC_Seconds' => __('seconds', 'ajaxEdit'), 'AEC_Second' => __('second', 'ajaxEdit'), 'AEC_Moderation' => __('Mark for Moderation?', 'ajaxEdit'), 'AEC_Approve' => __('Approve Comment?', 'ajaxEdit'), 'AEC_Spam' => __('Mark as Spam?', 'ajaxEdit'), 'AEC_Delete' => __('Delete this comment?', 'ajaxEdit'), 'AEC_Anon' => __('Anonymous', 'ajaxEdit'), 'AEC_Loading' => __('Loading...', 'ajaxEdit'), 'AEC_Ready' => __('Ready', 'ajaxEdit'), 'AEC_Sending' => __('Sending...', 'ajaxEdit'), 'AEC_Sent' => __('Message Sent', 'ajaxEdit'), 'AEC_LoadSuccessful' => __('Comment Loaded Successfully', 'ajaxEdit'), 'AEC_Saving' => __('Saving...', 'ajaxEdit'), 'AEC_Blacklisting' => __('Blacklisting...', 'ajaxEdit'), 'AEC_Saved' => __('Comment Successfully Saved', 'ajaxEdit'), 'AEC_Delink' => __('De-link Successful', 'ajaxEdit'), 'AEC_MoreOptions' => __('More Options', 'ajaxEdit'), 'AEC_LessOptions' => __('Less Options', 'ajaxEdit'), 'AEC_UseRTL' => $aecomments->get_admin_option('use_rtl'), 'AEC_RequestDeletionSuccess' => __('Request has been sent successfully', 'ajaxEdit'), 'AEC_RequestError' => __('Error sending request', 'ajaxEdit'), 'AEC_approving' => __('Approving...', 'ajaxEdit'), 'AEC_delinking' => __('De-linking...', 'ajaxEdit'), 'AEC_moderating' => __('Moderating...', 'ajaxEdit'), 'AEC_spamming' => __('Spamming...', 'ajaxEdit'), 'AEC_deleting' => __('Deleting...', 'ajaxEdit'), 'AEC_restoring' => __('Restoring...', 'ajaxEdit'), 'AEC_restored' => __('Comment Restored.', 'ajaxEdit'), 'AEC_undoing' => __('Undoing...', 'ajaxEdit'), 'AEC_undosuccess' => __('Undo Successful', 'ajaxEdit'), 'AEC_permdelete' => __('Comment Deleted Permanently', 'ajaxEdit'), 'AEC_fieldsrequired' => __('Input Fields are Required', 'ajaxEdit'), 'AEC_emailaddresserror' => __('E-mail Address is Invalid', 'ajaxEdit'), 'AEC_AftertheDeadline' => $aecomments->get_admin_option('after_deadline_popups') == "true" ? 'true' : 'false', 'AEC_AftertheDeadline_lang' => $aecomments->get_admin_option('atdlang'), 'AEC_Expand' => $aecomments->get_admin_option('expand_popups') == "true" ? 'true' : 'false', 'AEC_Yes' => __('Yes', 'ajaxEdit'), 'AEC_No' => __('No', 'ajaxEdit'), 'AEC_Sure' => __('Are you sure?', 'ajaxEdit'), 'AEC_colorbox_width' => absint($aecomments->get_admin_option('colorbox_width')), 'AEC_colorbox_height' => absint($aecomments->get_admin_option('colorbox_height'))); }
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_settings_link($links) { global $aecomments; $multisite_network = AECCore::is_multisite(); $admin_uri = add_query_arg(array('page' => 'wpaec'), admin_url(sprintf('%sadmin.php', $multisite_network ? 'network/' : ''))); array_push($links, sprintf('<a href="%s">%s</a>', $admin_uri, __("Settings", 'ajaxEdit'))); return $links; }
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
public function init() { //If registered users can only comment and user is not logged in, skip loading the plugin. include_once ABSPATH . WPINC . '/pluggable.php'; if (get_option('comment_registration') == '1') { if (!is_user_logged_in()) { return; } } //Initialize Addons do_action('aec-addons-init'); $this->plugin_url = apply_filters('aec-addons-plugin-directory', $this->get_plugin_url()); $this->colorbox_params['script_handler'] = apply_filters('aec-colorbox-script-name', 'colorbox'); $this->colorbox_params['style_handler'] = apply_filters('aec-colorbox-style-name', 'colorbox'); //If a user isn't logged in and has no comment cookie, don't load the plugin either if (!is_user_logged_in()) { $cookieloaded = false; foreach ($_COOKIE as $value => $key) { if (strstr($value, 'WPAjaxEditCommentsComment')) { $cookieloaded = true; break; } } if (!$cookieloaded) { add_action("wp_print_styles", array('AECDependencies', 'load_frontend_css')); add_action('wp_print_scripts', array('AECDependencies', 'load_frontend'), 1000); return; } } add_action('wp_print_scripts', array('AECDependencies', 'ajax_url'), 12); $this->errors = AECCore::initialize_errors(); $this->skip = false; //css add_action("wp_print_styles", array('AECDependencies', "load_frontend_css")); add_action("wp_print_styles", array('AECDependencies', "add_css")); add_action('admin_print_styles', array('AECDependencies', "add_css")); //JavaScript add_action('admin_print_scripts-index.php', array('AECDependencies', 'add_post_scripts'), 1000); add_action('admin_print_scripts-edit-comments.php', array('AECDependencies', 'add_post_scripts'), 1000); if (!is_admin()) { add_action('wp_print_scripts', array('AECDependencies', 'add_post_scripts'), 1000); } //Ajax stuff AECAjax::initialize_actions(); //Admin options if (AECCore::is_multisite()) { add_action('network_admin_menu', array("AECAdmin", 'add_admin_pages')); } else { add_action('admin_menu', array("AECAdmin", 'add_admin_pages')); } add_action('template_redirect', array($this, 'comment_text')); //front end add_action('auth_redirect', array($this, 'comment_text')); //admin panel //* Localization Code */ load_plugin_textdomain('ajaxEdit', false, dirname(plugin_basename(__FILE__)) . '/languages/'); }