Edit File by line
/home/barbar84/www/wp-conte.../plugins/akismet_.../_inc
File: akismet.js
jQuery( function ( $ ) {
[0] Fix | Delete
var mshotRemovalTimer = null;
[1] Fix | Delete
var mshotSecondTryTimer = null
[2] Fix | Delete
var mshotThirdTryTimer = null
[3] Fix | Delete
[4] Fix | Delete
var mshotEnabledLinkSelector = 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a';
[5] Fix | Delete
[6] Fix | Delete
$('.akismet-status').each(function () {
[7] Fix | Delete
var thisId = $(this).attr('commentid');
[8] Fix | Delete
$(this).prependTo('#comment-' + thisId + ' .column-comment');
[9] Fix | Delete
});
[10] Fix | Delete
$('.akismet-user-comment-count').each(function () {
[11] Fix | Delete
var thisId = $(this).attr('commentid');
[12] Fix | Delete
$(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
[13] Fix | Delete
});
[14] Fix | Delete
[15] Fix | Delete
akismet_enable_comment_author_url_removal();
[16] Fix | Delete
[17] Fix | Delete
$( '#the-comment-list' ).on( 'click', '.akismet_remove_url', function () {
[18] Fix | Delete
var thisId = $(this).attr('commentid');
[19] Fix | Delete
var data = {
[20] Fix | Delete
action: 'comment_author_deurl',
[21] Fix | Delete
_wpnonce: WPAkismet.comment_author_url_nonce,
[22] Fix | Delete
id: thisId
[23] Fix | Delete
};
[24] Fix | Delete
$.ajax({
[25] Fix | Delete
url: ajaxurl,
[26] Fix | Delete
type: 'POST',
[27] Fix | Delete
data: data,
[28] Fix | Delete
beforeSend: function () {
[29] Fix | Delete
// Removes "x" link
[30] Fix | Delete
$("a[commentid='"+ thisId +"']").hide();
[31] Fix | Delete
// Show temp status
[32] Fix | Delete
$("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Removing...'] ) );
[33] Fix | Delete
},
[34] Fix | Delete
success: function (response) {
[35] Fix | Delete
if (response) {
[36] Fix | Delete
// Show status/undo link
[37] Fix | Delete
$("#author_comment_url_"+ thisId)
[38] Fix | Delete
.attr('cid', thisId)
[39] Fix | Delete
.addClass('akismet_undo_link_removal')
[40] Fix | Delete
.html(
[41] Fix | Delete
$( '<span/>' ).text( WPAkismet.strings['URL removed'] )
[42] Fix | Delete
)
[43] Fix | Delete
.append( ' ' )
[44] Fix | Delete
.append(
[45] Fix | Delete
$( '<span/>' )
[46] Fix | Delete
.text( WPAkismet.strings['(undo)'] )
[47] Fix | Delete
.addClass( 'akismet-span-link' )
[48] Fix | Delete
);
[49] Fix | Delete
}
[50] Fix | Delete
}
[51] Fix | Delete
});
[52] Fix | Delete
[53] Fix | Delete
return false;
[54] Fix | Delete
}).on( 'click', '.akismet_undo_link_removal', function () {
[55] Fix | Delete
var thisId = $(this).attr('cid');
[56] Fix | Delete
var thisUrl = $(this).attr('href');
[57] Fix | Delete
var data = {
[58] Fix | Delete
action: 'comment_author_reurl',
[59] Fix | Delete
_wpnonce: WPAkismet.comment_author_url_nonce,
[60] Fix | Delete
id: thisId,
[61] Fix | Delete
url: thisUrl
[62] Fix | Delete
};
[63] Fix | Delete
$.ajax({
[64] Fix | Delete
url: ajaxurl,
[65] Fix | Delete
type: 'POST',
[66] Fix | Delete
data: data,
[67] Fix | Delete
beforeSend: function () {
[68] Fix | Delete
// Show temp status
[69] Fix | Delete
$("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Re-adding...'] ) );
[70] Fix | Delete
},
[71] Fix | Delete
success: function (response) {
[72] Fix | Delete
if (response) {
[73] Fix | Delete
// Add "x" link
[74] Fix | Delete
$("a[commentid='"+ thisId +"']").show();
[75] Fix | Delete
// Show link. Core strips leading http://, so let's do that too.
[76] Fix | Delete
$("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').text( thisUrl.replace( /^http:\/\/(www\.)?/ig, '' ) );
[77] Fix | Delete
}
[78] Fix | Delete
}
[79] Fix | Delete
});
[80] Fix | Delete
[81] Fix | Delete
return false;
[82] Fix | Delete
});
[83] Fix | Delete
[84] Fix | Delete
// Show a preview image of the hovered URL. Applies to author URLs and URLs inside the comments.
[85] Fix | Delete
if ( "enable_mshots" in WPAkismet && WPAkismet.enable_mshots ) {
[86] Fix | Delete
$( '#the-comment-list' ).on( 'mouseover', mshotEnabledLinkSelector, function () {
[87] Fix | Delete
clearTimeout( mshotRemovalTimer );
[88] Fix | Delete
[89] Fix | Delete
if ( $( '.akismet-mshot' ).length > 0 ) {
[90] Fix | Delete
if ( $( '.akismet-mshot:first' ).data( 'link' ) == this ) {
[91] Fix | Delete
// The preview is already showing for this link.
[92] Fix | Delete
return;
[93] Fix | Delete
}
[94] Fix | Delete
else {
[95] Fix | Delete
// A new link is being hovered, so remove the old preview.
[96] Fix | Delete
$( '.akismet-mshot' ).remove();
[97] Fix | Delete
}
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
clearTimeout( mshotSecondTryTimer );
[101] Fix | Delete
clearTimeout( mshotThirdTryTimer );
[102] Fix | Delete
[103] Fix | Delete
var thisHref = $( this ).attr( 'href' );
[104] Fix | Delete
[105] Fix | Delete
var mShot = $( '<div class="akismet-mshot mshot-container"><div class="mshot-arrow"></div><img src="' + akismet_mshot_url( thisHref ) + '" width="450" height="338" class="mshot-image" /></div>' );
[106] Fix | Delete
mShot.data( 'link', this );
[107] Fix | Delete
[108] Fix | Delete
var offset = $( this ).offset();
[109] Fix | Delete
[110] Fix | Delete
mShot.offset( {
[111] Fix | Delete
left : Math.min( $( window ).width() - 475, offset.left + $( this ).width() + 10 ), // Keep it on the screen if the link is near the edge of the window.
[112] Fix | Delete
top: offset.top + ( $( this ).height() / 2 ) - 101 // 101 = top offset of the arrow plus the top border thickness
[113] Fix | Delete
} );
[114] Fix | Delete
[115] Fix | Delete
// These retries appear to be superfluous if .mshot-image has already loaded, but it's because mShots
[116] Fix | Delete
// can return a "Generating thumbnail..." image if it doesn't have a thumbnail ready, so we need
[117] Fix | Delete
// to retry to see if we can get the newly generated thumbnail.
[118] Fix | Delete
mshotSecondTryTimer = setTimeout( function () {
[119] Fix | Delete
mShot.find( '.mshot-image' ).attr( 'src', akismet_mshot_url( thisHref, 2 ) );
[120] Fix | Delete
}, 6000 );
[121] Fix | Delete
[122] Fix | Delete
mshotThirdTryTimer = setTimeout( function () {
[123] Fix | Delete
mShot.find( '.mshot-image' ).attr( 'src', akismet_mshot_url( thisHref, 3 ) );
[124] Fix | Delete
}, 12000 );
[125] Fix | Delete
[126] Fix | Delete
$( 'body' ).append( mShot );
[127] Fix | Delete
} ).on( 'mouseout', 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a', function () {
[128] Fix | Delete
mshotRemovalTimer = setTimeout( function () {
[129] Fix | Delete
clearTimeout( mshotSecondTryTimer );
[130] Fix | Delete
clearTimeout( mshotThirdTryTimer );
[131] Fix | Delete
[132] Fix | Delete
$( '.akismet-mshot' ).remove();
[133] Fix | Delete
}, 200 );
[134] Fix | Delete
} ).on( 'mouseover', 'tr', function () {
[135] Fix | Delete
// When the mouse hovers over a comment row, begin preloading mshots for any links in the comment or the comment author.
[136] Fix | Delete
var linksToPreloadMshotsFor = $( this ).find( mshotEnabledLinkSelector );
[137] Fix | Delete
[138] Fix | Delete
linksToPreloadMshotsFor.each( function () {
[139] Fix | Delete
// Don't attempt to preload an mshot for a single link twice. Browser caching should cover this, but in case of
[140] Fix | Delete
// race conditions, save a flag locally when we've begun trying to preload one.
[141] Fix | Delete
if ( ! $( this ).data( 'akismet-mshot-preloaded' ) ) {
[142] Fix | Delete
akismet_preload_mshot( $( this ).attr( 'href' ) );
[143] Fix | Delete
$( this ).data( 'akismet-mshot-preloaded', true );
[144] Fix | Delete
}
[145] Fix | Delete
} );
[146] Fix | Delete
} );
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
$( '.checkforspam.enable-on-load' ).click( function( e ) {
[150] Fix | Delete
if ( $( this ).hasClass( 'ajax-disabled' ) ) {
[151] Fix | Delete
// Akismet hasn't been configured yet. Allow the user to proceed to the button's link.
[152] Fix | Delete
return;
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
e.preventDefault();
[156] Fix | Delete
[157] Fix | Delete
if ( $( this ).hasClass( 'button-disabled' ) ) {
[158] Fix | Delete
window.location.href = $( this ).data( 'success-url' ).replace( '__recheck_count__', 0 ).replace( '__spam_count__', 0 );
[159] Fix | Delete
return;
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
$('.checkforspam').addClass('button-disabled').addClass( 'checking' );
[163] Fix | Delete
$('.checkforspam-spinner').addClass( 'spinner' ).addClass( 'is-active' );
[164] Fix | Delete
[165] Fix | Delete
akismet_check_for_spam(0, 100);
[166] Fix | Delete
});
[167] Fix | Delete
$( '.checkforspam.enable-on-load' ).removeClass( 'button-disabled' );
[168] Fix | Delete
[169] Fix | Delete
var spam_count = 0;
[170] Fix | Delete
var recheck_count = 0;
[171] Fix | Delete
[172] Fix | Delete
function akismet_check_for_spam(offset, limit) {
[173] Fix | Delete
var check_for_spam_buttons = $( '.checkforspam' );
[174] Fix | Delete
[175] Fix | Delete
var nonce = check_for_spam_buttons.data( 'nonce' );
[176] Fix | Delete
[177] Fix | Delete
// We show the percentage complete down to one decimal point so even queues with 100k
[178] Fix | Delete
// pending comments will show some progress pretty quickly.
[179] Fix | Delete
var percentage_complete = Math.round( ( recheck_count / check_for_spam_buttons.data( 'pending-comment-count' ) ) * 1000 ) / 10;
[180] Fix | Delete
[181] Fix | Delete
// Update the progress counter on the "Check for Spam" button.
[182] Fix | Delete
$( '.checkforspam' ).text( check_for_spam_buttons.data( 'progress-label' ).replace( '%1$s', percentage_complete ) );
[183] Fix | Delete
[184] Fix | Delete
$.post(
[185] Fix | Delete
ajaxurl,
[186] Fix | Delete
{
[187] Fix | Delete
'action': 'akismet_recheck_queue',
[188] Fix | Delete
'offset': offset,
[189] Fix | Delete
'limit': limit,
[190] Fix | Delete
'nonce': nonce
[191] Fix | Delete
},
[192] Fix | Delete
function(result) {
[193] Fix | Delete
if ( 'error' in result ) {
[194] Fix | Delete
// An error is only returned in the case of a missing nonce, so we don't need the actual error message.
[195] Fix | Delete
window.location.href = check_for_spam_buttons.data( 'failure-url' );
[196] Fix | Delete
return;
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
recheck_count += result.counts.processed;
[200] Fix | Delete
spam_count += result.counts.spam;
[201] Fix | Delete
[202] Fix | Delete
if (result.counts.processed < limit) {
[203] Fix | Delete
window.location.href = check_for_spam_buttons.data( 'success-url' ).replace( '__recheck_count__', recheck_count ).replace( '__spam_count__', spam_count );
[204] Fix | Delete
}
[205] Fix | Delete
else {
[206] Fix | Delete
// Account for comments that were caught as spam and moved out of the queue.
[207] Fix | Delete
akismet_check_for_spam(offset + limit - result.counts.spam, limit);
[208] Fix | Delete
}
[209] Fix | Delete
}
[210] Fix | Delete
);
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
if ( "start_recheck" in WPAkismet && WPAkismet.start_recheck ) {
[214] Fix | Delete
$( '.checkforspam' ).click();
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
if ( typeof MutationObserver !== 'undefined' ) {
[218] Fix | Delete
// Dynamically add the "X" next the the author URL links when a comment is quick-edited.
[219] Fix | Delete
var comment_list_container = document.getElementById( 'the-comment-list' );
[220] Fix | Delete
[221] Fix | Delete
if ( comment_list_container ) {
[222] Fix | Delete
var observer = new MutationObserver( function ( mutations ) {
[223] Fix | Delete
for ( var i = 0, _len = mutations.length; i < _len; i++ ) {
[224] Fix | Delete
if ( mutations[i].addedNodes.length > 0 ) {
[225] Fix | Delete
akismet_enable_comment_author_url_removal();
[226] Fix | Delete
[227] Fix | Delete
// Once we know that we'll have to check for new author links, skip the rest of the mutations.
[228] Fix | Delete
break;
[229] Fix | Delete
}
[230] Fix | Delete
}
[231] Fix | Delete
} );
[232] Fix | Delete
[233] Fix | Delete
observer.observe( comment_list_container, { attributes: true, childList: true, characterData: true } );
[234] Fix | Delete
}
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
function akismet_enable_comment_author_url_removal() {
[238] Fix | Delete
$( '#the-comment-list' )
[239] Fix | Delete
.find( 'tr.comment, tr[id ^= "comment-"]' )
[240] Fix | Delete
.find( '.column-author a[href^="http"]:first' ) // Ignore mailto: links, which would be the comment author's email.
[241] Fix | Delete
.each(function () {
[242] Fix | Delete
if ( $( this ).parent().find( '.akismet_remove_url' ).length > 0 ) {
[243] Fix | Delete
return;
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
var linkHref = $(this).attr( 'href' );
[247] Fix | Delete
[248] Fix | Delete
// Ignore any links to the current domain, which are diagnostic tools, like the IP address link
[249] Fix | Delete
// or any other links another plugin might add.
[250] Fix | Delete
var currentHostParts = document.location.href.split( '/' );
[251] Fix | Delete
var currentHost = currentHostParts[0] + '//' + currentHostParts[2] + '/';
[252] Fix | Delete
[253] Fix | Delete
if ( linkHref.indexOf( currentHost ) != 0 ) {
[254] Fix | Delete
var thisCommentId = $(this).parents('tr:first').attr('id').split("-");
[255] Fix | Delete
[256] Fix | Delete
$(this)
[257] Fix | Delete
.attr("id", "author_comment_url_"+ thisCommentId[1])
[258] Fix | Delete
.after(
[259] Fix | Delete
$( '<a href="#" class="akismet_remove_url">x</a>' )
[260] Fix | Delete
.attr( 'commentid', thisCommentId[1] )
[261] Fix | Delete
.attr( 'title', WPAkismet.strings['Remove this URL'] )
[262] Fix | Delete
);
[263] Fix | Delete
}
[264] Fix | Delete
});
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
/**
[268] Fix | Delete
* Generate an mShot URL if given a link URL.
[269] Fix | Delete
*
[270] Fix | Delete
* @param string linkUrl
[271] Fix | Delete
* @param int retry If retrying a request, the number of the retry.
[272] Fix | Delete
* @return string The mShot URL;
[273] Fix | Delete
*/
[274] Fix | Delete
function akismet_mshot_url( linkUrl, retry ) {
[275] Fix | Delete
var mshotUrl = '//s0.wordpress.com/mshots/v1/' + encodeURIComponent( linkUrl ) + '?w=900';
[276] Fix | Delete
[277] Fix | Delete
if ( retry ) {
[278] Fix | Delete
mshotUrl += '&r=' + encodeURIComponent( retry );
[279] Fix | Delete
}
[280] Fix | Delete
[281] Fix | Delete
return mshotUrl;
[282] Fix | Delete
}
[283] Fix | Delete
[284] Fix | Delete
/**
[285] Fix | Delete
* Begin loading an mShot preview of a link.
[286] Fix | Delete
*
[287] Fix | Delete
* @param string linkUrl
[288] Fix | Delete
*/
[289] Fix | Delete
function akismet_preload_mshot( linkUrl ) {
[290] Fix | Delete
var img = new Image();
[291] Fix | Delete
img.src = akismet_mshot_url( linkUrl );
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
$( '.akismet-could-be-primary' ).each( function () {
[295] Fix | Delete
var form = $( this ).closest( 'form' );
[296] Fix | Delete
[297] Fix | Delete
form.data( 'initial-state', form.serialize() );
[298] Fix | Delete
[299] Fix | Delete
form.on( 'change keyup', function () {
[300] Fix | Delete
var self = $( this );
[301] Fix | Delete
var submit_button = self.find( '.akismet-could-be-primary' );
[302] Fix | Delete
[303] Fix | Delete
if ( self.serialize() != self.data( 'initial-state' ) ) {
[304] Fix | Delete
submit_button.addClass( 'akismet-is-primary' );
[305] Fix | Delete
}
[306] Fix | Delete
else {
[307] Fix | Delete
submit_button.removeClass( 'akismet-is-primary' );
[308] Fix | Delete
}
[309] Fix | Delete
} );
[310] Fix | Delete
} );
[311] Fix | Delete
[312] Fix | Delete
/**
[313] Fix | Delete
* Shows the Enter API key form
[314] Fix | Delete
*/
[315] Fix | Delete
$( '.akismet-enter-api-key-box a' ).on( 'click', function ( e ) {
[316] Fix | Delete
e.preventDefault();
[317] Fix | Delete
[318] Fix | Delete
var div = $( '.enter-api-key' );
[319] Fix | Delete
div.show( 500 );
[320] Fix | Delete
div.find( 'input[name=key]' ).focus();
[321] Fix | Delete
[322] Fix | Delete
$( this ).hide();
[323] Fix | Delete
} );
[324] Fix | Delete
[325] Fix | Delete
/**
[326] Fix | Delete
* Hides the Connect with Jetpack form | Shows the Activate Akismet Account form
[327] Fix | Delete
*/
[328] Fix | Delete
$( 'a.toggle-ak-connect' ).on( 'click', function ( e ) {
[329] Fix | Delete
e.preventDefault();
[330] Fix | Delete
[331] Fix | Delete
$( '.akismet-ak-connect' ).slideToggle('slow');
[332] Fix | Delete
$( 'a.toggle-ak-connect' ).hide();
[333] Fix | Delete
$( '.akismet-jp-connect' ).hide();
[334] Fix | Delete
$( 'a.toggle-jp-connect' ).show();
[335] Fix | Delete
} );
[336] Fix | Delete
[337] Fix | Delete
/**
[338] Fix | Delete
* Shows the Connect with Jetpack form | Hides the Activate Akismet Account form
[339] Fix | Delete
*/
[340] Fix | Delete
$( 'a.toggle-jp-connect' ).on( 'click', function ( e ) {
[341] Fix | Delete
e.preventDefault();
[342] Fix | Delete
[343] Fix | Delete
$( '.akismet-jp-connect' ).slideToggle('slow');
[344] Fix | Delete
$( 'a.toggle-jp-connect' ).hide();
[345] Fix | Delete
$( '.akismet-ak-connect' ).hide();
[346] Fix | Delete
$( 'a.toggle-ak-connect' ).show();
[347] Fix | Delete
} );
[348] Fix | Delete
});
[349] Fix | Delete
[350] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function