PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / 1.2.7
Advanced Ads – Ad Manager & AdSense v1.2.7
2.0.26 2.0.25 2.0.24 2.0.23 2.0.22 2.0.21 1.38.0 1.39.0 1.39.1 1.39.2 1.39.3 1.39.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.40.0 1.40.1 1.40.2 1.41.0 1.42.0 1.42.1 1.42.2 1.43.0 1.44.0 1.44.1 1.45.0 1.45.1 1.46.0 1.47.0 1.47.1 1.47.2 1.47.3 1.47.4 1.47.5 1.48.0 1.48.1 1.49.0 1.5.0 1.5.0.1 1.5.1 1.5.2 1.5.2.1 1.5.4 1.5.4.1 1.5.5 1.50.0 1.51.0 1.51.1 1.51.2 1.51.3 1.52.0 1.52.1 1.52.2 1.52.3 1.52.4 1.53.0 1.53.1 1.53.2 1.54.0 1.54.1 1.55.0 1.56.0 1.56.1 1.56.2 1.56.3 1.56.4 1.6 1.6.1 1.6.10 1.6.10.1 1.6.10.2 1.6.11 1.6.11.1 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.17.1 1.6.17.2 1.6.2 1.6.2.1 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.6.1 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.6.8.3 1.6.9 1.6.9.1 1.6.9.2 1.6.9.3 1.6.9.4 1.7 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.1.1 1.7.1.2 1.7.1.3 1.7.1.4 1.7.1.5 1.7.10 trunk 1.7.11 1.0.1 1.7.12 1.0.2 1.7.13 1.0.3 1.7.14 1.1.0 1.7.15 1.1.1 1.7.16 1.1.2 1.7.17 1.1.3 1.7.18 1.10 1.7.19 1.10.1 1.7.2 1.10.10 1.7.2.1 1.10.11 1.7.20 1.10.12 1.7.21 1.10.2 1.7.22 1.10.3 1.7.23 1.10.4 1.7.24 1.10.5 1.7.25 1.10.6 1.7.3 1.10.7 1.7.4 1.10.8 1.7.4.1 1.10.9 1.7.4.2 1.11 1.7.4.3 1.11.1 1.7.4.4 1.11.2 1.7.4.5 1.12 1.7.5 1.13 1.7.5.1 1.13.1 1.7.6 1.13.2 1.7.7 1.13.3 1.7.8 1.13.4 1.7.9 1.13.5 1.7.9.1 1.13.6 1.7.9.2 1.13.7 1.7.9.3 1.13.8 1.8 1.14 1.8.1 1.14.1 1.8.10 1.14.10 1.8.11 1.14.11 1.8.12 1.14.2 1.8.13 1.14.3 1.8.14 1.14.4 1.8.15 1.14.5 1.8.16 1.14.6 1.8.17 1.14.7 1.8.18 1.14.8 1.8.19 1.14.9 1.8.2 1.15 1.8.20 1.16 1.8.21 1.16.1 1.8.22 1.17 1.8.23 1.17.1 1.8.24 1.17.10 1.8.25 1.17.10-rc.1 1.8.26 1.17.11 1.8.27 1.17.12 1.8.28 1.17.12-rc.1 1.8.29 1.17.2 1.8.3 1.17.3 1.8.30 1.17.4 1.8.4 1.17.5 1.8.5 1.17.6 1.8.6 1.17.7 1.8.7 1.17.8 1.8.8 1.17.9 1.8.9 1.17.9-beta.1 1.9 1.18.0 2.0.0 1.19.0 2.0.1 1.19.1 2.0.10 1.2 2.0.11 1.2.1 2.0.12 1.2.2 2.0.13 1.2.3 2.0.14 1.2.4 2.0.15 1.2.5 2.0.16 1.2.6 2.0.17 1.2.7 2.0.18 1.20.0 2.0.19 1.20.0-rc.1 2.0.2 1.20.0-rc.2 2.0.20 1.20.1 2.0.3 1.20.2 2.0.4 1.20.3 2.0.5 1.21.0 2.0.6 1.21.1 2.0.7 1.22.0 2.0.8 1.22.1 2.0.9 1.22.2 1.23.0 1.23.1 1.23.2 1.24.0 1.24.1 1.24.2 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.29.0 1.29.1 1.3 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.30.0 1.30.1 1.30.2 1.30.2-rc.1 1.30.3 1.30.4 1.30.4-rc.1 1.30.5 1.31.0 1.31.1 1.32.0 1.32.0-rc.1 1.33.0 1.33.1 1.33.2 1.34.0 1.35.0 1.35.1 1.36.0 1.36.1 1.36.2 1.36.3 1.37.0 1.37.1 1.37.2
advanced-ads / admin / includes / class-display-condition-callbacks.php
advanced-ads / admin / includes Last commit date
class-ad-groups-list-table.php 11 years ago class-display-condition-callbacks.php 11 years ago class-list-table.php 12 years ago index.php 12 years ago
class-display-condition-callbacks.php
314 lines
1 <?php
2 /**
3 * container class for callbacks for display conditions
4 *
5 * @package WordPress
6 * @subpackage Advanced Ads Plugin
7 * @since 1.2.2
8 */
9 class AdvAds_Display_Condition_Callbacks {
10
11 /**
12 * render display condition for post types
13 *
14 * @param obj $ad ad object
15 * @since 1.2.2
16 */
17 public static function post_types($ad = false){
18
19 // set defaults
20 if(is_object($ad)){
21 $_all = (isset($ad->conditions['posttypes']['all'])) ? 1 : 0;
22 if(!$_all && !isset($ad->conditions['posttypes']['all']) && empty($ad->conditions['posttypes']['include']) && empty($ad->conditions['posttypes']['exclude'])){
23 $_all = 1;
24 }
25 }
26
27 ?><h4><label class="advads-conditions-all"><input type="checkbox" name="advanced_ad[conditions][posttypes][all]" value="1" <?php checked($_all, 1); ?>><?php
28 _e('Display on all public <strong>post types</strong>.', ADVADS_SLUG); ?></label></h4><?php
29 $post_types = get_post_types(array('public' => true, 'publicly_queryable' => true), 'object', 'or');
30 ?><div class="advads-conditions-single">
31 <p class="description"><?php _e('Choose the public post types on which to display the ad.', ADVADS_SLUG); ?></p><?php
32 // backward compatibility
33 // TODO: remove in a later version
34 $_includes = (!empty($ad->conditions['posttypes']['include']) && is_string($ad->conditions['posttypes']['include'])) ? explode(',', $ad->conditions['posttypes']['include']) : array();
35 $_excludes = (!empty($ad->conditions['posttypes']['exclude']) && is_string($ad->conditions['posttypes']['exclude'])) ? explode(',', $ad->conditions['posttypes']['exclude']) : array();
36
37 foreach($post_types as $_type_id => $_type){
38 // backward compatibility
39 // TODO: remove this in a later version
40 if($_includes == array() && count($_excludes) > 0 && !in_array($_type_id, $_excludes)){
41 $_val = 1;
42 } elseif(in_array($_type_id, $_includes)){
43 $_val = 1;
44 } else {
45 $_val = 0;
46 }
47
48 if(!$_val && isset($ad->conditions['posttypes']['include']) && is_array($ad->conditions['posttypes']['include']) && in_array($_type_id, $ad->conditions['posttypes']['include'])){
49 $_val = 1;
50 }
51
52 ?><label><input type="checkbox" name="advanced_ad[conditions][posttypes][include][]" <?php checked($_val, 1); ?> value="<?php echo $_type_id; ?>"><?php echo $_type->label; ?></label><?php
53 }
54 ?></div><?php
55 }
56
57 /**
58 * render display condition for post types
59 *
60 * @param obj $ad ad object
61 * @since 1.2.3
62 */
63 public static function terms($ad = false){
64
65 // set defaults
66 if(is_object($ad)){
67 $_all = (isset($ad->conditions['categoryids']['all'])) ? 1 : 0;
68 if(!$_all && !isset($ad->conditions['categoryids']['all']) && empty($ad->conditions['categoryids']['include']) && empty($ad->conditions['categoryids']['exclude'])){
69 $_all = 1;
70 }
71 }
72
73 if(!empty($ad->conditions['categoryids']['include'])){
74 // backward compatibility
75 // TODO: remove in a later version; this should already be an array
76 if(is_string($ad->conditions['categoryids']['include'])){
77 $_includes = explode(',', $ad->conditions['categoryids']['include']);
78 } else {
79 $_includes = $ad->conditions['categoryids']['include'];
80 }
81 } else {
82 $_includes = array();
83 }
84
85 ?><h4><label class="advads-conditions-all"><input type="checkbox" name="advanced_ad[conditions][categoryids][all]" value="1" <?php checked($_all, 1); ?>><?php
86 _e('Display for all <strong>categories, tags and taxonomies</strong>.', ADVADS_SLUG); ?></label></h4><?php
87 $taxonomies = get_taxonomies(array('public' => true, 'publicly_queryable' => true), 'objects', 'or');
88 ?><div class="advads-conditions-single"><h5 class="header"><?php _e('Display here', ADVADS_SLUG); ?></h5><p class="description"><?php _e('Choose terms from public categories, tags and other taxonomies a post must belong to in order to have ads.', ADVADS_SLUG); ?></p>
89 <table><?php
90 foreach($taxonomies as $_tax):
91 if($_tax->name === 'advanced_ads_groups') continue; // exclude adv ads groups
92 $terms = get_terms($_tax->name, array());
93 if ( !empty( $terms ) && !is_wp_error( $terms ) ):
94 ?><tr><th><?php echo $_tax->label; ?></th><?php
95 ?><td><?php
96 foreach($terms as $_term) :
97 ?><label><input type="checkbox" name="advanced_ad[conditions][categoryids][include][]" value="<?php echo $_term->term_id; ?>" <?php
98 checked(in_array($_term->term_id, $_includes), true); ?>><?php echo $_term->name; ?></label><?php
99 endforeach;
100 ?></td></tr><?php
101 endif;
102 endforeach;
103 ?></table><?php
104
105 if(!empty($ad->conditions['categoryids']['exclude'])){
106 // backward compatibility
107 // TODO: remove in a later version; this should already be an array
108 if(is_string($ad->conditions['categoryids']['exclude'])){
109 $_excludes = explode(',', $ad->conditions['categoryids']['exclude']);
110 } else {
111 $_excludes = $ad->conditions['categoryids']['exclude'];
112 }
113 } else {
114 $_excludes = array();
115 }
116
117 ?><h5 class="header"><?php _e('Hide from here', ADVADS_SLUG); ?></h5><p class="description"><?php _e('Choose the terms from public categories, tags and other taxonomies a post must belong to hide the ad from it.', ADVADS_SLUG); ?></p>
118 <table><?php
119 foreach($taxonomies as $_tax):
120 if($_tax->name === 'advanced_ads_groups') continue; // exclude adv ads groups
121 $terms = get_terms($_tax->name, array());
122 if ( !empty( $terms ) && !is_wp_error( $terms ) ):
123 ?><tr><th><?php echo $_tax->label; ?></th><?php
124 ?><td><?php
125 foreach($terms as $_term) :
126 ?><label><input type="checkbox" name="advanced_ad[conditions][categoryids][exclude][]" value="<?php echo $_term->term_id; ?>" <?php
127 checked(in_array($_term->term_id, $_excludes), true); ?>><?php echo $_term->name; ?></label><?php
128 endforeach;
129 ?></td></tr><?php
130 endif;
131 endforeach;
132 ?></table></div><?php
133 }
134
135 /**
136 * render display condition for taxonomy/term archive pages
137 *
138 * @param obj $ad ad object
139 * @since 1.2.5
140 */
141 public static function category_archives($ad = false){
142
143 // set defaults
144 if(is_object($ad)){
145 $_all = (isset($ad->conditions['categoryarchiveids']['all'])) ? 1 : 0;
146 if(!$_all && empty($ad->conditions['categoryarchiveids']['include']) && empty($ad->conditions['categoryarchiveids']['exclude'])){
147 $_all = 1;
148 }
149 }
150
151 if(!empty($ad->conditions['categoryarchiveids']['include'])){
152 // backward compatibility
153 // TODO: remove in a later version; this should already be an array
154 if(is_string($ad->conditions['categoryarchiveids']['include'])){
155 $_includes = explode(',', $ad->conditions['categoryarchiveids']['include']);
156 } else {
157 $_includes = $ad->conditions['categoryarchiveids']['include'];
158 }
159 } else {
160 $_includes = array();
161 }
162
163 ?><h4><label class="advads-conditions-all"><input type="checkbox" name="advanced_ad[conditions][categoryarchiveids][all]" value="1" <?php checked($_all, 1); ?>><?php
164 _e('Display on all <strong>category archive pages</strong>.', ADVADS_SLUG); ?></label></h4><?php
165 $taxonomies = get_taxonomies(array('public' => true, 'publicly_queryable' => true), 'objects', 'or');
166 ?><div class="advads-conditions-single"><table>
167 <p class="description"><?php _e('Choose the terms from public categories, tags and other taxonomies on which\'s archive page ads can appear', ADVADS_SLUG); ?></p>
168 <table><?php
169 foreach($taxonomies as $_tax):
170 if($_tax->name === 'advanced_ads_groups') continue; // exclude adv ads groups
171 $terms = get_terms($_tax->name, array());
172 if ( !empty( $terms ) && !is_wp_error( $terms ) ):
173 ?><tr><th><?php echo $_tax->label; ?></th><?php
174 ?><td><?php
175 foreach($terms as $_term) :
176 ?><label><input type="checkbox" name="advanced_ad[conditions][categoryarchiveids][include][]" value="<?php echo $_term->term_id; ?>" <?php
177 checked(in_array($_term->term_id, $_includes), true); ?>><?php echo $_term->name; ?></label><?php
178 endforeach;
179 ?></td></tr><?php
180 endif;
181 endforeach;
182 ?></table><?php
183
184 if(!empty($ad->conditions['categoryarchiveids']['exclude'])){
185 // backward compatibility
186 // TODO: remove in a later version; this should already be an array
187 if(is_string($ad->conditions['categoryarchiveids']['exclude'])){
188 $_excludes = explode(',', $ad->conditions['categoryarchiveids']['exclude']);
189 } else {
190 $_excludes = $ad->conditions['categoryarchiveids']['exclude'];
191 }
192 } else {
193 $_excludes = array();
194 }
195
196 ?><h5 class="header"><?php _e('Hide from here', ADVADS_SLUG); ?></h5><p class="description"><?php _e('Choose the terms from public categories, tags and other taxonomies on which\'s archive pages ads are hidden.', ADVADS_SLUG); ?></p>
197 <table><?php
198 foreach($taxonomies as $_tax):
199 if($_tax->name === 'advanced_ads_groups') continue; // exclude adv ads groups
200 $terms = get_terms($_tax->name, array());
201 if ( !empty( $terms ) && !is_wp_error( $terms ) ):
202 ?><tr><th><?php echo $_tax->label; ?></th><?php
203 ?><td><?php
204 foreach($terms as $_term) :
205 ?><label><input type="checkbox" name="advanced_ad[conditions][categoryarchiveids][exclude][]" value="<?php echo $_term->term_id; ?>" <?php
206 checked(in_array($_term->term_id, $_excludes), true); ?>><?php echo $_term->name; ?></label><?php
207 endforeach;
208 ?></td></tr><?php
209 endif;
210 endforeach;
211 ?></table></div><?php
212 }
213
214 /**
215 * render display condition for single post types
216 *
217 * @param obj $ad ad object
218 * @since 1.2.6
219 */
220 public static function single_posts($ad = false){
221
222 if(is_object($ad)){
223 $_all = (isset($ad->conditions['postids']['all'])) ? 1 : 0;
224 if(!$_all && empty($ad->conditions['postids']['include']) && empty($ad->conditions['postids']['exclude'])){
225 $_all = 1;
226 }
227 }
228
229 ?><h4><label class="advads-conditions-all"><input type="checkbox" name="advanced_ad[conditions][postids][all]" value="1" <?php
230 checked($_all, 1); ?>><?php _e('Display an all <strong>individual posts, pages</strong> and public post type pages', ADVADS_SLUG); ?></label></h4><?php
231
232 ?><div class="advads-conditions-single">
233 <p class="description"><?php _e('Choose on which individual posts, pages and public post type pages you want to display or hide ads.', ADVADS_SLUG); ?></p><?php
234
235 // derrive method from previous setup
236 // set defaults
237 if(is_object($ad)){
238 $_method = (isset($ad->conditions['postids']['method'])) ? $ad->conditions['postids']['method'] : 0;
239 if($_method === 0){
240 if(empty($ad->conditions['postids']['include']) && !empty($ad->conditions['postids']['exclude'])){
241 $_method = 'exclude';
242 } elseif(!empty($ad->conditions['postids']['include']) && empty($ad->conditions['postids']['exclude'])) {
243 $_method = 'include';
244 } else {
245 $_method = '';
246 }
247 }
248 }
249
250 ?><p><?php _e('What should happen with ads on the list of individual posts below?', ADVADS_SLUG); ?></p>
251 <label><input type="radio" name='advanced_ad[conditions][postids][method]' value='' <?php checked('', $_method); ?>><?php _e('ignore the list', ADVADS_SLUG); ?></label></li>
252 <label><input type="radio" name='advanced_ad[conditions][postids][method]' value='include' <?php checked('include', $_method); ?>><?php _e('display the ad only there', ADVADS_SLUG); ?></label></li>
253 <label><input type="radio" name='advanced_ad[conditions][postids][method]' value='exclude' <?php checked('exclude', $_method); ?>><?php _e('hide the ad here', ADVADS_SLUG); ?></label></li>
254 <?php
255
256 /**
257 * Update warning
258 * @todo remove on a later version, if no longer needed
259 */
260 if(!empty($ad->conditions['postids']['include']) && !empty($ad->conditions['postids']['exclude'])){
261 ?><div style="color: red;"><p><strong><?php _e('Update warning', ADVADS_SLUG); ?></strong></p>
262 <p><?php _e('Due to some conflicts before version 1.2.6, it is from now on only possible to choose either individual pages to include or exclude an ad, but not both with mixed settings. It seems you are still using mixed settings on this page. Please consider changing your setup for this ad.', ADVADS_SLUG); ?></p>
263 <p><?php _e('Your old values are:', ADVADS_SLUG); ?></p>
264 <p><?php _e('Post IDs the ad is displayed on:', ADVADS_SLUG); echo $ad->conditions['postids']['include']; ?></p>
265 <p><?php _e('Post IDs the ad is hidden from:', ADVADS_SLUG); echo $ad->conditions['postids']['exclude']; ?></p>
266 <p><?php _e('Below you find the pages the ad is displayed on. If this is ok, just save the ad. If not, please update your settings.', ADVADS_SLUG); ?></p>
267
268 </div><?php
269 }
270
271 if(!empty($ad->conditions['postids']['include'])){
272 // backward compatibility
273 // TODO: remove in a later version; this should already be an array
274 if(is_string($ad->conditions['postids']['include'])){
275 $_postids = explode(',', $ad->conditions['postids']['include']);
276 } else {
277 $_postids = $ad->conditions['postids']['include'];
278 }
279 } elseif(!empty($ad->conditions['postids']['exclude'])){
280 // backward compatibility
281 // TODO: remove in a later version; this should already be an array
282 if(is_string($ad->conditions['postids']['exclude'])){
283 $_postids = explode(',', $ad->conditions['postids']['exclude']);
284 } else {
285 $_postids = $ad->conditions['postids']['exclude'];
286 }
287 } else {
288 $_postids = array();
289 }
290
291 ?><ul class='advads-conditions-postids-list'><?php
292 if($_postids != array()){
293 $args = array(
294 'post_type' => 'any',
295 // 'post_status' => 'publish',
296 'post__in' => $_postids,
297 // 'ignore_sticky_posts' => 1,
298 );
299
300 $the_query = new WP_Query( $args );
301 while ( $the_query->have_posts() ) {
302 $the_query->next_post();
303 echo '<li><a class="remove" href="#">remove</a><a href="'.get_permalink($the_query->post->ID).'">' . get_the_title( $the_query->post->ID ) . '</a><input type="hidden" name="advanced_ad[conditions][postids][ids][]" value="'.$the_query->post->ID.'"></li>';
304 }
305 }
306 ?><li class="show-search"><a href="#"><?php _e('new', ADVADS_SLUG); ?></a>
307 <input type="text" style="display:none;" id="advads-display-conditions-individual-post" value="" placeholder="<?php
308 _e('type the title', ADVADS_SLUG); ?>"/>
309 <?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?>
310 </li>
311 </ul>
312 </div><?php
313 }
314 }