Changeset 13838 for trunk/wp-includes/query.php
- Timestamp:
- 03/27/2010 05:56:27 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r13830 r13838 1713 1713 $where .= " AND DAYOFMONTH($wpdb->posts.post_date)='" . $q['day'] . "'"; 1714 1714 1715 if ( !empty($q['post_type']) && !empty($q[ $q['post_type'] ]) ) { 1716 $q[ $q['post_type'] ] = str_replace('%2F', '/', urlencode(urldecode($q[ $q['post_type'] ]))); 1717 $post_type_object = get_post_type_object($q['post_type']); 1718 if ( ! $post_type_object->hierarchical || strpos($q[ $q['post_type'] ], '/') === false) { 1719 $q['name'] = $q[ $q['post_type'] ] = sanitize_title($q[ $q['post_type'] ]); 1720 $where .= " AND $wpdb->posts.post_name = '" . $q[ $q['post_type'] ] . "'"; 1721 } else { 1722 // Hierarchical post type, need to look deeper to see if its an attachment or this post_type 1723 if ( isset($this->queried_object_id) ) { 1724 $reqpage = $this->queried_object_id; 1715 if ( !empty($q['post_type']) ) { 1716 $_pt = is_array($q['post_type']) ? $q['post_type'] : array($q['post_type']); 1717 foreach ( $_pt as $_post_type ) { 1718 if ( empty($q[ $_post_type ]) ) 1719 continue; 1720 1721 $q[ $_post_type ] = str_replace('%2F', '/', urlencode(urldecode($q[ $_post_type ]))); 1722 $post_type_object = get_post_type_object($_post_type); 1723 if ( ! $post_type_object->hierarchical || strpos($q[ $_post_type ], '/') === false) { 1724 $q['name'] = $q[ $_post_type ] = sanitize_title($q[ $_post_type ]); 1725 $_names[] = $q[ $_post_type ]; 1725 1726 } else { 1726 $reqpage = get_page_by_path($q[ $q['post_type'] ], OBJECT, $q['post_type']); 1727 if ( !empty($reqpage) ) 1728 $reqpage = $reqpage->ID; 1729 else 1730 $reqpage = 0; 1727 // Hierarchical post type, need to look deeper to see if its an attachment or this post_type 1728 if ( isset($this->queried_object_id) ) { 1729 $reqpage = $this->queried_object_id; 1730 } else { 1731 $reqpage = get_page_by_path($q[ $_post_type ], OBJECT, $_post_type); 1732 if ( !empty($reqpage) ) 1733 $reqpage = $reqpage->ID; 1734 else 1735 $reqpage = 0; 1736 } 1737 $_ids[] = $reqpage; 1738 $reqpage_obj = get_page($reqpage); 1739 if ( is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type ) { 1740 $this->is_attachment = true; 1741 $q['attachment_id'] = $reqpage; 1742 $post_type = $q['post_type'] = 'attachment'; 1743 } 1731 1744 } 1732 $where .= " AND ($wpdb->posts.ID = '$reqpage')"; 1733 $reqpage_obj = get_page($reqpage); 1734 if ( is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type ) { 1735 $this->is_attachment = true; 1736 $q['attachment_id'] = $reqpage; 1737 $post_type = $q['post_type'] = 'attachment'; 1745 } //end foreach 1746 1747 if ( !empty($_names) || !empty($_ids) ) { 1748 $where .= ' AND (1=0'; 1749 if ( !empty($_names) ) 1750 $where .= " OR $wpdb->posts.post_name IN('" . implode("', '", $_names) . "')"; 1751 if ( !empty($_ids) ) { 1752 $_ids = array_map('absint', $_ids); 1753 $where .= " OR $wpdb->posts.ID IN(" . implode(',', $_ids) . ")"; 1738 1754 } 1739 } 1755 $where .= ')'; 1756 } 1757 unset($_ids, $_names, $_pt, $_post_type); 1740 1758 } elseif ( '' != $q['name'] ) { 1741 1759 $q['name'] = sanitize_title($q['name']); … … 2374 2392 if ( !$q['suppress_filters'] ) 2375 2393 $this->request = apply_filters_ref_array('posts_request', array( $this->request, &$this ) ); 2376 2394 var_Dump($this->request); 2377 2395 $this->posts = $wpdb->get_results($this->request); 2378 2396 // Raw results filter. Prior to status checks.
Note: See TracChangeset
for help on using the changeset viewer.