Advanced Ads - Version 1.2.2

Version Description

major changes

  • added overview page
  • new layout for display condition check for post types
  • added ad width and height values

fixes:

  • dont display ads that are not published or visible to logged in users only
Download this release

Release Info

Developer webzunft
Plugin Icon 128x128 Advanced Ads
Version 1.2.2
Comparing to
See all releases

Code changes from version 1.2.1 to 1.2.2

admin/assets/css/admin.css CHANGED
@@ -29,10 +29,17 @@
29
  .post-type-advanced_ads #advanced-ad-conditions {
30
  text-align: left;
31
  }
 
 
 
32
  .post-type-advanced_ads #advads-ad-content-plain {
33
  width: 100%;
34
  }
35
  .post-type-advanced_ads #ad-parameters-box .advads-ad-parameters-spinner { display: block; float: none; }
 
 
 
 
36
 
37
  /**
38
  AD GROUP LIST
@@ -57,4 +64,5 @@
57
  /**
58
  GENERAL ELEMENTS
59
  */
60
- .advads-toggle-link { cursor: pointer; }
 
29
  .post-type-advanced_ads #advanced-ad-conditions {
30
  text-align: left;
31
  }
32
+ .post-type-advanced_ads #ad-display-box label { margin-right: 1em; }
33
+ .post-type-advanced_ads .advads-conditions-all { display: block; }
34
+ .post-type-advanced_ads .advads-conditions-single.disabled { opacity: .5; }
35
  .post-type-advanced_ads #advads-ad-content-plain {
36
  width: 100%;
37
  }
38
  .post-type-advanced_ads #ad-parameters-box .advads-ad-parameters-spinner { display: block; float: none; }
39
+ .post-type-advanced_ads #advanced-ads-ad-parameters-size { margin-top: 1em; }
40
+ .post-type-advanced_ads #advanced-ads-ad-parameters-size p { float: left; margin: 0 1em 0 0; font-weight: bold; }
41
+ .post-type-advanced_ads #advanced-ads-ad-parameters-size label + label { margin-left: 1em; }
42
+ .post-type-advanced_ads #advanced-ads-ad-parameters-size input { width: 4em; margin-left: .5em; }
43
 
44
  /**
45
  AD GROUP LIST
64
  /**
65
  GENERAL ELEMENTS
66
  */
67
+ .advads-toggle-link { cursor: pointer; }
68
+ .advads-content-half { float: left; margin-right: 5%; width: 45%; min-width: 300px; }
admin/assets/js/admin.js CHANGED
@@ -38,10 +38,20 @@ jQuery(document).ready(function($) {
38
  // toggle display conditions
39
  $('#advanced-ad-conditions-enable input').click(function(){
40
  advads_toggle_display_conditions(this.value);
41
- })
42
  // display on load
43
  advads_toggle_display_conditions($('#advanced-ad-conditions-enable input:checked').val());
44
- })
 
 
 
 
 
 
 
 
 
 
45
 
46
  /**
47
  * toggle content elements (hide/show)
@@ -89,4 +99,17 @@ function advads_toggle_display_conditions(value){
89
  } else {
90
  jQuery('#advanced-ad-conditions').fadeOut();
91
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
38
  // toggle display conditions
39
  $('#advanced-ad-conditions-enable input').click(function(){
40
  advads_toggle_display_conditions(this.value);
41
+ });
42
  // display on load
43
  advads_toggle_display_conditions($('#advanced-ad-conditions-enable input:checked').val());
44
+
45
+ // display / hide options if all-option is checked for display condition
46
+ $('.advanced-ad-display-condition .advads-conditions-all input').click(function(){
47
+ advads_toggle_single_display_conditions(this);
48
+ });
49
+ // display / hide options if all-option is checked for display condition – on load
50
+ $('.advanced-ad-display-condition .advads-conditions-all input').each(function(){
51
+ advads_toggle_single_display_conditions(this);
52
+ });
53
+
54
+ });
55
 
56
  /**
57
  * toggle content elements (hide/show)
99
  } else {
100
  jQuery('#advanced-ad-conditions').fadeOut();
101
  }
102
+ }
103
+
104
+ /**
105
+ * disable new display conditions
106
+ * @param {string} checkbox element
107
+ */
108
+ function advads_toggle_single_display_conditions(checkbox){
109
+ // console.log(jQuery(checkbox).parent('div').find('label:not(.advads-conditions-all) input').css('border', 'solid'));
110
+ if(jQuery(checkbox).is(':checked')){
111
+ jQuery(checkbox).parents('.advanced-ad-display-condition').find('.advads-conditions-single').addClass('disabled').find('input').attr('disabled', 'disabled');
112
+ } else {
113
+ jQuery(checkbox).parents('.advanced-ad-display-condition').find('.advads-conditions-single').removeClass('disabled').find('input').removeAttr('disabled');
114
+ }
115
  }
