Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
CRAP
n/a
0 / 0
wpcom_set_blog_transient
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
wpcom_get_blog_transient
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
wpcom_delete_blog_transient
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * Blog-scoped transient helpers.
4 *
5 * Thin wrappers around WordPress transient functions that make
6 * per-blog storage intent explicit. On Simple sites (multisite),
7 * set_transient() already stores per-blog in each blog's wp_options
8 * table. On Atomic (single-site), there is only one blog.
9 *
10 * These wrappers add no runtime logic — they exist to make the
11 * intent self-documenting for developers and AI agents.
12 *
13 * @package automattic/jetpack-mu-wpcom
14 */
15
16/**
17 * Set a blog-scoped transient.
18 *
19 * Stores data that is specific to the current blog. On multisite
20 * (Simple), this is isolated per blog automatically. On single-site
21 * (Atomic), there is only one blog.
22 *
23 * @param string $key        Transient name. Must be 172 characters or fewer.
24 * @param mixed  $value      Transient value.
25 * @param int    $expiration Time until expiration in seconds. Default 0 (no expiration).
26 * @return bool True if the value was set, false otherwise.
27 */
28function wpcom_set_blog_transient( $key, $value, $expiration = 0 ) {
29    return set_transient( $key, $value, $expiration );
30}
31
32/**
33 * Get a blog-scoped transient.
34 *
35 * @param string $key Transient name.
36 * @return mixed Transient value or false if not set / expired.
37 */
38function wpcom_get_blog_transient( $key ) {
39    return get_transient( $key );
40}
41
42/**
43 * Delete a blog-scoped transient.
44 *
45 * @param string $key Transient name.
46 * @return bool True if the transient was deleted, false otherwise.
47 */
48function wpcom_delete_blog_transient( $key ) {
49    return delete_transient( $key );
50}