Plugin Directory


Ignore:
Timestamp:
11/10/2026 12:51:32 PM (6 days ago)
Author:
pristadigital
Message:

Release 0.55.0: flex grids, utility class families, breakpoint variants, security fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tokenforge/trunk/includes/platforms/class-bricks-theme.php

    r3784841 r3794418  
    3838
    3939        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.
    4141
    4242        /** Bricks colour fields => TokenForge colour family. */
    … …  
    388388
    389389        /**
     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        /**
    390411         * Button element: every style (colours, hover colours) and size, the shared
    391412         * typography, border and padding, all pointing at the TokenForge button variables.
    … …  
    402423                        // The TokenForge button variable first: a btn--* class on the button still decides.
    403424                        $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;
    405426                        };
    406427                        $bg                              = self::key( $prefix, 'Background' );
    … …  
    413434                        $out[ "button.$bo.color" ]       = $get( 'btn-border-color' );
    414435                        $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;
    415438                }
    416439                foreach ( self::BUTTON_TYPE as $prop => $key ) {
    … …  
    473496                        'width'  => self::sides( 'var(--btn-border-width)' ),
    474497                        'style'  => 'solid',
    475                         'color'  => array( 'raw' => $btn['btn-border-color'] ),
     498                        'color'  => array( 'raw' => self::btn_value( $btn, 'btn-border-color' ) ),
    476499                        'radius' => self::sides( 'var(--btn-border-radius)' ),
    477500                ) : null;
    … …  
    503526                                'width'  => self::sides( 'var(--btn-border-width)' ),
    504527                                'style'  => 'solid',
    505                                 'color'  => array( 'raw' => $btn['btn-border-color'] ),
     528                                'color'  => array( 'raw' => self::btn_value( $btn, 'btn-border-color' ) ),
    506529                                'radius' => self::sides( 'var(--btn-border-radius)' ),
    507530                        ) : null,
    … …  
    832855         *
    833856         * @param mixed $old Old value.
    834          * @param mixed $new New value.
     857         * @param mixed $new_value New value.
    835858         * @return void
    836859         */
    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 ) ) {
    839862                        return;
    840863                }
    841                 $id = self::style_id( $new );
     864                $id = self::style_id( $new_value );
    842865                if ( '' === $id ) {
    843866                        return;
    844867                }
    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();
    846869                $state    = self::state();
    847870                $changes  = array();
Note: See TracChangeset for help on using the changeset viewer.