1 | <?php |
||
21 | class Jetpack_Sitemap_Librarian { |
||
22 | |||
23 | /** |
||
24 | * Retrieve a single sitemap with given name and type. |
||
25 | * Returns null if no such sitemap exists. |
||
26 | * |
||
27 | * @access public |
||
28 | * @since 4.7.0 |
||
29 | * |
||
30 | * @param string $name Name of the sitemap to be retrieved. |
||
31 | * @param string $type Type of the sitemap to be retrieved. |
||
32 | * |
||
33 | * @return array $args { |
||
34 | * @type int $id ID number of the sitemap in the database. |
||
35 | * @type string $timestamp Most recent timestamp of the resources pointed to. |
||
36 | * @type string $name Name of the sitemap in the database. |
||
37 | * @type string $type Type of the sitemap in the database. |
||
38 | * @type string $text The content of the sitemap. |
||
39 | * } |
||
40 | */ |
||
41 | public function read_sitemap_data( $name, $type ) { |
||
56 | |||
57 | /** |
||
58 | * Store a sitemap of given type and index in the database. |
||
59 | * Note that the sitemap contents are run through esc_html before |
||
60 | * being stored, and the timestamp reencoded as 'Y-m-d H:i:s'. |
||
61 | * |
||
62 | * If a sitemap with that type and name does not exist, create it. |
||
63 | * If a sitemap with that type and name does exist, update it. |
||
64 | * |
||
65 | * @access public |
||
66 | * @since 4.7.0 |
||
67 | * |
||
68 | * @param string $index Index of the sitemap to be stored. |
||
69 | * @param string $type Type of the sitemap to be stored. |
||
70 | * @param string $contents Contents of the sitemap to be stored. |
||
71 | * @param string $timestamp Timestamp of the sitemap to be stored, in 'YYYY-MM-DD hh:mm:ss' format. |
||
72 | */ |
||
73 | public function store_sitemap_data( $index, $type, $contents, $timestamp ) { |
||
98 | |||
99 | /** |
||
100 | * Delete a sitemap by name and type. |
||
101 | * |
||
102 | * @access public |
||
103 | * @since 4.7.0 |
||
104 | * |
||
105 | * @param string $name Row name. |
||
106 | * @param string $type Row type. |
||
107 | * |
||
108 | * @return bool 'true' if a row was deleted, 'false' otherwise. |
||
109 | */ |
||
110 | public function delete_sitemap_data( $name, $type ) { |
||
120 | |||
121 | /** |
||
122 | * Retrieve the contents of a sitemap with given name and type. |
||
123 | * If no such sitemap exists, return the empty string. Note that the |
||
124 | * returned string is run through wp_specialchars_decode. |
||
125 | * |
||
126 | * @access public |
||
127 | * @since 4.7.0 |
||
128 | * |
||
129 | * @param string $name Row name. |
||
130 | * @param string $type Row type. |
||
131 | * |
||
132 | * @return string Text of the specified sitemap, or the empty string. |
||
133 | */ |
||
134 | public function get_sitemap_text( $name, $type ) { |
||
143 | |||
144 | /** |
||
145 | * Delete numbered sitemaps named prefix-(p+1), prefix-(p+2), ... |
||
146 | * until the first nonexistent sitemap is found. |
||
147 | * |
||
148 | * @access public |
||
149 | * @since 4.7.0 |
||
150 | * |
||
151 | * @param int $position Number before the first sitemap to be deleted. |
||
152 | * @param string $type Sitemap type. |
||
153 | */ |
||
154 | public function delete_numbered_sitemap_rows_after( $position, $type ) { |
||
165 | |||
166 | /** |
||
167 | * Deletes all stored sitemap data. |
||
168 | * |
||
169 | * @access public |
||
170 | * @since 4.7.0 |
||
171 | */ |
||
172 | public function delete_all_stored_sitemap_data() { |
||
203 | |||
204 | /** |
||
205 | * Retrieve an array of sitemap rows (of a given type) sorted by ID. |
||
206 | * |
||
207 | * Returns the smallest $num_posts sitemap rows (measured by ID) |
||
208 | * of the given type which are larger than $from_id. |
||
209 | * |
||
210 | * @access public |
||
211 | * @since 4.7.0 |
||
212 | * |
||
213 | * @param string $type Type of the sitemap rows to retrieve. |
||
214 | * @param int $from_id Greatest lower bound of retrieved sitemap post IDs. |
||
215 | * @param int $num_posts Largest number of sitemap posts to retrieve. |
||
216 | * |
||
217 | * @return array The sitemaps, as an array of associative arrays. |
||
218 | */ |
||
219 | public function query_sitemaps_after_id( $type, $from_id, $num_posts ) { |
||
237 | |||
238 | /** |
||
239 | * Retrieve an array of posts sorted by ID. |
||
240 | * |
||
241 | * More precisely, returns the smallest $num_posts posts |
||
242 | * (measured by ID) which are larger than $from_id. |
||
243 | * |
||
244 | * @access public |
||
245 | * @since 4.7.0 |
||
246 | * |
||
247 | * @param int $from_id Greatest lower bound of retrieved post IDs. |
||
248 | * @param int $num_posts Largest number of posts to retrieve. |
||
249 | * |
||
250 | * @return array The posts. |
||
251 | */ |
||
252 | public function query_posts_after_id( $from_id, $num_posts ) { |
||
279 | |||
280 | /** |
||
281 | * Get the most recent timestamp among approved comments for the given post_id. |
||
282 | * |
||
283 | * @access public |
||
284 | * @since 4.7.0 |
||
285 | * |
||
286 | * @param int $post_id Post identifier. |
||
287 | * |
||
288 | * @return int Timestamp in 'Y-m-d h:i:s' format (UTC) of the most recent comment on the given post, or null if no such comments exist. |
||
289 | */ |
||
290 | public function query_latest_approved_comment_time_on_post( $post_id ) { |
||
302 | |||
303 | /** |
||
304 | * Retrieve an array of image posts sorted by ID. |
||
305 | * |
||
306 | * More precisely, returns the smallest $num_posts image posts |
||
307 | * (measured by ID) which are larger than $from_id. |
||
308 | * |
||
309 | * @access public |
||
310 | * @since 4.7.0 |
||
311 | * |
||
312 | * @param int $from_id Greatest lower bound of retrieved image post IDs. |
||
313 | * @param int $num_posts Largest number of image posts to retrieve. |
||
314 | * |
||
315 | * @return array The posts. |
||
316 | */ |
||
317 | public function query_images_after_id( $from_id, $num_posts ) { |
||
334 | |||
335 | /** |
||
336 | * Retrieve an array of video posts sorted by ID. |
||
337 | * |
||
338 | * More precisely, returns the smallest $num_posts video posts |
||
339 | * (measured by ID) which are larger than $from_id. |
||
340 | * |
||
341 | * @access public |
||
342 | * @since 4.7.0 |
||
343 | * |
||
344 | * @param int $from_id Greatest lower bound of retrieved video post IDs. |
||
345 | * @param int $num_posts Largest number of video posts to retrieve. |
||
346 | * |
||
347 | * @return array The posts. |
||
348 | */ |
||
349 | public function query_videos_after_id( $from_id, $num_posts ) { |
||
366 | |||
367 | /** |
||
368 | * Retrieve an array of published posts from the last 2 days. |
||
369 | * |
||
370 | * @access public |
||
371 | * @since 4.7.0 |
||
372 | * |
||
373 | * @param int $num_posts Largest number of posts to retrieve. |
||
374 | * |
||
375 | * @return array The posts. |
||
376 | */ |
||
377 | public function query_most_recent_posts( $num_posts ) { |
||
416 | |||
417 | } |
||
418 |
This check looks for function calls that miss required arguments.