wp_throttle_comment_flood

函式
wp_throttle_comment_flood ( $block, $time_lastcomment, $time_newcomment )
引數
  • (bool) $block Whether plugin has already blocked comment.
    Required:
  • (int) $time_lastcomment Timestamp for last comment.
    Required:
  • (int) $time_newcomment Timestamp for new comment.
    Required:
返回值
  • (bool) Whether comment should be blocked.
定義位置
相關方法
wp_check_comment_floodcheck_comment_flood_dbwp_set_comment_cookieswp_trash_post_commentswp_update_comment_count
引入
2.1.0
棄用
-

wp_throttle_comment_flood是一個防止評論氾濫的函式,它檢查由同一IP地址提交的兩個連續評論之間的時間。如果兩個評論之間的時間小於指定的閾值,該函式返回true,表明該評論不應該被接受。

決定一個評論是否應該因為評論氾濫而被阻止。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_throttle_comment_flood( $block, $time_lastcomment, $time_newcomment ) {
if ( $block ) { // A plugin has already blocked... we'll let that decision stand.
return $block;
}
if ( ( $time_newcomment - $time_lastcomment ) < 15 ) {
return true;
}
return false;
}
function wp_throttle_comment_flood( $block, $time_lastcomment, $time_newcomment ) { if ( $block ) { // A plugin has already blocked... we'll let that decision stand. return $block; } if ( ( $time_newcomment - $time_lastcomment ) < 15 ) { return true; } return false; }
function wp_throttle_comment_flood( $block, $time_lastcomment, $time_newcomment ) {
	if ( $block ) { // A plugin has already blocked... we'll let that decision stand.
		return $block;
	}
	if ( ( $time_newcomment - $time_lastcomment ) < 15 ) {
		return true;
	}
	return false;
}

常見問題

FAQs
檢視更多 >