WPSEO_Bulk_List_Table::get_base_subquery()publicYoast 1.0

This function builds the base sql subquery used in this class.

This function takes into account the post types in which the current user can edit all posts, and the ones the current user can only edit his/her own.

Метод класса: WPSEO_Bulk_List_Table{}

Хуков нет.

Возвращает

Строку. The subquery, which should always be used in $wpdb->prepare(), passing the current user_id in as the first parameter.

Использование

$WPSEO_Bulk_List_Table = new WPSEO_Bulk_List_Table();
$WPSEO_Bulk_List_Table->get_base_subquery();

Код WPSEO_Bulk_List_Table::get_base_subquery() Yoast 22.3

public function get_base_subquery() {
	global $wpdb;

	$all_posts_string = "'" . implode( "', '", $this->all_posts ) . "'";
	$own_posts_string = "'" . implode( "', '", $this->own_posts ) . "'";

	$post_author = esc_sql( (int) get_current_user_id() );

	$subquery = "(
			SELECT *
			FROM {$wpdb->posts}
			WHERE post_type IN ({$all_posts_string})
			UNION ALL
			SELECT *
			FROM {$wpdb->posts}
			WHERE post_type IN ({$own_posts_string}) AND post_author = {$post_author}
		) sub_base";

	return $subquery;
}