Edit File by line
/home/barbar84/www/wp-inclu...
File: comment.php
function get_comment_meta( $comment_id, $key = '', $single = false ) {
[500] Fix | Delete
return get_metadata( 'comment', $comment_id, $key, $single );
[501] Fix | Delete
}
[502] Fix | Delete
[503] Fix | Delete
/**
[504] Fix | Delete
* Update comment meta field based on comment ID.
[505] Fix | Delete
*
[506] Fix | Delete
* Use the $prev_value parameter to differentiate between meta fields with the
[507] Fix | Delete
* same key and comment ID.
[508] Fix | Delete
*
[509] Fix | Delete
* If the meta field for the comment does not exist, it will be added.
[510] Fix | Delete
*
[511] Fix | Delete
* @since 2.9.0
[512] Fix | Delete
*
[513] Fix | Delete
* @link https://developer.wordpress.org/reference/functions/update_comment_meta/
[514] Fix | Delete
*
[515] Fix | Delete
* @param int $comment_id Comment ID.
[516] Fix | Delete
* @param string $meta_key Metadata key.
[517] Fix | Delete
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
[518] Fix | Delete
* @param mixed $prev_value Optional. Previous value to check before updating.
[519] Fix | Delete
* If specified, only update existing metadata entries with
[520] Fix | Delete
* this value. Otherwise, update all entries. Default empty.
[521] Fix | Delete
* @return int|bool Meta ID if the key didn't exist, true on successful update,
[522] Fix | Delete
* false on failure or if the value passed to the function
[523] Fix | Delete
* is the same as the one that is already in the database.
[524] Fix | Delete
*/
[525] Fix | Delete
function update_comment_meta( $comment_id, $meta_key, $meta_value, $prev_value = '' ) {
[526] Fix | Delete
return update_metadata( 'comment', $comment_id, $meta_key, $meta_value, $prev_value );
[527] Fix | Delete
}
[528] Fix | Delete
[529] Fix | Delete
/**
[530] Fix | Delete
* Queues comments for metadata lazy-loading.
[531] Fix | Delete
*
[532] Fix | Delete
* @since 4.5.0
[533] Fix | Delete
*
[534] Fix | Delete
* @param WP_Comment[] $comments Array of comment objects.
[535] Fix | Delete
*/
[536] Fix | Delete
function wp_queue_comments_for_comment_meta_lazyload( $comments ) {
[537] Fix | Delete
// Don't use `wp_list_pluck()` to avoid by-reference manipulation.
[538] Fix | Delete
$comment_ids = array();
[539] Fix | Delete
if ( is_array( $comments ) ) {
[540] Fix | Delete
foreach ( $comments as $comment ) {
[541] Fix | Delete
if ( $comment instanceof WP_Comment ) {
[542] Fix | Delete
$comment_ids[] = $comment->comment_ID;
[543] Fix | Delete
}
[544] Fix | Delete
}
[545] Fix | Delete
}
[546] Fix | Delete
[547] Fix | Delete
if ( $comment_ids ) {
[548] Fix | Delete
$lazyloader = wp_metadata_lazyloader();
[549] Fix | Delete
$lazyloader->queue_objects( 'comment', $comment_ids );
[550] Fix | Delete
}
[551] Fix | Delete
}
[552] Fix | Delete
[553] Fix | Delete
/**
[554] Fix | Delete
* Sets the cookies used to store an unauthenticated commentator's identity. Typically used
[555] Fix | Delete
* to recall previous comments by this commentator that are still held in moderation.
[556] Fix | Delete
*
[557] Fix | Delete
* @since 3.4.0
[558] Fix | Delete
* @since 4.9.6 The `$cookies_consent` parameter was added.
[559] Fix | Delete
*
[560] Fix | Delete
* @param WP_Comment $comment Comment object.
[561] Fix | Delete
* @param WP_User $user Comment author's user object. The user may not exist.
[562] Fix | Delete
* @param bool $cookies_consent Optional. Comment author's consent to store cookies. Default true.
[563] Fix | Delete
*/
[564] Fix | Delete
function wp_set_comment_cookies( $comment, $user, $cookies_consent = true ) {
[565] Fix | Delete
// If the user already exists, or the user opted out of cookies, don't set cookies.
[566] Fix | Delete
if ( $user->exists() ) {
[567] Fix | Delete
return;
[568] Fix | Delete
}
[569] Fix | Delete
[570] Fix | Delete
if ( false === $cookies_consent ) {
[571] Fix | Delete
// Remove any existing cookies.
[572] Fix | Delete
$past = time() - YEAR_IN_SECONDS;
[573] Fix | Delete
setcookie( 'comment_author_' . COOKIEHASH, ' ', $past, COOKIEPATH, COOKIE_DOMAIN );
[574] Fix | Delete
setcookie( 'comment_author_email_' . COOKIEHASH, ' ', $past, COOKIEPATH, COOKIE_DOMAIN );
[575] Fix | Delete
setcookie( 'comment_author_url_' . COOKIEHASH, ' ', $past, COOKIEPATH, COOKIE_DOMAIN );
[576] Fix | Delete
[577] Fix | Delete
return;
[578] Fix | Delete
}
[579] Fix | Delete
[580] Fix | Delete
/**
[581] Fix | Delete
* Filters the lifetime of the comment cookie in seconds.
[582] Fix | Delete
*
[583] Fix | Delete
* @since 2.8.0
[584] Fix | Delete
*
[585] Fix | Delete
* @param int $seconds Comment cookie lifetime. Default 30000000.
[586] Fix | Delete
*/
[587] Fix | Delete
$comment_cookie_lifetime = time() + apply_filters( 'comment_cookie_lifetime', 30000000 );
[588] Fix | Delete
[589] Fix | Delete
$secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
[590] Fix | Delete
[591] Fix | Delete
setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
[592] Fix | Delete
setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
[593] Fix | Delete
setcookie( 'comment_author_url_' . COOKIEHASH, esc_url( $comment->comment_author_url ), $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
[594] Fix | Delete
}
[595] Fix | Delete
[596] Fix | Delete
/**
[597] Fix | Delete
* Sanitizes the cookies sent to the user already.
[598] Fix | Delete
*
[599] Fix | Delete
* Will only do anything if the cookies have already been created for the user.
[600] Fix | Delete
* Mostly used after cookies had been sent to use elsewhere.
[601] Fix | Delete
*
[602] Fix | Delete
* @since 2.0.4
[603] Fix | Delete
*/
[604] Fix | Delete
function sanitize_comment_cookies() {
[605] Fix | Delete
if ( isset( $_COOKIE[ 'comment_author_' . COOKIEHASH ] ) ) {
[606] Fix | Delete
/**
[607] Fix | Delete
* Filters the comment author's name cookie before it is set.
[608] Fix | Delete
*
[609] Fix | Delete
* When this filter hook is evaluated in wp_filter_comment(),
[610] Fix | Delete
* the comment author's name string is passed.
[611] Fix | Delete
*
[612] Fix | Delete
* @since 1.5.0
[613] Fix | Delete
*
[614] Fix | Delete
* @param string $author_cookie The comment author name cookie.
[615] Fix | Delete
*/
[616] Fix | Delete
$comment_author = apply_filters( 'pre_comment_author_name', $_COOKIE[ 'comment_author_' . COOKIEHASH ] );
[617] Fix | Delete
$comment_author = wp_unslash( $comment_author );
[618] Fix | Delete
$comment_author = esc_attr( $comment_author );
[619] Fix | Delete
$_COOKIE[ 'comment_author_' . COOKIEHASH ] = $comment_author;
[620] Fix | Delete
}
[621] Fix | Delete
[622] Fix | Delete
if ( isset( $_COOKIE[ 'comment_author_email_' . COOKIEHASH ] ) ) {
[623] Fix | Delete
/**
[624] Fix | Delete
* Filters the comment author's email cookie before it is set.
[625] Fix | Delete
*
[626] Fix | Delete
* When this filter hook is evaluated in wp_filter_comment(),
[627] Fix | Delete
* the comment author's email string is passed.
[628] Fix | Delete
*
[629] Fix | Delete
* @since 1.5.0
[630] Fix | Delete
*
[631] Fix | Delete
* @param string $author_email_cookie The comment author email cookie.
[632] Fix | Delete
*/
[633] Fix | Delete
$comment_author_email = apply_filters( 'pre_comment_author_email', $_COOKIE[ 'comment_author_email_' . COOKIEHASH ] );
[634] Fix | Delete
$comment_author_email = wp_unslash( $comment_author_email );
[635] Fix | Delete
$comment_author_email = esc_attr( $comment_author_email );
[636] Fix | Delete
$_COOKIE[ 'comment_author_email_' . COOKIEHASH ] = $comment_author_email;
[637] Fix | Delete
}
[638] Fix | Delete
[639] Fix | Delete
if ( isset( $_COOKIE[ 'comment_author_url_' . COOKIEHASH ] ) ) {
[640] Fix | Delete
/**
[641] Fix | Delete
* Filters the comment author's URL cookie before it is set.
[642] Fix | Delete
*
[643] Fix | Delete
* When this filter hook is evaluated in wp_filter_comment(),
[644] Fix | Delete
* the comment author's URL string is passed.
[645] Fix | Delete
*
[646] Fix | Delete
* @since 1.5.0
[647] Fix | Delete
*
[648] Fix | Delete
* @param string $author_url_cookie The comment author URL cookie.
[649] Fix | Delete
*/
[650] Fix | Delete
$comment_author_url = apply_filters( 'pre_comment_author_url', $_COOKIE[ 'comment_author_url_' . COOKIEHASH ] );
[651] Fix | Delete
$comment_author_url = wp_unslash( $comment_author_url );
[652] Fix | Delete
$_COOKIE[ 'comment_author_url_' . COOKIEHASH ] = $comment_author_url;
[653] Fix | Delete
}
[654] Fix | Delete
}
[655] Fix | Delete
[656] Fix | Delete
/**
[657] Fix | Delete
* Validates whether this comment is allowed to be made.
[658] Fix | Delete
*
[659] Fix | Delete
* @since 2.0.0
[660] Fix | Delete
* @since 4.7.0 The `$avoid_die` parameter was added, allowing the function
[661] Fix | Delete
* to return a WP_Error object instead of dying.
[662] Fix | Delete
* @since 5.5.0 The `$avoid_die` parameter was renamed to `$wp_error`.
[663] Fix | Delete
*
[664] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[665] Fix | Delete
*
[666] Fix | Delete
* @param array $commentdata Contains information on the comment.
[667] Fix | Delete
* @param bool $wp_error When true, a disallowed comment will result in the function
[668] Fix | Delete
* returning a WP_Error object, rather than executing wp_die().
[669] Fix | Delete
* Default false.
[670] Fix | Delete
* @return int|string|WP_Error Allowed comments return the approval status (0|1|'spam'|'trash').
[671] Fix | Delete
* If `$wp_error` is true, disallowed comments return a WP_Error.
[672] Fix | Delete
*/
[673] Fix | Delete
function wp_allow_comment( $commentdata, $wp_error = false ) {
[674] Fix | Delete
global $wpdb;
[675] Fix | Delete
[676] Fix | Delete
// Simple duplicate check.
[677] Fix | Delete
// expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
[678] Fix | Delete
$dupe = $wpdb->prepare(
[679] Fix | Delete
"SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ",
[680] Fix | Delete
wp_unslash( $commentdata['comment_post_ID'] ),
[681] Fix | Delete
wp_unslash( $commentdata['comment_parent'] ),
[682] Fix | Delete
wp_unslash( $commentdata['comment_author'] )
[683] Fix | Delete
);
[684] Fix | Delete
if ( $commentdata['comment_author_email'] ) {
[685] Fix | Delete
$dupe .= $wpdb->prepare(
[686] Fix | Delete
'AND comment_author_email = %s ',
[687] Fix | Delete
wp_unslash( $commentdata['comment_author_email'] )
[688] Fix | Delete
);
[689] Fix | Delete
}
[690] Fix | Delete
$dupe .= $wpdb->prepare(
[691] Fix | Delete
') AND comment_content = %s LIMIT 1',
[692] Fix | Delete
wp_unslash( $commentdata['comment_content'] )
[693] Fix | Delete
);
[694] Fix | Delete
[695] Fix | Delete
$dupe_id = $wpdb->get_var( $dupe );
[696] Fix | Delete
[697] Fix | Delete
/**
[698] Fix | Delete
* Filters the ID, if any, of the duplicate comment found when creating a new comment.
[699] Fix | Delete
*
[700] Fix | Delete
* Return an empty value from this filter to allow what WP considers a duplicate comment.
[701] Fix | Delete
*
[702] Fix | Delete
* @since 4.4.0
[703] Fix | Delete
*
[704] Fix | Delete
* @param int $dupe_id ID of the comment identified as a duplicate.
[705] Fix | Delete
* @param array $commentdata Data for the comment being created.
[706] Fix | Delete
*/
[707] Fix | Delete
$dupe_id = apply_filters( 'duplicate_comment_id', $dupe_id, $commentdata );
[708] Fix | Delete
[709] Fix | Delete
if ( $dupe_id ) {
[710] Fix | Delete
/**
[711] Fix | Delete
* Fires immediately after a duplicate comment is detected.
[712] Fix | Delete
*
[713] Fix | Delete
* @since 3.0.0
[714] Fix | Delete
*
[715] Fix | Delete
* @param array $commentdata Comment data.
[716] Fix | Delete
*/
[717] Fix | Delete
do_action( 'comment_duplicate_trigger', $commentdata );
[718] Fix | Delete
[719] Fix | Delete
/**
[720] Fix | Delete
* Filters duplicate comment error message.
[721] Fix | Delete
*
[722] Fix | Delete
* @since 5.2.0
[723] Fix | Delete
*
[724] Fix | Delete
* @param string $comment_duplicate_message Duplicate comment error message.
[725] Fix | Delete
*/
[726] Fix | Delete
$comment_duplicate_message = apply_filters( 'comment_duplicate_message', __( 'Duplicate comment detected; it looks as though you’ve already said that!' ) );
[727] Fix | Delete
[728] Fix | Delete
if ( $wp_error ) {
[729] Fix | Delete
return new WP_Error( 'comment_duplicate', $comment_duplicate_message, 409 );
[730] Fix | Delete
} else {
[731] Fix | Delete
if ( wp_doing_ajax() ) {
[732] Fix | Delete
die( $comment_duplicate_message );
[733] Fix | Delete
}
[734] Fix | Delete
[735] Fix | Delete
wp_die( $comment_duplicate_message, 409 );
[736] Fix | Delete
}
[737] Fix | Delete
}
[738] Fix | Delete
[739] Fix | Delete
/**
[740] Fix | Delete
* Fires immediately before a comment is marked approved.
[741] Fix | Delete
*
[742] Fix | Delete
* Allows checking for comment flooding.
[743] Fix | Delete
*
[744] Fix | Delete
* @since 2.3.0
[745] Fix | Delete
* @since 4.7.0 The `$avoid_die` parameter was added.
[746] Fix | Delete
* @since 5.5.0 The `$avoid_die` parameter was renamed to `$wp_error`.
[747] Fix | Delete
*
[748] Fix | Delete
* @param string $comment_author_IP Comment author's IP address.
[749] Fix | Delete
* @param string $comment_author_email Comment author's email.
[750] Fix | Delete
* @param string $comment_date_gmt GMT date the comment was posted.
[751] Fix | Delete
* @param bool $wp_error Whether to return a WP_Error object instead of executing
[752] Fix | Delete
* wp_die() or die() if a comment flood is occurring.
[753] Fix | Delete
*/
[754] Fix | Delete
do_action(
[755] Fix | Delete
'check_comment_flood',
[756] Fix | Delete
$commentdata['comment_author_IP'],
[757] Fix | Delete
$commentdata['comment_author_email'],
[758] Fix | Delete
$commentdata['comment_date_gmt'],
[759] Fix | Delete
$wp_error
[760] Fix | Delete
);
[761] Fix | Delete
[762] Fix | Delete
/**
[763] Fix | Delete
* Filters whether a comment is part of a comment flood.
[764] Fix | Delete
*
[765] Fix | Delete
* The default check is wp_check_comment_flood(). See check_comment_flood_db().
[766] Fix | Delete
*
[767] Fix | Delete
* @since 4.7.0
[768] Fix | Delete
* @since 5.5.0 The `$avoid_die` parameter was renamed to `$wp_error`.
[769] Fix | Delete
*
[770] Fix | Delete
* @param bool $is_flood Is a comment flooding occurring? Default false.
[771] Fix | Delete
* @param string $comment_author_IP Comment author's IP address.
[772] Fix | Delete
* @param string $comment_author_email Comment author's email.
[773] Fix | Delete
* @param string $comment_date_gmt GMT date the comment was posted.
[774] Fix | Delete
* @param bool $wp_error Whether to return a WP_Error object instead of executing
[775] Fix | Delete
* wp_die() or die() if a comment flood is occurring.
[776] Fix | Delete
*/
[777] Fix | Delete
$is_flood = apply_filters(
[778] Fix | Delete
'wp_is_comment_flood',
[779] Fix | Delete
false,
[780] Fix | Delete
$commentdata['comment_author_IP'],
[781] Fix | Delete
$commentdata['comment_author_email'],
[782] Fix | Delete
$commentdata['comment_date_gmt'],
[783] Fix | Delete
$wp_error
[784] Fix | Delete
);
[785] Fix | Delete
[786] Fix | Delete
if ( $is_flood ) {
[787] Fix | Delete
/** This filter is documented in wp-includes/comment-template.php */
[788] Fix | Delete
$comment_flood_message = apply_filters( 'comment_flood_message', __( 'You are posting comments too quickly. Slow down.' ) );
[789] Fix | Delete
[790] Fix | Delete
return new WP_Error( 'comment_flood', $comment_flood_message, 429 );
[791] Fix | Delete
}
[792] Fix | Delete
[793] Fix | Delete
if ( ! empty( $commentdata['user_id'] ) ) {
[794] Fix | Delete
$user = get_userdata( $commentdata['user_id'] );
[795] Fix | Delete
$post_author = $wpdb->get_var(
[796] Fix | Delete
$wpdb->prepare(
[797] Fix | Delete
"SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1",
[798] Fix | Delete
$commentdata['comment_post_ID']
[799] Fix | Delete
)
[800] Fix | Delete
);
[801] Fix | Delete
}
[802] Fix | Delete
[803] Fix | Delete
if ( isset( $user ) && ( $commentdata['user_id'] == $post_author || $user->has_cap( 'moderate_comments' ) ) ) {
[804] Fix | Delete
// The author and the admins get respect.
[805] Fix | Delete
$approved = 1;
[806] Fix | Delete
} else {
[807] Fix | Delete
// Everyone else's comments will be checked.
[808] Fix | Delete
if ( check_comment(
[809] Fix | Delete
$commentdata['comment_author'],
[810] Fix | Delete
$commentdata['comment_author_email'],
[811] Fix | Delete
$commentdata['comment_author_url'],
[812] Fix | Delete
$commentdata['comment_content'],
[813] Fix | Delete
$commentdata['comment_author_IP'],
[814] Fix | Delete
$commentdata['comment_agent'],
[815] Fix | Delete
$commentdata['comment_type']
[816] Fix | Delete
) ) {
[817] Fix | Delete
$approved = 1;
[818] Fix | Delete
} else {
[819] Fix | Delete
$approved = 0;
[820] Fix | Delete
}
[821] Fix | Delete
[822] Fix | Delete
if ( wp_check_comment_disallowed_list(
[823] Fix | Delete
$commentdata['comment_author'],
[824] Fix | Delete
$commentdata['comment_author_email'],
[825] Fix | Delete
$commentdata['comment_author_url'],
[826] Fix | Delete
$commentdata['comment_content'],
[827] Fix | Delete
$commentdata['comment_author_IP'],
[828] Fix | Delete
$commentdata['comment_agent']
[829] Fix | Delete
) ) {
[830] Fix | Delete
$approved = EMPTY_TRASH_DAYS ? 'trash' : 'spam';
[831] Fix | Delete
}
[832] Fix | Delete
}
[833] Fix | Delete
[834] Fix | Delete
/**
[835] Fix | Delete
* Filters a comment's approval status before it is set.
[836] Fix | Delete
*
[837] Fix | Delete
* @since 2.1.0
[838] Fix | Delete
* @since 4.9.0 Returning a WP_Error value from the filter will short-circuit comment insertion
[839] Fix | Delete
* and allow skipping further processing.
[840] Fix | Delete
*
[841] Fix | Delete
* @param int|string|WP_Error $approved The approval status. Accepts 1, 0, 'spam', 'trash',
[842] Fix | Delete
* or WP_Error.
[843] Fix | Delete
* @param array $commentdata Comment data.
[844] Fix | Delete
*/
[845] Fix | Delete
return apply_filters( 'pre_comment_approved', $approved, $commentdata );
[846] Fix | Delete
}
[847] Fix | Delete
[848] Fix | Delete
/**
[849] Fix | Delete
* Hooks WP's native database-based comment-flood check.
[850] Fix | Delete
*
[851] Fix | Delete
* This wrapper maintains backward compatibility with plugins that expect to
[852] Fix | Delete
* be able to unhook the legacy check_comment_flood_db() function from
[853] Fix | Delete
* 'check_comment_flood' using remove_action().
[854] Fix | Delete
*
[855] Fix | Delete
* @since 2.3.0
[856] Fix | Delete
* @since 4.7.0 Converted to be an add_filter() wrapper.
[857] Fix | Delete
*/
[858] Fix | Delete
function check_comment_flood_db() {
[859] Fix | Delete
add_filter( 'wp_is_comment_flood', 'wp_check_comment_flood', 10, 5 );
[860] Fix | Delete
}
[861] Fix | Delete
[862] Fix | Delete
/**
[863] Fix | Delete
* Checks whether comment flooding is occurring.
[864] Fix | Delete
*
[865] Fix | Delete
* Won't run, if current user can manage options, so to not block
[866] Fix | Delete
* administrators.
[867] Fix | Delete
*
[868] Fix | Delete
* @since 4.7.0
[869] Fix | Delete
*
[870] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[871] Fix | Delete
*
[872] Fix | Delete
* @param bool $is_flood Is a comment flooding occurring?
[873] Fix | Delete
* @param string $ip Comment author's IP address.
[874] Fix | Delete
* @param string $email Comment author's email address.
[875] Fix | Delete
* @param string $date MySQL time string.
[876] Fix | Delete
* @param bool $avoid_die When true, a disallowed comment will result in the function
[877] Fix | Delete
* returning without executing wp_die() or die(). Default false.
[878] Fix | Delete
* @return bool Whether comment flooding is occurring.
[879] Fix | Delete
*/
[880] Fix | Delete
function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = false ) {
[881] Fix | Delete
[882] Fix | Delete
global $wpdb;
[883] Fix | Delete
[884] Fix | Delete
// Another callback has declared a flood. Trust it.
[885] Fix | Delete
if ( true === $is_flood ) {
[886] Fix | Delete
return $is_flood;
[887] Fix | Delete
}
[888] Fix | Delete
[889] Fix | Delete
// Don't throttle admins or moderators.
[890] Fix | Delete
if ( current_user_can( 'manage_options' ) || current_user_can( 'moderate_comments' ) ) {
[891] Fix | Delete
return false;
[892] Fix | Delete
}
[893] Fix | Delete
[894] Fix | Delete
$hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS );
[895] Fix | Delete
[896] Fix | Delete
if ( is_user_logged_in() ) {
[897] Fix | Delete
$user = get_current_user_id();
[898] Fix | Delete
$check_column = '`user_id`';
[899] Fix | Delete
} else {
[900] Fix | Delete
$user = $ip;
[901] Fix | Delete
$check_column = '`comment_author_IP`';
[902] Fix | Delete
}
[903] Fix | Delete
[904] Fix | Delete
$sql = $wpdb->prepare(
[905] Fix | Delete
"SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( $check_column = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1",
[906] Fix | Delete
$hour_ago,
[907] Fix | Delete
$user,
[908] Fix | Delete
$email
[909] Fix | Delete
);
[910] Fix | Delete
[911] Fix | Delete
$lasttime = $wpdb->get_var( $sql );
[912] Fix | Delete
[913] Fix | Delete
if ( $lasttime ) {
[914] Fix | Delete
$time_lastcomment = mysql2date( 'U', $lasttime, false );
[915] Fix | Delete
$time_newcomment = mysql2date( 'U', $date, false );
[916] Fix | Delete
[917] Fix | Delete
/**
[918] Fix | Delete
* Filters the comment flood status.
[919] Fix | Delete
*
[920] Fix | Delete
* @since 2.1.0
[921] Fix | Delete
*
[922] Fix | Delete
* @param bool $bool Whether a comment flood is occurring. Default false.
[923] Fix | Delete
* @param int $time_lastcomment Timestamp of when the last comment was posted.
[924] Fix | Delete
* @param int $time_newcomment Timestamp of when the new comment was posted.
[925] Fix | Delete
*/
[926] Fix | Delete
$flood_die = apply_filters( 'comment_flood_filter', false, $time_lastcomment, $time_newcomment );
[927] Fix | Delete
[928] Fix | Delete
if ( $flood_die ) {
[929] Fix | Delete
/**
[930] Fix | Delete
* Fires before the comment flood message is triggered.
[931] Fix | Delete
*
[932] Fix | Delete
* @since 1.5.0
[933] Fix | Delete
*
[934] Fix | Delete
* @param int $time_lastcomment Timestamp of when the last comment was posted.
[935] Fix | Delete
* @param int $time_newcomment Timestamp of when the new comment was posted.
[936] Fix | Delete
*/
[937] Fix | Delete
do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment );
[938] Fix | Delete
[939] Fix | Delete
if ( $avoid_die ) {
[940] Fix | Delete
return true;
[941] Fix | Delete
} else {
[942] Fix | Delete
/**
[943] Fix | Delete
* Filters the comment flood error message.
[944] Fix | Delete
*
[945] Fix | Delete
* @since 5.2.0
[946] Fix | Delete
*
[947] Fix | Delete
* @param string $comment_flood_message Comment flood error message.
[948] Fix | Delete
*/
[949] Fix | Delete
$comment_flood_message = apply_filters( 'comment_flood_message', __( 'You are posting comments too quickly. Slow down.' ) );
[950] Fix | Delete
[951] Fix | Delete
if ( wp_doing_ajax() ) {
[952] Fix | Delete
die( $comment_flood_message );
[953] Fix | Delete
}
[954] Fix | Delete
[955] Fix | Delete
wp_die( $comment_flood_message, 429 );
[956] Fix | Delete
}
[957] Fix | Delete
}
[958] Fix | Delete
}
[959] Fix | Delete
[960] Fix | Delete
return false;
[961] Fix | Delete
}
[962] Fix | Delete
[963] Fix | Delete
/**
[964] Fix | Delete
* Separates an array of comments into an array keyed by comment_type.
[965] Fix | Delete
*
[966] Fix | Delete
* @since 2.7.0
[967] Fix | Delete
*
[968] Fix | Delete
* @param WP_Comment[] $comments Array of comments
[969] Fix | Delete
* @return WP_Comment[] Array of comments keyed by comment_type.
[970] Fix | Delete
*/
[971] Fix | Delete
function separate_comments( &$comments ) {
[972] Fix | Delete
$comments_by_type = array(
[973] Fix | Delete
'comment' => array(),
[974] Fix | Delete
'trackback' => array(),
[975] Fix | Delete
'pingback' => array(),
[976] Fix | Delete
'pings' => array(),
[977] Fix | Delete
);
[978] Fix | Delete
[979] Fix | Delete
$count = count( $comments );
[980] Fix | Delete
[981] Fix | Delete
for ( $i = 0; $i < $count; $i++ ) {
[982] Fix | Delete
$type = $comments[ $i ]->comment_type;
[983] Fix | Delete
[984] Fix | Delete
if ( empty( $type ) ) {
[985] Fix | Delete
$type = 'comment';
[986] Fix | Delete
}
[987] Fix | Delete
[988] Fix | Delete
$comments_by_type[ $type ][] = &$comments[ $i ];
[989] Fix | Delete
[990] Fix | Delete
if ( 'trackback' === $type || 'pingback' === $type ) {
[991] Fix | Delete
$comments_by_type['pings'][] = &$comments[ $i ];
[992] Fix | Delete
}
[993] Fix | Delete
}
[994] Fix | Delete
[995] Fix | Delete
return $comments_by_type;
[996] Fix | Delete
}
[997] Fix | Delete
[998] Fix | Delete
/**
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function