Make WordPress Core

Ticket #36295: 36295.3.diff

File 36295.3.diff, 4.9 KB (added by stevenkword, 9 years ago)
  • src/wp-includes/class-feed.php

     
    33if ( ! class_exists( 'SimplePie', false ) )
    44        require_once( ABSPATH . WPINC . '/class-simplepie.php' );
    55
     6/**
     7 * WordPress Feed Cache Class.
     8 *
     9 * Caches feeds using SimplePie_Cache.
     10 *
     11 * @since 2.8.0
     12 */
    613class WP_Feed_Cache extends SimplePie_Cache {
     14
    715        /**
    8          * Create a new SimplePie_Cache object
     16         * Creates a new SimplePie_Cache object.
    917         *
    10          * @static
    11          * @access public
     18         * @since 2.8.0
    1219         *
    1320         * @param string $location  URL location (scheme is used to determine handler).
    1421         * @param string $filename  Unique identifier for cache object.
     
    2027        }
    2128}
    2229
     30/**
     31 * WordPress Feed Cache Transient Class.
     32 *
     33 * Caches feeds using SimplePie_Cache.
     34 *
     35 * @since 2.8.0
     36 */
    2337class WP_Feed_Cache_Transient {
     38
     39        /**
     40         * Holds the transient name.
     41         *
     42         * @since 2.8.0
     43         * @access public
     44         * @var string
     45         */
    2446        public $name;
     47
     48        /**
     49         * Holds the transient mod name.
     50         *
     51         * @since 2.8.0
     52         * @access public
     53         * @var string
     54         */
    2555        public $mod_name;
    26         public $lifetime = 43200; //Default lifetime in cache of 12 hours
    2756
    2857        /**
    29          * Class instantiator.
    30          *
     58         * Holds the cache duration in seconds.
     59         *
     60         * Defaults to 43200 seconds (12 hours).
     61         *
     62         * @since 2.8.0
     63         * @access public
     64         * @var int
     65         */
     66        public $lifetime = 43200;
     67
     68        /**
     69         * Constructor.
     70         *
     71         * @since 2.8.0
     72         * @since 3.2.0 Update to PHP5 constructor
     73         *
    3174         * @param string $location  URL location (scheme is used to determine handler).
    3275         * @param string $filename  Unique identifier for cache object.
    3376         * @param string $extension 'spi' or 'spc'.
     
    4992        }
    5093
    5194        /**
    52          * @access public
     95         * Sets the transient.
    5396         *
     97         * @since 2.8.0
     98         *
    5499         * @param SimplePie $data Data to save.
    55100         * @return true Always true.
    56101         */
     
    65110        }
    66111
    67112        /**
    68          * @access public
     113         * Gets the transient.
     114         *
     115         * @since 2.8.0
     116         * @return mixed Transient value.
    69117         */
    70118        public function load() {
    71119                return get_transient($this->name);
     
    72120        }
    73121
    74122        /**
    75          * @access public
     123         * Gets mod transient.
     124         *
     125         * @since 2.8.0
     126         * @return mixed Transient value.
    76127         */
    77128        public function mtime() {
    78129                return get_transient($this->mod_name);
     
    79130        }
    80131
    81132        /**
    82          * @access public
     133         * Sets mod transient.
     134         *
     135         * @since 2.8.0
     136         * @return bool False if value was not set and true if value was set.
    83137         */
    84138        public function touch() {
    85139                return set_transient($this->mod_name, time(), $this->lifetime);
     
    86140        }
    87141
    88142        /**
    89          * @access public
     143         * Deletes transients.
     144         *
     145         * @since 2.8.0
     146         * @return true Always true.
    90147         */
    91148        public function unlink() {
    92149                delete_transient($this->name);
     
    95152        }
    96153}
    97154
     155/**
     156 * WordPress SimplePie File Class.
     157 *
     158 * Fetches remote files and reads local files.
     159 *
     160 * @since 2.8.0
     161 */
    98162class WP_SimplePie_File extends SimplePie_File {
    99163
     164        /**
     165         * Constructor.
     166         *
     167         * @since 2.8.0
     168         * @since 3.2.0 Update to PHP5 constructor
     169         *
     170         * @param string       $url             Remote file URL.
     171         * @param integer      $timeout         How long the connection should stay open in seconds. Default: 10.
     172         * @param integer      $redirects       The number of allowed redirects. Default: 5.
     173         * @param string|array $headers         Array or string of headers to send with the request. Default: null.
     174         * @param string       $useragent       User-agent value sent. Default: null.
     175         * @param boolean      $force_fsockopen Whether to force opening internet or unix domain socket connection
     176         *                                      or not. Default: false.
     177         */
    100178        public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) {
    101179                $this->url = $url;
    102180                $this->timeout = $timeout;
     
    136214}
    137215
    138216/**
    139  * WordPress SimplePie Sanitization Class
     217 * WordPress SimplePie Sanitization Class.
    140218 *
    141  * Extension of the SimplePie_Sanitize class to use KSES, because
    142  * we cannot universally count on DOMDocument being available
     219 * Extends the SimplePie_Sanitize class to use KSES, because
     220 * we cannot universally count on DOMDocument being available.
    143221 *
    144  * @package WordPress
    145222 * @since 3.5.0
    146223 */
    147224class WP_SimplePie_Sanitize_KSES extends SimplePie_Sanitize {
     225
     226        /**
     227         * WordPress SimplePie sanitization using KSES.
     228         *
     229         * Sanitizes the incoming data, to ensure that it matches the type of data expected, using KSES.
     230         *
     231         * @since 3.5.0
     232         *
     233         * @param mixed   $data The data that needs to be sanitized.
     234         * @param integer $type The type of data that it's supposed to be.
     235         * @param string  $base The `xml:base` value to use when converting relative URLs to absolute ones.
     236         * @return mixed Sanitized data.
     237         */
    148238        public function sanitize( $data, $type, $base = '' ) {
    149239                $data = trim( $data );
    150240                if ( $type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML ) {