- Timestamp:
- 11/10/2026 12:51:32 PM (6 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tokenforge/trunk/includes/platforms/class-bricks-theme.php
r3784841 r3794418 38 38 39 39 const OPTION = 'bricks_theme_styles'; 40 const STATE = 'tokenforge_theme_sync'; // { style, pushed: { path => value }, prev: { path => value } }40 const STATE = 'tokenforge_theme_sync'; // Holds the style, the values pushed and the previous values, each keyed by path. 41 41 42 42 /** Bricks colour fields => TokenForge colour family. */ … … 388 388 389 389 /** 390 * A button variable's value from a button map, where a value that names 391 * another button variable (the border colour is var(--btn-background)) also 392 * carries that variable's value as its fallback: a button without a btn--* 393 * class defines none of them, and an undefined variable voids the whole 394 * border declaration (no border at all, outline buttons included). 395 * 396 * @param array $map Button map (Components::btn_var_map()). 397 * @param string $k Variable name without the dashes. 398 * @return string 399 */ 400 public static function btn_value( $map, $k ) { 401 return preg_replace_callback( 402 '/var\(--(btn-[a-z-]+)\)/', 403 function ( $m ) use ( $map ) { 404 return isset( $map[ $m[1] ] ) ? 'var(--' . $m[1] . ', ' . $map[ $m[1] ] . ')' : $m[0]; 405 }, 406 (string) $map[ $k ] 407 ); 408 } 409 410 /** 390 411 * Button element: every style (colours, hover colours) and size, the shared 391 412 * typography, border and padding, all pointing at the TokenForge button variables. … … 402 423 // The TokenForge button variable first: a btn--* class on the button still decides. 403 424 $get = function ( $k ) use ( $map ) { 404 return isset( $map[ $k ] ) ? array( 'raw' => 'var(--' . $k . ', ' . $map[ $k ]. ')' ) : null;425 return isset( $map[ $k ] ) ? array( 'raw' => 'var(--' . $k . ', ' . self::btn_value( $map, $k ) . ')' ) : null; 405 426 }; 406 427 $bg = self::key( $prefix, 'Background' ); … … 413 434 $out[ "button.$bo.color" ] = $get( 'btn-border-color' ); 414 435 $out[ "button.$bo:hover.color" ] = $get( 'btn-border-color-hover' ); 436 // Outline styles carry their own border width (the shared width below is the solid one). 437 $out[ "button.$bo.width" ] = isset( $map['btn-border-width'] ) ? self::sides( $map['btn-border-width'] ) : null; 415 438 } 416 439 foreach ( self::BUTTON_TYPE as $prop => $key ) { … … 473 496 'width' => self::sides( 'var(--btn-border-width)' ), 474 497 'style' => 'solid', 475 'color' => array( 'raw' => $btn['btn-border-color']),498 'color' => array( 'raw' => self::btn_value( $btn, 'btn-border-color' ) ), 476 499 'radius' => self::sides( 'var(--btn-border-radius)' ), 477 500 ) : null; … … 503 526 'width' => self::sides( 'var(--btn-border-width)' ), 504 527 'style' => 'solid', 505 'color' => array( 'raw' => $btn['btn-border-color']),528 'color' => array( 'raw' => self::btn_value( $btn, 'btn-border-color' ) ), 506 529 'radius' => self::sides( 'var(--btn-border-radius)' ), 507 530 ) : null, … … 832 855 * 833 856 * @param mixed $old Old value. 834 * @param mixed $new New value.857 * @param mixed $new_value New value. 835 858 * @return void 836 859 */ 837 public static function on_saved( $old, $new ) {838 if ( self::$busy || ! self::enabled() || ! is_array( $new ) ) {860 public static function on_saved( $old, $new_value ) { 861 if ( self::$busy || ! self::enabled() || ! is_array( $new_value ) ) { 839 862 return; 840 863 } 841 $id = self::style_id( $new );864 $id = self::style_id( $new_value ); 842 865 if ( '' === $id ) { 843 866 return; 844 867 } 845 $settings = isset( $new [ $id ]['settings'] ) && is_array( $new[ $id ]['settings'] ) ? $new[ $id ]['settings'] : array();868 $settings = isset( $new_value[ $id ]['settings'] ) && is_array( $new_value[ $id ]['settings'] ) ? $new_value[ $id ]['settings'] : array(); 846 869 $state = self::state(); 847 870 $changes = array();
Note:
See TracChangeset
for help on using the changeset viewer.