$data ) { $result[ $id ] = ct_get_color( $data ); } return $result; } return false; } /** * Extract color from a descriptor. * id: * - fw-custom * - fw-no-color * - color_skin_* * - fw-inherit:location * - fw-inherit:location:hover * - fw-inherit:location:default * * @param array $color_descriptor Single color descriptor. */ function ct_get_color( $color_descriptor ) { if ( ! isset( $color_descriptor['color'] ) ) { return null; } return $color_descriptor['color']; } function ct_expand_responsive_value( $value ) { if ( is_array( $value ) && isset( $value['desktop'] ) ) { return $value; } return [ 'desktop' => $value, 'tablet' => $value, 'mobile' => $value, ]; } function ct_output_responsive_variable( $css, $selector, $variableName, $value ) { $value = ct_expand_responsive_value( $value ); $css->put( $selector, '--' . $variableName . '-sm: ' . $value['mobile'] . 'px' ); $css->put( $selector, '--' . $variableName . '-md: ' . $value['tablet'] . 'px' ); $css->put( $selector, '--' . $variableName . '-lg: ' . $value['desktop'] . 'px' ); } function ct_output_responsive( $css, $tablet_css, $mobile_css, $selector, $variableName, $value, $unit = 'px' ) { $value = ct_expand_responsive_value( $value ); $mobile_css->put( $selector, '--' . $variableName . ': ' . $value['mobile'] . $unit ); $tablet_css->put( $selector, '--' . $variableName . ': ' . $value['tablet'] . $unit ); $css->put( $selector, '--' . $variableName . ': ' . $value['desktop'] . $unit ); } function ct_units_config( $overrides = [] ) { $units = [ [ 'unit' => 'px', 'min' => 0, 'max' => 40, ], [ 'unit' => 'em', 'min' => 0, 'max' => 30, ], [ 'unit' => '%', 'min' => 0, 'max' => 100, ], [ 'unit' => 'vw', 'min' => 0, 'max' => 100, ], [ 'unit' => 'vh', 'min' => 0, 'max' => 100, ], [ 'unit' => 'pt', 'min' => 0, 'max' => 100, ], [ 'unit' => 'rem', 'min' => 0, 'max' => 30, ], ]; foreach ( $overrides as $single_override ) { foreach ( $units as $key => $single_unit ) { if ( $single_override['unit'] === $single_unit['unit'] ) { $units[ $key ] = $single_override; } } } return $units; }