-
Notifications
You must be signed in to change notification settings - Fork 0
/
jacket-ads.php
39 lines (26 loc) · 1002 Bytes
/
jacket-ads.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/*
Plugin Name: Jacket Ads
Plugin URI: https://github.com/bhsjacket/jacket-ads
Author: Jerome Paulos
Author URI: https://jeromepaulos.com
Description: An ad manager and injector for WordPress
Version: 1.4
*/
require_once('register.php');
function jacket_generateAdCode() {
if( $ads = get_field('horizontal_ads', 'option') ) {
if( get_post_type() !== 'page' || is_front_page() ) {
$ad = $ads[array_rand($ads)];
$adUrl = esc_url($ad['caption']);
$adImage = esc_url($ad['url']);
?>
<script>
var ad_html = '<section class="align-full ad-container"><span class="ad-label">Advertisement</span><a href="<?php echo $adUrl; ?>?ref=bhsjacket" target="_blank"><img src="<?php echo $adImage ?>"></a></section>';
</script>
<script src="<?php echo plugin_dir_url(__FILE__); ?>content-injection.js"></script>
<?
}
}
}
add_action('wp_head', 'jacket_generateAdCode');