admin/class-advanced-ads-admin.php CHANGED
@@ -83,6 +83,7 @@ class Advanced_Ads_Admin {
83
  // Add menu items
84
  add_action('admin_menu', array($this, 'add_ad_group_menu'));
85
  add_action('admin_menu', array($this, 'add_plugin_admin_menu'));
 
86
 
87
  // on post/ad edit screen
88
  add_action('edit_form_after_title', array($this, 'edit_form_below_title'));
@@ -192,6 +193,10 @@ class Advanced_Ads_Admin {
192
  */
193
  public function add_plugin_admin_menu() {
194
 
 
 
 
 
195
  // add placements page
196
  add_submenu_page(
197
  'edit.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG, __('Ad Placements', $this->plugin_slug), __('Placements', $this->plugin_slug), 'manage_options', $this->plugin_slug . '-placements', array($this, 'display_placements_page')
@@ -205,6 +210,31 @@ class Advanced_Ads_Admin {
205
  );
206
  }
207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  /**
209
  * Render the settings page
210
  *
@@ -266,7 +296,7 @@ class Advanced_Ads_Admin {
266
  public function add_ad_group_menu() {
267
 
268
  $this->ad_group_hook_suffix = add_submenu_page(
269
- 'edit.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG, __('Ad Groups', $this->plugin_slug), __('Ad Groups', $this->plugin_slug), 'manage_options', $this->plugin_slug . '-groups', array($this, 'ad_group_admin_page')
270
  );
271
  }
272
 
@@ -488,6 +518,15 @@ class Advanced_Ads_Admin {
488
  } else {
489
  $ad->set_option('injection', array());
490
  }
 
 
 
 
 
 
 
 
 
491
 
492
  if(!empty($_POST['advanced_ad']['content']))
493
  $ad->content = $_POST['advanced_ad']['content'];
83
  // Add menu items
84
  add_action('admin_menu', array($this, 'add_ad_group_menu'));
85
  add_action('admin_menu', array($this, 'add_plugin_admin_menu'));
86
+ add_action('admin_init', array($this, 'organize_admin_menu'));
87
 
88
  // on post/ad edit screen
89
  add_action('edit_form_after_title', array($this, 'edit_form_below_title'));
193
  */
194
  public function add_plugin_admin_menu() {
195
 
196
+ // add overview page
197
+ add_submenu_page(
198
+ 'edit.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG, __('Overview', $this->plugin_slug), __('Overview', $this->plugin_slug), 'manage_options', $this->plugin_slug . '-overview', array($this, 'display_overview_page')
199
+ );
200
  // add placements page
201
  add_submenu_page(
202
  'edit.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG, __('Ad Placements', $this->plugin_slug), __('Placements', $this->plugin_slug), 'manage_options', $this->plugin_slug . '-placements', array($this, 'display_placements_page')
210
  );
211
  }
212
 
213
+ /**
214
+ * push the overview page to the top of the advanced ads menu
215
+ *
216
+ * @global array $submenu
217
+ * @since 1.2.2
218
+ */
219
+ public function organize_admin_menu(){
220
+ global $submenu;
221
+ $submenu['edit.php?post_type=advanced_ads'][1] = $submenu['edit.php?post_type=advanced_ads'][17];
222
+ unset($submenu['edit.php?post_type=advanced_ads'][17]);
223
+ ksort($submenu['edit.php?post_type=advanced_ads']);
224
+ }
225
+
226
+ /**
227
+ * Render the overview page
228
+ *
229
+ * @since 1.2.2
230
+ */
231
+ public function display_overview_page() {
232
+ $recent_ads = Advanced_Ads::get_ads();
233
+ $groups = Advanced_Ads::get_ad_groups();
234
+ $placements = Advanced_Ads::get_ad_placements_array();
235
+ include_once( 'views/overview.php' );
236
+ }
237
+
238
  /**
239
  * Render the settings page
240
  *
296
  public function add_ad_group_menu() {
297
 
298
  $this->ad_group_hook_suffix = add_submenu_page(
299
+ 'edit.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG, __('Ad Groups', $this->plugin_slug), __('Groups', $this->plugin_slug), 'manage_options', $this->plugin_slug . '-groups', array($this, 'ad_group_admin_page')
300
  );
301
  }
302
 
518
  } else {
519
  $ad->set_option('injection', array());
520
  }
521
+ // save size
522
+ $ad->width = 0;
523
+ if(isset($_POST['advanced_ad']['width'])) {
524
+ $ad->width = absint($_POST['advanced_ad']['width']);
525
+ }
526
+ $ad->height = 0;
527
+ if(isset($_POST['advanced_ad']['height'])) {
528
+ $ad->height = absint($_POST['advanced_ad']['height']);
529
+ }
530
 
531
  if(!empty($_POST['advanced_ad']['content']))
532
  $ad->content = $_POST['advanced_ad']['content'];
admin/includes/class-display-condition-callbacks.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * display 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
+ ?><label class="advads-conditions-all"><input type="checkbox" name="advanced_ad[conditions][posttypes][all]" value="1" <?php checked($_all, 1); ?>><?php _e('Display on all public post types.', ADVADS_SLUG); ?></label><?php
28
+ $post_types = get_post_types(array('public' => true, 'publicly_queryable' => true), 'object', 'or');
29
+ ?><div class="advads-conditions-single"><?php
30
+ // backward compatibility
31
+ // TODO: remove in a later version
32
+ $_includes = (!empty($ad->conditions['posttypes']['include']) && is_string($ad->conditions['posttypes']['include'])) ? explode(',', $ad->conditions['posttypes']['include']) : array();
33
+ $_excludes = (!empty($ad->conditions['posttypes']['exclude']) && is_string($ad->conditions['posttypes']['exclude'])) ? explode(',', $ad->conditions['posttypes']['exclude']) : array();
34
+
35
+ foreach($post_types as $_type_id => $_type){
36
+ // backward compatibility
37
+ // TODO: remove this in a later version
38
+ if($_includes == array() && count($_excludes) > 0 && !in_array($_type_id, $_excludes)){
39
+ $_val = 1;
40
+ } elseif(in_array($_type_id, $_includes)){
41
+ $_val = 1;
42
+ } else {
43
+ $_val = 0;
44
+ }
45
+
46
+ if(!$_val && isset($ad->conditions['posttypes']['include']) && is_array($ad->conditions['posttypes']['include']) && in_array($_type_id, $ad->conditions['posttypes']['include'])){
47
+ $_val = 1;
48
+ }
49
+
50
+ ?><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
51
+ }
52
+ ?></div><?php
53
+ }
54
+ }
admin/views/ad-display-metabox.php CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  <?php $types = Advanced_Ads::get_instance()->ad_types; ?>
2
  <p class="description"><?php _e('Choose where to display the ad and where not.', ADVADS_SLUG); ?></p>
3
  <div id="advanced-ad-conditions-enable">
@@ -14,18 +17,30 @@
14
  <li><?php _e('When using one of the two choices on checkbox conditions, the rule is binding. E.g. "Front Page: show here" will result on the ad being only visible on the front page.', $this->plugin_slug); ?></li>
15
  <li><?php _e('If there is nothing in the row, there won’t be any check. Meaning, if you leave everything empty, the ad will be displayed everywhere.', $this->plugin_slug); ?></li>
16
  </ul>
17
-
18
- <table id="advanced-ad-conditions">
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  <thead>
20
  <tr>
21
  <th></th>
22
  <th><?php _e('show here', $this->plugin_slug); ?></th>
23
  <th><?php _e('DON’T show', $this->plugin_slug); ?></th>
24
  <th></th>
25
- </tr>
26
- <?php global $advanced_ads_ad_conditions;
27
- if (is_array($advanced_ads_ad_conditions))
28
  foreach ($advanced_ads_ad_conditions as $_key => $_condition) :
 
29
  ?><tr>
30
  <th><?php echo $_condition['label']; ?>
31
  <?php if (!empty($_condition['description'])) : ?>
@@ -42,6 +57,8 @@
42
  <?php endif; ?>
43
  <td><button type="button" class="clear-radio"><?php _e('clear', $this->plugin_slug); ?></button></td>
44
  </tr>
45
- <?php endforeach; ?>
46
  </thead>
47
- </table>
 
 
1
+ <?php // include callback file
2
+ require_once(ADVADS_BASE_PATH . 'admin/includes/class-display-condition-callbacks.php');
3
+ ?>
4
  <?php $types = Advanced_Ads::get_instance()->ad_types; ?>
5
  <p class="description"><?php _e('Choose where to display the ad and where not.', ADVADS_SLUG); ?></p>
6
  <div id="advanced-ad-conditions-enable">
17
  <li><?php _e('When using one of the two choices on checkbox conditions, the rule is binding. E.g. "Front Page: show here" will result on the ad being only visible on the front page.', $this->plugin_slug); ?></li>
18
  <li><?php _e('If there is nothing in the row, there won’t be any check. Meaning, if you leave everything empty, the ad will be displayed everywhere.', $this->plugin_slug); ?></li>
19
  </ul>
20
+ <div id="advanced-ad-conditions">
21
+ <?php global $advanced_ads_ad_conditions;
22
+ if (is_array($advanced_ads_ad_conditions)) :
23
+ foreach ($advanced_ads_ad_conditions as $_key => $_condition) :
24
+ if(!isset($_condition['callback'])) continue;
25
+ ?><div class="advanced-ad-display-condition">
26
+ <h4><?php echo $_condition['label']; ?></h4>
27
+ <p class="description"><?php echo $_condition['description']; ?></p>
28
+ <?php if(is_array($_condition['callback']) && method_exists($_condition['callback'][0], $_condition['callback'][1])) {
29
+ $_condition['callback'][0]::$_condition['callback'][1]($ad);
30
+ }
31
+ ?></div><?php
32
+ endforeach;
33
+ ?><p><?php _e('UPDATE NOTICE: I am currently moving the old settings from below to a new form (above). Don’t worry, the old settings will still work in the future.', ADVADS_SLUG); ?></p>
34
+ <table>
35
  <thead>
36
  <tr>
37
  <th></th>
38
  <th><?php _e('show here', $this->plugin_slug); ?></th>
39
  <th><?php _e('DON’T show', $this->plugin_slug); ?></th>
40
  <th></th>
41
+ </tr><?php
 
 
42
  foreach ($advanced_ads_ad_conditions as $_key => $_condition) :
43
+ if(isset($_condition['callback'])) continue;
44
  ?><tr>
45
  <th><?php echo $_condition['label']; ?>
46
  <?php if (!empty($_condition['description'])) : ?>
57
  <?php endif; ?>
58
  <td><button type="button" class="clear-radio"><?php _e('clear', $this->plugin_slug); ?></button></td>
59
  </tr>
60
+ <?php endforeach;?>
61
  </thead>
62
+ </table>
63
+ </div>
64
+ <?php endif;
admin/views/ad-parameters-metabox.php CHANGED
@@ -9,6 +9,12 @@
9
  ?>
10
  <div id="advanced-ads-ad-parameters">
11
  <?php $type = (isset($types[$ad->type])) ? $types[$ad->type] : current($types);
12
- $type->render_parameters($ad); ?>
 
 
 
 
 
 
13
  </div>
14
  <?php do_action('advanced-ads-ad-params-after', $ad, $types);
9
  ?>
10
  <div id="advanced-ads-ad-parameters">
11
  <?php $type = (isset($types[$ad->type])) ? $types[$ad->type] : current($types);
12
+ $type->render_parameters($ad);
13
+ ?>
14
+ <div id="advanced-ads-ad-parameters-size">
15
+ <p><?php _e('size:', ADVADS_SLUG); ?></p>
16
+ <label><?php _e('width', ADVADS_SLUG); ?><input type="number" size="4" maxlength="4" value="<?php echo isset($ad->width) ? $ad->width : 0; ?>" name="advanced_ad[width]">px</label>
17
+ <label><?php _e('height', ADVADS_SLUG); ?><input type="number" size="4" maxlength="4" value="<?php echo isset($ad->height) ? $ad->height : 0; ?>" name="advanced_ad[height]">px</label>
18
+ </div>
19
  </div>
20
  <?php do_action('advanced-ads-ad-params-after', $ad, $types);
admin/views/overview.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * the view for the settings page
4
+ */
5
+ ?><div class="wrap">
6
+ <?php screen_icon(); ?>
7
+ <h1><?php echo esc_html(get_admin_page_title()); ?></h1>
8
+ <div class="advads-content-half">
9
+ <h2><?php _e('Ads', ADVADS_SLUG); ?></h2>
10
+ <p class="description"><?php _e('Ads are the smallest unit, containing the content or a single ad to be displayed.', ADVADS_SLUG); ?></p>
11
+ <p><?php printf(__('You have published %d ads.', ADVADS_SLUG), count($recent_ads));?>&nbsp;<?php
12
+ printf(__('<a href="%s">Manage</a> them or <a href="%s">create</a> a new one', ADVADS_SLUG),
13
+ 'edit.php?post_type='. Advanced_Ads::POST_TYPE_SLUG,
14
+ 'post-new.php?post_type='. Advanced_Ads::POST_TYPE_SLUG);
15
+ ?>
16
+ </p>
17
+ </div>
18
+ <div class="advads-content-half">
19
+ <?php if(count($recent_ads) > 0) : ?>
20
+ <h4><?php _e('recent ads', ADVADS_SLUG); ?></h4>
21
+ <ul>
22
+ <?php foreach($recent_ads as $_index => $_ad) : ?>
23
+ <li><a href="<?php echo get_edit_post_link($_ad->ID); ?>"><?php echo $_ad->post_title; ?></a></li><?php
24
+ if($_index == 2) break;
25
+ ?>
26
+ <?php endforeach; ?>
27
+ </ul>
28
+ <?php endif; ?>
29
+ </div>
30
+ <br class="clear"/>
31
+ <div class="advads-content-half">
32
+ <h2><?php _e('Groups', ADVADS_SLUG); ?></h2>
33
+ <p class="description"><?php _e('Ad Groups contain ads and are currently used to rotate multiple ads on a single spot.', ADVADS_SLUG); ?></p>
34
+ <p><?php printf(__('You have %d groups.', ADVADS_SLUG), count($groups)); ?>&nbsp;<?php
35
+ printf(__('<a href="%s">Manage</a> them.', ADVADS_SLUG),
36
+ 'edit.php?post_type='. Advanced_Ads::POST_TYPE_SLUG .'&page=advanced-ads-groups');
37
+ ?></p>
38
+ </div>
39
+ <div class="advads-content-half">
40
+ <?php if(count($groups) > 0) : ?>
41
+ <h4><?php _e('recent groups', ADVADS_SLUG); ?></h4>
42
+ <ul>
43
+ <?php foreach($groups as $_index => $_group) : ?>
44
+ <li><?php echo $_group->name; ?></li><?php
45
+ if($_index == 2) break;
46
+ ?>
47
+ <?php endforeach; ?>
48
+ </ul>
49
+ <?php endif; ?>
50
+ </div>
51
+ <br class="clear"/>
52
+ <div class="advads-content-half">
53
+ <h2><?php _e('Placements', ADVADS_SLUG); ?></h2>
54
+ <p class="description"><?php _e('Ad Placements are the best way to manage where to display ads and groups.', ADVADS_SLUG); ?></p>
55
+ <p><?php printf(__('You have %d placements.', ADVADS_SLUG), count($placements)); ?>&nbsp;<?php
56
+ printf(__('<a href="%s">Manage</a> them.', ADVADS_SLUG),
57
+ 'edit.php?post_type='. Advanced_Ads::POST_TYPE_SLUG .'&page=advanced-ads-placements');
58
+ ?></p>
59
+ </div>
60
+ <div class="advads-content-half">
61
+ <?php if(count($placements) > 0) : ?>
62
+ <h4><?php _e('recent placements', ADVADS_SLUG); ?></h4>
63
+ <ul>
64
+ <?php $_i = 0; foreach($placements as $_index => $_placement) : ?>
65
+ <li><?php echo $_placement['name']; ?></li><?php
66
+ if($_i++ == 2) break;
67
+ ?>
68
+ <?php endforeach; ?>
69
+ </ul>
70
+ <?php endif; ?>
71
+ </div>
72
+ <br class="clear"/>
73
+ <h2><?php _e('Manual and Support', ADVADS_SLUG); ?></h2>
74
+ <p><?php _e('Need some help? These are your options', ADVADS_SLUG); ?></p>
75
+ <ul>
76
+ <li><?php printf(__('Visit the <a href="%s">plugin homepage</a>', ADVADS_SLUG), 'http://wpadvancedads.com/advancedads/'); ?></li>
77
+ <li><?php printf(__('Have a look into the <a href="%s">manual</a>', ADVADS_SLUG), 'http://wpadvancedads.com/advancedads/manual/'); ?></li>
78
+ <li><?php printf(__('Ask a question to other users in the <a href="%s">wordpress.org forum</a>', ADVADS_SLUG), 'http://wordpress.org/plugins/advanced-ads/'); ?></li>
79
+ <li><?php printf(__('<a href="%s">Hire the developer</a>', ADVADS_SLUG), 'http://webgilde.com/en/contact/'); ?></li>
80
+ </ul>
81
+ </div>
advanced-ads.php CHANGED
@@ -12,7 +12,7 @@
12
  * Plugin Name: Advanced Ads
13
  * Plugin URI: http://wpadvancedads.com
14
  * Description: Manage and optimize your ads in WordPress
15
- * Version: 1.2.1
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.com
18
  * Text Domain: advanced-ads
12
  * Plugin Name: Advanced Ads
13
  * Plugin URI: http://wpadvancedads.com
14
  * Description: Manage and optimize your ads in WordPress
15
+ * Version: 1.2.2
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.com
18
  * Text Domain: advanced-ads
classes/ad.php CHANGED
@@ -33,6 +33,16 @@ class Advads_Ad {
33
  */
34
  public $type = 'content';
35
 
 
 
 
 
 
 
 
 
 
 
36
  /**
37
  * object of current ad type
38
  */
@@ -128,7 +138,8 @@ class Advads_Ad {
128
  } else {
129
  $this->type_obj = new Advads_Ad_Type_Abstract;
130
  }
131
-
 
132
  $this->conditions = $this->options('conditions');
133
  $this->status = $_data->post_status;
134
 
@@ -215,6 +226,11 @@ class Advads_Ad {
215
  $options = Advanced_Ads::get_instance()->options();
216
  $see_ads_capability = (!empty($options['hide-for-user-role'])) ? $options['hide-for-user-role'] : 0;
217
 
 
 
 
 
 
218
  // check if user is logged in and if so if users with his rights can see ads
219
  if (is_user_logged_in() && $see_ads_capability && current_user_can($see_ads_capability)) {
220
  return false;
@@ -306,14 +322,21 @@ class Advads_Ad {
306
  break;
307
  // check for included post types
308
  case 'posttypes' :
 
 
309
  if(!empty($_cond_value['include'])){
310
- $post_types = explode(',', $_cond_value['include']);
 
 
 
 
311
  // check if currently in a post (not post page, but also posts in loops)
312
  if(is_array($post_types) && !in_array(get_post_type(), $post_types)) {
313
  return false;
314
  }
315
  }
316
  // check for excluded post types
 
317
  if(!empty($_cond_value['exclude'])){
318
  $post_types = explode(',', $_cond_value['exclude']);
319
  // check if currently in a post (not post page, but also posts in loops)
@@ -419,6 +442,8 @@ class Advads_Ad {
419
  $options = $this->options();
420
 
421
  $options['type'] = $this->type;
 
 
422
  $options['conditions'] = $conditions;
423
 
424
  // filter to manipulate options or add more to be saved
33
  */
34
  public $type = 'content';
35
 
36
+ /**
37
+ * ad width
38
+ */
39
+ public $width = 0;
40
+
41
+ /**
42
+ * ad height
43
+ */
44
+ public $height = 0;
45
+
46
  /**
47
  * object of current ad type
48
  */
138
  } else {
139
  $this->type_obj = new Advads_Ad_Type_Abstract;
140
  }
141
+ $this->width = $this->options('width');
142
+ $this->height = $this->options('height');
143
  $this->conditions = $this->options('conditions');
144
  $this->status = $_data->post_status;
145
 
226
  $options = Advanced_Ads::get_instance()->options();
227
  $see_ads_capability = (!empty($options['hide-for-user-role'])) ? $options['hide-for-user-role'] : 0;
228
 
229
+ // don’t display ads that are not published or private for users not logged in
230
+ if($this->status !== 'publish' && ($this->status === 'private' && !is_user_logged_in())){
231
+ return false;
232
+ }
233
+
234
  // check if user is logged in and if so if users with his rights can see ads
235
  if (is_user_logged_in() && $see_ads_capability && current_user_can($see_ads_capability)) {
236
  return false;
322
  break;
323
  // check for included post types
324
  case 'posttypes' :
325
+ // display everywhere, if include not set (= all is checked)
326
+ // TODO remove condition check for string; deprecated since 1.2.2
327
  if(!empty($_cond_value['include'])){
328
+ if(is_string($_cond_value['include'])){
329
+ $post_types = explode(',', $_cond_value['include']);
330
+ } else {
331
+ $post_types = $_cond_value['include'];
332
+ }
333
  // check if currently in a post (not post page, but also posts in loops)
334
  if(is_array($post_types) && !in_array(get_post_type(), $post_types)) {
335
  return false;
336
  }
337
  }
338
  // check for excluded post types
339
+ // TODO remove in a later version, deprecated since 1.2.2
340
  if(!empty($_cond_value['exclude'])){
341
  $post_types = explode(',', $_cond_value['exclude']);
342
  // check if currently in a post (not post page, but also posts in loops)
442
  $options = $this->options();
443
 
444
  $options['type'] = $this->type;
445
+ $options['width'] = $this->width;
446
+ $options['height'] = $this->height;
447
  $options['conditions'] = $conditions;
448
 
449
  // filter to manipulate options or add more to be saved
includes/array_ad_conditions.php CHANGED
@@ -22,6 +22,12 @@
22
  $advanced_ads_slug = Advanced_Ads::get_instance()->get_plugin_slug();
23
 
24
  $advanced_ads_ad_conditions = array(
 
 
 
 
 
 
25
  'postids' => array(
26
  'label' => __('Single Pages/Posts', $advanced_ads_slug),
27
  'description' => __('comma seperated IDs of post, page or custom post type', $advanced_ads_slug),
@@ -37,11 +43,6 @@ $advanced_ads_ad_conditions = array(
37
  'description' => __('comma seperated IDs of category archives', $advanced_ads_slug),
38
  'type' => 'idfield',
39
  ),
40
- 'posttypes' => array(
41
- 'label' => __('Post Types', $advanced_ads_slug),
42
- 'description' => __('comma seperated list of post types', $advanced_ads_slug),
43
- 'type' => 'textvalues',
44
- ),
45
  'is_front_page' => array(
46
  'label' => __('Home Page', $advanced_ads_slug),
47
  'description' => __('(don’t) show on Home page', $advanced_ads_slug),
22
  $advanced_ads_slug = Advanced_Ads::get_instance()->get_plugin_slug();
23
 
24
  $advanced_ads_ad_conditions = array(
25
+ 'posttypes' => array(
26
+ 'label' => __('Post Types', $advanced_ads_slug),
27
+ 'description' => __('Choose the public post types on which to display the ad.', $advanced_ads_slug),
28
+ 'type' => 'textvalues',
29
+ 'callback' => array('AdvAds_Display_Condition_Callbacks', 'post_types')
30
+ ),
31
  'postids' => array(
32
  'label' => __('Single Pages/Posts', $advanced_ads_slug),
33
  'description' => __('comma seperated IDs of post, page or custom post type', $advanced_ads_slug),
43
  'description' => __('comma seperated IDs of category archives', $advanced_ads_slug),
44
  'type' => 'idfield',
45
  ),
 
 
 
 
 
46
  'is_front_page' => array(
47
  'label' => __('Home Page', $advanced_ads_slug),
48
  'description' => __('(don’t) show on Home page', $advanced_ads_slug),
public/class-advanced-ads.php CHANGED
@@ -25,7 +25,7 @@ class Advanced_Ads {
25
  * @var string
26
  */
27
 
28
- const VERSION = '1.2.1';
29
 
30
  /**
31
  * post type slug
@@ -492,7 +492,7 @@ class Advanced_Ads {
492
  'update_item' => __('Update Ad Group', $this->plugin_slug),
493
  'add_new_item' => __('Add New Ad Group', $this->plugin_slug),
494
  'new_item_name' => __('New Ad Groups Name', $this->plugin_slug),
495
- 'menu_name' => __('Ad Groups', $this->plugin_slug),
496
  'not_found' => __('No Ad Group found', $this->plugin_slug),
497
  );
498
 
@@ -520,7 +520,7 @@ class Advanced_Ads {
520
  $labels = array(
521
  'name' => __('Ads', $this->plugin_slug),
522
  'singular_name' => __('Ad', $this->plugin_slug),
523
- 'add_new' => 'Add New',
524
  'add_new_item' => __('Add New Ad', $this->plugin_slug),
525
  'edit' => __('Edit', $this->plugin_slug),
526
  'edit_item' => __('Edit Ad', $this->plugin_slug),
25
  * @var string
26
  */
27
 
28
+ const VERSION = '1.2.2';
29
 
30
  /**
31
  * post type slug
492
  'update_item' => __('Update Ad Group', $this->plugin_slug),
493
  'add_new_item' => __('Add New Ad Group', $this->plugin_slug),
494
  'new_item_name' => __('New Ad Groups Name', $this->plugin_slug),
495
+ 'menu_name' => __('Groups', $this->plugin_slug),
496
  'not_found' => __('No Ad Group found', $this->plugin_slug),
497
  );
498
 
520
  $labels = array(
521
  'name' => __('Ads', $this->plugin_slug),
522
  'singular_name' => __('Ad', $this->plugin_slug),
523
+ 'add_new' => 'New Ad',
524
  'add_new_item' => __('Add New Ad', $this->plugin_slug),
525
  'edit' => __('Edit', $this->plugin_slug),
526
  'edit_item' => __('Edit Ad', $this->plugin_slug),
readme.txt CHANGED
@@ -3,26 +3,28 @@ Contributors: webzunft
3
  Tags: ads, ad, adsense, display, banner, advertisements, adverts, advert, monetization
4
  Requires at least: 3.5
5
  Tested up to: 4.0.0
6
- Stable tag: 1.2.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
- Manage and optimize your ads in WordPress as easy as creating posts.
11
 
12
  == Description ==
13
 
14
- Advanced Ads is made by publishers for publishers. Based on my experience delivering millions of ads per month I build this plugin as a powerful, but light weight solution to not only manage and serve ads in WordPress, but to test and optimize them as well.
15
 
16
  Learn more on the [plugin homepage](http://wpadvancedads.com).
17
 
18
  = create and manage ads =
19
 
20
  * create ads as easy as creating posts
21
- * group ads
 
 
22
 
23
  = display ads =
24
 
25
- * auto inject ads into header, footer and posts content
26
  * display ad in template files (with functions)
27
  * display ad in post content (with shortcodes)
28
  * widget to display ads in widget areas (sidebars)
@@ -46,6 +48,18 @@ display ads by conditions based on the visitor
46
  * all devices, mobile only or exclude mobile users
47
  * hide all ads from logged in users based on their role
48
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  = based on WordPress standards =
50
 
51
  * integrated into WordPress using standards like custom post types, taxonomies and hooks
@@ -119,7 +133,19 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
119
 
120
  == Changelog ==
121
 
122
- = 1.2.1 ==
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
  major changes:
125
 
3
  Tags: ads, ad, adsense, display, banner, advertisements, adverts, advert, monetization
4
  Requires at least: 3.5
5
  Tested up to: 4.0.0
6
+ Stable tag: 1.2.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
+ Manage and optimize your ads in WordPress as easy as creating posts. + ad injection, ad planning and ad rotation.
11
 
12
  == Description ==
13
 
14
+ Advanced Ads is a simple ad manager made by publishers for publishers. Based on my experience delivering millions of ads per month I build this plugin as a powerful, but light weight solution to not only manage and serve ads in WordPress, but to test and optimize them as well.
15
 
16
  Learn more on the [plugin homepage](http://wpadvancedads.com).
17
 
18
  = create and manage ads =
19
 
20
  * create ads as easy as creating posts
21
+ * group ads to create ad rotations
22
+ * create drafts or ads only visible to logged in users
23
+ * set a date for when to publish the ad
24
 
25
  = display ads =
26
 
27
+ * auto inject ads (see _ad injection_ below)
28
  * display ad in template files (with functions)
29
  * display ad in post content (with shortcodes)
30
  * widget to display ads in widget areas (sidebars)
48
  * all devices, mobile only or exclude mobile users
49
  * hide all ads from logged in users based on their role
50
 
51
+ = ad injection =
52
+
53
+ Advanced Ads comes with many options for ad injection (= display ads without the need to alter content or code)
54
+
55
+ * inject ads into header and footer
56
+ * inject ads into posts content (top, bottom, by paragraph)
57
+
58
+ = ad networks =
59
+
60
+ Advanced Ads is compatible with all ad networks and banners from affiliate programs like Google AdSense, Chitika, Clickbank, Amazon, etc.
61
+ You can also use it to add additional ad network tags into header or footer of your site without additional coding)
62
+
63
  = based on WordPress standards =
64
 
65
  * integrated into WordPress using standards like custom post types, taxonomies and hooks
133
 
134
  == Changelog ==
135
 
136
+ = 1.2.2 =
137
+
138
+ major changes
139
+
140
+ * added overview page
141
+ * new layout for display condition check for post types
142
+ * added ad width and height values
143
+
144
+ fixes:
145
+
146
+ * don’t display ads that are not published or visible to logged in users only
147
+
148
+ = 1.2.1 =
149
 
150
  major changes:
151