diff --git a/README.md b/README.md index 1946161..b358b1f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Comment Mention # **Contributors:** [bhargavbhandari90](https://profiles.wordpress.org/bhargavbhandari90/), [biliplugins](https://profiles.wordpress.org/biliplugins/), [hackkzy404](https://profiles.wordpress.org/hackkzy404/) **Donate link:** https://www.paypal.me/BnB90/50 -**Tags:** comments, mention, email, user, bbpress, buntywp +**Tags:** comments, mention, email, user, bbpress **Requires at least:** 4.6 **Tested up to:** 6.6.2 -**Stable tag:** 1.7.11 +**Stable tag:** 1.7.12 **Requires PHP:** 5.6 **License:** GPLv2 or later **License URI:** https://www.gnu.org/licenses/gpl-2.0.html @@ -63,6 +63,9 @@ e.g. ## Changelog ## +### 1.7.12 ### +* Mention script improvisation. + ### 1.7.11 ### * Hook added : `cmt_mntn_comment_pre_content`. * Updated mention script for pro feature. diff --git a/comment-mention.php b/comment-mention.php index 877cfd5..605125d 100644 --- a/comment-mention.php +++ b/comment-mention.php @@ -6,7 +6,7 @@ * Author URI: https://bhargavb.com * Text Domain: comment-mention * Domain Path: /languages - * Version: 1.7.11 + * Version: 1.7.12 * * @package Comment_Mention */ @@ -21,7 +21,7 @@ /** * The version of the plugin. */ - define( 'CMT_MNTN_VERSION', '1.7.11' ); + define( 'CMT_MNTN_VERSION', '1.7.12' ); } if ( ! defined( 'CMT_MNTN_PATH' ) ) { /** diff --git a/readme.txt b/readme.txt index 23e0237..71984b3 100644 --- a/readme.txt +++ b/readme.txt @@ -1,10 +1,10 @@ === Comment Mention === Contributors: bhargavbhandari90, biliplugins, hackkzy404 Donate link: https://www.paypal.me/BnB90/50 -Tags: comments, mention, email, user, bbpress, buntywp +Tags: comments, mention, email, user, bbpress Requires at least: 4.6 Tested up to: 6.6.2 -Stable tag: 1.7.11 +Stable tag: 1.7.12 Requires PHP: 5.6 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -63,6 +63,9 @@ e.g. == Changelog == += 1.7.12 = +* Mention script improvisation. + = 1.7.11 = * Hook added : `cmt_mntn_comment_pre_content`. * Updated mention script for pro feature. diff --git a/src/js/tribute-config.js b/src/js/tribute-config.js index c47a210..cab1b94 100644 --- a/src/js/tribute-config.js +++ b/src/js/tribute-config.js @@ -1,5 +1,6 @@ jQuery( function ($) { + let getUsers; const mentionMap = {}; let tribute = new Tribute( { @@ -9,12 +10,17 @@ jQuery( term: search, }; - $.ajax( + getUsers = $.ajax( { url: Comment_Mention.ajaxurl, // Replace with your API endpoint method: 'GET', data: data, // Send current text as the search term dataType: 'json', + beforeSend: function () { + if (getUsers != null) { + getUsers.abort(); + } + }, success: function(response) { // Format the response for Tribute.js // const results = response.data; @@ -67,6 +73,7 @@ jQuery( Object.keys( mentionMap ).forEach( name => { + const nameMention = '@' + mentionMap[name]; // Mention format in textarea1 (name) const usernameMention = '@' + name; // Mention format in textarea2 (username) content = content.split( nameMention ).join( usernameMention );