| @@ 131-148 (lines=18) @@ | ||
| 128 | $args['type'] = isset( $args['type'] ) ? $args['type'] : 'post'; |
|
| 129 | ||
| 130 | // make sure the user can read or edit the requested post type(s) |
|
| 131 | if ( is_array( $args['type'] ) ) { |
|
| 132 | $allowed_types = array(); |
|
| 133 | foreach ( $args['type'] as $post_type ) { |
|
| 134 | if ( $this->current_user_can_access_post_type( $post_type, $args['context'] ) ) { |
|
| 135 | $allowed_types[] = $post_type; |
|
| 136 | } |
|
| 137 | } |
|
| 138 | ||
| 139 | if ( empty( $allowed_types ) ) { |
|
| 140 | return array( 'found' => 0, 'posts' => array() ); |
|
| 141 | } |
|
| 142 | $args['type'] = $allowed_types; |
|
| 143 | } |
|
| 144 | else { |
|
| 145 | if ( ! $this->current_user_can_access_post_type( $args['type'], $args['context'] ) ) { |
|
| 146 | return array( 'found' => 0, 'posts' => array() ); |
|
| 147 | } |
|
| 148 | } |
|
| 149 | ||
| 150 | $query = array( |
|
| 151 | 'posts_per_page' => $args['number'], |
|
| @@ 144-161 (lines=18) @@ | ||
| 141 | $args['type'] = isset( $args['type'] ) ? $args['type'] : 'post'; |
|
| 142 | ||
| 143 | // make sure the user can read or edit the requested post type(s) |
|
| 144 | if ( is_array( $args['type'] ) ) { |
|
| 145 | $allowed_types = array(); |
|
| 146 | foreach ( $args['type'] as $post_type ) { |
|
| 147 | if ( $site->current_user_can_access_post_type( $post_type, $args['context'] ) ) { |
|
| 148 | $allowed_types[] = $post_type; |
|
| 149 | } |
|
| 150 | } |
|
| 151 | ||
| 152 | if ( empty( $allowed_types ) ) { |
|
| 153 | return array( |
|
| 154 | 'found' => 0, |
|
| 155 | 'posts' => array(), |
|
| 156 | ); |
|
| 157 | } |
|
| 158 | $args['type'] = $allowed_types; |
|
| 159 | } else { |
|
| 160 | if ( ! $site->current_user_can_access_post_type( $args['type'], $args['context'] ) ) { |
|
| 161 | return array( |
|
| 162 | 'found' => 0, |
|
| 163 | 'posts' => array(), |
|
| 164 | ); |
|
| @@ 109-126 (lines=18) @@ | ||
| 106 | } |
|
| 107 | ||
| 108 | // make sure the user can read or edit the requested post type(s) |
|
| 109 | if ( is_array( $args['type'] ) ) { |
|
| 110 | $allowed_types = array(); |
|
| 111 | foreach ( $args['type'] as $post_type ) { |
|
| 112 | if ( $site->current_user_can_access_post_type( $post_type, $args['context'] ) ) { |
|
| 113 | $allowed_types[] = $post_type; |
|
| 114 | } |
|
| 115 | } |
|
| 116 | ||
| 117 | if ( empty( $allowed_types ) ) { |
|
| 118 | return array( |
|
| 119 | 'found' => 0, |
|
| 120 | 'posts' => array(), |
|
| 121 | ); |
|
| 122 | } |
|
| 123 | $args['type'] = $allowed_types; |
|
| 124 | } else { |
|
| 125 | if ( ! $site->current_user_can_access_post_type( $args['type'], $args['context'] ) ) { |
|
| 126 | return array( |
|
| 127 | 'found' => 0, |
|
| 128 | 'posts' => array(), |
|
| 129 | ); |
|