| 1 |
<?php |
| 2 |
function wp_template_ad($ad_ID) { |
| 3 |
$output = ''; |
| 4 |
global $random; |
| 5 |
$page_details = wp_insert_get_current_page_details(); |
| 6 |
|
| 7 |
if(get_option('wp_insert_template_ad_'.$ad_ID.'_enable')) { |
| 8 |
$ad_style = get_option('wp_insert_template_ad_'.$ad_ID.'_style'); |
| 9 |
if($ad_style == '') { $ad_style = 'margin: 5px; padding: 0px;'; } |
| 10 |
if(!get_option('wp_insert_template_ad_'.$ad_ID.'_exclude_home') && ($page_details == 'HOME')) { |
| 11 |
switch($random) { |
| 12 |
case 0: |
| 13 |
$output .= '<div id="template_ad_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_template_ad_'.$ad_ID.'_content').'</div>'; |
| 14 |
break; |
| 15 |
case 1: |
| 16 |
$output .= '<div id="template_ad_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_template_ad_'.$ad_ID.'_content_1').'</div>'; |
| 17 |
break; |
| 18 |
case 2: |
| 19 |
$output .= '<div id="template_ad_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_template_ad_'.$ad_ID.'_content_2').'</div>'; |
| 20 |
break; |
| 21 |
} |
| 22 |
} |
| 23 |
else if(!get_option('wp_insert_template_ad_'.$ad_ID.'_exclude_archives') && ($page_details == 'ARCHIVE')) { |
| 24 |
switch($random) { |
| 25 |
case 0: |
| 26 |
$output .= '<div id="template_ad_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_template_ad_'.$ad_ID.'_content').'</div>'; |
| 27 |
break; |
| 28 |
case 1: |
| 29 |
$output .= '<div id="template_ad_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_template_ad_'.$ad_ID.'_content_1').'</div>'; |
| 30 |
break; |
| 31 |
case 2: |
| 32 |
$output .= '<div id="template_ad_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_template_ad_'.$ad_ID.'_content_2').'</div>'; |
| 33 |
break; |
| 34 |
} |
| 35 |
} |
| 36 |
else { |
| 37 |
if(is_singular()) { |
| 38 |
$page_ids = explode(',', str_replace(" ", "", get_option('wp_insert_template_ad_'.$ad_ID.'_exclude_ids'))); |
| 39 |
if(wp_insert_is_in_array($page_details, $page_ids) =='FALSE') { |
| 40 |
switch($random) { |
| 41 |
case 0: |
| 42 |
$output .= '<div id="template_ad_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_template_ad_'.$ad_ID.'_content').'</div>'; |
| 43 |
break; |
| 44 |
case 1: |
| 45 |
$output .= '<div id="template_ad_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_template_ad_'.$ad_ID.'_content_1').'</div>'; |
| 46 |
break; |
| 47 |
case 2: |
| 48 |
$output .= '<div id="template_ad_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_template_ad_'.$ad_ID.'_content_2').'</div>'; |
| 49 |
break; |
| 50 |
} |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
echo $output; |
| 57 |
} |
| 58 |
?> |