]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/rss.php
Wordpress 2.8-scripts
[autoinstalls/wordpress.git] / wp-includes / rss.php
index 9962773486de233bbd9d54779e1f443326186978..d48230ac6f5477eab405de2d0113b6df06a11d7f 100644 (file)
@@ -170,7 +170,7 @@ class MagpieRSS {
                {
                        // if tags are inlined, then flatten
                        $attrs_str = join(' ',
                {
                        // if tags are inlined, then flatten
                        $attrs_str = join(' ',
-                                       array_map('map_attrs',
+                                       array_map(array('MagpieRSS', 'map_attrs'),
                                        array_keys($attrs),
                                        array_values($attrs) ) );
 
                                        array_keys($attrs),
                                        array_values($attrs) ) );
 
@@ -712,16 +712,8 @@ class RSSCache {
        function set ($url, $rss) {
                global $wpdb;
                $cache_option = 'rss_' . $this->file_name( $url );
        function set ($url, $rss) {
                global $wpdb;
                $cache_option = 'rss_' . $this->file_name( $url );
-               $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
 
 
-               // shouldn't these be using get_option() ?
-               if ( !$wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name = %s", $cache_option ) ) )
-                       add_option($cache_option, '', '', 'no');
-               if ( !$wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name = %s", $cache_timestamp ) ) )
-                       add_option($cache_timestamp, '', '', 'no');
-
-               update_option($cache_option, $rss);
-               update_option($cache_timestamp, time() );
+               set_transient($cache_option, $rss, $this->MAX_AGE);
 
                return $cache_option;
        }
 
                return $cache_option;
        }
@@ -736,15 +728,13 @@ class RSSCache {
                $this->ERROR = "";
                $cache_option = 'rss_' . $this->file_name( $url );
 
                $this->ERROR = "";
                $cache_option = 'rss_' . $this->file_name( $url );
 
-               if ( ! get_option( $cache_option ) ) {
+               if ( ! $rss = get_transient( $cache_option ) ) {
                        $this->debug(
                                "Cache doesn't contain: $url (cache option: $cache_option)"
                        );
                        return 0;
                }
 
                        $this->debug(
                                "Cache doesn't contain: $url (cache option: $cache_option)"
                        );
                        return 0;
                }
 
-               $rss = get_option( $cache_option );
-
                return $rss;
        }
 
                return $rss;
        }
 
@@ -757,23 +747,12 @@ class RSSCache {
 \*=======================================================================*/
        function check_cache ( $url ) {
                $this->ERROR = "";
 \*=======================================================================*/
        function check_cache ( $url ) {
                $this->ERROR = "";
-               $cache_option = $this->file_name( $url );
-               $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
-
-               if ( $mtime = get_option($cache_timestamp) ) {
-                       // find how long ago the file was added to the cache
-                       // and whether that is longer then MAX_AGE
-                       $age = time() - $mtime;
-                       if ( $this->MAX_AGE > $age ) {
-                               // object exists and is current
+               $cache_option = 'rss_' . $this->file_name( $url );
+
+               if ( get_transient($cache_option) ) {
+                       // object exists and is current
                                return 'HIT';
                                return 'HIT';
-                       }
-                       else {
-                               // object exists but is old
-                               return 'STALE';
-                       }
-               }
-               else {
+               } else {
                        // object does not exist
                        return 'MISS';
                }
                        // object does not exist
                        return 'MISS';
                }
@@ -893,8 +872,8 @@ function wp_rss( $url, $num_items = -1 ) {
                foreach ( (array) $rss->items as $item ) {
                        printf(
                                '<li><a href="%1$s" title="%2$s">%3$s</a></li>',
                foreach ( (array) $rss->items as $item ) {
                        printf(
                                '<li><a href="%1$s" title="%2$s">%3$s</a></li>',
-                               clean_url( $item['link'] ),
-                               attribute_escape( strip_tags( $item['description'] ) ),
+                               esc_url( $item['link'] ),
+                               esc_attr( strip_tags( $item['description'] ) ),
                                htmlentities( $item['title'] )
                        );
                }
                                htmlentities( $item['title'] )
                        );
                }