Edit File by line
/home/barbar84/public_h.../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' ).on( '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
}).removeClass( 'button-disabled' );
[167] Fix | Delete
[168] Fix | Delete
var spam_count = 0;
[169] Fix | Delete
var recheck_count = 0;
[170] Fix | Delete
[171] Fix | Delete
function akismet_check_for_spam(offset, limit) {
[172] Fix | Delete
var check_for_spam_buttons = $( '.checkforspam' );
[173] Fix | Delete
[174] Fix | Delete
var nonce = check_for_spam_buttons.data( 'nonce' );
[175] Fix | Delete
[176] Fix | Delete
// We show the percentage complete down to one decimal point so even queues with 100k
[177] Fix | Delete
// pending comments will show some progress pretty quickly.
[178] Fix | Delete
var percentage_complete = Math.round( ( recheck_count / check_for_spam_buttons.data( 'pending-comment-count' ) ) * 1000 ) / 10;
[179] Fix | Delete
[180] Fix | Delete
// Update the progress counter on the "Check for Spam" button.
[181] Fix | Delete
$( '.checkforspam' ).text( check_for_spam_buttons.data( 'progress-label' ).replace( '%1$s', percentage_complete ) );
[182] Fix | Delete
[183] Fix | Delete
$.post(
[184] Fix | Delete
ajaxurl,
[185] Fix | Delete
{
[186] Fix | Delete
'action': 'akismet_recheck_queue',
[187] Fix | Delete
'offset': offset,
[188] Fix | Delete
'limit': limit,
[189] Fix | Delete
'nonce': nonce
[190] Fix | Delete
},
[191] Fix | Delete
function(result) {
[192] Fix | Delete
if ( 'error' in result ) {
[193] Fix | Delete
// An error is only returned in the case of a missing nonce, so we don't need the actual error message.
[194] Fix | Delete
window.location.href = check_for_spam_buttons.data( 'failure-url' );
[195] Fix | Delete
return;
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
recheck_count += result.counts.processed;
[199] Fix | Delete
spam_count += result.counts.spam;
[200] Fix | Delete
[201] Fix | Delete
if (result.counts.processed < limit) {
[202] Fix | Delete
window.location.href = check_for_spam_buttons.data( 'success-url' ).replace( '__recheck_count__', recheck_count ).replace( '__spam_count__', spam_count );
[203] Fix | Delete
}
[204] Fix | Delete
else {
[205] Fix | Delete
// Account for comments that were caught as spam and moved out of the queue.
[206] Fix | Delete
akismet_check_for_spam(offset + limit - result.counts.spam, limit);
[207] Fix | Delete
}
[208] Fix | Delete
}
[209] Fix | Delete
);
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
if ( "start_recheck" in WPAkismet && WPAkismet.start_recheck ) {
[213] Fix | Delete
$( '.checkforspam' ).click();
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
if ( typeof MutationObserver !== 'undefined' ) {
[217] Fix | Delete
// Dynamically add the "X" next the the author URL links when a comment is quick-edited.
[218] Fix | Delete
var comment_list_container = document.getElementById( 'the-comment-list' );
[219] Fix | Delete
[220] Fix | Delete
if ( comment_list_container ) {
[221] Fix | Delete
var observer = new MutationObserver( function ( mutations ) {
[222] Fix | Delete
for ( var i = 0, _len = mutations.length; i < _len; i++ ) {
[223] Fix | Delete
if ( mutations[i].addedNodes.length > 0 ) {
[224] Fix | Delete
akismet_enable_comment_author_url_removal();
[225] Fix | Delete
[226] Fix | Delete
// Once we know that we'll have to check for new author links, skip the rest of the mutations.
[227] Fix | Delete
break;
[228] Fix | Delete
}
[229] Fix | Delete
}
[230] Fix | Delete
} );
[231] Fix | Delete
[232] Fix | Delete
observer.observe( comment_list_container, { attributes: true, childList: true, characterData: true } );
[233] Fix | Delete
}
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
function akismet_enable_comment_author_url_removal() {
[237] Fix | Delete
$( '#the-comment-list' )
[238] Fix | Delete
.find( 'tr.comment, tr[id ^= "comment-"]' )
[239] Fix | Delete
.find( '.column-author a[href^="http"]:first' ) // Ignore mailto: links, which would be the comment author's email.
[240] Fix | Delete
.each(function () {
[241] Fix | Delete
if ( $( this ).parent().find( '.akismet_remove_url' ).length > 0 ) {
[242] Fix | Delete
return;
[243] Fix | Delete
}
[244] Fix | Delete
[245] Fix | Delete
var linkHref = $(this).attr( 'href' );
[246] Fix | Delete
[247] Fix | Delete
// Ignore any links to the current domain, which are diagnostic tools, like the IP address link
[248] Fix | Delete
// or any other links another plugin might add.
[249] Fix | Delete
var currentHostParts = document.location.href.split( '/' );
[250] Fix | Delete
var currentHost = currentHostParts[0] + '//' + currentHostParts[2] + '/';
[251] Fix | Delete
[252] Fix | Delete
if ( linkHref.indexOf( currentHost ) != 0 ) {
[253] Fix | Delete
var thisCommentId = $(this).parents('tr:first').attr('id').split("-");
[254] Fix | Delete
[255] Fix | Delete
$(this)
[256] Fix | Delete
.attr("id", "author_comment_url_"+ thisCommentId[1])
[257] Fix | Delete
.after(
[258] Fix | Delete
$( '<a href="#" class="akismet_remove_url">x</a>' )
[259] Fix | Delete
.attr( 'commentid', thisCommentId[1] )
[260] Fix | Delete
.attr( 'title', WPAkismet.strings['Remove this URL'] )
[261] Fix | Delete
);
[262] Fix | Delete
}
[263] Fix | Delete
});
[264] Fix | Delete
}
[265] Fix | Delete
[266] Fix | Delete
/**
[267] Fix | Delete
* Generate an mShot URL if given a link URL.
[268] Fix | Delete
*
[269] Fix | Delete
* @param string linkUrl
[270] Fix | Delete
* @param int retry If retrying a request, the number of the retry.
[271] Fix | Delete
* @return string The mShot URL;
[272] Fix | Delete
*/
[273] Fix | Delete
function akismet_mshot_url( linkUrl, retry ) {
[274] Fix | Delete
var mshotUrl = '//s0.wordpress.com/mshots/v1/' + encodeURIComponent( linkUrl ) + '?w=900';
[275] Fix | Delete
[276] Fix | Delete
if ( retry ) {
[277] Fix | Delete
mshotUrl += '&r=' + encodeURIComponent( retry );
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
return mshotUrl;
[281] Fix | Delete
}
[282] Fix | Delete
[283] Fix | Delete
/**
[284] Fix | Delete
* Begin loading an mShot preview of a link.
[285] Fix | Delete
*
[286] Fix | Delete
* @param string linkUrl
[287] Fix | Delete
*/
[288] Fix | Delete
function akismet_preload_mshot( linkUrl ) {
[289] Fix | Delete
var img = new Image();
[290] Fix | Delete
img.src = akismet_mshot_url( linkUrl );
[291] Fix | Delete
}
[292] Fix | Delete
[293] Fix | Delete
$( '.akismet-could-be-primary' ).each( function () {
[294] Fix | Delete
var form = $( this ).closest( 'form' );
[295] Fix | Delete
[296] Fix | Delete
form.data( 'initial-state', form.serialize() );
[297] Fix | Delete
[298] Fix | Delete
form.on( 'change keyup', function () {
[299] Fix | Delete
var self = $( this );
[300] Fix | Delete
var submit_button = self.find( '.akismet-could-be-primary' );
[301] Fix | Delete
[302] Fix | Delete
if ( self.serialize() != self.data( 'initial-state' ) ) {
[303] Fix | Delete
submit_button.addClass( 'akismet-is-primary' );
[304] Fix | Delete
}
[305] Fix | Delete
else {
[306] Fix | Delete
submit_button.removeClass( 'akismet-is-primary' );
[307] Fix | Delete
}
[308] Fix | Delete
} );
[309] Fix | Delete
} );
[310] Fix | Delete
[311] Fix | Delete
/**
[312] Fix | Delete
* Shows the Enter API key form
[313] Fix | Delete
*/
[314] Fix | Delete
$( '.akismet-enter-api-key-box a' ).on( 'click', function ( e ) {
[315] Fix | Delete
e.preventDefault();
[316] Fix | Delete
[317] Fix | Delete
var div = $( '.enter-api-key' );
[318] Fix | Delete
div.show( 500 );
[319] Fix | Delete
div.find( 'input[name=key]' ).focus();
[320] Fix | Delete
[321] Fix | Delete
$( this ).hide();
[322] Fix | Delete
} );
[323] Fix | Delete
[324] Fix | Delete
/**
[325] Fix | Delete
* Hides the Connect with Jetpack form | Shows the Activate Akismet Account form
[326] Fix | Delete
*/
[327] Fix | Delete
$( 'a.toggle-ak-connect' ).on( 'click', function ( e ) {
[328] Fix | Delete
e.preventDefault();
[329] Fix | Delete
[330] Fix | Delete
$( '.akismet-ak-connect' ).slideToggle('slow');
[331] Fix | Delete
$( 'a.toggle-ak-connect' ).hide();
[332] Fix | Delete
$( '.akismet-jp-connect' ).hide();
[333] Fix | Delete
$( 'a.toggle-jp-connect' ).show();
[334] Fix | Delete
} );
[335] Fix | Delete
[336] Fix | Delete
/**
[337] Fix | Delete
* Shows the Connect with Jetpack form | Hides the Activate Akismet Account form
[338] Fix | Delete
*/
[339] Fix | Delete
$( 'a.toggle-jp-connect' ).on( 'click', function ( e ) {
[340] Fix | Delete
e.preventDefault();
[341] Fix | Delete
[342] Fix | Delete
$( '.akismet-jp-connect' ).slideToggle('slow');
[343] Fix | Delete
$( 'a.toggle-jp-connect' ).hide();
[344] Fix | Delete
$( '.akismet-ak-connect' ).hide();
[345] Fix | Delete
$( 'a.toggle-ak-connect' ).show();
[346] Fix | Delete
} );
[347] Fix | Delete
});
[348] Fix | Delete
[349] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function