From 6e8b6db28ec374667acaef41e39e870528773539 Mon Sep 17 00:00:00 2001 From: datorik Date: Sun, 17 May 2026 13:21:58 +0300 Subject: [PATCH 1/4] Code. Links from backend --- inc/cleantalk-admin.php | 5 ++++- js/cleantalk-comments-editscreen.min.js | 2 +- js/cleantalk-comments-editscreen.min.js.map | 2 +- js/cleantalk-users-editscreen.min.js | 2 +- js/cleantalk-users-editscreen.min.js.map | 2 +- js/src/cleantalk-comments-editscreen.js | 4 ++-- js/src/cleantalk-users-editscreen.js | 4 ++-- lib/Cleantalk/ApbctWP/LinkConstructor.php | 6 ++++++ lib/Cleantalk/ApbctWP/Localize/CtPublicLocalize.php | 5 +++++ 9 files changed, 23 insertions(+), 9 deletions(-) diff --git a/inc/cleantalk-admin.php b/inc/cleantalk-admin.php index 9d623214c..0d6f59fbc 100644 --- a/inc/cleantalk-admin.php +++ b/inc/cleantalk-admin.php @@ -3,6 +3,7 @@ use Cleantalk\ApbctWP\AdjustToEnvironmentModule\AdjustToEnvironmentHandler; use Cleantalk\ApbctWP\AJAXService; use Cleantalk\ApbctWP\ApbctEnqueue; +use Cleantalk\ApbctWP\Localize\CtPublicLocalize; use Cleantalk\ApbctWP\CleantalkSettingsTemplates; use Cleantalk\ApbctWP\ContactsEncoder\ContactsEncoder; use Cleantalk\ApbctWP\Escape; @@ -638,6 +639,7 @@ function apbct_admin__enqueue_scripts($hook) (if the Extra package is activated) ago.', 'cleantalk-spam-protect'), 'ct_show_check_links' => (bool)$apbct->settings['comments__show_check_links'], 'ct_img_src_new_tab' => plugin_dir_url(__FILE__) . "images/new_window.gif", + 'links' => CtPublicLocalize::getData()['links'], )); } @@ -648,7 +650,8 @@ function apbct_admin__enqueue_scripts($hook) wp_localize_script('cleantalk-users-editscreen-js', 'ctUsersScreen', array( 'spambutton_text' => __("Find spam-users", 'cleantalk-spam-protect'), 'ct_show_check_links' => (bool)$apbct->settings['comments__show_check_links'], - 'ct_img_src_new_tab' => plugin_dir_url(__FILE__) . "images/new_window.gif" + 'ct_img_src_new_tab' => plugin_dir_url(__FILE__) . "images/new_window.gif", + 'links' => CtPublicLocalize::getData()['links'], )); } } diff --git a/js/cleantalk-comments-editscreen.min.js b/js/cleantalk-comments-editscreen.min.js index 6dca2ae3c..3ee5d0d97 100644 --- a/js/cleantalk-comments-editscreen.min.js +++ b/js/cleantalk-comments-editscreen.min.js @@ -1,2 +1,2 @@ -function ct_is_email(e){return e.search(/.*@.*\..*/)}function ct_is_ip(e){return e.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)}function ct_send_feedback_request(t,c,n){var e={action:"ct_feedback_comment",security:ctCommentsScreen.ct_ajax_nonce,comment_id:t,comment_status:c};jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){ct_feedback_message_output(t,c,e,n)},error:function(e,t,c){console.log(e),console.log(t),console.log(c)},timeout:5e3})}function ct_feedback_message_output(e,t,c,n){1==c&&("approve"!=t||n||jQuery("tr#comment-"+e).html("").show().append("").children("td").css("background","rgba(110,240,110,0.7)").append("
"+ctCommentsScreen.ct_feedback_msg+"
"),"spam"==t)&&(jQuery("tr").is("#undo-"+e)?(jQuery("tr#undo-"+e).css("background","rgba(240,110,110,0.7)"),jQuery("tr#undo-"+e+" div.spam-undo-inside").append(" "+ctCommentsScreen.ct_feedback_msg)):jQuery("tr#comment-"+e).html("").show().css("background","rgba(240,110,110,0.7)").append("").children("td").append("
"+ctCommentsScreen.ct_feedback_msg+"
"))}jQuery(document).ready(function(){var t;parseInt(ctCommentsScreen.ct_show_check_links)&&jQuery(".column-author a, .comment-author a").each(function(){var e=jQuery(this).html();-1==ct_is_email(e)&&-1==ct_is_ip(e)||(e+="?utm_source=admin_side&utm_medium=comments&utm_content=avatar&utm_campaign=apbct_links",jQuery(this).after(' '))}),jQuery("span.approve").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],ct_send_feedback_request(undo_comment_id=t,"approve",0)}),jQuery("span.unapprove").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],ct_send_feedback_request(undo_comment_id=t,"spam",0)}),jQuery("span.spam").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],ct_send_feedback_request(undo_comment_id=t,"spam",0),setTimeout(function(){jQuery("tr#undo-"+t+" span.unspam a").click(function(){var e=(e=jQuery(this).attr("href")).match(/^comment\.php\?.*&c=(\d*).*/);ct_send_feedback_request(t=e[1],"approve",1)})},202)}),jQuery("span.unspam").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);ct_send_feedback_request(t=e[1],"approve",0)}),jQuery("span.untrash a").on("click",function(){var e=(e=jQuery(this).attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],feedback_result=ct_send_feedback_request(t,"approve",0)})}); +function ct_is_email(e){return e.search(/.*@.*\..*/)}function ct_is_ip(e){return e.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)}function ct_send_feedback_request(t,c,n){var e={action:"ct_feedback_comment",security:ctCommentsScreen.ct_ajax_nonce,comment_id:t,comment_status:c};jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){ct_feedback_message_output(t,c,e,n)},error:function(e,t,c){console.log(e),console.log(t),console.log(c)},timeout:5e3})}function ct_feedback_message_output(e,t,c,n){1==c&&("approve"!=t||n||jQuery("tr#comment-"+e).html("").show().append("").children("td").css("background","rgba(110,240,110,0.7)").append("
"+ctCommentsScreen.ct_feedback_msg+"
"),"spam"==t)&&(jQuery("tr").is("#undo-"+e)?(jQuery("tr#undo-"+e).css("background","rgba(240,110,110,0.7)"),jQuery("tr#undo-"+e+" div.spam-undo-inside").append(" "+ctCommentsScreen.ct_feedback_msg)):jQuery("tr#comment-"+e).html("").show().css("background","rgba(240,110,110,0.7)").append("").children("td").append("
"+ctCommentsScreen.ct_feedback_msg+"
"))}jQuery(document).ready(function(){var t;parseInt(ctCommentsScreen.ct_show_check_links)&&jQuery(".column-author a, .comment-author a").each(function(){var e=jQuery(this).html();-1==ct_is_email(e)&&-1==ct_is_ip(e)||(e=ctCommentsScreen.links.comments_editscreen.replace("{TARGET}",e),jQuery(this).after(' '))}),jQuery("span.approve").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],ct_send_feedback_request(undo_comment_id=t,"approve",0)}),jQuery("span.unapprove").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],ct_send_feedback_request(undo_comment_id=t,"spam",0)}),jQuery("span.spam").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],ct_send_feedback_request(undo_comment_id=t,"spam",0),setTimeout(function(){jQuery("tr#undo-"+t+" span.unspam a").click(function(){var e=(e=jQuery(this).attr("href")).match(/^comment\.php\?.*&c=(\d*).*/);ct_send_feedback_request(t=e[1],"approve",1)})},202)}),jQuery("span.unspam").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);ct_send_feedback_request(t=e[1],"approve",0)}),jQuery("span.untrash a").on("click",function(){var e=(e=jQuery(this).attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],feedback_result=ct_send_feedback_request(t,"approve",0)})}); //# sourceMappingURL=cleantalk-comments-editscreen.min.js.map diff --git a/js/cleantalk-comments-editscreen.min.js.map b/js/cleantalk-comments-editscreen.min.js.map index 0c26ff627..29b80c8db 100644 --- a/js/cleantalk-comments-editscreen.min.js.map +++ b/js/cleantalk-comments-editscreen.min.js.map @@ -1 +1 @@ -{"version":3,"file":"cleantalk-comments-editscreen.min.js","sources":["cleantalk-comments-editscreen.js"],"sourcesContent":["function ct_is_email(str){\n\treturn str.search(/.*@.*\\..*/);\n}\nfunction ct_is_ip(str){\n\treturn str.search(/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/);\n}\n\njQuery(document).ready(function(){\n\t/* Shows link to blacklists near every email and IP address */\n\tif(parseInt(ctCommentsScreen.ct_show_check_links))\n\t\tjQuery('.column-author a, .comment-author a').each(function(){\n\t\t\tvar ct_curr_str = jQuery(this).html();\n\t\t\tif(ct_is_email(ct_curr_str) != -1 || ct_is_ip(ct_curr_str) != -1){\n\t\t\t\tct_curr_str += '?utm_source=admin_side&utm_medium=comments&utm_content=avatar&utm_campaign=apbct_links';\n\t\t\t\tjQuery(this).after(' ');\n\t\t\t}\n\t\t});\n\n\t/* Feedback for comments */\n\tvar ct_comment_id;\n\n\t// For approved\n\tjQuery('span.approve').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tundo_comment_id = ct_comment_id;\n\t\tct_send_feedback_request(ct_comment_id, 'approve', 0);\n\t});\n\n\t// For unapprove\n\tjQuery('span.unapprove').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tundo_comment_id = ct_comment_id;\n\t\tct_send_feedback_request(ct_comment_id, 'spam', 0);\n\t});\n\n\t// For spammed\n\tjQuery('span.spam').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tundo_comment_id = ct_comment_id;\n\t\tct_send_feedback_request(ct_comment_id, 'spam', 0);\n\t\tsetTimeout(function(){\n\t\t\tjQuery('tr#undo-'+ct_comment_id+' span.unspam a').click(function(){\n\t\t\t\tvar result = jQuery(this).attr('href');\n\t\t\t\tresult = result.match(/^comment\\.php\\?.*&c=(\\d*).*/);\n\t\t\t\tct_comment_id = result[1];\n\t\t\t\tct_send_feedback_request(ct_comment_id, 'approve', 1);\n\t\t\t});\n\t\t}, 202);\n\n\t});\n\n\t// For unspammed\n\tjQuery('span.unspam').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tct_send_feedback_request(ct_comment_id, 'approve', 0);\n\t});\n\n\t// For untrashed\n\tjQuery('span.untrash a').on('click', function(){\n\t\tvar result = jQuery(this).attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tfeedback_result = ct_send_feedback_request(ct_comment_id, 'approve', 0);\n\t});\n});\n\n// Send feedback to backend\nfunction ct_send_feedback_request(ct_comment_id, ct_comment_status, ct_undo){\n\n\tvar data = {\n\t\t'action': 'ct_feedback_comment',\n\t\t'security': ctCommentsScreen.ct_ajax_nonce,\n\t\t'comment_id': ct_comment_id,\n\t\t'comment_status': ct_comment_status\n\t};\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(msg){\n\t\t\tct_feedback_message_output(ct_comment_id, ct_comment_status, msg, ct_undo);\n\t\t},\n error: function(jqXHR, textStatus, errorThrown) {\n\t\t\tconsole.log(jqXHR);\n\t\t\tconsole.log(textStatus);\n\t\t\tconsole.log(errorThrown);\n\t\t},\n timeout: 5000\n\t});\n}\n\n// Outputs CT message about feedback\nfunction ct_feedback_message_output(ct_comment_id, ct_comment_status, ct_result, ct_undo){\n\tif(ct_result == 1){\n\t\tif(ct_comment_status == 'approve' && !ct_undo){\n\t\t\tjQuery('tr#comment-'+ct_comment_id)\n\t\t\t\t.html('')\n\t\t\t\t.show()\n\t\t\t\t.append(\"\").children('td')\n\t\t\t\t\t.css('background', 'rgba(110,240,110,0.7)')\n\t\t\t\t\t.append(\"
\"+ctCommentsScreen.ct_feedback_msg+\"
\");\n\t\t}\n\t\tif(ct_comment_status == 'spam'){\n\t\t\tif(jQuery('tr').is('#undo-'+ct_comment_id)){\n\t\t\t\tjQuery('tr#undo-'+ct_comment_id)\n\t\t\t\t\t.css('background', 'rgba(240,110,110,0.7)');\n\t\t\t\tjQuery('tr#undo-'+ct_comment_id+' div.spam-undo-inside')\n\t\t\t\t\t.append(\" \"+ctCommentsScreen.ct_feedback_msg);\n\t\t\t}else{\n\t\t\t\tjQuery('tr#comment-'+ct_comment_id)\n\t\t\t\t.html('')\n\t\t\t\t.show()\n\t\t\t\t.css('background', 'rgba(240,110,110,0.7)')\n\t\t\t\t.append(\"\").children('td')\n\t\t\t\t\t.append(\"
\"+ctCommentsScreen.ct_feedback_msg+\"
\");\n\t\t\t}\n\t\t}\n\t}\n\tif(ct_result == 0){\n\t\t// Error occurred\n\t}if(ct_result == 'no_hash'){\n\t\t// No hash for this comment\n\t}\n}\n"],"names":["ct_is_email","str","search","ct_is_ip","ct_send_feedback_request","ct_comment_id","ct_comment_status","ct_undo","data","action","security","ctCommentsScreen","ct_ajax_nonce","comment_id","comment_status","jQuery","ajax","type","url","ajaxurl","success","msg","ct_feedback_message_output","error","jqXHR","textStatus","errorThrown","console","log","timeout","ct_result","html","show","append","children","css","ct_feedback_msg","is","document","ready","parseInt","ct_show_check_links","each","ct_curr_str","this","after","ct_img_src_new_tab","on","result","attr","match","undo_comment_id","setTimeout","click","feedback_result"],"mappings":"AAAA,SAASA,YAAYC,GACpB,OAAOA,EAAIC,OAAO,WAAW,CAC9B,CACA,SAASC,SAASF,GACjB,OAAOA,EAAIC,OAAO,sCAAsC,CACzD,CAsEA,SAASE,yBAAyBC,EAAeC,EAAmBC,GAEnE,IAAIC,EAAO,CACVC,OAAU,sBACVC,SAAYC,iBAAiBC,cAC7BC,WAAcR,EACdS,eAAkBR,CACnB,EAEAS,OAAOC,KAAK,CACXC,KAAM,OACNC,IAAKC,QACLX,KAAMA,EACNY,QAAS,SAASC,GACjBC,2BAA2BjB,EAAeC,EAAmBe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AyBC,EAAe,UAAW,CAAC,CACvE,CAAC,CACF,CAAC"} \ No newline at end of file +{"version":3,"file":"cleantalk-comments-editscreen.min.js","sources":["cleantalk-comments-editscreen.js"],"sourcesContent":["function ct_is_email(str){\n\treturn str.search(/.*@.*\\..*/);\n}\nfunction ct_is_ip(str){\n\treturn str.search(/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/);\n}\n\njQuery(document).ready(function(){\n\t/* Shows link to blacklists near every email and IP address */\n\tif(parseInt(ctCommentsScreen.ct_show_check_links))\n\t\tjQuery('.column-author a, .comment-author a').each(function(){\n\t\t\tvar ct_curr_str = jQuery(this).html();\n\t\t\tif(ct_is_email(ct_curr_str) != -1 || ct_is_ip(ct_curr_str) != -1){\n\t\t\t\tvar ct_url = ctCommentsScreen.links.comments_editscreen.replace('{TARGET}', ct_curr_str);\n\t\t\t\tjQuery(this).after(' ');\n\t\t\t}\n\t\t});\n\n\t/* Feedback for comments */\n\tvar ct_comment_id;\n\n\t// For approved\n\tjQuery('span.approve').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tundo_comment_id = ct_comment_id;\n\t\tct_send_feedback_request(ct_comment_id, 'approve', 0);\n\t});\n\n\t// For unapprove\n\tjQuery('span.unapprove').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tundo_comment_id = ct_comment_id;\n\t\tct_send_feedback_request(ct_comment_id, 'spam', 0);\n\t});\n\n\t// For spammed\n\tjQuery('span.spam').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tundo_comment_id = ct_comment_id;\n\t\tct_send_feedback_request(ct_comment_id, 'spam', 0);\n\t\tsetTimeout(function(){\n\t\t\tjQuery('tr#undo-'+ct_comment_id+' span.unspam a').click(function(){\n\t\t\t\tvar result = jQuery(this).attr('href');\n\t\t\t\tresult = result.match(/^comment\\.php\\?.*&c=(\\d*).*/);\n\t\t\t\tct_comment_id = result[1];\n\t\t\t\tct_send_feedback_request(ct_comment_id, 'approve', 1);\n\t\t\t});\n\t\t}, 202);\n\n\t});\n\n\t// For unspammed\n\tjQuery('span.unspam').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tct_send_feedback_request(ct_comment_id, 'approve', 0);\n\t});\n\n\t// For untrashed\n\tjQuery('span.untrash a').on('click', function(){\n\t\tvar result = jQuery(this).attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tfeedback_result = ct_send_feedback_request(ct_comment_id, 'approve', 0);\n\t});\n});\n\n// Send feedback to backend\nfunction ct_send_feedback_request(ct_comment_id, ct_comment_status, ct_undo){\n\n\tvar data = {\n\t\t'action': 'ct_feedback_comment',\n\t\t'security': ctCommentsScreen.ct_ajax_nonce,\n\t\t'comment_id': ct_comment_id,\n\t\t'comment_status': ct_comment_status\n\t};\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(msg){\n\t\t\tct_feedback_message_output(ct_comment_id, ct_comment_status, msg, ct_undo);\n\t\t},\n error: function(jqXHR, textStatus, errorThrown) {\n\t\t\tconsole.log(jqXHR);\n\t\t\tconsole.log(textStatus);\n\t\t\tconsole.log(errorThrown);\n\t\t},\n timeout: 5000\n\t});\n}\n\n// Outputs CT message about feedback\nfunction ct_feedback_message_output(ct_comment_id, ct_comment_status, ct_result, ct_undo){\n\tif(ct_result == 1){\n\t\tif(ct_comment_status == 'approve' && !ct_undo){\n\t\t\tjQuery('tr#comment-'+ct_comment_id)\n\t\t\t\t.html('')\n\t\t\t\t.show()\n\t\t\t\t.append(\"\").children('td')\n\t\t\t\t\t.css('background', 'rgba(110,240,110,0.7)')\n\t\t\t\t\t.append(\"
\"+ctCommentsScreen.ct_feedback_msg+\"
\");\n\t\t}\n\t\tif(ct_comment_status == 'spam'){\n\t\t\tif(jQuery('tr').is('#undo-'+ct_comment_id)){\n\t\t\t\tjQuery('tr#undo-'+ct_comment_id)\n\t\t\t\t\t.css('background', 'rgba(240,110,110,0.7)');\n\t\t\t\tjQuery('tr#undo-'+ct_comment_id+' div.spam-undo-inside')\n\t\t\t\t\t.append(\" \"+ctCommentsScreen.ct_feedback_msg);\n\t\t\t}else{\n\t\t\t\tjQuery('tr#comment-'+ct_comment_id)\n\t\t\t\t.html('')\n\t\t\t\t.show()\n\t\t\t\t.css('background', 'rgba(240,110,110,0.7)')\n\t\t\t\t.append(\"\").children('td')\n\t\t\t\t\t.append(\"
\"+ctCommentsScreen.ct_feedback_msg+\"
\");\n\t\t\t}\n\t\t}\n\t}\n\tif(ct_result == 0){\n\t\t// Error occurred\n\t}if(ct_result == 'no_hash'){\n\t\t// No hash for this comment\n\t}\n}\n"],"names":["ct_is_email","str","search","ct_is_ip","ct_send_feedback_request","ct_comment_id","ct_comment_status","ct_undo","data","action","security","ctCommentsScreen","ct_ajax_nonce","comment_id","comment_status","jQuery","ajax","type","url","ajaxurl","success","msg","ct_feedback_message_output","error","jqXHR","textStatus","errorThrown","console","log","timeout","ct_result","html","show","append","children","css","ct_feedback_msg","is","document","ready","parseInt","ct_show_check_links","each","ct_curr_str","this","ct_url","links","comments_editscreen","replace","after","ct_img_src_new_tab","on","result","attr","match","undo_comment_id","setTimeout","click","feedback_result"],"mappings":"AAAA,SAASA,YAAYC,GACpB,OAAOA,EAAIC,OAAO,WAAW,CAC9B,CACA,SAASC,SAASF,GACjB,OAAOA,EAAIC,OAAO,sCAAsC,CACzD,CAsEA,SAASE,yBAAyBC,EAAeC,EAA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K,MAAM,GACnCC,MAAM,4BAA4B,EAElDlD,yBADAC,EAAgB+C,EAAO,GACiB,UAAW,CAAC,CACrD,CAAC,EAGDrC,OAAO,gBAAgB,EAAEoC,GAAG,QAAS,WACpC,IACAC,GAASA,EADIrC,OAAO6B,IAAI,EAAES,KAAK,MAAM,GACrBC,MAAM,4BAA4B,EAClDjD,EAAgB+C,EAAO,GACvBM,gBAAkBtD,yBAAyBC,EAAe,UAAW,CAAC,CACvE,CAAC,CACF,CAAC"} \ No newline at end of file diff --git a/js/cleantalk-users-editscreen.min.js b/js/cleantalk-users-editscreen.min.js index ab2180ec8..cd68c413c 100644 --- a/js/cleantalk-users-editscreen.min.js +++ b/js/cleantalk-users-editscreen.min.js @@ -1,2 +1,2 @@ -function ct_is_email(e){return e.search(/.*@.*\..*/)}function ct_is_ip(e){return e.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)}jQuery(document).ready(function(){parseInt(ctUsersScreen.ct_show_check_links)&&(jQuery(".column-email a").each(function(){var e=jQuery(this).html();-1!==ct_is_email(e)&&(e+="?utm_source=admin_side&utm_medium=comments&utm_content=avatar&utm_campaign=apbct_links",jQuery(this).after(' '))}),jQuery(".username.column-username").each(function(){var e=jQuery(this).siblings(".apbct_status").children("span"),t=e.attr("id"),e=e.text(),e=jQuery("",{text:e}),c=jQuery("",{class:"apbct-icon-ok"}),r=jQuery("",{class:"apbct-icon-cancel",css:{color:"red"}});"apbct_not_checked"===t&&jQuery(this).children(".row-actions").before(c).before(e),"apbct_checked_not_spam"===t&&(c.attr("style","color:green;"),jQuery(this).children(".row-actions").before(c).before(e)),"apbct_checked_spam"===t&&jQuery(this).children(".row-actions").before(r).before(e)}))}); +function ct_is_email(e){return e.search(/.*@.*\..*/)}function ct_is_ip(e){return e.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)}jQuery(document).ready(function(){parseInt(ctUsersScreen.ct_show_check_links)&&(jQuery(".column-email a").each(function(){var e=jQuery(this).html();-1!==ct_is_email(e)&&(e=ctUsersScreen.links.users_editscreen.replace("{TARGET}",e),jQuery(this).after(' '))}),jQuery(".username.column-username").each(function(){var e=jQuery(this).siblings(".apbct_status").children("span"),c=e.attr("id"),e=e.text(),e=jQuery("",{text:e}),r=jQuery("",{class:"apbct-icon-ok"}),t=jQuery("",{class:"apbct-icon-cancel",css:{color:"red"}});"apbct_not_checked"===c&&jQuery(this).children(".row-actions").before(r).before(e),"apbct_checked_not_spam"===c&&(r.attr("style","color:green;"),jQuery(this).children(".row-actions").before(r).before(e)),"apbct_checked_spam"===c&&jQuery(this).children(".row-actions").before(t).before(e)}))}); //# sourceMappingURL=cleantalk-users-editscreen.min.js.map diff --git a/js/cleantalk-users-editscreen.min.js.map b/js/cleantalk-users-editscreen.min.js.map index caaec1d63..b52631952 100644 --- a/js/cleantalk-users-editscreen.min.js.map +++ b/js/cleantalk-users-editscreen.min.js.map @@ -1 +1 @@ -{"version":3,"file":"cleantalk-users-editscreen.min.js","sources":["cleantalk-users-editscreen.js"],"sourcesContent":["function ct_is_email(str){\n\treturn str.search(/.*@.*\\..*/);\n}\nfunction ct_is_ip(str){\n\treturn str.search(/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/);\n}\n\njQuery(document).ready(function(){\n\n\n\tif(parseInt(ctUsersScreen.ct_show_check_links)) {\n\n\t\t/* Shows link to blacklists near every email and IP address */\n\t\tjQuery('.column-email a').each(function(){\n\t\t\tvar ct_curr_str = jQuery(this).html();\n\t\t\tif( ct_is_email(ct_curr_str) !== -1 ){\n\t\t\t\tct_curr_str += '?utm_source=admin_side&utm_medium=comments&utm_content=avatar&utm_campaign=apbct_links';\n\t\t\t\tjQuery(this).after(' ');\n\t\t\t}\n\t\t});\n\n\t\t/* Show checked ico near avatar */\n\t\tjQuery('.username.column-username').each(function(){\n\n\t\t\tvar apbct_checking_el = jQuery(this).siblings('.apbct_status').children('span');\n\t\t\tvar apbct_checking_status = apbct_checking_el.attr('id');\n\t\t\tvar apbct_checking_status_text = apbct_checking_el.text();\n\n\t\t\tvar apbct_add_text_element = jQuery('', {\n\t\t\t\ttext : apbct_checking_status_text\n\t\t\t});\n\t\t\tvar apbct_add_ico_ok = jQuery('', {\n\t\t\t\tclass : 'apbct-icon-ok'\n\t\t\t});\n\t\t\tvar apbct_add_ico_cancel = jQuery('', {\n\t\t\t\tclass : 'apbct-icon-cancel',\n\t\t\t\tcss : {\n\t\t\t\t\tcolor : 'red'\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif( apbct_checking_status ==='apbct_not_checked' ) {\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_ok).before(apbct_add_text_element);\n\t\t\t}\n\t\t\tif( apbct_checking_status ==='apbct_checked_not_spam' ) {\n\t\t\t\tapbct_add_ico_ok.attr('style', 'color:green;');\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_ok).before(apbct_add_text_element);\n\t\t\t}\n\t\t\tif( apbct_checking_status ==='apbct_checked_spam' ) {\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_cancel).before(apbct_add_text_element);\n\t\t\t}\n\n\t\t});\n\n\t}\n\n});"],"names":["ct_is_email","str","search","ct_is_ip","jQuery","document","ready","parseInt","ctUsersScreen","ct_show_check_links","each","ct_curr_str","this","html","after","ct_img_src_new_tab","apbct_checking_el","siblings","children","apbct_checking_status","attr","apbct_checking_status_text","text","apbct_add_text_element","apbct_add_ico_ok","class","apbct_add_ico_cancel","css","color","before"],"mappings":"AAAA,SAASA,YAAYC,GACpB,OAAOA,EAAIC,OAAO,WAAW,CAC9B,CACA,SAASC,SAASF,GACjB,OAAOA,EAAIC,OAAO,sCAAsC,CACzD,CAEAE,OAAOC,QAAQ,EAAEC,MAAM,WAGnBC,SAASC,cAAcC,mBAAmB,IAG5CL,OAAO,iBAAiB,EAAEM,KAAK,WAC9B,IAAIC,EAAcP,OAAOQ,IAAI,EAAEC,KAAK,EACH,CAAC,IAA9Bb,YAAYW,CAAW,IAC1BA,GAAe,yFACfP,OAAOQ,IAAI,EAAEE,MAAM,mDAAmDH,EAAY,6DAA6DA,EAAY,uCAAuCH,cAAcO,mBAAmB,QAAQ,EAE7O,CAAC,EAGDX,OAAO,2BAA2B,EAAEM,KAAK,WAExC,IAAIM,EAAoBZ,OAAOQ,IAAI,EAAEK,SAAS,eAAe,EAAEC,SAAS,MAAM,EAC1EC,EAAwBH,EAAkBI,KAAK,IAAI,EACnDC,EAA6BL,EAAkBM,KAAK,EAEpDC,EAAyBnB,OAAO,SAAU,CAC7CkB,KAAOD,CACR,CAAC,EACGG,EAAmBpB,OAAO,MAAO,CACpCqB,MAAS,eACV,CAAC,EACGC,EAAuBtB,OAAO,MAAO,CACxCqB,MAAS,oBACTE,IAAM,CACLC,MAAQ,KACT,CACD,CAAC,EAE4B,sBAAzBT,GACHf,OAAOQ,IAAI,EAAEM,SAAS,cAAc,EAAEW,OAAOL,CAAgB,EAAEK,OAAON,CAAsB,EAEhE,2BAAzBJ,IACHK,EAAiBJ,KAAK,QAAS,cAAc,EAC7ChB,OAAOQ,IAAI,EAAEM,SAAS,cAAc,EAAEW,OAAOL,CAAgB,EAAEK,OAAON,CAAsB,GAEhE,uBAAzBJ,GACHf,OAAOQ,IAAI,EAAEM,SAAS,cAAc,EAAEW,OAAOH,CAAoB,EAAEG,OAAON,CAAsB,CAGlG,CAAC,EAIH,CAAC"} \ No newline at end of file +{"version":3,"file":"cleantalk-users-editscreen.min.js","sources":["cleantalk-users-editscreen.js"],"sourcesContent":["function ct_is_email(str){\n\treturn str.search(/.*@.*\\..*/);\n}\nfunction ct_is_ip(str){\n\treturn str.search(/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/);\n}\n\njQuery(document).ready(function(){\n\n\n\tif(parseInt(ctUsersScreen.ct_show_check_links)) {\n\n\t\t/* Shows link to blacklists near every email and IP address */\n\t\tjQuery('.column-email a').each(function(){\n\t\t\tvar ct_curr_str = jQuery(this).html();\n\t\t\tif( ct_is_email(ct_curr_str) !== -1 ){\n\t\t\t\tvar ct_url = ctUsersScreen.links.users_editscreen.replace('{TARGET}', ct_curr_str);\n\t\t\t\tjQuery(this).after(' ');\n\t\t\t}\n\t\t});\n\n\t\t/* Show checked ico near avatar */\n\t\tjQuery('.username.column-username').each(function(){\n\n\t\t\tvar apbct_checking_el = jQuery(this).siblings('.apbct_status').children('span');\n\t\t\tvar apbct_checking_status = apbct_checking_el.attr('id');\n\t\t\tvar apbct_checking_status_text = apbct_checking_el.text();\n\n\t\t\tvar apbct_add_text_element = jQuery('', {\n\t\t\t\ttext : apbct_checking_status_text\n\t\t\t});\n\t\t\tvar apbct_add_ico_ok = jQuery('', {\n\t\t\t\tclass : 'apbct-icon-ok'\n\t\t\t});\n\t\t\tvar apbct_add_ico_cancel = jQuery('', {\n\t\t\t\tclass : 'apbct-icon-cancel',\n\t\t\t\tcss : {\n\t\t\t\t\tcolor : 'red'\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif( apbct_checking_status ==='apbct_not_checked' ) {\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_ok).before(apbct_add_text_element);\n\t\t\t}\n\t\t\tif( apbct_checking_status ==='apbct_checked_not_spam' ) {\n\t\t\t\tapbct_add_ico_ok.attr('style', 'color:green;');\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_ok).before(apbct_add_text_element);\n\t\t\t}\n\t\t\tif( apbct_checking_status ==='apbct_checked_spam' ) {\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_cancel).before(apbct_add_text_element);\n\t\t\t}\n\n\t\t});\n\n\t}\n\n});"],"names":["ct_is_email","str","search","ct_is_ip","jQuery","document","ready","parseInt","ctUsersScreen","ct_show_check_links","each","ct_curr_str","this","html","ct_url","links","users_editscreen","replace","after","ct_img_src_new_tab","apbct_checking_el","siblings","children","apbct_checking_status","attr","apbct_checking_status_text","text","apbct_add_text_element","apbct_add_ico_ok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IH,CAAC"} \ No newline at end of file diff --git a/js/src/cleantalk-comments-editscreen.js b/js/src/cleantalk-comments-editscreen.js index d32289c09..6418336fd 100644 --- a/js/src/cleantalk-comments-editscreen.js +++ b/js/src/cleantalk-comments-editscreen.js @@ -11,8 +11,8 @@ jQuery(document).ready(function(){ jQuery('.column-author a, .comment-author a').each(function(){ var ct_curr_str = jQuery(this).html(); if(ct_is_email(ct_curr_str) != -1 || ct_is_ip(ct_curr_str) != -1){ - ct_curr_str += '?utm_source=admin_side&utm_medium=comments&utm_content=avatar&utm_campaign=apbct_links'; - jQuery(this).after(' '); + var ct_url = ctCommentsScreen.links.comments_editscreen.replace('{TARGET}', ct_curr_str); + jQuery(this).after(' '); } }); diff --git a/js/src/cleantalk-users-editscreen.js b/js/src/cleantalk-users-editscreen.js index 78151c3ac..663537c02 100644 --- a/js/src/cleantalk-users-editscreen.js +++ b/js/src/cleantalk-users-editscreen.js @@ -14,8 +14,8 @@ jQuery(document).ready(function(){ jQuery('.column-email a').each(function(){ var ct_curr_str = jQuery(this).html(); if( ct_is_email(ct_curr_str) !== -1 ){ - ct_curr_str += '?utm_source=admin_side&utm_medium=comments&utm_content=avatar&utm_campaign=apbct_links'; - jQuery(this).after(' '); + var ct_url = ctUsersScreen.links.users_editscreen.replace('{TARGET}', ct_curr_str); + jQuery(this).after(' '); } }); diff --git a/lib/Cleantalk/ApbctWP/LinkConstructor.php b/lib/Cleantalk/ApbctWP/LinkConstructor.php index 3d71472d2..7f4bde96a 100644 --- a/lib/Cleantalk/ApbctWP/LinkConstructor.php +++ b/lib/Cleantalk/ApbctWP/LinkConstructor.php @@ -224,6 +224,12 @@ class LinkConstructor extends \Cleantalk\Common\LinkConstructor 'utm_medium' => 'settings', 'utm_content' => 'antispam', ), + 'admin_blacklists_avatar_link' => array( + 'utm_source' => 'admin_side', + 'utm_medium' => 'comments', + 'utm_content' => 'avatar', + 'utm_campaign' => 'apbct_links', + ), ); public static function buildCleanTalkLink($utm_preset, $uri = '', $get_params = array(), $domain = 'https://cleantalk.org') diff --git a/lib/Cleantalk/ApbctWP/Localize/CtPublicLocalize.php b/lib/Cleantalk/ApbctWP/Localize/CtPublicLocalize.php index 361e4fcda..8f12b1e97 100644 --- a/lib/Cleantalk/ApbctWP/Localize/CtPublicLocalize.php +++ b/lib/Cleantalk/ApbctWP/Localize/CtPublicLocalize.php @@ -3,6 +3,7 @@ namespace Cleantalk\ApbctWP\Localize; use Cleantalk\ApbctWP\CleantalkRealPerson; +use Cleantalk\ApbctWP\LinkConstructor; class CtPublicLocalize { @@ -41,6 +42,10 @@ public static function getData() 'advancedCacheExists' => apbct_is_advanced_cache_exists(), 'varnishCacheExists' => apbct_is_varnish_cache_exists(), 'wc_ajax_add_to_cart' => get_option('woocommerce_enable_ajax_add_to_cart') === 'yes', + 'links' => array( + 'users_editscreen' => LinkConstructor::buildCleanTalkLink('admin_blacklists_avatar_link', 'blacklists/{TARGET}'), + 'comments_editscreen' => LinkConstructor::buildCleanTalkLink('admin_blacklists_avatar_link', 'blacklists/{TARGET}'), + ), ); if ( $apbct->settings['comments__the_real_person'] ) { $localize_array = array_merge($localize_array, CleantalkRealPerson::getLocalizingData()); From 33ed070c7c3f26ae6d551dd3b6e9746034c2a7a3 Mon Sep 17 00:00:00 2001 From: datorik Date: Mon, 18 May 2026 07:38:38 +0300 Subject: [PATCH 2/4] Unit tests --- .../ApbctWP/Localize/TestCtPublicLocalize.php | 26 +++++++++++++++++++ tests/ApbctWP/TestCleanTalkLinks.php | 23 ++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/tests/ApbctWP/Localize/TestCtPublicLocalize.php b/tests/ApbctWP/Localize/TestCtPublicLocalize.php index ffa1ca500..34291ec80 100644 --- a/tests/ApbctWP/Localize/TestCtPublicLocalize.php +++ b/tests/ApbctWP/Localize/TestCtPublicLocalize.php @@ -30,4 +30,30 @@ public function testGetData() $this->assertArrayHasKey('bot_detector_enabled', $localize_data); $this->assertArrayNotHasKey('data__bot_detector_enabled', $localize_data); } + + public function testGetDataContainsLinksArray() + { + $localize_data = CtPublicLocalize::getData(); + + $this->assertArrayHasKey('links', $localize_data); + $this->assertIsArray($localize_data['links']); + $this->assertArrayHasKey('users_editscreen', $localize_data['links']); + $this->assertArrayHasKey('comments_editscreen', $localize_data['links']); + } + + public function testGetDataLinksUsersEditscreen() + { + $localize_data = CtPublicLocalize::getData(); + + $expected = 'https://cleantalk.org/blacklists/{TARGET}?utm_source=admin_side&utm_medium=comments&utm_content=avatar&utm_campaign=apbct_links'; + $this->assertSame($expected, $localize_data['links']['users_editscreen']); + } + + public function testGetDataLinksCommentsEditscreen() + { + $localize_data = CtPublicLocalize::getData(); + + $expected = 'https://cleantalk.org/blacklists/{TARGET}?utm_source=admin_side&utm_medium=comments&utm_content=avatar&utm_campaign=apbct_links'; + $this->assertSame($expected, $localize_data['links']['comments_editscreen']); + } } \ No newline at end of file diff --git a/tests/ApbctWP/TestCleanTalkLinks.php b/tests/ApbctWP/TestCleanTalkLinks.php index a1d28afab..b4e39808b 100644 --- a/tests/ApbctWP/TestCleanTalkLinks.php +++ b/tests/ApbctWP/TestCleanTalkLinks.php @@ -47,6 +47,29 @@ public function testDashboardWidgetLink() $link); } + public function testAdminBlacklistsAvatarLink() + { + $link = LinkConstructor::buildCleanTalkLink( + 'admin_blacklists_avatar_link', + 'blacklists/{TARGET}' + ); + $this->assertIsString($link); + $this->assertEquals( + 'https://cleantalk.org/blacklists/{TARGET}?utm_source=admin_side&utm_medium=comments&utm_content=avatar&utm_campaign=apbct_links', + $link + ); + } + + public function testAdminBlacklistsAvatarLinkPresetExists() + { + $this->assertArrayHasKey('admin_blacklists_avatar_link', LinkConstructor::$utm_presets); + $preset = LinkConstructor::$utm_presets['admin_blacklists_avatar_link']; + $this->assertSame('admin_side', $preset['utm_source']); + $this->assertSame('comments', $preset['utm_medium']); + $this->assertSame('avatar', $preset['utm_content']); + $this->assertSame('apbct_links', $preset['utm_campaign']); + } + public function testRenewalLink() { $token = 'test_token'; From 42e6d9ea4acb937d44f1b9c83a36c0e711277646 Mon Sep 17 00:00:00 2001 From: datorik Date: Mon, 18 May 2026 13:50:29 +0300 Subject: [PATCH 3/4] Code. Code review --- inc/cleantalk-admin.php | 13 +++++++------ js/cleantalk-comments-editscreen.min.js | 2 +- js/cleantalk-comments-editscreen.min.js.map | 2 +- js/cleantalk-users-editscreen.min.js | 2 +- js/cleantalk-users-editscreen.min.js.map | 2 +- js/src/cleantalk-comments-editscreen.js | 2 +- js/src/cleantalk-users-editscreen.js | 4 +++- lib/Cleantalk/ApbctWP/Localize/CtPublicLocalize.php | 5 ----- 8 files changed, 15 insertions(+), 17 deletions(-) diff --git a/inc/cleantalk-admin.php b/inc/cleantalk-admin.php index 0d6f59fbc..2b9dea260 100644 --- a/inc/cleantalk-admin.php +++ b/inc/cleantalk-admin.php @@ -3,7 +3,6 @@ use Cleantalk\ApbctWP\AdjustToEnvironmentModule\AdjustToEnvironmentHandler; use Cleantalk\ApbctWP\AJAXService; use Cleantalk\ApbctWP\ApbctEnqueue; -use Cleantalk\ApbctWP\Localize\CtPublicLocalize; use Cleantalk\ApbctWP\CleantalkSettingsTemplates; use Cleantalk\ApbctWP\ContactsEncoder\ContactsEncoder; use Cleantalk\ApbctWP\Escape; @@ -540,6 +539,10 @@ function apbct_admin__enqueue_scripts($hook) 'notice_when_deleting_user_text' => esc_html__('Warning! Users are deleted without the possibility of restoring them, you can only restore them from a site backup.', 'cleantalk-spam-protect'), 'apbctNoticeDismissSuccess' => esc_html__('Thank you for the review! We strive to make our Anti-Spam plugin better every day.', 'cleantalk-spam-protect'), 'apbctNoticeForceProtectionOn' => esc_html__('This option affects the reflection of the page by checking the user and adds a cookie "apbct_force_protection_check", which serves as an indicator of successful or unsuccessful verification. If the check is successful, it will no longer run.', 'cleantalk-spam-protect'), + 'links' => array( + 'users_editscreen' => LinkConstructor::buildCleanTalkLink('admin_blacklists_avatar_link', 'blacklists/{TARGET}'), + 'comments_editscreen' => LinkConstructor::buildCleanTalkLink('admin_blacklists_avatar_link', 'blacklists/{TARGET}'), + ), ); $data = array_merge($data, ContactsEncoder::getLocalizationText()); wp_localize_script('cleantalk-admin-js', 'ctAdminCommon', $data); @@ -617,7 +620,7 @@ function apbct_admin__enqueue_scripts($hook) 'ctTrpAdminLocalize', \Cleantalk\ApbctWP\CleantalkRealPerson::getLocalizingData() ); - ApbctEnqueue::getInstance()->js('cleantalk-comments-editscreen.js'); + ApbctEnqueue::getInstance()->js('cleantalk-comments-editscreen.js', array('cleantalk-admin-js')); $link = LinkConstructor::buildCleanTalkLink( 'public_comments_page_go_to_cp', 'my', @@ -635,23 +638,21 @@ function apbct_admin__enqueue_scripts($hook) __("Feedback has been sent to %sCleanTalk Dashboard%s.", 'cleantalk-spam-protect'), $apbct->user_token ? "" : '', $apbct->user_token ? "" : '' - ) . ' ' . esc_html__('The service accepts feedback only for requests made no more than 7 or 45 days + ) . ' ' . esc_html__('The service accepts feedback only for requests made no more than 7 or 45 days (if the Extra package is activated) ago.', 'cleantalk-spam-protect'), 'ct_show_check_links' => (bool)$apbct->settings['comments__show_check_links'], 'ct_img_src_new_tab' => plugin_dir_url(__FILE__) . "images/new_window.gif", - 'links' => CtPublicLocalize::getData()['links'], )); } // USERS page JavaScript if ( $hook == 'users.php' ) { ApbctEnqueue::getInstance()->css('cleantalk-icons.css'); - ApbctEnqueue::getInstance()->js('cleantalk-users-editscreen.js'); + ApbctEnqueue::getInstance()->js('cleantalk-users-editscreen.js', array('cleantalk-admin-js')); wp_localize_script('cleantalk-users-editscreen-js', 'ctUsersScreen', array( 'spambutton_text' => __("Find spam-users", 'cleantalk-spam-protect'), 'ct_show_check_links' => (bool)$apbct->settings['comments__show_check_links'], 'ct_img_src_new_tab' => plugin_dir_url(__FILE__) . "images/new_window.gif", - 'links' => CtPublicLocalize::getData()['links'], )); } } diff --git a/js/cleantalk-comments-editscreen.min.js b/js/cleantalk-comments-editscreen.min.js index 3ee5d0d97..e3200aaf8 100644 --- a/js/cleantalk-comments-editscreen.min.js +++ b/js/cleantalk-comments-editscreen.min.js @@ -1,2 +1,2 @@ -function ct_is_email(e){return e.search(/.*@.*\..*/)}function ct_is_ip(e){return e.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)}function ct_send_feedback_request(t,c,n){var e={action:"ct_feedback_comment",security:ctCommentsScreen.ct_ajax_nonce,comment_id:t,comment_status:c};jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){ct_feedback_message_output(t,c,e,n)},error:function(e,t,c){console.log(e),console.log(t),console.log(c)},timeout:5e3})}function ct_feedback_message_output(e,t,c,n){1==c&&("approve"!=t||n||jQuery("tr#comment-"+e).html("").show().append("").children("td").css("background","rgba(110,240,110,0.7)").append("
"+ctCommentsScreen.ct_feedback_msg+"
"),"spam"==t)&&(jQuery("tr").is("#undo-"+e)?(jQuery("tr#undo-"+e).css("background","rgba(240,110,110,0.7)"),jQuery("tr#undo-"+e+" div.spam-undo-inside").append(" "+ctCommentsScreen.ct_feedback_msg)):jQuery("tr#comment-"+e).html("").show().css("background","rgba(240,110,110,0.7)").append("").children("td").append("
"+ctCommentsScreen.ct_feedback_msg+"
"))}jQuery(document).ready(function(){var t;parseInt(ctCommentsScreen.ct_show_check_links)&&jQuery(".column-author a, .comment-author a").each(function(){var e=jQuery(this).html();-1==ct_is_email(e)&&-1==ct_is_ip(e)||(e=ctCommentsScreen.links.comments_editscreen.replace("{TARGET}",e),jQuery(this).after(' '))}),jQuery("span.approve").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],ct_send_feedback_request(undo_comment_id=t,"approve",0)}),jQuery("span.unapprove").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],ct_send_feedback_request(undo_comment_id=t,"spam",0)}),jQuery("span.spam").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],ct_send_feedback_request(undo_comment_id=t,"spam",0),setTimeout(function(){jQuery("tr#undo-"+t+" span.unspam a").click(function(){var e=(e=jQuery(this).attr("href")).match(/^comment\.php\?.*&c=(\d*).*/);ct_send_feedback_request(t=e[1],"approve",1)})},202)}),jQuery("span.unspam").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);ct_send_feedback_request(t=e[1],"approve",0)}),jQuery("span.untrash a").on("click",function(){var e=(e=jQuery(this).attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],feedback_result=ct_send_feedback_request(t,"approve",0)})}); +function ct_is_email(e){return e.search(/.*@.*\..*/)}function ct_is_ip(e){return e.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)}function ct_send_feedback_request(t,c,n){var e={action:"ct_feedback_comment",security:ctCommentsScreen.ct_ajax_nonce,comment_id:t,comment_status:c};jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){ct_feedback_message_output(t,c,e,n)},error:function(e,t,c){console.log(e),console.log(t),console.log(c)},timeout:5e3})}function ct_feedback_message_output(e,t,c,n){1==c&&("approve"!=t||n||jQuery("tr#comment-"+e).html("").show().append("").children("td").css("background","rgba(110,240,110,0.7)").append("
"+ctCommentsScreen.ct_feedback_msg+"
"),"spam"==t)&&(jQuery("tr").is("#undo-"+e)?(jQuery("tr#undo-"+e).css("background","rgba(240,110,110,0.7)"),jQuery("tr#undo-"+e+" div.spam-undo-inside").append(" "+ctCommentsScreen.ct_feedback_msg)):jQuery("tr#comment-"+e).html("").show().css("background","rgba(240,110,110,0.7)").append("").children("td").append("
"+ctCommentsScreen.ct_feedback_msg+"
"))}jQuery(document).ready(function(){var t;parseInt(ctCommentsScreen.ct_show_check_links)&&jQuery(".column-author a, .comment-author a").each(function(){var e=jQuery(this).html();-1==ct_is_email(e)&&-1==ct_is_ip(e)||(e=ctAdminCommon.links.comments_editscreen.replace("{TARGET}",e),jQuery(this).after(' '))}),jQuery("span.approve").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],ct_send_feedback_request(undo_comment_id=t,"approve",0)}),jQuery("span.unapprove").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],ct_send_feedback_request(undo_comment_id=t,"spam",0)}),jQuery("span.spam").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],ct_send_feedback_request(undo_comment_id=t,"spam",0),setTimeout(function(){jQuery("tr#undo-"+t+" span.unspam a").click(function(){var e=(e=jQuery(this).attr("href")).match(/^comment\.php\?.*&c=(\d*).*/);ct_send_feedback_request(t=e[1],"approve",1)})},202)}),jQuery("span.unspam").on("click",function(){var e=(e=jQuery(this).children("a").attr("href")).match(/^comment\.php\?.*c=(\d*).*/);ct_send_feedback_request(t=e[1],"approve",0)}),jQuery("span.untrash a").on("click",function(){var e=(e=jQuery(this).attr("href")).match(/^comment\.php\?.*c=(\d*).*/);t=e[1],feedback_result=ct_send_feedback_request(t,"approve",0)})}); //# sourceMappingURL=cleantalk-comments-editscreen.min.js.map diff --git a/js/cleantalk-comments-editscreen.min.js.map b/js/cleantalk-comments-editscreen.min.js.map index 29b80c8db..8ec7925a0 100644 --- a/js/cleantalk-comments-editscreen.min.js.map +++ b/js/cleantalk-comments-editscreen.min.js.map @@ -1 +1 @@ -{"version":3,"file":"cleantalk-comments-editscreen.min.js","sources":["cleantalk-comments-editscreen.js"],"sourcesContent":["function ct_is_email(str){\n\treturn str.search(/.*@.*\\..*/);\n}\nfunction ct_is_ip(str){\n\treturn str.search(/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/);\n}\n\njQuery(document).ready(function(){\n\t/* Shows link to blacklists near every email and IP address */\n\tif(parseInt(ctCommentsScreen.ct_show_check_links))\n\t\tjQuery('.column-author a, .comment-author a').each(function(){\n\t\t\tvar ct_curr_str = jQuery(this).html();\n\t\t\tif(ct_is_email(ct_curr_str) != -1 || ct_is_ip(ct_curr_str) != -1){\n\t\t\t\tvar ct_url = ctCommentsScreen.links.comments_editscreen.replace('{TARGET}', ct_curr_str);\n\t\t\t\tjQuery(this).after(' ');\n\t\t\t}\n\t\t});\n\n\t/* Feedback for comments */\n\tvar ct_comment_id;\n\n\t// For approved\n\tjQuery('span.approve').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tundo_comment_id = ct_comment_id;\n\t\tct_send_feedback_request(ct_comment_id, 'approve', 0);\n\t});\n\n\t// For unapprove\n\tjQuery('span.unapprove').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tundo_comment_id = ct_comment_id;\n\t\tct_send_feedback_request(ct_comment_id, 'spam', 0);\n\t});\n\n\t// For spammed\n\tjQuery('span.spam').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tundo_comment_id = ct_comment_id;\n\t\tct_send_feedback_request(ct_comment_id, 'spam', 0);\n\t\tsetTimeout(function(){\n\t\t\tjQuery('tr#undo-'+ct_comment_id+' span.unspam a').click(function(){\n\t\t\t\tvar result = jQuery(this).attr('href');\n\t\t\t\tresult = result.match(/^comment\\.php\\?.*&c=(\\d*).*/);\n\t\t\t\tct_comment_id = result[1];\n\t\t\t\tct_send_feedback_request(ct_comment_id, 'approve', 1);\n\t\t\t});\n\t\t}, 202);\n\n\t});\n\n\t// For unspammed\n\tjQuery('span.unspam').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tct_send_feedback_request(ct_comment_id, 'approve', 0);\n\t});\n\n\t// For untrashed\n\tjQuery('span.untrash a').on('click', function(){\n\t\tvar result = jQuery(this).attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tfeedback_result = ct_send_feedback_request(ct_comment_id, 'approve', 0);\n\t});\n});\n\n// Send feedback to backend\nfunction ct_send_feedback_request(ct_comment_id, ct_comment_status, ct_undo){\n\n\tvar data = {\n\t\t'action': 'ct_feedback_comment',\n\t\t'security': ctCommentsScreen.ct_ajax_nonce,\n\t\t'comment_id': ct_comment_id,\n\t\t'comment_status': ct_comment_status\n\t};\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(msg){\n\t\t\tct_feedback_message_output(ct_comment_id, ct_comment_status, msg, ct_undo);\n\t\t},\n error: function(jqXHR, textStatus, errorThrown) {\n\t\t\tconsole.log(jqXHR);\n\t\t\tconsole.log(textStatus);\n\t\t\tconsole.log(errorThrown);\n\t\t},\n timeout: 5000\n\t});\n}\n\n// Outputs CT message about feedback\nfunction ct_feedback_message_output(ct_comment_id, ct_comment_status, ct_result, ct_undo){\n\tif(ct_result == 1){\n\t\tif(ct_comment_status == 'approve' && !ct_undo){\n\t\t\tjQuery('tr#comment-'+ct_comment_id)\n\t\t\t\t.html('')\n\t\t\t\t.show()\n\t\t\t\t.append(\"\").children('td')\n\t\t\t\t\t.css('background', 'rgba(110,240,110,0.7)')\n\t\t\t\t\t.append(\"
\"+ctCommentsScreen.ct_feedback_msg+\"
\");\n\t\t}\n\t\tif(ct_comment_status == 'spam'){\n\t\t\tif(jQuery('tr').is('#undo-'+ct_comment_id)){\n\t\t\t\tjQuery('tr#undo-'+ct_comment_id)\n\t\t\t\t\t.css('background', 'rgba(240,110,110,0.7)');\n\t\t\t\tjQuery('tr#undo-'+ct_comment_id+' div.spam-undo-inside')\n\t\t\t\t\t.append(\" \"+ctCommentsScreen.ct_feedback_msg);\n\t\t\t}else{\n\t\t\t\tjQuery('tr#comment-'+ct_comment_id)\n\t\t\t\t.html('')\n\t\t\t\t.show()\n\t\t\t\t.css('background', 'rgba(240,110,110,0.7)')\n\t\t\t\t.append(\"\").children('td')\n\t\t\t\t\t.append(\"
\"+ctCommentsScreen.ct_feedback_msg+\"
\");\n\t\t\t}\n\t\t}\n\t}\n\tif(ct_result == 0){\n\t\t// Error occurred\n\t}if(ct_result == 'no_hash'){\n\t\t// No hash for this comment\n\t}\n}\n"],"names":["ct_is_email","str","search","ct_is_ip","ct_send_feedback_request","ct_comment_id","ct_comment_status","ct_undo","data","action","security","ctCommentsScreen","ct_ajax_nonce","comment_id","comment_status","jQuery","ajax","type","url","ajaxurl","success","msg","ct_feedback_message_output","error","jqXHR","textStatus","errorThrown","console","log","timeout","ct_result","html","show","append","children","css","ct_feedback_msg","is","document","ready","parseInt","ct_show_check_links","each","ct_curr_str","this","ct_url","links","comments_editscreen","replace","after","ct_img_src_new_tab","on","result","attr","match","undo_comment_id","setTimeout","click","feedback_result"],"mappings":"AAAA,SAASA,YAAYC,GACpB,OAAOA,EAAIC,OAAO,WAAW,CAC9B,CACA,SAASC,SAASF,GACjB,OAAOA,EAAIC,OAAO,sCAAsC,CACzD,CAsEA,SAASE,yBAAyBC,EAAeC,EAAmBC,GAEnE,IAAIC,EAAO,CACVC,OAAU,sBACVC,SAAYC,iBAAiBC,cAC7BC,WAAcR,EACdS,eAAkBR,CACnB,EAEAS,OAAOC,KAAK,CACXC,KAAM,OACNC,IAAKC,QACLX,KAAMA,EACNY,QAAS,SAASC,GACjBC,2BAA2BjB,EAAeC,EAAmBe,EAAKd,CAAO,CAC1E,EACMgB,MAAO,SAASC,EAAOC,EAAYC,GACxCC,QAAQC,IAAIJ,CAAK,EACjBG,QAAQC,IAAIH,CAAU,EACtBE,QAAQC,IAAIF,CAAW,CACxB,EACMG,QAAS,GAChB,CAAC,CACF,CAGA,SAAS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hD,yBADAmD,gBAAkBlD,EACsB,UAAW,CAAC,CACrD,CAAC,EAGDU,OAAO,gBAAgB,EAAEoC,GAAG,QAAS,WACpC,IACAC,GAASA,EADIrC,OAAO6B,IAAI,EAAEV,SAAS,GAAG,EAAEmB,KAAK,MAAM,GACnCC,MAAM,4BAA4B,EAClDjD,EAAgB+C,EAAO,GAEvBhD,yBADAmD,gBAAkBlD,EACsB,OAAQ,CAAC,CAClD,CAAC,EAGDU,OAAO,WAAW,EAAEoC,GAAG,QAAS,WAC/B,IACAC,GAASA,EADIrC,OAAO6B,IAAI,EAAEV,SAAS,GAAG,EAAEmB,KAAK,MAAM,GACnCC,MAAM,4BAA4B,EAClDjD,EAAgB+C,EAAO,GAEvBhD,yBADAmD,gBAAkBlD,EACsB,OAAQ,CAAC,EACjDmD,WAAW,WACVzC,OAAO,WAAWV,EAAc,gBAAgB,EAAEoD,MAAM,WACvD,IACAL,GAASA,EADIrC,OAAO6B,IAAI,EAAES,KAAK,MAAM,GACrBC,MAAM,6BAA6B,EAEnDlD,yBADAC,EAAgB+C,EAAO,GACiB,UAAW,CAAC,CACrD,CAAC,CACF,EAAG,GAAG,CAEP,CAAC,EAGDrC,OAAO,aAAa,EAAEoC,GAAG,QAAS,WACjC,IACAC,GAASA,EADIrC,OAAO6B,IAAI,EAAEV,SAAS,GAAG,EAAEmB,KAAK,MAAM,GACnCC,MAAM,4BAA4B,EAElDlD,yBADAC,EAAgB+C,EAAO,GACiB,UAAW,CAAC,CACrD,CAAC,EAGDrC,OAAO,gBAAgB,EAAEoC,GAAG,QAAS,WACpC,IACAC,GAASA,EADIrC,OAAO6B,IAAI,EAAES,KAAK,MAAM,GACrBC,MAAM,4BAA4B,EAClDjD,EAAgB+C,EAAO,GACvBM,gBAAkBtD,yBAAyBC,EAAe,UAAW,CAAC,CACvE,CAAC,CACF,CAAC"} \ No newline at end of file +{"version":3,"file":"cleantalk-comments-editscreen.min.js","sources":["cleantalk-comments-editscreen.js"],"sourcesContent":["function ct_is_email(str){\n\treturn str.search(/.*@.*\\..*/);\n}\nfunction ct_is_ip(str){\n\treturn str.search(/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/);\n}\n\njQuery(document).ready(function(){\n\t/* Shows link to blacklists near every email and IP address */\n\tif(parseInt(ctCommentsScreen.ct_show_check_links))\n\t\tjQuery('.column-author a, .comment-author a').each(function(){\n\t\t\tvar ct_curr_str = jQuery(this).html();\n\t\t\tif(ct_is_email(ct_curr_str) != -1 || ct_is_ip(ct_curr_str) != -1){\n\t\t\t\tvar ct_url = ctAdminCommon.links.comments_editscreen.replace('{TARGET}', ct_curr_str);\n\t\t\t\tjQuery(this).after(' ');\n\t\t\t}\n\t\t});\n\n\t/* Feedback for comments */\n\tvar ct_comment_id;\n\n\t// For approved\n\tjQuery('span.approve').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tundo_comment_id = ct_comment_id;\n\t\tct_send_feedback_request(ct_comment_id, 'approve', 0);\n\t});\n\n\t// For unapprove\n\tjQuery('span.unapprove').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tundo_comment_id = ct_comment_id;\n\t\tct_send_feedback_request(ct_comment_id, 'spam', 0);\n\t});\n\n\t// For spammed\n\tjQuery('span.spam').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tundo_comment_id = ct_comment_id;\n\t\tct_send_feedback_request(ct_comment_id, 'spam', 0);\n\t\tsetTimeout(function(){\n\t\t\tjQuery('tr#undo-'+ct_comment_id+' span.unspam a').click(function(){\n\t\t\t\tvar result = jQuery(this).attr('href');\n\t\t\t\tresult = result.match(/^comment\\.php\\?.*&c=(\\d*).*/);\n\t\t\t\tct_comment_id = result[1];\n\t\t\t\tct_send_feedback_request(ct_comment_id, 'approve', 1);\n\t\t\t});\n\t\t}, 202);\n\n\t});\n\n\t// For unspammed\n\tjQuery('span.unspam').on('click', function(){\n\t\tvar result = jQuery(this).children('a').attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tct_send_feedback_request(ct_comment_id, 'approve', 0);\n\t});\n\n\t// For untrashed\n\tjQuery('span.untrash a').on('click', function(){\n\t\tvar result = jQuery(this).attr('href');\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\n\t\tct_comment_id = result[1];\n\t\tfeedback_result = ct_send_feedback_request(ct_comment_id, 'approve', 0);\n\t});\n});\n\n// Send feedback to backend\nfunction ct_send_feedback_request(ct_comment_id, ct_comment_status, ct_undo){\n\n\tvar data = {\n\t\t'action': 'ct_feedback_comment',\n\t\t'security': ctCommentsScreen.ct_ajax_nonce,\n\t\t'comment_id': ct_comment_id,\n\t\t'comment_status': ct_comment_status\n\t};\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(msg){\n\t\t\tct_feedback_message_output(ct_comment_id, ct_comment_status, msg, ct_undo);\n\t\t},\n error: function(jqXHR, textStatus, errorThrown) {\n\t\t\tconsole.log(jqXHR);\n\t\t\tconsole.log(textStatus);\n\t\t\tconsole.log(errorThrown);\n\t\t},\n timeout: 5000\n\t});\n}\n\n// Outputs CT message about feedback\nfunction ct_feedback_message_output(ct_comment_id, ct_comment_status, ct_result, ct_undo){\n\tif(ct_result == 1){\n\t\tif(ct_comment_status == 'approve' && !ct_undo){\n\t\t\tjQuery('tr#comment-'+ct_comment_id)\n\t\t\t\t.html('')\n\t\t\t\t.show()\n\t\t\t\t.append(\"\").children('td')\n\t\t\t\t\t.css('background', 'rgba(110,240,110,0.7)')\n\t\t\t\t\t.append(\"
\"+ctCommentsScreen.ct_feedback_msg+\"
\");\n\t\t}\n\t\tif(ct_comment_status == 'spam'){\n\t\t\tif(jQuery('tr').is('#undo-'+ct_comment_id)){\n\t\t\t\tjQuery('tr#undo-'+ct_comment_id)\n\t\t\t\t\t.css('background', 'rgba(240,110,110,0.7)');\n\t\t\t\tjQuery('tr#undo-'+ct_comment_id+' div.spam-undo-inside')\n\t\t\t\t\t.append(\" \"+ctCommentsScreen.ct_feedback_msg);\n\t\t\t}else{\n\t\t\t\tjQuery('tr#comment-'+ct_comment_id)\n\t\t\t\t.html('')\n\t\t\t\t.show()\n\t\t\t\t.css('background', 'rgba(240,110,110,0.7)')\n\t\t\t\t.append(\"\").children('td')\n\t\t\t\t\t.append(\"
\"+ctCommentsScreen.ct_feedback_msg+\"
\");\n\t\t\t}\n\t\t}\n\t}\n\tif(ct_result == 0){\n\t\t// Error occurred\n\t}if(ct_result == 'no_hash'){\n\t\t// No hash for this comment\n\t}\n}\n"],"names":["ct_is_email","str","search","ct_is_ip","ct_send_feedback_request","ct_comment_id","ct_comment_status","ct_undo","data","action","security","ctCommentsScreen","ct_ajax_nonce","comment_id","comment_status","jQuery","ajax","type","url","ajaxurl","success","msg","ct_feedback_message_output","error","jqXHR","textStatus","errorThrown","console","log","timeout","ct_result","html","show","append","children","css","ct_feedback_msg","is","document","ready","parseInt","ct_show_check_links","each","ct_curr_str","this","ct_url","ctAdminCommon","links","comments_editscreen","replace","after","ct_img_src_new_tab","on","result","attr","match","undo_comment_id","setTimeout","click","feedback_result"],"mappings":"AAAA,SAASA,YAAYC,GACpB,OAAOA,EAAIC,OAAO,WAAW,CAC9B,CACA,SAASC,SAASF,GACjB,OAAOA,EAAIC,OAAO,sCAAsC,CACzD,CAsEA,SAASE,yBAAyBC,EAAeC,EAAmBC,GAEnE,IAAIC,EAAO,CACVC,OAAU,sBACVC,SAAYC,iBAAiBC,cAC7BC,WAAcR,EACdS,eAAkBR,CACnB,EAEAS,OAAOC,KAAK,CACX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S,WACpC,IACAC,GAASA,EADItC,OAAO6B,IAAI,EAAEU,KAAK,MAAM,GACrBC,MAAM,4BAA4B,EAClDlD,EAAgBgD,EAAO,GACvBM,gBAAkBvD,yBAAyBC,EAAe,UAAW,CAAC,CACvE,CAAC,CACF,CAAC"} \ No newline at end of file diff --git a/js/cleantalk-users-editscreen.min.js b/js/cleantalk-users-editscreen.min.js index cd68c413c..f778bc4e7 100644 --- a/js/cleantalk-users-editscreen.min.js +++ b/js/cleantalk-users-editscreen.min.js @@ -1,2 +1,2 @@ -function ct_is_email(e){return e.search(/.*@.*\..*/)}function ct_is_ip(e){return e.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)}jQuery(document).ready(function(){parseInt(ctUsersScreen.ct_show_check_links)&&(jQuery(".column-email a").each(function(){var e=jQuery(this).html();-1!==ct_is_email(e)&&(e=ctUsersScreen.links.users_editscreen.replace("{TARGET}",e),jQuery(this).after(' '))}),jQuery(".username.column-username").each(function(){var e=jQuery(this).siblings(".apbct_status").children("span"),c=e.attr("id"),e=e.text(),e=jQuery("",{text:e}),r=jQuery("",{class:"apbct-icon-ok"}),t=jQuery("",{class:"apbct-icon-cancel",css:{color:"red"}});"apbct_not_checked"===c&&jQuery(this).children(".row-actions").before(r).before(e),"apbct_checked_not_spam"===c&&(r.attr("style","color:green;"),jQuery(this).children(".row-actions").before(r).before(e)),"apbct_checked_spam"===c&&jQuery(this).children(".row-actions").before(t).before(e)}))}); +function ct_is_email(e){return e.search(/.*@.*\..*/)}function ct_is_ip(e){return e.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)}jQuery(document).ready(function(){parseInt(ctUsersScreen.ct_show_check_links)&&(jQuery(".column-email a").each(function(){var e=jQuery(this).html();-1!==ct_is_email(e)&&(e=ctAdminCommon.links.users_editscreen.replace("{TARGET}",e),jQuery(this).after(' '))}),jQuery(".username.column-username").each(function(){var e=jQuery(this).siblings(".apbct_status").children("span"),c=e.attr("id"),e=e.text(),e=jQuery("",{text:e}),r=jQuery("",{class:"apbct-icon-ok"}),t=jQuery("",{class:"apbct-icon-cancel",css:{color:"red"}});"apbct_not_checked"===c&&jQuery(this).children(".row-actions").before(r).before(e),"apbct_checked_not_spam"===c&&(r.attr("style","color:green;"),jQuery(this).children(".row-actions").before(r).before(e)),"apbct_checked_spam"===c&&jQuery(this).children(".row-actions").before(t).before(e)}))}); //# sourceMappingURL=cleantalk-users-editscreen.min.js.map diff --git a/js/cleantalk-users-editscreen.min.js.map b/js/cleantalk-users-editscreen.min.js.map index b52631952..4bd237066 100644 --- a/js/cleantalk-users-editscreen.min.js.map +++ b/js/cleantalk-users-editscreen.min.js.map @@ -1 +1 @@ -{"version":3,"file":"cleantalk-users-editscreen.min.js","sources":["cleantalk-users-editscreen.js"],"sourcesContent":["function ct_is_email(str){\n\treturn str.search(/.*@.*\\..*/);\n}\nfunction ct_is_ip(str){\n\treturn str.search(/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/);\n}\n\njQuery(document).ready(function(){\n\n\n\tif(parseInt(ctUsersScreen.ct_show_check_links)) {\n\n\t\t/* Shows link to blacklists near every email and IP address */\n\t\tjQuery('.column-email a').each(function(){\n\t\t\tvar ct_curr_str = jQuery(this).html();\n\t\t\tif( ct_is_email(ct_curr_str) !== -1 ){\n\t\t\t\tvar ct_url = ctUsersScreen.links.users_editscreen.replace('{TARGET}', ct_curr_str);\n\t\t\t\tjQuery(this).after(' ');\n\t\t\t}\n\t\t});\n\n\t\t/* Show checked ico near avatar */\n\t\tjQuery('.username.column-username').each(function(){\n\n\t\t\tvar apbct_checking_el = jQuery(this).siblings('.apbct_status').children('span');\n\t\t\tvar apbct_checking_status = apbct_checking_el.attr('id');\n\t\t\tvar apbct_checking_status_text = apbct_checking_el.text();\n\n\t\t\tvar apbct_add_text_element = jQuery('', {\n\t\t\t\ttext : apbct_checking_status_text\n\t\t\t});\n\t\t\tvar apbct_add_ico_ok = jQuery('', {\n\t\t\t\tclass : 'apbct-icon-ok'\n\t\t\t});\n\t\t\tvar apbct_add_ico_cancel = jQuery('', {\n\t\t\t\tclass : 'apbct-icon-cancel',\n\t\t\t\tcss : {\n\t\t\t\t\tcolor : 'red'\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif( apbct_checking_status ==='apbct_not_checked' ) {\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_ok).before(apbct_add_text_element);\n\t\t\t}\n\t\t\tif( apbct_checking_status ==='apbct_checked_not_spam' ) {\n\t\t\t\tapbct_add_ico_ok.attr('style', 'color:green;');\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_ok).before(apbct_add_text_element);\n\t\t\t}\n\t\t\tif( apbct_checking_status ==='apbct_checked_spam' ) {\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_cancel).before(apbct_add_text_element);\n\t\t\t}\n\n\t\t});\n\n\t}\n\n});"],"names":["ct_is_email","str","search","ct_is_ip","jQuery","document","ready","parseInt","ctUsersScreen","ct_show_check_links","each","ct_curr_str","this","html","ct_url","links","users_editscreen","replace","after","ct_img_src_new_tab","apbct_checking_el","siblings","children","apbct_checking_status","attr","apbct_checking_status_text","text","apbct_add_text_element","apbct_add_ico_ok","class","apbct_add_ico_cancel","css","color","before"],"mappings":"AAAA,SAASA,YAAYC,GACpB,OAAOA,EAAIC,OAAO,WAAW,CAC9B,CACA,SAASC,SAASF,GACjB,OAAOA,EAAIC,OAAO,sCAAsC,CACzD,CAEAE,OAAOC,QAAQ,EAAEC,MAAM,WAGnBC,SAASC,cAAcC,mBAAmB,IAG5CL,OAAO,iBAAiB,EAAEM,KAAK,WAC9B,IAAIC,EAAcP,OAAOQ,IAAI,EAAEC,KAAK,EACH,CAAC,IAA9Bb,YAAYW,CAAW,IACtBG,EAASN,cAAcO,MAAMC,iBAAiBC,QAAQ,WAAYN,CAAW,EACjFP,OAAOQ,IAAI,EAAEM,MAAM,kBAAkBJ,EAAO,4BAA4BA,EAAO,uCAAuCN,cAAcW,mBAAmB,QAAQ,EAEjK,CAAC,EAGDf,OAAO,2BAA2B,EAAEM,KAAK,WAExC,IAAIU,EAAoBhB,OAAOQ,IAAI,EAAES,SAAS,eAAe,EAAEC,SAAS,MAAM,EAC1EC,EAAwBH,EAAkBI,KAAK,IAAI,EACnDC,EAA6BL,EAAkBM,KAAK,EAEpDC,EAAyBvB,OAAO,SAAU,CAC7CsB,KAAOD,CACR,CAAC,EACGG,EAAmBxB,OAAO,MAAO,CACpCyB,MAAS,eACV,CAAC,EACGC,EAAuB1B,OAAO,MAAO,CACxCyB,MAAS,oBACTE,IAAM,CACLC,MAAQ,KACT,CACD,CAAC,EAE4B,sBAAzBT,GACHnB,OAAOQ,IAAI,EAAEU,SAAS,cAAc,EAAEW,OAAOL,CAAgB,EAAEK,OAAON,CAAsB,EAEhE,2BAAzBJ,IACHK,EAAiBJ,KAAK,QAAS,cAAc,EAC7CpB,OAAOQ,IAAI,EAAEU,SAAS,cAAc,EAAEW,OAAOL,CAAgB,EAAEK,OAAON,CAAsB,GAEhE,uBAAzBJ,GACHnB,OAAOQ,IAAI,EAAEU,SAAS,cAAc,EAAEW,OAAOH,CAAoB,EAAEG,OAAON,CAAsB,CAGlG,CAAC,EAIH,CAAC"} \ No newline at end of file +{"version":3,"file":"cleantalk-users-editscreen.min.js","sources":["cleantalk-users-editscreen.js"],"sourcesContent":["function ct_is_email(str){\n\treturn str.search(/.*@.*\\..*/);\n}\nfunction ct_is_ip(str){\n\treturn str.search(/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/);\n}\n\njQuery(document).ready(function(){\n\n\n\tif(parseInt(ctUsersScreen.ct_show_check_links)) {\n\n\t\t/* Shows link to blacklists near every email and IP address */\n\t\tjQuery('.column-email a').each(function(){\n\t\t\tvar ct_curr_str = jQuery(this).html();\n\t\t\tif( ct_is_email(ct_curr_str) !== -1 ){\n\n\n\t\t\t\tvar ct_url = ctAdminCommon.links.users_editscreen.replace('{TARGET}', ct_curr_str);\n\t\t\t\tjQuery(this).after(' ');\n\t\t\t}\n\t\t});\n\n\t\t/* Show checked ico near avatar */\n\t\tjQuery('.username.column-username').each(function(){\n\n\t\t\tvar apbct_checking_el = jQuery(this).siblings('.apbct_status').children('span');\n\t\t\tvar apbct_checking_status = apbct_checking_el.attr('id');\n\t\t\tvar apbct_checking_status_text = apbct_checking_el.text();\n\n\t\t\tvar apbct_add_text_element = jQuery('', {\n\t\t\t\ttext : apbct_checking_status_text\n\t\t\t});\n\t\t\tvar apbct_add_ico_ok = jQuery('', {\n\t\t\t\tclass : 'apbct-icon-ok'\n\t\t\t});\n\t\t\tvar apbct_add_ico_cancel = jQuery('', {\n\t\t\t\tclass : 'apbct-icon-cancel',\n\t\t\t\tcss : {\n\t\t\t\t\tcolor : 'red'\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif( apbct_checking_status ==='apbct_not_checked' ) {\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_ok).before(apbct_add_text_element);\n\t\t\t}\n\t\t\tif( apbct_checking_status ==='apbct_checked_not_spam' ) {\n\t\t\t\tapbct_add_ico_ok.attr('style', 'color:green;');\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_ok).before(apbct_add_text_element);\n\t\t\t}\n\t\t\tif( apbct_checking_status ==='apbct_checked_spam' ) {\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_cancel).before(apbct_add_text_element);\n\t\t\t}\n\n\t\t});\n\n\t}\n\n});"],"names":["ct_is_email","str","search","ct_is_ip","jQuery","document","ready","parseInt","ctUsersScreen","ct_show_check_links","each","ct_curr_str","this","html","ct_url","ctAdminCommon","links","users_editscreen","replace","after","ct_img_src_new_tab","apbct_checking_el","siblings","children","apbct_checking_status","attr","apbct_checking_status_text","text","apbct_add_text_element","apbct_add_ico_ok","class","apbct_add_ico_cancel","css","color","before"],"mappings":"AAAA,SAASA,YAAYC,GACpB,OAAOA,EAAIC,O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en.js index 6418336fd..4402cd85b 100644 --- a/js/src/cleantalk-comments-editscreen.js +++ b/js/src/cleantalk-comments-editscreen.js @@ -11,7 +11,7 @@ jQuery(document).ready(function(){ jQuery('.column-author a, .comment-author a').each(function(){ var ct_curr_str = jQuery(this).html(); if(ct_is_email(ct_curr_str) != -1 || ct_is_ip(ct_curr_str) != -1){ - var ct_url = ctCommentsScreen.links.comments_editscreen.replace('{TARGET}', ct_curr_str); + var ct_url = ctAdminCommon.links.comments_editscreen.replace('{TARGET}', ct_curr_str); jQuery(this).after(' '); } }); diff --git a/js/src/cleantalk-users-editscreen.js b/js/src/cleantalk-users-editscreen.js index 663537c02..88724b046 100644 --- a/js/src/cleantalk-users-editscreen.js +++ b/js/src/cleantalk-users-editscreen.js @@ -14,7 +14,9 @@ jQuery(document).ready(function(){ jQuery('.column-email a').each(function(){ var ct_curr_str = jQuery(this).html(); if( ct_is_email(ct_curr_str) !== -1 ){ - var ct_url = ctUsersScreen.links.users_editscreen.replace('{TARGET}', ct_curr_str); + + + var ct_url = ctAdminCommon.links.users_editscreen.replace('{TARGET}', ct_curr_str); jQuery(this).after(' '); } }); diff --git a/lib/Cleantalk/ApbctWP/Localize/CtPublicLocalize.php b/lib/Cleantalk/ApbctWP/Localize/CtPublicLocalize.php index 8f12b1e97..361e4fcda 100644 --- a/lib/Cleantalk/ApbctWP/Localize/CtPublicLocalize.php +++ b/lib/Cleantalk/ApbctWP/Localize/CtPublicLocalize.php @@ -3,7 +3,6 @@ namespace Cleantalk\ApbctWP\Localize; use Cleantalk\ApbctWP\CleantalkRealPerson; -use Cleantalk\ApbctWP\LinkConstructor; class CtPublicLocalize { @@ -42,10 +41,6 @@ public static function getData() 'advancedCacheExists' => apbct_is_advanced_cache_exists(), 'varnishCacheExists' => apbct_is_varnish_cache_exists(), 'wc_ajax_add_to_cart' => get_option('woocommerce_enable_ajax_add_to_cart') === 'yes', - 'links' => array( - 'users_editscreen' => LinkConstructor::buildCleanTalkLink('admin_blacklists_avatar_link', 'blacklists/{TARGET}'), - 'comments_editscreen' => LinkConstructor::buildCleanTalkLink('admin_blacklists_avatar_link', 'blacklists/{TARGET}'), - ), ); if ( $apbct->settings['comments__the_real_person'] ) { $localize_array = array_merge($localize_array, CleantalkRealPerson::getLocalizingData()); From 3686bcbfc3d1821765e60a9a96bde16325aeb9b9 Mon Sep 17 00:00:00 2001 From: datorik Date: Mon, 18 May 2026 14:06:30 +0300 Subject: [PATCH 4/4] Code. Code review --- .../ApbctWP/Localize/TestCtPublicLocalize.php | 26 ------- tests/Inc/TestCleantalkAdmin.php | 70 +++++++++++++++++++ 2 files changed, 70 insertions(+), 26 deletions(-) create mode 100644 tests/Inc/TestCleantalkAdmin.php diff --git a/tests/ApbctWP/Localize/TestCtPublicLocalize.php b/tests/ApbctWP/Localize/TestCtPublicLocalize.php index 34291ec80..ffa1ca500 100644 --- a/tests/ApbctWP/Localize/TestCtPublicLocalize.php +++ b/tests/ApbctWP/Localize/TestCtPublicLocalize.php @@ -30,30 +30,4 @@ public function testGetData() $this->assertArrayHasKey('bot_detector_enabled', $localize_data); $this->assertArrayNotHasKey('data__bot_detector_enabled', $localize_data); } - - public function testGetDataContainsLinksArray() - { - $localize_data = CtPublicLocalize::getData(); - - $this->assertArrayHasKey('links', $localize_data); - $this->assertIsArray($localize_data['links']); - $this->assertArrayHasKey('users_editscreen', $localize_data['links']); - $this->assertArrayHasKey('comments_editscreen', $localize_data['links']); - } - - public function testGetDataLinksUsersEditscreen() - { - $localize_data = CtPublicLocalize::getData(); - - $expected = 'https://cleantalk.org/blacklists/{TARGET}?utm_source=admin_side&utm_medium=comments&utm_content=avatar&utm_campaign=apbct_links'; - $this->assertSame($expected, $localize_data['links']['users_editscreen']); - } - - public function testGetDataLinksCommentsEditscreen() - { - $localize_data = CtPublicLocalize::getData(); - - $expected = 'https://cleantalk.org/blacklists/{TARGET}?utm_source=admin_side&utm_medium=comments&utm_content=avatar&utm_campaign=apbct_links'; - $this->assertSame($expected, $localize_data['links']['comments_editscreen']); - } } \ No newline at end of file diff --git a/tests/Inc/TestCleantalkAdmin.php b/tests/Inc/TestCleantalkAdmin.php new file mode 100644 index 000000000..0c801b5c0 --- /dev/null +++ b/tests/Inc/TestCleantalkAdmin.php @@ -0,0 +1,70 @@ +remove('cleantalk-admin-js'); + } + + protected function tearDown(): void + { + global $apbct; + unset($apbct); + wp_scripts()->remove('cleantalk-admin-js'); + parent::tearDown(); + } + + /** + * Pulls the `ctAdminCommon` payload that `apbct_admin__enqueue_scripts` registers + * via `wp_localize_script`, decoded back to a PHP array. + */ + private function getCtAdminCommonData() + { + apbct_admin__enqueue_scripts('index.php'); + + $raw = wp_scripts()->get_data('cleantalk-admin-js', 'data'); + $this->assertIsString($raw, 'ctAdminCommon was not localized on cleantalk-admin-js'); + + preg_match('/var ctAdminCommon = (.*);$/s', $raw, $matches); + $this->assertNotEmpty($matches, 'Could not extract ctAdminCommon JSON payload'); + + return json_decode($matches[1], true); + } + + public function testCtAdminCommonContainsLinksArray() + { + $data = $this->getCtAdminCommonData(); + + $this->assertArrayHasKey('links', $data); + $this->assertIsArray($data['links']); + $this->assertArrayHasKey('users_editscreen', $data['links']); + $this->assertArrayHasKey('comments_editscreen', $data['links']); + } + + public function testCtAdminCommonLinksUsersEditscreen() + { + $data = $this->getCtAdminCommonData(); + + $expected = 'https://cleantalk.org/blacklists/{TARGET}?utm_source=admin_side&utm_medium=comments&utm_content=avatar&utm_campaign=apbct_links'; + $this->assertSame($expected, $data['links']['users_editscreen']); + } + + public function testCtAdminCommonLinksCommentsEditscreen() + { + $data = $this->getCtAdminCommonData(); + + $expected = 'https://cleantalk.org/blacklists/{TARGET}?utm_source=admin_side&utm_medium=comments&utm_content=avatar&utm_campaign=apbct_links'; + $this->assertSame($expected, $data['links']['comments_editscreen']); + } +}