~canonical-sysadmins/wordpress/5.1

« back to all changes in this revision

Viewing changes to wp-includes/class-wp-feed-cache-transient.php

  • Committer: Barry Price
  • Date: 2019-02-22 03:51:26 UTC
  • mfrom: (1.2.12 upstream)
  • Revision ID: barry.price@canonical.com-20190222035126-o28k38qs8jfyjsxt
Merge WP5.1 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
         * @param string $filename  Unique identifier for cache object.
51
51
         * @param string $extension 'spi' or 'spc'.
52
52
         */
53
 
        public function __construct($location, $filename, $extension) {
54
 
                $this->name = 'feed_' . $filename;
 
53
        public function __construct( $location, $filename, $extension ) {
 
54
                $this->name     = 'feed_' . $filename;
55
55
                $this->mod_name = 'feed_mod_' . $filename;
56
56
 
57
57
                $lifetime = $this->lifetime;
63
63
                 * @param int    $lifetime Cache duration in seconds. Default is 43200 seconds (12 hours).
64
64
                 * @param string $filename Unique identifier for the cache object.
65
65
                 */
66
 
                $this->lifetime = apply_filters( 'wp_feed_cache_transient_lifetime', $lifetime, $filename);
 
66
                $this->lifetime = apply_filters( 'wp_feed_cache_transient_lifetime', $lifetime, $filename );
67
67
        }
68
68
 
69
69
        /**
74
74
         * @param SimplePie $data Data to save.
75
75
         * @return true Always true.
76
76
         */
77
 
        public function save($data) {
 
77
        public function save( $data ) {
78
78
                if ( $data instanceof SimplePie ) {
79
79
                        $data = $data->data;
80
80
                }
81
81
 
82
 
                set_transient($this->name, $data, $this->lifetime);
83
 
                set_transient($this->mod_name, time(), $this->lifetime);
 
82
                set_transient( $this->name, $data, $this->lifetime );
 
83
                set_transient( $this->mod_name, time(), $this->lifetime );
84
84
                return true;
85
85
        }
86
86
 
92
92
         * @return mixed Transient value.
93
93
         */
94
94
        public function load() {
95
 
                return get_transient($this->name);
 
95
                return get_transient( $this->name );
96
96
        }
97
97
 
98
98
        /**
103
103
         * @return mixed Transient value.
104
104
         */
105
105
        public function mtime() {
106
 
                return get_transient($this->mod_name);
 
106
                return get_transient( $this->mod_name );
107
107
        }
108
108
 
109
109
        /**
114
114
         * @return bool False if value was not set and true if value was set.
115
115
         */
116
116
        public function touch() {
117
 
                return set_transient($this->mod_name, time(), $this->lifetime);
 
117
                return set_transient( $this->mod_name, time(), $this->lifetime );
118
118
        }
119
119
 
120
120
        /**
125
125
         * @return true Always true.
126
126
         */
127
127
        public function unlink() {
128
 
                delete_transient($this->name);
129
 
                delete_transient($this->mod_name);
 
128
                delete_transient( $this->name );
 
129
                delete_transient( $this->mod_name );
130
130
                return true;
131
131
        }
132
132
}