Advanced Ads - Version 1.3.11

Version Description

  • COOL: disable ads completely, on 404 pages or for non-singular pages with a single click
  • renamed hooks starting with advads to advanced-ads for better names consistency
  • ordered ads by ad title not by date in placement and widget ad select list

Good to know: AdSense does not allow ads on 404 pages, so if you use AdSense a lot, be sure to check this new option on your settings page.

Download this release

Release Info

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

Code changes from version 1.3.10 to 1.3.11

admin/class-advanced-ads-admin.php CHANGED
@@ -577,6 +577,14 @@ class Advanced_Ads_Admin {
577
  $hook
578
  );
579
 
 
 
 
 
 
 
 
 
580
  // add setting fields for user role
581
  add_settings_field(
582
  'hide-for-user-role',
@@ -604,6 +612,26 @@ class Advanced_Ads_Admin {
604
  // for whatever purpose there might come
605
  }
606
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
  /**
608
  * render setting to hide ads from logged in users
609
  *
577
  $hook
578
  );
579
 
580
+ // add setting fields to disable ads
581
+ add_settings_field(
582
+ 'disable-ads',
583
+ __('Disable ads', ADVADS_SLUG),
584
+ array($this, 'render_settings_disable_ads'),
585
+ $hook,
586
+ 'advanced_ads_setting_section'
587
+ );
588
  // add setting fields for user role
589
  add_settings_field(
590
  'hide-for-user-role',
612
  // for whatever purpose there might come
613
  }
614
 
615
+ /**
616
+ * options to disable ads
617
+ *
618
+ * @since 1.3.11
619
+ */
620
+ public function render_settings_disable_ads(){
621
+ $options = Advanced_Ads::get_instance()->options();
622
+
623
+ // set the variables
624
+ $disable_all = isset($options['disabled-ads']['all']) ? 1 : 0;
625
+ $disable_404 = isset($options['disabled-ads']['404']) ? 1 : 0;
626
+ $disable_archives = isset($options['disabled-ads']['archives']) ? 1 : 0;
627
+
628
+ // load the template
629
+ $view = plugin_dir_path(__FILE__) . 'views/settings_disable_ads.php';
630
+ if (is_file($view)) {
631
+ require( $view );
632
+ }
633
+ }
634
+
635
  /**
636
  * render setting to hide ads from logged in users
637
  *
admin/views/placements.php CHANGED
@@ -75,7 +75,7 @@
75
  <td><?php echo (isset($_placement['type']) && !empty($placement_types[$_placement['type']]['title'])) ? $placement_types[$_placement['type']]['title'] : __('default', ADVADS_SLUG); ?></td>
76
  <th><?php echo $_placement_slug; ?></th>
77
  <td class="advads-placements-table-options">
78
- <?php do_action('advads-placement-options-before', $_placement_slug, $_placement);
79
  $items = Advads_Ad_Placements::items_for_select(); ?>
80
  <label for="adsads-placements-item-<?php echo $_placement_slug; ?>"><?php _e('Item', ADVADS_SLUG); ?></label>
81
  <select id="adsads-placements-item-<?php echo $_placement_slug; ?>" name="advads[placements][<?php echo $_placement_slug; ?>][item]">
@@ -120,7 +120,7 @@
120
  </div><?php
121
  break;
122
  endswitch;
123
- do_action('advads-placement-options-after', $_placement_slug, $_placement);
124
  ?>
125
  </td>
126
  <td>
75
  <td><?php echo (isset($_placement['type']) && !empty($placement_types[$_placement['type']]['title'])) ? $placement_types[$_placement['type']]['title'] : __('default', ADVADS_SLUG); ?></td>
76
  <th><?php echo $_placement_slug; ?></th>
77
  <td class="advads-placements-table-options">
78
+ <?php do_action('advanced-ads-placement-options-before', $_placement_slug, $_placement);
79
  $items = Advads_Ad_Placements::items_for_select(); ?>
80
  <label for="adsads-placements-item-<?php echo $_placement_slug; ?>"><?php _e('Item', ADVADS_SLUG); ?></label>
81
  <select id="adsads-placements-item-<?php echo $_placement_slug; ?>" name="advads[placements][<?php echo $_placement_slug; ?>][item]">
120
  </div><?php
121
  break;
122
  endswitch;
123
+ do_action('advanced-ads-placement-options-after', $_placement_slug, $_placement);
124
  ?>
125
  </td>
126
  <td>
admin/views/settings_disable_ads.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <label><input id="advanced-ads-disable-ads-all" type="checkbox" value="1" name="<?php
2
+ echo ADVADS_SLUG ?>[disabled-ads][all]" <?php checked($disable_all, 1);
3
+ ?>><?php _e('Disable all ads in frontend', ADVADS_SLUG); ?></label>
4
+ <p class="description"><?php _e('Use this option to disable all ads in the frontend, but still be able to use the plugin.', ADVADS_SLUG); ?></p>
5
+
6
+ <label><input id="advanced-ads-disable-ads-404" type="checkbox" value="1" name="<?php
7
+ echo ADVADS_SLUG; ?>[disabled-ads][404]" <?php checked($disable_404, 1);
8
+ ?>><?php _e('Disable ads on 404 error pages', ADVADS_SLUG); ?></label>
9
+
10
+ <br/><label><input id="advanced-ads-disable-ads-archives" type="checkbox" value="1" name="<?php
11
+ echo ADVADS_SLUG; ?>[disabled-ads][archives]" <?php checked($disable_archives, 1);
12
+ ?>><?php _e('Disable ads on non-singular pages', ADVADS_SLUG); ?></label>
13
+ <p class="description"><?php _e('e.g. archive pages like categories, tags, authors, front page (if a list)', ADVADS_SLUG); ?></p>
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.3.10
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.3.11
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.com
18
  * Text Domain: advanced-ads
classes/ad_placements.php CHANGED
@@ -52,7 +52,7 @@ class Advads_Ad_Placements {
52
  'description' => __('Injected into the post content. You can choose the paragraph after which the ad content is displayed.', ADVADS_SLUG),
53
  ),
54
  );
55
- return apply_filters('advads-placement-types', $types);
56
  }
57
 
58
  /**
@@ -144,7 +144,7 @@ class Advads_Ad_Placements {
144
  }
145
 
146
  // load all ads
147
- $ads = Advanced_Ads::get_ads();
148
  foreach ($ads as $_ad) {
149
  $select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
150
  }
52
  'description' => __('Injected into the post content. You can choose the paragraph after which the ad content is displayed.', ADVADS_SLUG),
53
  ),
54
  );
55
+ return apply_filters('advanced-ads-placement-types', $types);
56
  }
57
 
58
  /**
144
  }
145
 
146
  // load all ads
147
+ $ads = Advanced_Ads::get_ads(array('orderby' => 'name', 'order' => 'ASC'));
148
  foreach ($ads as $_ad) {
149
  $select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
150
  }
classes/widget.php CHANGED
@@ -82,7 +82,7 @@ class Advads_Widget extends WP_Widget {
82
  $select = array();
83
 
84
  // load all ads
85
- $ads = Advanced_Ads::get_ads();
86
  foreach($ads as $_ad){
87
  $select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
88
  }
82
  $select = array();
83
 
84
  // load all ads
85
+ $ads = Advanced_Ads::get_ads(array('orderby' => 'name', 'order' => 'ASC'));
86
  foreach($ads as $_ad){
87
  $select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
88
  }
public/class-advanced-ads.php CHANGED
@@ -104,7 +104,7 @@ class Advanced_Ads {
104
  register_activation_hook(__FILE__, array($this,'post_types_rewrite_flush'));
105
 
106
  // register hook for global constants
107
- add_action('wp', array($this, 'set_global_constants'));
108
 
109
  // add short codes
110
  add_shortcode('the_ad', array($this, 'shortcode_display_ad'));
@@ -135,18 +135,42 @@ class Advanced_Ads {
135
  }
136
 
137
  /**
138
- * set global constants for the current page view
139
  *
140
  * @since 1.3.10
141
  */
142
- public function set_global_constants(){
143
 
144
  global $post;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  // check if ads are disabled on the current page
146
- if(is_singular() && isset($post->ID) && !defined('ADVADS_ADS_DISABLED')){
147
- $options = get_post_meta( $post->ID, '_advads_ad_settings', true );
148
 
149
- if(!empty($options['disable_ads'])){
150
  define('ADVADS_ADS_DISABLED', true);
151
  }
152
  };
104
  register_activation_hook(__FILE__, array($this,'post_types_rewrite_flush'));
105
 
106
  // register hook for global constants
107
+ add_action('wp', array($this, 'set_disabled_constant'));
108
 
109
  // add short codes
110
  add_shortcode('the_ad', array($this, 'shortcode_display_ad'));
135
  }
136
 
137
  /**
138
+ * set global constant that prevents ads from being displayed on the current page view
139
  *
140
  * @since 1.3.10
141
  */
142
+ public function set_disabled_constant(){
143
 
144
  global $post;
145
+
146
+ // don't set the constant if already defined
147
+ if(defined('ADVADS_ADS_DISABLED')) return;
148
+
149
+ $options = $this->options();
150
+
151
+ // check if ads are disabled completely
152
+ if(!empty($options['disabled-ads']['all'])){
153
+ define('ADVADS_ADS_DISABLED', true);
154
+ return;
155
+ }
156
+
157
+ // check if ads are disabled from 404 pages
158
+ if(is_404() && !empty($options['disabled-ads']['404'])){
159
+ define('ADVADS_ADS_DISABLED', true);
160
+ return;
161
+ }
162
+
163
+ // check if ads are disabled from non singular pages (often = archives)
164
+ if(!is_singular() && !empty($options['disabled-ads']['archives'])){
165
+ define('ADVADS_ADS_DISABLED', true);
166
+ return;
167
+ }
168
+
169
  // check if ads are disabled on the current page
170
+ if(is_singular() && isset($post->ID)){
171
+ $post_ad_options = get_post_meta( $post->ID, '_advads_ad_settings', true );
172
 
173
+ if(!empty($post_ad_options['disable_ads'])){
174
  define('ADVADS_ADS_DISABLED', true);
175
  }
176
  };
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id
4
  Tags: ads, ad, adsense, display, banner, advertisements, adverts, advert, monetization
5
  Requires at least: WP 3.5, PHP 5.3
6
  Tested up to: 4.1.
7
- Stable tag: 1.3.10
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -148,6 +148,14 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
148
 
149
  == Changelog ==
150
 
 
 
 
 
 
 
 
 
151
  = 1.3.10 =
152
 
153
  * COOL: disable all ads on individual single pages
4
  Tags: ads, ad, adsense, display, banner, advertisements, adverts, advert, monetization
5
  Requires at least: WP 3.5, PHP 5.3
6
  Tested up to: 4.1.
7
+ Stable tag: 1.3.11
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
148
 
149
  == Changelog ==
150
 
151
+ = 1.3.11 =
152
+
153
+ * COOL: disable ads completely, on 404 pages or for non-singular pages with a single click
154
+ * renamed hooks starting with _advads_ to _advanced-ads_ for better names consistency
155
+ * ordered ads by ad title not by date in placement and widget ad select list
156
+
157
+ Good to know: AdSense does not allow ads on 404 pages, so if you use AdSense a lot, be sure to check this new option on your settings page.
158
+
159
  = 1.3.10 =
160
 
161
  * COOL: disable all ads on individual single pages