Skip to content

Commit

Permalink
1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
kn007 committed Jan 20, 2017
1 parent cd36cb1 commit 37bd3b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ See the [screenshots](/assets/) for more details.

## Changelog

<b>Version 1.4</b> (21 Jan 2017)
* Using back Wordpress API to edit comment.
* Change: double-click a row to call reply dialog form.
* Add a hotkey to the form(`Ctrl+Enter` to submit).

<b>Version 1.3</b> (19 Jan 2017)
* Feature: reply comment.
* Review POST request.
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate Link: https://kn007.net/donate/
Tags: comments, view, spam, control, ajax, search, management, manager, comment search, comment view, comment edit, comment reply, comment approval, comment moderation, comment spam, comment trash, comment delete
Requires at least: 3.6
Tested up to: 4.7.1
Stable tag: 1.3
Stable tag: 1.4
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -45,6 +45,11 @@ No technical skills needed.

== Changelog ==

= 1.4 =
* Using back Wordpress API to edit comment.
* Change: double-click a row to call reply dialog form.
* Add a hotkey to the form(`Ctrl+Enter` to submit).

= 1.3 =
* Feature: reply comment.
* Review POST request.
Expand Down
8 changes: 4 additions & 4 deletions wp-comments-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
/*
Plugin Name:Wordpress Comments Manager
Plugin URI: https://kn007.net/topics/new-wordpress-comment-management-system/
Version: 1.4-beta
Version: 1.4
Description: Wordpress Comments Manager help you to quickly find comments and manage comments. It can be very convenient to review selected comments, open the comment in a new window, reply comment, edit comment and delete comments. See the screenshots for more details.
Author: kn007
Author URI: https://kn007.net/
*/

if ( !defined('ABSPATH') ) exit;

if ( version_compare( $GLOBALS['wp_version'], '3.6', '<' ) ) wp_die('Wordpress version too old. Please upgrade your wordpress.');
if ( version_compare( $GLOBALS['wp_version'], '3.6', '<' ) ) wp_die('Wordpress version too old. Please upgrade your Wordpress.');

