bbp_check_for_duplicate (数组post_data美元=数组())
检查重复的主题/回复
描述
检查以确保用户没有重复发布
参数
- post_data美元
-
(数组)(可选)包含关于注释的信息
默认值:数组()
返回
(保龄球)如果不是重复的为True,如果是false
源
函数bbp_check_for_duplicate($post_data = array()){//没有重复检查谁可以节流如果(current_user_can('throttle'))返回true;//定义global使用get_meta_sql()和get_var()方法global $wpdb;/ /解析反对默认值$ r = bbp_parse_args (post_data美元,阵列(post_author = > 0, ' post_type ' = >数组(bbp_get_topic_post_type (), bbp_get_reply_post_type()),“post_parent”= > 0,post_content ' => '', ' post_status ' = > bbp_get_trash_status_id(),“anonymous_data”= > false),“check_for_duplicate”);/ /检查匿名帖子如果(空($ r [' post_author '] ) && ( ! 空($ r [' anonymous_data ']) & & !空($ r [' anonymous_data '] [bbp_anonymous_email '] ) ) ) { $ 条款= get_meta_sql(数组(数组(“关键”= >“_bbp_anonymous_email”,“价值”= > sanitize_email ($ r [' anonymous_data '] [bbp_anonymous_email '] ) ) ), ' 帖子,wpdb - >文章,ID ');加入=美元条款(“加入”);$ = $条款(“那里”);} else {$join = $where = ";} // Unslash $r to pass through $wpdb->prepare() // // @see: http://bbpress.trac.wordpress.org/ticket/2185/ // @see: http://core.trac.wordpress.org/changeset/23973/ $r = function_exists('wp_unslash') ?Wp_unslash ($r): stripslashes_deep($r);$query = $wpdb-> Prepare ("SELECT ID FROM {$wpdb->posts} {$join} WHERE post_type = %s AND post_status != %s AND post_author = %d AND post_content = %s {$ WHERE}", $r['post_type'], $r['post_status'], $r['post_author'], $r['post_content']); $query .= !empty( $r['post_parent'] ) ? $wpdb->prepare( " AND post_parent = %d", $r['post_parent'] ) : ''; $query .= " LIMIT 1"; $dupe = apply_filters( 'bbp_check_for_duplicate_query', $query, $r ); if ( $wpdb->get_var( $dupe ) ) { do_action( 'bbp_check_for_duplicate_trigger', $post_data ); return false; } return true; }
更新日志
版本 | 描述 |
---|---|
bbPress (r2763) | 介绍了。 |