Overlays refresh themselves after updates; media URLs versioned; frameless (transparent) alerts
- Overlay\Build id (plugin version + admin epoch) in X-SG-Build; overlay.js reloads once on mismatch (loop-guarded); 'Refresh all overlays now' - Media URLs carry ?v=<mtime> - Alert option 'Frameless' (schema v5): no box so transparent PNG/GIF/WebP and VP9-alpha WebM show through; admin preview with checkerboard and ffmpeg help Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9249b80cb6
commit
afa768fa42
21 files changed
+287
-16
No files matched your search
@@ -66,6 +66,24 @@ final class Media {
|
||||
return is_numeric( $v ) ? max( 0, min( 100, (int) $v ) ) : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends ?v=<timestamp> so a replaced file with the same name is fetched again. The timestamp comes from the
|
||||
* server (file mtime, else the attachment's post_modified_gmt), never from input. Unknown time = URL unchanged.
|
||||
*/
|
||||
public static function withVersion( string $url, int $fileMtime, ?string $postModifiedGmt = null ): string {
|
||||
$v = $fileMtime;
|
||||
if ( $v <= 0 && null !== $postModifiedGmt && preg_match( '/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $postModifiedGmt ) ) {
|
||||
$t = strtotime( $postModifiedGmt . ' UTC' );
|
||||
$v = false === $t ? 0 : $t;
|
||||
}
|
||||
if ( $v <= 0 || str_contains( $url, '#' ) ) {
|
||||
return $url;
|
||||
}
|
||||
$base = preg_replace( '/([?&])v=[^&]*(&|$)/', '$1', $url ) ?? $url;
|
||||
$base = rtrim( $base, '?&' );
|
||||
return $base . ( str_contains( $base, '?' ) ? '&' : '?' ) . 'v=' . $v;
|
||||
}
|
||||
|
||||
/** Only plain http(s) URLs are ever handed to the overlay. */
|
||||
public static function safeUrl( mixed $url ): ?string {
|
||||
if ( ! is_string( $url ) || '' === $url || strlen( $url ) > 2000 || preg_match( '/[\x00-\x20\x7F"\'<>\\\\]/', $url ) ) {
|
||||
|
||||
Reference in new issue
Block a user