function wpcm_menu() {
if (current_user_can('moderate_comments')) {
Expand Down Expand Up @@ -48,7 +48,7 @@ function wpcm_get_item($order) {
$record = $wpdb->get_row( "SELECT `comment_ID`,`comment_post_ID`,`comment_author`,`comment_author_email`,`comment_author_url`,`comment_content` FROM `".$wpdb->comments."` WHERE `comment_ID`=".absint($order['recid']) );
break;
case 'replyform':
$record = $wpdb->get_row( "SELECT `comment_ID`,`comment_post_ID` FROM `".$wpdb->comments."` WHERE `comment_ID`=".absint($order['recid']) );
$record = $wpdb->get_row( "SELECT `comment_ID`,`comment_post_ID`,`comment_content` FROM `".$wpdb->comments."` WHERE `comment_ID`=".absint($order['recid']) );
break;
default:
$res = Array();
Expand Down Expand Up @@ -316,7 +316,7 @@ function wpcm_delete_comments($order) {
function wpcm_page(){
?>
<script type="text/javascript">
jQuery(document).ready(function($){var config={tabs:{name:"tabs",active:"tab1",tabs:[{id:"tab1",caption:"All"},{id:"tab2",caption:"Moderated"},{id:"tab3",caption:"Approved"},{id:"tab4",caption:"Spam"},{id:"tab5",caption:"Trash"}],onClick:function(a){switch(w2ui.grid.reset(),a.target){case"tab1":w2ui.grid.postData.approved="all";break;case"tab2":w2ui.grid.postData.approved="0";break;case"tab3":w2ui.grid.postData.approved="1";break;case"tab4":w2ui.grid.postData.approved="spam";break;case"tab5":w2ui.grid.postData.approved="trash"}w2ui.grid.searchReset()}},grid:{name:"grid",url:'<?php echo admin_url("admin.php?page=wordpress-comments-manager"); ?>',method:"POST",columns:[{field:"comment_author",caption:"Author",size:"80px",resizable:!0},{field:"comment_author_email",caption:"Email",size:"130px",resizable:!0},{field:"comment_author_url",caption:"Site",size:"120px",resizable:!0,render:function(a){return'<div><a href="'+a.comment_author_url+'" target="_blank">'+a.comment_author_url+"</a></div>"}},{field:"comment_content",caption:"Content",size:"250px"},{field:"comment_author_IP",caption:"IP",size:"120px",resizable:!0},{field:"comment_date",caption:"Date",size:"150px",render:"datetime:yyyy-mm-dd|hh24:mm:ss",resizable:!0},{field:"comment_agent",caption:"Agent",size:"30%"}],searches:[{field:"comment_author",caption:"Author",type:"text",operator:"contains"},{field:"comment_author_email",caption:"Email",type:"text",operator:"contains"},{field:"comment_author_url",caption:"Site",type:"text",operator:"contains"},{field:"comment_content",caption:"Content",type:"text",operator:"contains"},{field:"comment_author_IP",caption:"IP",type:"text",operator:"contains"},{field:"comment_agent",caption:"Agent",type:"text",operator:"contains"},{field:"comment_date",caption:"Date",type:"datetime",operator:"less"}],postData:{approved:"all",wpcm_nonce:"<?php echo wp_create_nonce('wordpress-comments-manager'); ?>"},toolbar:{items:[{type:"break",id:"break1"},{type:"button",id:"w2ui-reply",text:"Reply",icon:"w2ui-icon-pencil",tooltip:"Reply This Comment",disabled:!0},{type:"button",id:"w2ui-open",text:"<?php if (!wp_is_mobile()) echo 'View'; ?>",icon:"w2ui-icon-info",tooltip:"View This Comment",disabled:!0},{type:"menu",id:"w2ui-status",text:"<?php if (!wp_is_mobile()) echo 'Set Status'; ?>",icon:"w2ui-icon-settings",tooltip:"Change Comment Status",disabled:!0,items:[{id:"approve",text:"Approve",icon:"w2ui-icon-check"},{id:"hold",text:"Hold",icon:"w2ui-icon-reload"},{id:"spam",text:"Spam",icon:"w2ui-icon-colors"},{text:"--"},{id:"trash",text:"Trash",icon:"w2ui-icon-cross"}]},{type:"break",id:"break2"},{type:"button",id:"w2ui-edit",text:"Edit",icon:"w2ui-icon-pencil",tooltip:"Edit This Comment",disabled:!0},{type:"button",id:"w2ui-delete",text:"<?php if (!wp_is_mobile()) echo 'Delete'; ?>",icon:"w2ui-icon-cross",tooltip:"Delete Comments",disabled:!0}],onClick:function(a){switch(a.target){case"w2ui-status:approve":w2ui.grid.postData.status_changed="approve",w2ui.grid.save(),delete w2ui.grid.postData.status_changed;break;case"w2ui-status:hold":w2ui.grid.postData.status_changed="hold",w2ui.grid.save(),delete w2ui.grid.postData.status_changed;break;case"w2ui-status:spam":w2ui.grid.postData.status_changed="spam",w2ui.grid.save(),delete w2ui.grid.postData.status_changed;break;case"w2ui-status:trash":w2ui.grid.postData.status_changed="trash",w2ui.grid.save(),delete w2ui.grid.postData.status_changed;break;case"w2ui-reply":w2ui.replyform.clear();var sel=w2ui.grid.getSelection();w2ui.replyform.recid=sel[0],w2popup.open({body:'<div id="form" style="width: 100%; height: 100%;position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;"></div>',width:500,height:300,onOpen:function(a){a.onComplete=function(){$("#w2ui-popup #form").w2render("replyform")}}});break;case"w2ui-open":w2ui.grid.postData.view="get",w2ui.grid.save(),delete w2ui.grid.postData.view}}},onDblClick:function(a){w2alert(this.get(a.recid).comment_content)},onEdit:function(a){w2ui.editform.clear(),w2ui.editform.recid=a.recid,w2popup.open({body:'<div id="form" style="width:100%;height:100%;position:absolute;left:0px;top:0px;right:0px;bottom:0px;"></div>',width:380,height:420,onOpen:function(a){a.onComplete=function(){$("#w2ui-popup #form").w2render("editform")}}})},onSave:function(event){event.onComplete=function(){void 0!==event.xhr&&(data=eval("("+event.xhr.responseText+")"),void 0!==data.view?window.open(data.view):"success"==data.status&&(w2ui.grid.selectNone(),"all"!==w2ui.grid.postData.approved&&w2ui.grid.reload()))}}},editform:{name:"editform",header:"Edit Comment",url:'<?php echo admin_url("admin.php?page=wordpress-comments-manager"); ?>',method:"POST",fields:[{name:"comment_author",type:"text",required:!0,html:{caption:"Author",attr:'style="width:90%"'}},{name:"comment_author_email",type:"email",<?php if (get_option('require_name_email')) echo 'required:!0,'; ?>html:{caption:"Email",attr:'style="width:90%"'}},{name:"comment_author_url",type:"text",html:{caption:"Site",attr:'style="width:90%"'}},{name:"comment_content",type:"textarea",required:!0,html:{caption:"Content",attr:'style="width:90%;height:180px;resize:none"'}}],postData:{wpcm_nonce:"<?php echo wp_create_nonce('wordpress-comments-manager'); ?>"},actions:{Close:function(){this.clear(),w2popup.close()},Update:function(){var a=this.validate();a.length>0||this.save({},function(a){w2popup.close(),"success"==a.status?(w2ui.grid.reload(w2ui.grid.select(w2ui.editform.recid),w2ui.grid.scrollIntoView(w2ui.grid.get(w2ui.editform.recid,!0)))):w2alert("Update Failed!"),w2ui.editform.clear()})}}},replyform:{name:"replyform",header:"Reply Comment",url:'<?php echo admin_url("admin.php?page=wordpress-comments-manager"); ?>',method:"POST",fields:[{name:"reply_content",type:"textarea",required:!0,html:{caption:"Content",attr:'style="width:90%;height:170px;resize:none"'}}],postData:{reply:"action",wpcm_nonce:"<?php echo wp_create_nonce('wordpress-comments-manager'); ?>"},actions:{Close:function(){this.clear(),w2popup.close()},Reply:function(){var a=this.validate();a.length>0||this.save({},function(a){w2popup.close(),"success"==a.status?w2ui.grid.reload():w2alert("Submit Failed!"),w2ui.replyform.clear()})}}}};$("#tabs").w2tabs(config.tabs),$("#tab").show(),$("#grid").w2grid(config.grid),$().w2form(config.editform),$().w2form(config.replyform)<?php if (wp_is_mobile()) echo ",w2ui.grid.toolbar.hide('w2ui-column-on-off', 'w2ui-search-advanced', 'w2ui-reply', 'w2ui-edit')"; ?>});
jQuery(document).ready(function($){var config={tabs:{name:"tabs",active:"tab1",tabs:[{id:"tab1",caption:"All"},{id:"tab2",caption:"Moderated"},{id:"tab3",caption:"Approved"},{id:"tab4",caption:"Spam"},{id:"tab5",caption:"Trash"}],onClick:function(a){switch(w2ui.grid.reset(),a.target){case"tab1":w2ui.grid.postData.approved="all";break;case"tab2":w2ui.grid.postData.approved="0";break;case"tab3":w2ui.grid.postData.approved="1";break;case"tab4":w2ui.grid.postData.approved="spam";break;case"tab5":w2ui.grid.postData.approved="trash"}w2ui.grid.searchReset()}},grid:{name:"grid",url:'<?php echo admin_url("admin.php?page=wordpress-comments-manager"); ?>',method:"POST",columns:[{field:"comment_author",caption:"Author",size:"80px",resizable:!0},{field:"comment_author_email",caption:"Email",size:"130px",resizable:!0},{field:"comment_author_url",caption:"Site",size:"120px",resizable:!0,render:function(a){return'<div><a href="'+a.comment_author_url+'" target="_blank">'+a.comment_author_url+"</a></div>"}},{field:"comment_content",caption:"Content",size:"250px"},{field:"comment_author_IP",caption:"IP",size:"120px",resizable:!0},{field:"comment_date",caption:"Date",size:"150px",render:"datetime:yyyy-mm-dd|hh24:mm:ss",resizable:!0},{field:"comment_agent",caption:"Agent",size:"30%"}],searches:[{field:"comment_author",caption:"Author",type:"text",operator:"contains"},{field:"comment_author_email",caption:"Email",type:"text",operator:"contains"},{field:"comment_author_url",caption:"Site",type:"text",operator:"contains"},{field:"comment_content",caption:"Content",type:"text",operator:"contains"},{field:"comment_author_IP",caption:"IP",type:"text",operator:"contains"},{field:"comment_agent",caption:"Agent",type:"text",operator:"contains"},{field:"comment_date",caption:"Date",type:"datetime",operator:"less"}],postData:{approved:"all",wpcm_nonce:"<?php echo wp_create_nonce('wordpress-comments-manager'); ?>"},toolbar:{items:[{type:"break",id:"break1"},{type:"button",id:"w2ui-reply",text:"Reply",icon:"w2ui-icon-pencil",tooltip:"Reply This Comment",disabled:!0},{type:"button",id:"w2ui-open",text:"<?php if (!wp_is_mobile()) echo 'View'; ?>",icon:"w2ui-icon-info",tooltip:"View This Comment",disabled:!0},{type:"menu",id:"w2ui-status",text:"<?php if (!wp_is_mobile()) echo 'Set Status'; ?>",icon:"w2ui-icon-settings",tooltip:"Change Comment Status",disabled:!0,items:[{id:"approve",text:"Approve",icon:"w2ui-icon-check"},{id:"hold",text:"Hold",icon:"w2ui-icon-reload"},{id:"spam",text:"Spam",icon:"w2ui-icon-colors"},{text:"--"},{id:"trash",text:"Trash",icon:"w2ui-icon-cross"}]},{type:"break",id:"break2"},{type:"button",id:"w2ui-edit",text:"Edit",icon:"w2ui-icon-pencil",tooltip:"Edit This Comment",disabled:!0},{type:"button",id:"w2ui-delete",text:"<?php if (!wp_is_mobile()) echo 'Delete'; ?>",icon:"w2ui-icon-cross",tooltip:"Delete Comments",disabled:!0}],onClick:function(a){switch(a.target){case"w2ui-status:approve":w2ui.grid.postData.status_changed="approve",w2ui.grid.save(),delete w2ui.grid.postData.status_changed;break;case"w2ui-status:hold":w2ui.grid.postData.status_changed="hold",w2ui.grid.save(),delete w2ui.grid.postData.status_changed;break;case"w2ui-status:spam":w2ui.grid.postData.status_changed="spam",w2ui.grid.save(),delete w2ui.grid.postData.status_changed;break;case"w2ui-status:trash":w2ui.grid.postData.status_changed="trash",w2ui.grid.save(),delete w2ui.grid.postData.status_changed;break;case"w2ui-reply":w2ui.replyform.clear();var sel=w2ui.grid.getSelection();w2ui.replyform.recid=sel[0],w2popup.open({body:'<div id="form" style="width: 100%; height: 100%;position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;"></div>',width:500,height:360,onOpen:function(a){a.onComplete=function(){$("#w2ui-popup #form").w2render("replyform")}},onKeydown:function(a){null!=a.originalEvent&&a.originalEvent.ctrlKey&&13==a.originalEvent.keyCode&&$('#w2ui-popup .w2ui-form-box .w2ui-btn-blue').focus().click()}});break;case"w2ui-open":w2ui.grid.postData.view="get",w2ui.grid.save(),delete w2ui.grid.postData.view}}},onDblClick:function(a){w2ui.grid_toolbar.click('w2ui-reply')},onEdit:function(a){w2ui.editform.clear(),w2ui.editform.recid=a.recid,w2popup.open({body:'<div id="form" style="width:100%;height:100%;position:absolute;left:0px;top:0px;right:0px;bottom:0px;"></div>',width:380,height:420,onOpen:function(a){a.onComplete=function(){$("#w2ui-popup #form").w2render("editform")}},onKeydown:function(a){null!=a.originalEvent&&a.originalEvent.ctrlKey&&13==a.originalEvent.keyCode&&$('#w2ui-popup .w2ui-form-box .w2ui-btn-blue').focus().click()}})},onSave:function(event){event.onComplete=function(){void 0!==event.xhr&&(data=eval("("+event.xhr.responseText+")"),void 0!==data.view?window.open(data.view):"success"==data.status&&(w2ui.grid.selectNone(),"all"!==w2ui.grid.postData.approved&&w2ui.grid.reload()))}}},editform:{name:"editform",header:"Edit Comment",url:'<?php echo admin_url("admin.php?page=wordpress-comments-manager"); ?>',method:"POST",fields:[{name:"comment_author",type:"text",required:!0,html:{caption:"Author",attr:'style="width:90%"'}},{name:"comment_author_email",type:"email",<?php if (get_option('require_name_email')) echo 'required:!0,'; ?>html:{caption:"Email",attr:'style="width:90%"'}},{name:"comment_author_url",type:"text",html:{caption:"Site",attr:'style="width:90%"'}},{name:"comment_content",type:"textarea",required:!0,html:{caption:"Content",attr:'style="width:90%;height:180px;resize:none"'}}],postData:{wpcm_nonce:"<?php echo wp_create_nonce('wordpress-comments-manager'); ?>"},actions:{Close:function(){this.clear(),w2popup.close()},Update:function(){var a=this.validate();a.length>0||this.save({},function(a){w2popup.close(),"success"==a.status?(w2ui.grid.reload(w2ui.grid.select(w2ui.editform.recid),w2ui.grid.scrollIntoView(w2ui.grid.get(w2ui.editform.recid,!0)))):w2alert("Update Failed!"),w2ui.editform.clear()})}}},replyform:{name:"replyform",header:"Reply Comment",url:'<?php echo admin_url("admin.php?page=wordpress-comments-manager"); ?>',method:"POST",focus:2,fields:[{name:"comment_content",type:"textarea",disabled:!0,html:{caption:"Comment",attr:'style="width:90%;height:100px;resize:none" readonly'}},{name:"reply_content",type:"textarea",required:!0,html:{caption:"Response",attr:'style="width:90%;height:125px;resize:none" autofocus'}}],postData:{reply:"action",wpcm_nonce:"<?php echo wp_create_nonce('wordpress-comments-manager'); ?>"},actions:{Close:function(){this.clear(),w2popup.close()},Reply:function(){var a=this.validate();a.length>0||this.save({},function(a){w2popup.close(),"success"==a.status?w2ui.grid.reload():w2alert("Submit Failed!"),w2ui.replyform.clear()})}}}};$("#tabs").w2tabs(config.tabs),$("#tab").show(),$("#grid").w2grid(config.grid),$().w2form(config.editform),$().w2form(config.replyform)<?php if (wp_is_mobile()) echo ",w2ui.grid.toolbar.hide('w2ui-column-on-off','w2ui-search-advanced','w2ui-reply','w2ui-edit');"; ?>});
</script>
<div class="wrap wpcm">
<h2>Wordpress Comments Manager</h2>
Expand Down

0 comments on commit 37bd3b1

Please sign in to comment.