Skip to content

Commit 7797872

Browse files
committed
Initial check-in
1 parent 55eb8c2 commit 7797872

19 files changed

+1018
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.svnignore
2+
.sass-cache
3+
.DS_Store
4+
.thumbsdb
5+
.svn

ad-layers.php

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?php
2+
/**
3+
* Ad Layers Base Plugin File.
4+
*
5+
* @package AdLayers
6+
* @version 0.0.1
7+
*/
8+
9+
/*
10+
Plugin Name: Ad Layers
11+
Plugin URI: https://github.com/alleyinteractive/ad-layers
12+
Description: Manages custom ad layers.
13+
Author: Bradford Campeau-Laurion, Alley Interactive
14+
Version: 0.0.1
15+
Author URI: http://www.alleyinteractive.com/
16+
*/
17+
18+
/*
19+
This program is free software; you can redistribute it and/or modify
20+
it under the terms of the GNU General Public License as published by
21+
the Free Software Foundation; either version 2 of the License, or
22+
(at your option) any later version.
23+
24+
This program is distributed in the hope that it will be useful,
25+
but WITHOUT ANY WARRANTY; without even the implied warranty of
26+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+
GNU General Public License for more details.
28+
29+
You should have received a copy of the GNU General Public License
30+
along with this program; if not, write to the Free Software
31+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32+
*/
33+
34+
/**
35+
* Version number.
36+
*
37+
* @var string
38+
*/
39+
define( 'AD_LAYERS_VERSION', '0.0.1' );
40+
41+
/**
42+
* Filesystem path to Ad Layers.
43+
*
44+
* @var string
45+
*/
46+
define( 'AD_LAYERS_BASE_DIR', dirname( __FILE__ ) );
47+
48+
/**
49+
* Default version number for static assets.
50+
*
51+
* @var int
52+
*/
53+
define( 'AD_LAYERS_GLOBAL_ASSET_VERSION', '0.0.1' );
54+
55+
/**
56+
* Option name for ad layers settings.
57+
*
58+
* @var string
59+
*/
60+
define( 'AD_LAYERS_OPTION_NAME', 'ad_layers_settings' );
61+
62+
/**
63+
* Base singleton class for Ad Layers classes.
64+
*/
65+
require_once( AD_LAYERS_BASE_DIR . '/php/class-ad-layers-singleton.php' );
66+
67+
/**
68+
* Custom post type.
69+
*/
70+
require_once( AD_LAYERS_BASE_DIR . '/php/class-ad-layers-post-type.php' );
71+
72+
/**
73+
* Ad widget.
74+
*/
75+
require_once( AD_LAYERS_BASE_DIR . '/php/class-ad-layers-widget.php' );
76+
77+
/**
78+
* Ad shortcode.
79+
*/
80+
require_once( AD_LAYERS_BASE_DIR . '/php/class-ad-layers-shortcode.php' );
81+
82+
/**
83+
* Admin dashboard features.
84+
*/
85+
if ( is_admin() ) {
86+
require_once( AD_LAYERS_BASE_DIR . '/php/class-ad-layers-meta-boxes.php' );
87+
require_once( AD_LAYERS_BASE_DIR . '/php/class-ad-layers-admin.php' );
88+
}
89+
90+
/**
91+
* Instantiate the Ad Layers base class to handle required plugin setup
92+
*/
93+
if ( ! class_exists( 'Ad_Layers' ) ) :
94+
95+
class Ad_Layers extends Ad_Layers_Singleton {
96+
97+
/**
98+
* Built-in ad server support
99+
*
100+
* @var Ad_Layers
101+
*/
102+
private $ad_servers = array(
103+
'DFP' => AD_LAYERS_BASE_DIR . '/php/ad-servers/class-dfp.php',
104+
);
105+
106+
/**
107+
* Current ad layers settings
108+
*
109+
* @var string
110+
*/
111+
private $settings = 'ad_layers_options';
112+
113+
/**
114+
* Setup the singleton.
115+
*/
116+
public function setup() {
117+
// Load current settings
118+
$this->settings = get_option( AD_LAYERS_OPTION_NAME );
119+
120+
// Allow additional ad servers to be loaded via filter within a theme
121+
$ad_servers = apply_filters( 'ad_layers_ad_servers', $this->ad_servers );
122+
123+
if ( ! empty( $ad_servers ) && is_array( $ad_servers ) ) {
124+
foreach ( $ad_servers as $ad_server ) {
125+
if ( file_exists( $ad_server ) ) {
126+
require_once( $ad_server );
127+
}
128+
}
129+
}
130+
131+
// Load the base Javascript library early
132+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5 );
133+
}
134+
135+
/**
136+
* Load scripts.
137+
*/
138+
public function enqueue_scripts() {
139+
// Load the base Javascript library
140+
wp_enqueue_script( 'ad-layers-js', AD_LAYERS_BASE_DIR . '/js/ad-layers.js', array( 'jquery' ), AD_LAYERS_GLOBAL_ASSET_VERSION, false );
141+
142+
// If set, localize with the active ad server
143+
if ( ! empty( $this->settings['ad_server'] ) ) {
144+
wp_localize_script( 'ad-layers-js', 'ad-layers', array(
145+
'ad_server' => $this->settings['ad_server'],
146+
) );
147+
}
148+
149+
// Load the CSS. Mostly used in debug mode.
150+
wp_enqueue_style( 'ad-layers-css', AD_LAYERS_BASE_DIR . '/css/ad-layers.css', array(), AD_LAYERS_GLOBAL_ASSET_VERSION );
151+
}
152+
}
153+
154+
Ad_Layers::instance();
155+
156+
endif;

css/ad-layers-edit.css

Whitespace-only changes.

css/ad-layers.css

Whitespace-only changes.

js/ad-layers-edit.js

Whitespace-only changes.

js/ad-layers.js

Whitespace-only changes.

0 commit comments

Comments
 (0)