1+ <?php
2+ /**
3+ * Google AdSense Ad Provider for Ad Code manager
4+ */
5+ class Google_AdSense_ACM_Provider extends ACM_Provider {
6+ /**
7+ * Register default options for Google AdSense
8+ *
9+ * @uses apply_filters, parent::__construct
10+ * @return null
11+ */
12+ public function __construct () {
13+ // Default output HTML
14+ $ this ->output_html = '<script type="text/javascript">GA_googleFillSlot( "%slot%" );</script> ' ;
15+
16+ // Default Ad Tag Ids (you will pass this in your shortcode or template tag)
17+ $ this ->ad_tag_ids = array (
18+ array (
19+ 'tag ' => 'popunder ' ,
20+ 'url_vars ' => array (
21+ 'slot ' => 'generic '
22+ )
23+ ),
24+ array (
25+ 'tag ' => 'background ' ,
26+ 'url_vars ' => array (
27+ 'slot ' => 'generic '
28+ )
29+ ),
30+ array (
31+ 'tag ' => 'masthead ' ,
32+ 'url_vars ' => array (
33+ 'slot ' => 'generic '
34+ )
35+ )
36+ );
37+
38+ //Since URLs aren't used with AdSense, value 'null' is included as ACM uses parse_url to validate URLs
39+ $ this ->whitelisted_script_urls = array ( '%slot% ' , null );
40+
41+ //Specify table columns
42+ $ this ->columns = apply_filters ( 'acm_provider_columns ' , array ( 'slot ' => 'Slot ' ) );
43+
44+ parent ::__construct ();
45+ }
46+ }
47+
48+ /**
49+ * Google AdSense list table for Ad Code Manager
50+ */
51+ class Google_AdSense_ACM_WP_List_Table extends ACM_WP_List_Table {
52+ /**
53+ * Register table settings
54+ *
55+ * @uses parent::__construct
56+ * @return null
57+ */
58+ public function __construct () {
59+ parent ::__construct ( array (
60+ 'singular ' => 'google_adsense_acm_wp_list_table ' ,
61+ 'plural ' => 'google_adsense_acm_wp_list_table ' ,
62+ 'ajax ' => true
63+ ) );
64+ }
65+
66+ /**
67+ * Specify table columns
68+ *
69+ * @uses apply_filters
70+ * @return array
71+ */
72+ public function get_columns () {
73+ $ columns = array (
74+ 'id ' => __ ( 'ID ' , 'ad-code-manager ' ),
75+ 'slot ' => __ ( 'Slot ' , 'ad-code-manager ' ),
76+ 'priority ' => __ ( 'Priority ' , 'ad-code-manager ' ),
77+ 'conditionals ' => __ ( 'Conditionals ' , 'ad-code-manager ' ),
78+ );
79+
80+ return apply_filters ( 'acm_list_table_columns ' , $ columns );
81+ }
82+
83+ /**
84+ * Output ad slot in table
85+ *
86+ * @param array $item
87+ * @uses esc_html, this::row_actions_output
88+ * @return string
89+ */
90+ public function column_slot ( $ item ) {
91+ $ output = esc_html ( $ item [ 'url_vars ' ][ 'slot ' ] );
92+ $ output .= $ this ->row_actions_output ( $ item );
93+
94+ return $ output ;
95+ }
96+ }
97+ ?>
0 commit comments