$_placement ){
if ( isset($_placement['type']) && 'background' == $_placement['type'] ){
// display the placement content with placement options
$_options = isset( $_placement['options'] ) ? $_placement['options'] : array();
echo Advanced_Ads_Select::get_instance()->get_ad_by_method( $_placement_id, 'placement', $_options );
}
}
}
}
/**
* Change ad output.
*
* @param string $output Ad output.
* @param Advanced_Ads_Ad $ad Ad object.
* @param array $output_options Output options.
* @return string
*/
public function ad_output( $output, $ad, $output_options ) {
if ( ! isset( $ad->args['placement_type'] ) || 'background' !== $ad->args['placement_type'] ) {
return $output;
}
if( !isset( $ad->type ) || 'image' !== $ad->type ){
return $output;
}
// get background color
$bg_color = isset( $ad->args['bg_color'] ) ? sanitize_text_field( $ad->args['bg_color'] ) : false;
// get tracking plugin
$click_tracking_active = false;
$plugin_active = class_exists( 'Advanced_Ads_Tracking_Plugin', false );
if ( $plugin_active ) {
$click_tracking_active = Advanced_Ads_Tracking_Plugin::get_instance()->check_ad_tracking_enabled( $ad, 'click' );
}
// get prefix and generate new body class
$prefix = Advanced_Ads_Plugin::get_instance()->get_frontend_prefix();
$class = $prefix . 'body-background';
// get correct link
if ( class_exists( 'Advanced_Ads_Tracking' ) && method_exists( 'Advanced_Ads_Tracking', 'build_click_tracking_url' ) ) {
$link = Advanced_Ads_Tracking::build_click_tracking_url( $ad );
} elseif( !empty( $ad->url ) ) {
$link = $ad->url;
} elseif( !empty( $ad->output['url'] ) ) { // might no longer be needed
$link = $ad->output['url'];
} else {
$link = false;
}
// get image
if( isset( $ad->output['image_id'] ) ){
$image = wp_get_attachment_image_src( $ad->output['image_id'], 'full' );
if ( $image ) {
list( $image_url, $image_width, $image_height ) = $image;
}
}
if( empty( $image_url ) ){
return $output;
}
$selector = apply_filters( 'advanced-ads-pro-background-selector', 'body' );
ob_start();
?>
options( 'output' );
if ( ! empty( $output_options['custom-code'] ) ) {
echo $output_options['custom-code'];
}
return ob_get_clean();
//return $output;
}
}