Skip to content

Commit

Permalink
Merge pull request #39 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 16, 2024
2 parents dfeac36 + 3f85a5e commit 691f660
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 15 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
**Donate link:** https://www.paypal.me/BnB90/50
**Tags:** comments, mention, email, user, bbpress
**Requires at least:** 4.6
**Tested up to:** 6.6.2
**Stable tag:** 1.7.13
**Tested up to:** 6.7
**Stable tag:** 1.7.14
**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,10 @@ e.g.

## Changelog ##

### 1.7.14 ###
* Mention script improvisation for pro plugin.
* Added hooks for pro plugin.

### 1.7.13 ###
* Mention script improvisation for pro plugin.

Expand Down
2 changes: 1 addition & 1 deletion app/main/class-bbpress-user-mention.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function cmt_mntn_bbpress_mention_user_email( $post_id ) {
}

// Get topic content.
$topic_content = get_post_field( 'post_content', $post_id );
$topic_content = apply_filters( 'cmt_mntn_bbp_post_content', get_post_field( 'post_content', $post_id ) );

// Prevention.
if ( empty( $topic_content ) ) {
Expand Down
2 changes: 1 addition & 1 deletion app/main/class-comment-mention.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public function cmt_mntn_preprocess_comment( $comment_ID, $comment_status, $comm
}

// Get content.
$content = $comment_data['comment_content'];
$content = apply_filters( 'cmt_mntn_main_content', $comment_data['comment_content'], $comment_ID );

// Add data to array for post use.
$comment_data['comment_ID'] = $comment_ID;
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.13
* Version: 1.7.14
*
* @package Comment_Mention
*/
Expand All @@ -21,7 +21,7 @@
/**
* The version of the plugin.
*/
define( 'CMT_MNTN_VERSION', '1.7.13' );
define( 'CMT_MNTN_VERSION', '1.7.14' );
}
if ( ! defined( 'CMT_MNTN_PATH' ) ) {
/**
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: bhargavbhandari90, biliplugins, hackkzy404
Donate link: https://www.paypal.me/BnB90/50
Tags: comments, mention, email, user, bbpress
Requires at least: 4.6
Tested up to: 6.6.2
Stable tag: 1.7.13
Tested up to: 6.7
Stable tag: 1.7.14
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,10 @@ e.g.

== Changelog ==

= 1.7.14 =
* Mention script improvisation for pro plugin.
* Added hooks for pro plugin.

= 1.7.13 =
* Mention script improvisation for pro plugin.

Expand Down
36 changes: 29 additions & 7 deletions src/js/tribute-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ jQuery(
},
selectTemplate: function(item) {
if ( 'undefined' !== typeof( Comment_Mention.mention_by_fullname ) && '1' === Comment_Mention.mention_by_fullname ) {
return '@' + item.original.name; // Use `name` in textarea1
return '@' + item.original.name;
} else {
return '@' + item.original.key; // Use `name` in textarea1
return '@' + item.original.key;
}
}
}
Expand All @@ -63,13 +63,35 @@ jQuery(
tribute.attach( $( ".bbp-reply-form form textarea" ) );

if ( $( '#main_comment' ).length > 0 ) {
$( '#comment' ).on( 'tribute-replaced', cmt_mntn_sync_usernames );
$( '#comment' ).on( 'input', cmt_mntn_sync_usernames );
$( '#comment' ).on( 'tribute-replaced', function() {
cmt_mntn_sync_usernames( 'comment', 'main_comment' );
});
$( '#comment' ).on( 'input', function() {
cmt_mntn_sync_usernames( 'comment', 'main_comment' );
});
}

function cmt_mntn_sync_usernames() {
if ( $( '#bbp_main_reply_content' ).length > 0 ) {
$( '#bbp_reply_content' ).on( 'tribute-replaced', function() {
cmt_mntn_sync_usernames( 'bbp_reply_content', 'bbp_main_reply_content' );
});
$( '#bbp_reply_content' ).on( 'input', function() {
cmt_mntn_sync_usernames( 'bbp_reply_content', 'bbp_main_reply_content' );
});
}

if ( $( '#bbp_main_topic_content' ).length > 0 ) {
$( '#bbp_topic_content' ).on( 'tribute-replaced', function() {
cmt_mntn_sync_usernames( 'bbp_topic_content', 'bbp_main_topic_content' );
});
$( '#bbp_topic_content' ).on( 'input', function() {
cmt_mntn_sync_usernames( 'bbp_topic_content', 'bbp_main_topic_content' );
});
}

function cmt_mntn_sync_usernames( default_id, main_id ) {

let content = $( '#comment' ).val();
let content = $( '#' + default_id ).val();

let already_mentioned = localStorage.getItem('mentionMap');

Expand All @@ -88,7 +110,7 @@ jQuery(
}
);

$( '#main_comment' ).val( content );
$( '#' + main_id ).val( content );
}
}
);

0 comments on commit 691f660

Please sign in to comment.