<?php

$leap_top_banner = get_post_meta( leap_get_current_page_id(), 'leap_top_banner', TRUE );
if ( $leap_top_banner != 'default' ) {
	if ( $leap_top_banner != 'none' ) {
		echo '<div class="top-banner pull-right">';
		if ( $leap_top_banner == 'image' ) {
			$leap_top_banner_image	 = get_post_meta( leap_get_current_page_id(), 'leap_top_banner_image', TRUE );
			$leap_top_banner_link	 = get_post_meta( leap_get_current_page_id(), 'leap_top_banner_link', TRUE );
			$leap_top_banner_target	 = get_post_meta( leap_get_current_page_id(), 'leap_top_banner_target', TRUE );
			$target					 = '';
			if ( $leap_top_banner_target == 'on' ) {
				$target = 'target="_blank"';
			}
			if ( $leap_top_banner_link ) {
				echo '<a href="' . esc_url( $leap_top_banner_link ) . '" ' . $target . '>';
			}

			if ( $leap_top_banner_image ) {
				echo '<img alt="" src="' . esc_url( $leap_top_banner_image ) . '" />';
			}

			if ( $leap_top_banner_link ) {
				echo '</a>';
			}
		}

		if ( $leap_top_banner == 'code' ) {
			echo get_post_meta( leap_get_current_page_id(), 'leap_top_banner_code', TRUE );
		}

		echo '</div>';
	}
} else {
	// Above post banner
	$top_banner = ot_get_option( 'top_banner', 'none' );
	if ( $top_banner != 'none' ) {
		echo '<div class="top-banner pull-right">';
		if ( $top_banner == 'image' ) {
			$top_banner_image	 = ot_get_option( 'top_banner_image', '' );
			$top_banner_link	 = ot_get_option( 'top_banner_link', '' );
			$top_banner_target	 = ot_get_option( 'top_banner_target', 'on' );
			$target				 = '';
			if ( $top_banner_target == 'on' ) {
				$target = 'target="_blank"';
			}
			if ( $top_banner_link ) {
				echo '<a href="' . esc_url( $top_banner_link ) . '" ' . $target . '>';
			}

			if ( $top_banner_image ) {
				echo '<img alt="" src="' . esc_url( $top_banner_image ) . '" />';
			}

			if ( $top_banner_link ) {
				echo '</a>';
			}
		}

		if ( $top_banner == 'code' ) {
			echo ot_get_option( 'top_banner_code', '' );
		}

		echo '</div>';
	}
}
