assets
11 years ago
includes
12 years ago
views
12 years ago
class-advanced-ads.php
11 years ago
functions.php
11 years ago
functions.php
92 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * functions that are directly available in WordPress themes (and plugins) |
| 5 | */ |
| 6 | |
| 7 | /** |
| 8 | * return ad content |
| 9 | * |
| 10 | * @since 1.0.0 |
| 11 | * @param int $id id of the ad (post) |
| 12 | * @param arr $args additional arguments |
| 13 | */ |
| 14 | function get_ad($id = 0, $args = array()){ |
| 15 | $id = absint($id); |
| 16 | if(empty($id)) return; |
| 17 | |
| 18 | // get ad |
| 19 | $ad = new Advads_Ad($id, $args); |
| 20 | |
| 21 | // check conditions |
| 22 | if($ad->can_display()) |
| 23 | return $ad->output(); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * echo an ad |
| 28 | * |
| 29 | * @since 1.0.0 |
| 30 | * @param int $id id of the ad (post) |
| 31 | * @param arr $args additional arguments |
| 32 | */ |
| 33 | function the_ad($id = 0, $args = array()){ |
| 34 | |
| 35 | echo get_ad($id, $args); |
| 36 | |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * return an ad from an ad group based on ad weight |
| 41 | * |
| 42 | * @since 1.0.0 |
| 43 | * @param int $id id of the ad group (taxonomy) |
| 44 | * |
| 45 | */ |
| 46 | function get_ad_group($id = 0){ |
| 47 | $id = absint($id); |
| 48 | if(empty($id)) return; |
| 49 | |
| 50 | // get ad |
| 51 | $adgroup = new Advads_Ad_Group($id); |
| 52 | return $adgroup->output_random_ad(); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * echo an ad from an ad group |
| 57 | * |
| 58 | * @since 1.0.0 |
| 59 | * @param int $id id of the ad (post) |
| 60 | */ |
| 61 | function the_ad_group($id = 0){ |
| 62 | |
| 63 | echo get_ad_group($id); |
| 64 | |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * return content of an ad placement |
| 69 | * |
| 70 | * @since 1.1.0 |
| 71 | * @param string $id slug of the ad placement |
| 72 | * |
| 73 | */ |
| 74 | function get_ad_placement($id = ''){ |
| 75 | if($id == '') return; |
| 76 | |
| 77 | // get placement content |
| 78 | $output = Advads_Ad_Placements::output($id); |
| 79 | return $output; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * return content of an ad placement |
| 84 | * |
| 85 | * @since 1.1.0 |
| 86 | * @param string $id slug of the ad placement |
| 87 | */ |
| 88 | function the_ad_placement($id = ''){ |
| 89 | |
| 90 | echo get_ad_placement($id); |
| 91 | |
| 92 | } |