Skip to content

Commit

Permalink
Merge pull request #37 from BhargavBhandari90/mention-by-name
Browse files Browse the repository at this point in the history
Mention by name
  • Loading branch information
BhargavBhandari90 authored Nov 3, 2024
2 parents cde582b + 0228b5d commit 088799c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions comment-mention.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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' ) ) {
/**
Expand Down
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 8 additions & 1 deletion src/js/tribute-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
jQuery(
function ($) {
let getUsers;
const mentionMap = {};
let tribute = new Tribute(
{
Expand All @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 088799c

Please sign in to comment.