array( 'normal', 'hover' ), * 'background' => array( 'normal', 'hover' ), * 'border_radius', * 'padding' *) */ public static function get_default_settings() { return array( 'background_color' => array( 'normal' => '#ffffff', 'hover' => '#ffffff', ), 'text_color' => array( 'normal' => 'var(--wp--preset--color--brandy-primary-text)', 'hover' => 'var(--wp--preset--color--brandy-primary-text)', ), 'typography' => TypographyService::get_default_typography_value(), 'border' => array( 'width' => array( 'unit' => 'px', 'value' => 1, 'min' => 0, 'max' => 5, ), 'color' => array( 'normal' => '#ACB6BF', 'hover' => '#7B8A99', 'focus' => '#272829', ), 'radius' => array( 'unit' => 'px', 'value' => 9, 'min' => 0, 'max' => 100, ), ), 'padding' => array( 'unit' => 'px', 'top' => 14, 'right' => 26, 'bottom' => 14, 'left' => 14, 'is_constraints' => false, ), ); } /** * Print out global css */ public static function print_css() { $settings = self::get_settings(); $css = ' select:not(.components-select-control__input, .attachment-filters), .select2-selection{ display: inline-flex; width: fit-content; background-color: ' . $settings['background_color']['normal'] . '; color: ' . $settings['text_color']['normal'] . '; padding: ' . StylesDataHelpers::get_spacing_css( $settings['padding'] ) . '; border-width: ' . StylesDataHelpers::get_dimension_css( $settings['border']['width'] ) . '; border-color: ' . $settings['border']['color']['normal'] . '; border-style: solid; border-radius: ' . StylesDataHelpers::get_dimension_css( $settings['border']['radius'] ) . '; outline-width: ' . StylesDataHelpers::get_dimension_css( $settings['border']['width'] ) . '; outline-color: transparent; outline-style: solid; box-shadow: none; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg width=\'21\' height=\'13\' xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath d=\'M18.5.379L20.621 2.5 10.5 12.621.379 2.5 2.5.379l8 8z\' fill=\'%234F5D6D\' fill-rule=\'nonzero\'/%3E%3C/svg%3E"); background-repeat: no-repeat, repeat; background-size: 8px auto, 100%; background-position: right 10px top 50%, 0 0; min-height: 44px; cursor: pointer; transition-property: outline, border; transition-duration: var(--theme-input-transition-duration); transition-timing-function: ease-in-out; transition-delay: 0s; } select:not(.components-select-control__input, .attachment-filters):hover, .select2-selection:hover{ border-color: ' . $settings['border']['color']['hover'] . '; color: ' . $settings['text_color']['hover'] . '; background-color: ' . $settings['background_color']['hover'] . '; } select:not(.components-select-control__input, .attachment-filters):focus, .select2-selection:focus{ outline-color: ' . $settings['border']['color']['focus'] . '; border-color: transparent; outline-width: calc(var(--select-border-width) + 1px); color: ' . ($settings['text_color']['focus'] ?? $settings['text_color']['normal']) . '; background-color: ' . ($settings['background_color']['focus'] ?? $settings['background_color']['normal']) . '; } select:not(.components-select-control__input, .attachment-filters)::placeholder, .select2-selection::placeholder{ color: ' . $settings['text_color']['normal'] . '; opacity: 0.5; } select:not(.components-select-control__input, .attachment-filters):-ms-input-placeholder, .select2-selection:-ms-input-placeholder{ color: ' . $settings['text_color']['normal'] . '; } '; $variables = StylesDataHelpers::get_typography_css_variables( $settings['typography'], 'select:not(.components-select-control__input, .attachment-filters), .select2-selection' ); foreach ( $variables as $device => $device_variables ) { $child_css = ''; foreach ( $device_variables as $selector => $value ) { $child_css .= $selector . '{' . implode( ';', $value ) . '}'; } if ( 'tablet' === $device ) { $child_css = DynamicCss::wrap_tablet_responsive( $child_css ); } if ( 'mobile' === $device ) { $child_css = DynamicCss::wrap_mobile_responsive( $child_css ); } $css .= $child_css; } echo wp_kses_post( $css ); } /** * Returns settings * * @return array * @example Returns object with these value * array( * 'color' => array( 'normal', 'hover' ), * 'background_color' => array( 'normal', 'hover' ), * 'border_radius', * 'padding' *) */ public static function get_settings() { $default_settings = self::get_default_settings(); $select_settings = get_theme_mod( self::get_option_key(), $default_settings ); $select_settings = Helpers::recursive_wp_parse_args( $select_settings, $default_settings ); foreach ( array_keys( $select_settings ) as $key ) { if ( ! key_exists( $key, $default_settings ) ) { unset( $select_settings[ $key ] ); } } return $select_settings; } public static function save_settings( $data ) { $default_settings = self::get_default_settings(); $select_settings = Helpers::recursive_wp_parse_args( $data, $default_settings ); foreach ( array_keys( $select_settings ) as $key ) { if ( ! key_exists( $key, $default_settings ) ) { unset( $select_settings[ $key ] ); } } set_theme_mod( self::get_option_key(), $select_settings ); } }