PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | modules/comment-likes/comment-like-count.js +42 -0 16.2-beta → 16.3-beta View file →
@@ -1,0 +1,42 @@
1 +jQuery( document ).ready( function ( $ ) {
2 + var jsonAPIbase = 'https://public-api.wordpress.com/rest/v1',
3 + APIqueue = [];
4 +
5 + function getCommentLikeCounts() {
6 + $( '.comment-like-count' ).each( function () {
7 + var blogId = $( this ).attr( 'data-blog-id' ),
8 + commentId = $( this ).attr( 'data-comment-id' );
9 +
10 + APIqueue.push( '/sites/' + blogId + '/comments/' + commentId + '/likes' );
11 + } );
12 +
13 + return $.ajax( {
14 + type: 'GET',
15 + url: jsonAPIbase + '/batch',
16 + dataType: 'jsonp',
17 + data: 'urls[]=' + APIqueue.map( encodeURIComponent ).join( '&urls[]=' ),
18 + success: function ( response ) {
19 + for ( var path in response ) {
20 + if ( ! response[ path ].error_data ) {
21 + var urlPieces = path.split( '/' ),
22 + commentId = urlPieces[ 4 ],
23 + likeCount = response[ path ].found;
24 +
25 + if ( likeCount < 1 ) {
26 + return;
27 + }
28 +
29 + $( '#comment-like-count-' + commentId )
30 + .find( '.like-count' )
31 + .hide()
32 + .text( likeCount )
33 + .fadeIn();
34 + }
35 + }
36 + },
37 + error: function () {},
38 + } );
39 + }
40 +
41 + getCommentLikeCounts();
42 +} );