Make WordPress Core

Ticket #12750: 12750.diff

File 12750.diff, 2.3 KB (added by jfarthing84, 15 years ago)

Fix custom taxonomy status and attachment queries.

  • post.php

     
    15451545 * @since 2.5.0
    15461546 *
    15471547 * @param string|array $mime_types List of mime types or comma separated string of mime types.
     1548 * @param string $table_alias Optional. Specify a table alias, if needed.
    15481549 * @return string The SQL AND clause for mime searching.
    15491550 */
    1550 function wp_post_mime_type_where($post_mime_types) {
     1551function wp_post_mime_type_where($post_mime_types, $table_alias = '') {
    15511552        $where = '';
    15521553        $wildcards = array('', '%', '%/%');
    15531554        if ( is_string($post_mime_types) )
     
    15751576                        return '';
    15761577
    15771578                if ( false !== strpos($mime_pattern, '%') )
    1578                         $wheres[] = "post_mime_type LIKE '$mime_pattern'";
     1579                        $wheres[] = empty($table_alias) ? "post_mime_type LIKE '$mime_pattern'" : "$table_alias.post_mime_type LIKE '$mime_pattern'";
    15791580                else
    1580                         $wheres[] = "post_mime_type = '$mime_pattern'";
     1581                        $wheres[] = empty($table_alias) ? "post_mime_type = '$mime_pattern'" : "$table_alias.post_mime_type = '$mime_pattern'";
    15811582        }
    15821583        if ( !empty($wheres) )
    15831584                $where = ' AND (' . join(' OR ', $wheres) . ') ';
  • query.php

     
    20382038                                $post_ids = get_objects_in_term($term_ids, $taxonomy);
    20392039                                if ( !is_wp_error($post_ids) && !empty($post_ids) ) {
    20402040                                        $whichcat .= " AND $wpdb->posts.ID IN (" . implode(', ', $post_ids) . ") ";
    2041                                         $post_type = 'any';
    2042                                         $q['post_status'] = 'publish';
     2041                                        if ( empty($post_type) )
     2042                                                $post_type = 'any';
     2043                                        if ( empty($q['post_status']) )
     2044                                                $q['post_status'] = 'publish';
    20432045                                        $post_status_join = true;
    20442046                                } else {
    20452047                                        $whichcat = " AND 0 ";
     
    20922094
    20932095                // MIME-Type stuff for attachment browsing
    20942096
    2095                 if ( isset($q['post_mime_type']) && '' != $q['post_mime_type'] )
    2096                         $whichmimetype = wp_post_mime_type_where($q['post_mime_type']);
     2097                if ( isset($q['post_mime_type']) && '' != $q['post_mime_type'] ) {
     2098                        $table_alias = $post_status_join ? $wpdb->posts : '';
     2099                        $whichmimetype = wp_post_mime_type_where($q['post_mime_type'], $table_alias);
     2100                }
    20972101
    20982102                $where .= $search.$whichcat.$whichauthor.$whichmimetype;
    20992103