diff --git a/inc/cleantalk-admin.php b/inc/cleantalk-admin.php index 9d623214c..2b9dea260 100644 --- a/inc/cleantalk-admin.php +++ b/inc/cleantalk-admin.php @@ -539,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); @@ -616,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', @@ -634,7 +638,7 @@ 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", @@ -644,11 +648,11 @@ function apbct_admin__enqueue_scripts($hook) // 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" + 'ct_img_src_new_tab' => plugin_dir_url(__FILE__) . "images/new_window.gif", )); } } diff --git a/js/cleantalk-comments-editscreen.min.js b/js/cleantalk-comments-editscreen.min.js index 6dca2ae3c..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+="?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=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 0c26ff627..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\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":"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"} \ 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":"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"} \ No newline at end of file diff --git a/js/cleantalk-users-editscreen.min.js b/js/cleantalk-users-editscreen.min.js index ab2180ec8..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+="?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=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 caaec1d63..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\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\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,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,IAGtBG,EAASC,cAAcC,MAAMC,iBAAiBC,QAAQ,WAAYP,CAAW,EACjFP,OAAOQ,IAAI,EAAEO,MAAM,kBAAkBL,EAAO,4BAA4BA,EAAO,uCAAuCN,cAAcY,mBAAmB,QAAQ,EAEjK,CAAC,EAGDhB,OAAO,2BAA2B,EAAEM,KAAK,WAExC,IAAIW,EAAoBjB,OAAOQ,IAAI,EAAEU,SAAS,eAAe,EAAEC,SAAS,MAAM,EAC1EC,EAAwBH,EAAkBI,KAAK,IAAI,EACnDC,EAA6BL,EAAkBM,KAAK,EAEpDC,EAAyBxB,OAAO,SAAU,CAC7CuB,KAAOD,CACR,CAAC,EACGG,EAAmBzB,OAAO,MAAO,CACpC0B,MAAS,eACV,CAAC,EACGC,EAAuB3B,OAAO,MAAO,CACxC0B,MAAS,oBACTE,IAAM,CACLC,MAAQ,KACT,CACD,CAAC,EAE4B,sBAAzBT,GACHpB,OAAOQ,IAAI,EAAEW,SAAS,cAAc,EAAEW,OAAOL,CAAgB,EAAEK,OAAON,CAAsB,EAEhE,2BAAzBJ,IACHK,EAAiBJ,KAAK,QAAS,cAAc,EAC7CrB,OAAOQ,IAAI,EAAEW,SAAS,cAAc,EAAEW,OAAOL,CAAgB,EAAEK,OAAON,CAAsB,GAEhE,uBAAzBJ,GACHpB,OAAOQ,IAAI,EAAEW,SAAS,cAAc,EAAEW,OAAOH,CAAoB,EAAEG,OAAON,CAAsB,CAGlG,CAAC,EAIH,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..4402cd85b 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 = 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 78151c3ac..88724b046 100644 --- a/js/src/cleantalk-users-editscreen.js +++ b/js/src/cleantalk-users-editscreen.js @@ -14,8 +14,10 @@ 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 = ctAdminCommon.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/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'; 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']); + } +}