2
0
Fork 0
mirror of https://github.com/discourse/wp-discourse.git synced 2025-10-03 08:59:21 +08:00
wp-discourse/js/load-comments.js
Angus McLeod 4b95944d27
Some checks failed
WP-Discourse Formatting / Formatting on PHP 5.6 (push) Has been cancelled
WP-Discourse Formatting / Formatting on PHP 7.0 (push) Has been cancelled
WP-Discourse Formatting / Formatting on PHP 7.4 (push) Has been cancelled
WP-Discourse Formatting / Formatting on PHP 8.0 (push) Has been cancelled
WP-Discourse Tests / Tests on PHP 8.2 (push) Has been cancelled
Only load comments if we have a post id (#553)
2025-09-30 21:01:32 +01:00

31 lines
640 B
JavaScript

/* globals wpdc */
/**
* Loads Discourse comments into the .wpdc-comments div.
*
* @package WPDiscourse
*/
(function( $ ) {
$( document ).ready(
function() {
var commentsURL = wpdc.commentsURL,
$commentArea = $( '#wpdc-comments' ),
postId = $commentArea.data( 'post-id' );
if (!postId) {
return;
}
$.ajax(
{
url: commentsURL + '?post_id=' + postId,
success: function( response ) {
$commentArea.removeClass( 'wpdc-comments-loading' );
$commentArea.addClass( 'wpdc-comments-loaded' );
$commentArea.html( response );
}
}
);
}
);
})( jQuery );