| @@ -220,8 +220,32 @@ | ||
| 220 | 220 | return is_string( $filtered ) && '' !== trim( $filtered ) ? $filtered : $title; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
| 224 | + * Decode a rendered title into the plain text the desktop paints with. | |
| 225 | + * | |
| 226 | + * `wptexturize()` encodes the characters titles are full of — `&` as | |
| 227 | + * `&`, an apostrophe as `’` — and the shell writes titles | |
| 228 | + * into text nodes, where the entity renders as itself. Same reasoning | |
| 229 | + * as {@see openstation_site_title()}, one layer down. | |
| 230 | + * | |
| 231 | + * Decode BEFORE the tag strip, never after: `<script>` decodes | |
| 232 | + * into a real tag, and stripping second is what removes it. | |
| 233 | + * | |
| 234 | + * @param string $rendered A title that has been through a display filter. | |
| 235 | + * @return string Plain text, tag-free. | |
| 236 | + */ | |
| 237 | +function openstation_plain_text_title( $rendered ) { | |
| 238 | + $decoded = html_entity_decode( | |
| 239 | + (string) $rendered, | |
| 240 | + ENT_QUOTES, | |
| 241 | + get_bloginfo( 'charset' ) | |
| 242 | + ); | |
| 243 | + | |
| 244 | + return trim( wp_strip_all_tags( $decoded ) ); | |
| 245 | +} | |
| 246 | + | |
| 247 | +/** | |
| 224 | 248 | * Build a `WP_Error` for a openstation registration failure. |
| 225 | 249 | * |
| 226 | 250 | * Centralises the error-code vocabulary used by every |
| 227 | 251 | * `openstation_register_*()` function so plugin authors see a |