astra_get_background_obj( array $bg_obj )
Adjust Brightness
Description
Parameters
- $bg_obj
-
(array) (Required) Color code in HEX.
Return
(array) Color code in HEX.
Source
File: classes/astra-common-functions.php
function astra_get_background_obj( $bg_obj ) { $gen_bg_css = array(); $bg_img = isset( $bg_obj['background-image'] ) ? $bg_obj['background-image'] : ''; $bg_color = isset( $bg_obj['background-color'] ) ? $bg_obj['background-color'] : ''; $bg_type = isset( $bg_obj['background-type'] ) ? $bg_obj['background-type'] : ''; if ( '' !== $bg_type ) { switch ( $bg_type ) { case 'color': if ( '' !== $bg_img && '' !== $bg_color ) { $gen_bg_css['background-image'] = 'linear-gradient(to right, ' . $bg_color . ', ' . $bg_color . '), url(' . $bg_img . ');'; } elseif ( '' === $bg_img ) { $gen_bg_css['background-color'] = $bg_color . ';'; } break; case 'image': if ( '' !== $bg_img && '' !== $bg_color && ( ! is_numeric( strpos( $bg_color, 'linear-gradient' ) ) && ! is_numeric( strpos( $bg_color, 'radial-gradient' ) ) ) ) { $gen_bg_css['background-image'] = 'linear-gradient(to right, ' . $bg_color . ', ' . $bg_color . '), url(' . $bg_img . ');'; } if ( '' === $bg_color || is_numeric( strpos( $bg_color, 'linear-gradient' ) ) || is_numeric( strpos( $bg_color, 'radial-gradient' ) ) && '' !== $bg_img ) { $gen_bg_css['background-image'] = 'url(' . $bg_img . ');'; } break; case 'gradient': if ( isset( $bg_color ) ) { $gen_bg_css['background-image'] = $bg_color . ';'; } break; default: break; } } elseif ( '' !== $bg_color ) { $gen_bg_css['background-color'] = $bg_color . ';'; } if ( '' !== $bg_img ) { if ( isset( $bg_obj['background-repeat'] ) ) { $gen_bg_css['background-repeat'] = esc_attr( $bg_obj['background-repeat'] ); } if ( isset( $bg_obj['background-position'] ) ) { $gen_bg_css['background-position'] = esc_attr( $bg_obj['background-position'] ); } if ( isset( $bg_obj['background-size'] ) ) { $gen_bg_css['background-size'] = esc_attr( $bg_obj['background-size'] ); } if ( isset( $bg_obj['background-attachment'] ) ) { $gen_bg_css['background-attachment'] = esc_attr( $bg_obj['background-attachment'] ); } } return $gen_bg_css; }
Expand full source code Collapse full source code View on Trac