WordPress.org

Make WordPress Core

Changeset 13318


Ignore:
Timestamp:
02/23/2010 01:13:37 AM (8 years ago)
Author:
ryan
Message:

Revert [13187] pending further debate. see #12267

Location:
trunk/wp-includes
Files:
3 edited

Legend:

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

    r13315 r13318  
    16981698}
    16991699
    1700 // A factory and constructor that upgrades stdClass "rows" to WordPress classes.
    1701 class wp_row {
    1702     // Factory. Call statically to upgrade a stdClass object to its specialized class: $o = wp_row::get($row).
    1703     function get($row) {
    1704         if ( is_a($row, 'wp_row') || is_subclass_of($row, 'wp_row') )
    1705             return $row;
    1706 
    1707         if ( is_array($row) )
    1708             $row = (object) $row;
    1709 
    1710         $class = 'wp_row';
    1711         if ( isset($row->post_type) ) {
    1712             if ( class_exists("wp_" . $row->post_type) )
    1713                 $class = "wp_" . $row->post_type;
    1714             else
    1715                 $class = "wp_post";
    1716         } elseif ( isset($row->comment_type) ) {
    1717             if ( class_exists("wp_" . $row->comment_type) )
    1718                 $class = "wp_" . $row->comment_type;
    1719             else
    1720                 $class = "wp_comment";
    1721         }
    1722 
    1723         if ( function_exists("apply_filters") ) {
    1724             $filtered_class = apply_filters("wp_row_class", $class, $row);
    1725             if ( class_exists($filtered_class) )
    1726                 $class = $filtered_class;
    1727         }
    1728 
    1729         return call_user_func(array($class, 'get'), $row);
    1730     }
    1731 
    1732     function wp_row(&$row) {
    1733         return $this->__construct($row);
    1734     }
    1735 
    1736     function __construct($row) {
    1737         if ( is_array($row) )
    1738             $row = (object) $row;
    1739 
    1740         foreach ( (array) $row as $k => $v )
    1741             $this->$k = $row->$k;
    1742     }
    1743 }
    1744 
    1745 class wp_post extends wp_row {
    1746     // Factory
    1747     function get($post) {
    1748         if ( $post = get_post($post) )
    1749             return new wp_post($post);
    1750         else
    1751             return new WP_Error(404, "Post not found.");
    1752     }
    1753 
    1754     function id() { return $this->ID; }
    1755     function post_id() { return $this->ID; }
    1756     function type_id() { return 'post-' . $this->ID; }
    1757     function classes($class='') { return join( ' ', get_post_class( $class, $this->id() ) ); }
    1758 
    1759     function permalink() { return get_permalink($this); }
    1760     function title() { return get_the_title($this); }
    1761     function date($format='') { return; }
    1762     function time($format='') { return get_the_time($format, $this); }
    1763     function author() { $authordata = get_userdata($this->post_author); return $authordata->display_name; }
    1764     function content() { return get_content($this); }
    1765 }
    1766 
    1767 class wp_comment extends wp_row {
    1768     // Factory
    1769     function get($comment) {
    1770         if ( $comment = get_comment($comment) )
    1771             return new wp_comment($comment);
    1772         else
    1773             return new WP_Error(404, "Comment not found.");
    1774     }
    1775 
    1776     function id() { return $this->comment_ID; }
    1777     function post_id() { return $this->comment_post_ID; }
    1778     function type_id() { return 'comment-' . $this->comment_ID; }
    1779     function classes($class='') { return join( ' ', get_comment_class( $class, $this->id() ) ); }
    1780 
    1781     function permalink() { return get_comment_link($this); }
    1782     function title() { return sprintf(__("Comment on %s"), get_the_title($this->post_id())); }
    1783     function time($format='') { return mysql2date($format?$format:get_option('time_format'), $this->comment_date); }
    1784     function date($format='') { return date($format?$format:get_option('date_format'), $this->time('U')); }
    1785     function author() { return $this->comment_author; }
    1786     function excerpt() { return $this->comment_content; }
    1787     function content() { return get_comment_content($this); }
    1788 }
    1789 
    1790 function is_post($object) {
    1791     return is_a('wp_post', $object);
    1792 }
    1793 
    1794 function is_comment($object) {
    1795     return is_a('wp_comment', $object);
    1796 }
    1797 
    17981700?>
  • trunk/wp-includes/custom-navigation.php

    r13317 r13318  
    204204                        ?></a><?php
    205205                    } elseif ( $type == 'backend' ) {
    206                         //BACKEND draggable and droppable elements
    207206                        $link_type = $menu_type;
    208207                        ?>
  • trunk/wp-includes/query.php

    r13187 r13318  
    23022302        if ( !$q['suppress_filters'] )
    23032303            $this->posts = apply_filters('posts_results', $this->posts);
    2304 
    2305         // Turn each row into a classed object, e.g. wp_post, wp_comment.
    2306         if ( is_array($this->posts) )
    2307             $this->posts = array_map(array('wp_row', 'get'), $this->posts);
    23082304
    23092305        if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {
Note: See TracChangeset for help on using the changeset viewer.