Changeset 3749853 for translate/trunk/Components/SwitcherPlacement.php
- Timestamp:
- 10/16/2026 07:26:04 AM (3 weeks ago)
- File:
-
- 1 edited
-
translate/trunk/Components/SwitcherPlacement.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
translate/trunk/Components/SwitcherPlacement.php
r3717606 r3749853 4 4 5 5 /** 6 * Where the switcher sits inside the document when it is placed inline: a 7 * suggested zone, or an unrestricted anchor (a CSS path plus a position 8 * relative to it). Stored as a reproducible description, never as viewport 9 * coordinates, so it survives across page loads. A page placement wins over 10 * the site-wide one while it exists. 6 * Where the switcher sits inside the document when it is placed inline: an 7 * anchor, a CSS path plus the side of that element the switcher sits on. 8 * Stored as a reproducible description, never as viewport coordinates, so it 9 * survives across page loads. A page placement wins over the site-wide one 10 * while it exists. Zones and the prepend and append positions are read for 11 * placements stored by earlier versions. 11 12 */ 12 13 class SwitcherPlacement { … … 16 17 public const ZONES = [ 'header', 'before_content', 'after_content', 'sidebar', 'footer' ]; 17 18 18 public const ANCHOR_POSITIONS = [ 'before', 'after', 'prepend', 'append' ]; 19 public const ANCHOR_POSITIONS = [ 'before', 'after', 'left', 'right', 'prepend', 'append' ]; 20 21 public const ANCHOR_FALLBACKS = [ 'floating', 'none' ]; 22 23 public const ANCHOR_FALLBACK_KEY = 'anchor_fallback'; 19 24 20 25 private const MAX_SELECTOR_LENGTH = 1024; … … 74 79 } 75 80 81 /** What a page shows when the stored anchor matches none of its elements. */ 82 public static function anchor_fallback(): string { 83 $switcher = Options::get( 'languages.switcher', [] ); 84 $value = is_array( $switcher ) ? sanitize_key( (string) ( $switcher[ self::ANCHOR_FALLBACK_KEY ] ?? '' ) ) : ''; 85 86 return in_array( $value, self::ANCHOR_FALLBACKS, true ) ? $value : 'floating'; 87 } 88 89 public static function save_anchor_fallback( string $value ): void { 90 $value = sanitize_key( $value ); 91 if ( ! in_array( $value, self::ANCHOR_FALLBACKS, true ) ) { 92 return; 93 } 94 $switcher = Options::get( 'languages.switcher', [] ); 95 $switcher = is_array( $switcher ) ? $switcher : []; 96 $switcher[ self::ANCHOR_FALLBACK_KEY ] = $value; 97 Options::update( 'languages.switcher', $switcher ); 98 } 99 76 100 public static function page_placement( int $post_id ): ?array { 77 101 if ( $post_id <= 0 ) {
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)