<?php

$bg_type = carbon_get_post_meta(  $post_id, 'qp_popup_bg_type' );

if ( $bg_type === 'regular' ) {
	$bg_color = carbon_get_post_meta(  $post_id, 'qp_popup_bg' );
	$bg_color = ! empty( $bg_color ) ? $bg_color : '#fff';

	$bg_style = sprintf( 'background-color: %s;', $bg_color );
} else {
	$color_1 = carbon_get_post_meta( $post_id, 'qp_popup_gradient_color_1' );
	$color_1 = ! empty( $color_1 ) ? $color_1 : '#fff';

	$color_2 = carbon_get_post_meta( $post_id, 'qp_popup_gradient_color_2' );
	$color_2 = ! empty( $color_2 ) ? $color_2 : '#fff';

	$direction = carbon_get_post_meta( $post_id, 'qp_popup_gradient_direction' );

	$bg_style = sprintf( 'background-image: linear-gradient(%s, %s, %s);', str_replace( '_', ' ', $direction ), $color_1, $color_2 );
}