get_posts_by_author_sql [ WordPress Function ]
get_posts_by_author_sql ( $post_type, $full = true, $post_author = null )
| Parameters: |
|
| See: | |
| Returns: |
|
| Defined at: |
|
Benzer Fonksiyonlar: get_the_author_icq, get_the_author_msn, get_the_author_url, get_post_ancestors, get_the_author_link
Retrieve the post SQL based on capability, author, and type.
Source
<?php
function get_posts_by_author_sql( $post_type, $full = true, $post_author = null ) {
global $user_ID, $wpdb;
// Private posts
$post_type_obj = get_post_type_object( $post_type );
if ( ! $post_type_obj )
return $full ? 'WHERE 1 = 0' : ' 1 = 0 ';
// This hook is deprecated. Why you'd want to use it, I dunno.
if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) )
$cap = $post_type_obj->cap->read_private_posts;
if ( $full ) {
if ( null === $post_author ) {
$sql = $wpdb->prepare( 'WHERE post_type = %s AND ', $post_type );
} else {
$sql = $wpdb->prepare( 'WHERE post_author = %d AND post_type = %s AND ', $post_author, $post_type );
}
} else {
$sql = '';
}
$sql .= "(post_status = 'publish'";
if ( current_user_can( $cap ) ) {
// Does the user have the capability to view private posts? Guess so.
$sql .= " OR post_status = 'private'";
} elseif ( is_user_logged_in() ) {
// Users can view their own private posts.
$id = (int) $user_ID;
if ( null === $post_author || ! $full ) {
$sql .= " OR post_status = 'private' AND post_author = $id";
} elseif ( $id == (int) $post_author ) {
$sql .= " OR post_status = 'private'";
} // else none
} // else none
$sql .= ')';
return $sql;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/get posts by author sql « WordPress Codex
Description. Retrieve the post SQL based on capability, author, and type. <?php get_posts_by_author_sql( $post_type, $full = true, $post_author = null ); ?> ...
codex.wordpress.org - #17220 (get_posts_by_author_sql() should use the post type object ...
The filter there, pub_priv_sql_capability, is pretty useless, particularly since it doesn't receive any context. Suggesting we simply remove it. Patch also adds a ...
core.trac.wordpress.org - get_posts_by_author_sql
Function and Method Cross Reference. get_posts_by_author_sql(). Defined at: / wp-includes/post.php -> line 4189. Referenced 4 times: /wp-includes/user.php ...
phpxref.ftwr.co.uk - get_posts_by_author_sql() WordPress function reference ...
Retrieve the post SQL based on capability, author, and type.
queryposts.com