← All changes
|
includes/abilities/media/class-image-alt-ability-base.php
+42
-0
2.7.0
→
2.12.0
View file →
| @@ -131,8 +131,50 @@ | ||
| 131 | 131 | ]; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | + * The shape a cache-purge outcome is reported in. | |
| 136 | + * | |
| 137 | + * An alt-text write lands in post meta, but what a visitor reads is HTML | |
| 138 | + * something else rendered and stored. Reporting only the write let an agent | |
| 139 | + * tell a user the image was fixed while the page still showed the old words | |
| 140 | + * (#763), so the outcome of clearing those caches travels with the result. | |
| 141 | + * | |
| 142 | + * @return array<string, mixed> | |
| 143 | + */ | |
| 144 | + protected function cache_property(): array { | |
| 145 | + return [ | |
| 146 | + 'type' => 'object', | |
| 147 | + 'description' => __( 'What was cleared so the new alt text is visible, and what the user still has to clear by hand.', 'thinkrank' ), | |
| 148 | + 'properties' => [ | |
| 149 | + 'posts_purged' => [ | |
| 150 | + 'type' => 'integer', | |
| 151 | + 'description' => __( 'Pages whose cached rendering of this image was dropped.', 'thinkrank' ), | |
| 152 | + ], | |
| 153 | + 'warnings' => [ | |
| 154 | + 'type' => 'array', | |
| 155 | + 'items' => [ 'type' => 'string' ], | |
| 156 | + 'description' => __( 'Caching layers that are active but cannot be cleared from here. Pass these on: the page keeps serving the old alt text until the user clears them.', 'thinkrank' ), | |
| 157 | + ], | |
| 158 | + ], | |
| 159 | + ]; | |
| 160 | + } | |
| 161 | + | |
| 162 | + /** | |
| 163 | + * The cache outcome of the write that just happened. | |
| 164 | + * | |
| 165 | + * @return array{posts_purged: int, warnings: string[]} | |
| 166 | + */ | |
| 167 | + protected function cache_outcome(): array { | |
| 168 | + $purge = $this->manager()->last_alt_cache_purge(); | |
| 169 | + | |
| 170 | + return [ | |
| 171 | + 'posts_purged' => count( $purge['posts'] ), | |
| 172 | + 'warnings' => $purge['warnings'], | |
| 173 | + ]; | |
| 174 | + } | |
| 175 | + | |
| 176 | + /** | |
| 135 | 177 | * Post statuses an image can carry. |
| 136 | 178 | * |
| 137 | 179 | * Mirrors Image_SEO_Manager's own list: 'inherit' alone misses the private |
| 138 | 180 | * attachments media-protection and membership plugins create, which is the |