Make WordPress Core


Ignore:
Timestamp:
03/13/2006 01:44:32 AM (21 years ago)
Author:
ryan
Message:

Move WP_Query and its wrapper functions to query.php. #2525

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r3638 r3639  
    14711471}
    14721472
    1473 function &query_posts($query) {
    1474         global $wp_query;
    1475         return $wp_query->query($query);
    1476 }
    1477 
    14781473function update_post_cache(&$posts) {
    14791474        global $post_cache;
    … …  
    15821577function wp_footer() {
    15831578        do_action('wp_footer');
    1584 }
    1585 
    1586 function is_single ($post = '') {
    1587         global $wp_query;
    1588 
    1589         if ( !$wp_query->is_single )
    1590                 return false;
    1591 
    1592         if ( empty( $post) )
    1593                 return true;
    1594 
    1595         $post_obj = $wp_query->get_queried_object();
    1596 
    1597         if ( $post == $post_obj->ID )
    1598                 return true;
    1599         elseif ( $post == $post_obj->post_title )
    1600                 return true;
    1601         elseif ( $post == $post_obj->post_name )
    1602                 return true;
    1603 
    1604         return false;
    1605 }
    1606 
    1607 function is_page ($page = '') {
    1608         global $wp_query;
    1609 
    1610         if ( !$wp_query->is_page )
    1611                 return false;
    1612 
    1613         if ( empty($page) )
    1614                 return true;
    1615 
    1616         $page_obj = $wp_query->get_queried_object();
    1617 
    1618         if ( $page == $page_obj->ID )
    1619                 return true;
    1620         elseif ( $page == $page_obj->post_title )
    1621                 return true;
    1622         else if ( $page == $page_obj->post_name )
    1623                 return true;
    1624 
    1625         return false;
    1626 }
    1627 
    1628 function is_attachment () {
    1629         global $wp_query;
    1630 
    1631         return $wp_query->is_attachment;
    1632 }
    1633 
    1634 function is_preview() {
    1635         global $wp_query;
    1636 
    1637         return $wp_query->is_preview;
    1638 }
    1639 
    1640 function is_archive () {
    1641         global $wp_query;
    1642 
    1643         return $wp_query->is_archive;
    1644 }
    1645 
    1646 function is_date () {
    1647         global $wp_query;
    1648 
    1649         return $wp_query->is_date;
    1650 }
    1651 
    1652 function is_year () {
    1653         global $wp_query;
    1654 
    1655         return $wp_query->is_year;
    1656 }
    1657 
    1658 function is_month () {
    1659         global $wp_query;
    1660 
    1661         return $wp_query->is_month;
    1662 }
    1663 
    1664 function is_day () {
    1665         global $wp_query;
    1666 
    1667         return $wp_query->is_day;
    1668 }
    1669 
    1670 function is_time () {
    1671         global $wp_query;
    1672 
    1673         return $wp_query->is_time;
    1674 }
    1675 
    1676 function is_author ($author = '') {
    1677         global $wp_query;
    1678 
    1679         if ( !$wp_query->is_author )
    1680                 return false;
    1681 
    1682         if ( empty($author) )
    1683                 return true;
    1684 
    1685         $author_obj = $wp_query->get_queried_object();
    1686 
    1687         if ( $author == $author_obj->ID )
    1688                 return true;
    1689         elseif ( $author == $author_obj->nickname )
    1690                 return true;
    1691         elseif ( $author == $author_obj->user_nicename )
    1692                 return true;
    1693 
    1694         return false;
    1695 }
    1696 
    1697 function is_category ($category = '') {
    1698         global $wp_query;
    1699 
    1700         if ( !$wp_query->is_category )
    1701                 return false;
    1702 
    1703         if ( empty($category) )
    1704                 return true;
    1705 
    1706         $cat_obj = $wp_query->get_queried_object();
    1707 
    1708         if ( $category == $cat_obj->cat_ID )
    1709                 return true;
    1710         else if ( $category == $cat_obj->cat_name )
    1711                 return true;
    1712         elseif ( $category == $cat_obj->category_nicename )
    1713                 return true;
    1714 
    1715         return false;
    1716 }
    1717 
    1718 function is_search () {
    1719         global $wp_query;
    1720 
    1721         return $wp_query->is_search;
    1722 }
    1723 
    1724 function is_feed () {
    1725         global $wp_query;
    1726 
    1727         return $wp_query->is_feed;
    1728 }
    1729 
    1730 function is_trackback () {
    1731         global $wp_query;
    1732 
    1733         return $wp_query->is_trackback;
    1734 }
    1735 
    1736 function is_admin () {
    1737         global $wp_query;
    1738 
    1739         return ( $wp_query->is_admin || strstr($_SERVER['REQUEST_URI'], 'wp-admin/') );
    1740 }
    1741 
    1742 function is_home () {
    1743         global $wp_query;
    1744 
    1745         return $wp_query->is_home;
    1746 }
    1747 
    1748 function is_404 () {
    1749         global $wp_query;
    1750 
    1751         return $wp_query->is_404;
    1752 }
    1753 
    1754 function is_comments_popup () {
    1755         global $wp_query;
    1756 
    1757         return $wp_query->is_comments_popup;
    1758 }
    1759 
    1760 function is_paged () {
    1761         global $wp_query;
    1762 
    1763         return $wp_query->is_paged;
    1764 }
    1765 
    1766 function in_the_loop() {
    1767         global $wp_query;
    1768 
    1769         return $wp_query->in_the_loop;
    1770 }
    1771 
    1772 function get_query_var($var) {
    1773         global $wp_query;
    1774 
    1775         return $wp_query->get($var);
    1776 }
    1777 
    1778 function have_posts() {
    1779         global $wp_query;
    1780 
    1781         return $wp_query->have_posts();
    1782 }
    1783 
    1784 function rewind_posts() {
    1785         global $wp_query;
    1786 
    1787         return $wp_query->rewind_posts();
    1788 }
    1789 
    1790 function the_post() {
    1791         global $wp_query;
    1792 
    1793         $wp_query->the_post();
    17941579}
    17951580
    … …  
    21641949}
    21651950
    2166 
    2167 function is_plugin_page() {
    2168         global $plugin_page;
    2169 
    2170         if ( isset($plugin_page) )
    2171                 return true;
    2172 
    2173         return false;
    2174 }
    2175 
    21761951/*
    21771952add_query_arg: Returns a modified querystring by adding
Note: See TracChangeset for help on using the changeset viewer.