Advanced Ads - Version 1.5.5

Version Description

  • fixed outdated links to the manual and feature requests
  • added hooks and options to be able to extend ad groups
Download this release

Release Info

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

Code changes from version 1.5.4.1 to 1.5.5

admin/includes/class-ad-groups-list.php CHANGED
@@ -311,10 +311,15 @@ class Advanced_Ads_Groups_List {
311
  // save other attributes
312
  $type = isset($_group['type']) ? $_group['type'] : 'default';
313
  $ad_count = isset($_group['ad_count']) ? $_group['ad_count'] : 1;
314
- $atts = array(
 
 
 
315
  'type' => $type,
316
- 'ad_count' => $ad_count
317
- );
 
 
318
  $group->save( $atts );
319
  }
320
  }
311
  // save other attributes
312
  $type = isset($_group['type']) ? $_group['type'] : 'default';
313
  $ad_count = isset($_group['ad_count']) ? $_group['ad_count'] : 1;
314
+ $options = isset($_group['options']) ? $_group['options'] : array();
315
+
316
+ // allow other add-ons to save their own group attributes
317
+ $atts = apply_filters( 'advanced-ads-group-save-atts', array(
318
  'type' => $type,
319
+ 'ad_count' => $ad_count,
320
+ 'options' => $options,
321
+ ), $_group);
322
+
323
  $group->save( $atts );
324
  }
325
  }
admin/includes/class-overview-widgets.php CHANGED
@@ -134,9 +134,9 @@ foreach ( $next_steps as $_step ){
134
  public static function render_support(){
135
  ?><ul>
136
  <li><?php printf( __( '<a href="%s" target="_blank">Plugin Homepage</a>', ADVADS_SLUG ), ADVADS_URL . 'advancedads/' ); ?> –
137
- <?php printf( __( '<a href="%s" target="_blank">Manual</a>', ADVADS_SLUG ), ADVADS_URL . 'advancedads/manual/' ); ?></li>
138
  <li><?php printf( __( 'Ask other users in the <a href="%s" target="_blank">wordpress.org forum</a>', ADVADS_SLUG ), 'http://wordpress.org/plugins/advanced-ads/' ); ?></li>
139
- <li><?php printf( __( 'Vote for a <a href="%s" target="_blank">feature</a>', ADVADS_SLUG ), ADVADS_URL . 'advancedads/feature-requests/' ); ?></li>
140
  <li><?php printf( __( 'Thank the developer with a &#9733;&#9733;&#9733;&#9733;&#9733; review on <a href="%s" target="_blank">wordpress.org</a>', ADVADS_SLUG ), 'https://wordpress.org/support/view/plugin-reviews/advanced-ads' ); ?></li>
141
  </ul><?php
142
  }
134
  public static function render_support(){
135
  ?><ul>
136
  <li><?php printf( __( '<a href="%s" target="_blank">Plugin Homepage</a>', ADVADS_SLUG ), ADVADS_URL . 'advancedads/' ); ?> –
137
+ <?php printf( __( '<a href="%s" target="_blank">Manual</a>', ADVADS_SLUG ), ADVADS_URL . 'manual/' ); ?></li>
138
  <li><?php printf( __( 'Ask other users in the <a href="%s" target="_blank">wordpress.org forum</a>', ADVADS_SLUG ), 'http://wordpress.org/plugins/advanced-ads/' ); ?></li>
139
+ <li><?php printf( __( 'Vote for a <a href="%s" target="_blank">feature</a>', ADVADS_SLUG ), ADVADS_URL . 'feature-requests/' ); ?></li>
140
  <li><?php printf( __( 'Thank the developer with a &#9733;&#9733;&#9733;&#9733;&#9733; review on <a href="%s" target="_blank">wordpress.org</a>', ADVADS_SLUG ), 'https://wordpress.org/support/view/plugin-reviews/advanced-ads' ); ?></li>
141
  </ul><?php
142
  }
admin/views/ad-display-metabox.php CHANGED
@@ -14,7 +14,7 @@ $jquery_ui_buttons = array();
14
  <ul id="advads-how-it-works">
15
  <li><?php _e( 'If you want to display the ad everywhere, don\'t do anything here. ', ADVADS_SLUG ); ?></li>
16
  <li><?php _e( 'The fewer conditions you enter, the better the performance will be.', ADVADS_SLUG ); ?></li>
17
- <li><?php printf( __( 'Learn more about display conditions from the <a href="%s" target="_blank">manual</a>.', ADVADS_SLUG ), ADVADS_URL . 'advancedads/manual/display-conditions/' ); ?></li>
18
  </ul>
19
  <?php
20
  // -TODO use model
14
  <ul id="advads-how-it-works">
15
  <li><?php _e( 'If you want to display the ad everywhere, don\'t do anything here. ', ADVADS_SLUG ); ?></li>
16
  <li><?php _e( 'The fewer conditions you enter, the better the performance will be.', ADVADS_SLUG ); ?></li>
17
+ <li><?php printf( __( 'Learn more about display conditions from the <a href="%s" target="_blank">manual</a>.', ADVADS_SLUG ), ADVADS_URL . 'manual/display-conditions/' ); ?></li>
18
  </ul>
19
  <?php
20
  // -TODO use model
admin/views/ad-group-list-form-row.php CHANGED
@@ -5,7 +5,7 @@
5
  <label><strong><?php _e( 'Description', ADVADS_SLUG ); ?></strong><input type="text" name="advads-groups[<?php
6
  echo $group->id; ?>][description]" value="<?php echo $group->description; ?>"/></label><br/>
7
  <strong><?php _e( 'Type', ADVADS_SLUG ); ?></strong>
8
- <ul><?php foreach ( $this->types as $_type_key => $_type ) :
9
  ?><li><label><input type="radio" name="advads-groups[<?php echo $group->id;
10
  ?>][type]" value="<?php echo $_type_key; ?>" <?php checked( $group->type, $_type_key )?>/><?php
11
  echo $_type['title']; ?></label>
@@ -21,6 +21,7 @@
21
  </select>
22
  </label>
23
  <p class="description"><?php _e( 'Number of ads to display in the block', ADVADS_SLUG ); ?></p>
 
24
  <h3><?php _e( 'Ads', ADVADS_SLUG ); ?></h3>
25
  <?php if ( count( $ad_form_rows ) ) : ?>
26
  <table>
5
  <label><strong><?php _e( 'Description', ADVADS_SLUG ); ?></strong><input type="text" name="advads-groups[<?php
6
  echo $group->id; ?>][description]" value="<?php echo $group->description; ?>"/></label><br/>
7
  <strong><?php _e( 'Type', ADVADS_SLUG ); ?></strong>
8
+ <ul class="advads-ad-group-type"><?php foreach ( $this->types as $_type_key => $_type ) :
9
  ?><li><label><input type="radio" name="advads-groups[<?php echo $group->id;
10
  ?>][type]" value="<?php echo $_type_key; ?>" <?php checked( $group->type, $_type_key )?>/><?php
11
  echo $_type['title']; ?></label>
21
  </select>
22
  </label>
23
  <p class="description"><?php _e( 'Number of ads to display in the block', ADVADS_SLUG ); ?></p>
24
+ <?php do_action( 'advanced-ads-group-form-options', $group ); ?>
25
  <h3><?php _e( 'Ads', ADVADS_SLUG ); ?></h3>
26
  <?php if ( count( $ad_form_rows ) ) : ?>
27
  <table>
admin/views/ad-group-list-row.php CHANGED
@@ -11,7 +11,7 @@
11
  <label><?php _e( 'template', ADVADS_SLUG ); ?>
12
  <code><input type="text" onclick="this.select();" value="the_ad_group(<?php echo $group->id; ?>);"/></code>
13
  </label>
14
- <p><?php printf( __( 'Learn more about using groups in the <a href="%s" target="_blank">manual</a>.', ADVADS_SLUG ), ADVADS_URL . 'advanced-ads/manual/ad-groups/' ); ?></p>
15
  </div>
16
  </td>
17
  <td>
11
  <label><?php _e( 'template', ADVADS_SLUG ); ?>
12
  <code><input type="text" onclick="this.select();" value="the_ad_group(<?php echo $group->id; ?>);"/></code>
13
  </label>
14
+ <p><?php printf( __( 'Learn more about using groups in the <a href="%s" target="_blank">manual</a>.', ADVADS_SLUG ), ADVADS_URL . 'manual/ad-groups/' ); ?></p>
15
  </div>
16
  </td>
17
  <td>
admin/views/ad-group.php CHANGED
@@ -59,7 +59,7 @@ if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) || iss
59
  <div id="ajax-response"></div>
60
  <a onclick="advads_toggle('#advads-ad-group-display-info')"><?php _e( 'How to display an Ad Group?', ADVADS_SLUG ); ?></a>
61
  <div id="advads-ad-group-display-info" style="display: none;">
62
- <p><?php printf( __( 'Examples on how to display an ad group? Find more help and examples in the <a href="%s" target="_blank">manual</a>', ADVADS_SLUG ), ADVADS_URL . 'advanced-ads/manual/ad-groups/' ); ?></p>
63
  <h4><?php _e( 'shortcode', ADVADS_SLUG ); ?></h4>
64
  <p class="description"><?php _e( 'To display an ad group with the ID 6 in content fields', ADVADS_SLUG ); ?></p>
65
  <pre><input type="text" onclick="this.select();" style="width: 250px;" value='[the_ad_group id="6"]'/></pre>
59
  <div id="ajax-response"></div>
60
  <a onclick="advads_toggle('#advads-ad-group-display-info')"><?php _e( 'How to display an Ad Group?', ADVADS_SLUG ); ?></a>
61
  <div id="advads-ad-group-display-info" style="display: none;">
62
+ <p><?php printf( __( 'Examples on how to display an ad group? Find more help and examples in the <a href="%s" target="_blank">manual</a>', ADVADS_SLUG ), ADVADS_URL . 'manual/ad-groups/' ); ?></p>
63
  <h4><?php _e( 'shortcode', ADVADS_SLUG ); ?></h4>
64
  <p class="description"><?php _e( 'To display an ad group with the ID 6 in content fields', ADVADS_SLUG ); ?></p>
65
  <pre><input type="text" onclick="this.select();" style="width: 250px;" value='[the_ad_group id="6"]'/></pre>
admin/views/ad-info.php CHANGED
@@ -2,7 +2,7 @@
2
  <a onclick="advads_toggle('#advads-ad-info')"><?php _e( 'How to use this Ad?', ADVADS_SLUG ); ?></a>
3
  </p>
4
  <div id="advads-ad-info" style="display: none;">
5
- <p><?php printf( __( 'How to display the ad directly? Find more help and examples in the <a href="%s" target="_blank">manual</a>', ADVADS_SLUG ), ADVADS_URL . 'advanced-ads/manual/display-ads/' ); ?></p>
6
  <h4><?php _e( 'shortcode', ADVADS_SLUG ); ?></h4>
7
  <p class="description"><?php _e( 'To display an ad in content fields', ADVADS_SLUG ); ?></p>
8
  <pre><input type="text" onclick="this.select();" value='[the_ad id="<?php echo $post->ID; ?>"]'/></pre>
2
  <a onclick="advads_toggle('#advads-ad-info')"><?php _e( 'How to use this Ad?', ADVADS_SLUG ); ?></a>
3
  </p>
4
  <div id="advads-ad-info" style="display: none;">
5
+ <p><?php printf( __( 'How to display the ad directly? Find more help and examples in the <a href="%s" target="_blank">manual</a>', ADVADS_SLUG ), ADVADS_URL . 'manual/display-ads/' ); ?></p>
6
  <h4><?php _e( 'shortcode', ADVADS_SLUG ); ?></h4>
7
  <p class="description"><?php _e( 'To display an ad in content fields', ADVADS_SLUG ); ?></p>
8
  <pre><input type="text" onclick="this.select();" value='[the_ad id="<?php echo $post->ID; ?>"]'/></pre>
admin/views/placements.php CHANGED
@@ -13,12 +13,12 @@
13
  <?php screen_icon(); ?>
14
  <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
15
  <p class="description"><?php _e( 'Placements are physically places in your theme and posts. You can use them if you plan to change ads and ad groups on the same place without the need to change your templates.', ADVADS_SLUG ); ?></p>
16
- <p class="description"><?php printf( __( 'See also the manual for more information on <a href="%s">placements</a> and <a href="%s">auto injection</a>.', ADVADS_SLUG ), ADVADS_URL . 'advancedads/manual/placements/', ADVADS_URL . 'advancedads/manual/auto-injection/' ); ?></p>
17
  <?php if ( isset($placements) && is_array( $placements ) && count( $placements ) ) : ?>
18
  <h2><?php _e( 'Placements', ADVADS_SLUG ); ?></h2>
19
  <a onclick="advads_toggle('#advads-ad-place-display-info')"><?php _e( 'How to use the <i>default</i> Ad Placement?', ADVADS_SLUG ); ?></a>
20
  <div id="advads-ad-place-display-info" style="display: none;">
21
- <p><?php printf( __( 'Examples on how to use the <i>default</i> ad placement? Find more help and examples in the <a href="%s" target="_blank">manual</a>', ADVADS_SLUG ), ADVADS_URL . 'advanced-ads/manual/placements/' ); ?></p>
22
  <h4><?php _e( 'shortcode', ADVADS_SLUG ); ?></h4>
23
  <p class="description"><?php _e( 'To use an ad placement with the ID skyscraper_left in content fields', ADVADS_SLUG ); ?></p>
24
  <pre><input type="text" onclick="this.select();" style="width: 400px;" value='[the_ad_placement id="skyscraper_left"]'/></pre>
13
  <?php screen_icon(); ?>
14
  <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
15
  <p class="description"><?php _e( 'Placements are physically places in your theme and posts. You can use them if you plan to change ads and ad groups on the same place without the need to change your templates.', ADVADS_SLUG ); ?></p>
16
+ <p class="description"><?php printf( __( 'See also the manual for more information on <a href="%s">placements</a> and <a href="%s">auto injection</a>.', ADVADS_SLUG ), ADVADS_URL . 'manual/placements/', ADVADS_URL . 'manual/auto-injection/' ); ?></p>
17
  <?php if ( isset($placements) && is_array( $placements ) && count( $placements ) ) : ?>
18
  <h2><?php _e( 'Placements', ADVADS_SLUG ); ?></h2>
19
  <a onclick="advads_toggle('#advads-ad-place-display-info')"><?php _e( 'How to use the <i>default</i> Ad Placement?', ADVADS_SLUG ); ?></a>
20
  <div id="advads-ad-place-display-info" style="display: none;">
21
+ <p><?php printf( __( 'Examples on how to use the <i>default</i> ad placement? Find more help and examples in the <a href="%s" target="_blank">manual</a>', ADVADS_SLUG ), ADVADS_URL . 'manual/placements/' ); ?></p>
22
  <h4><?php _e( 'shortcode', ADVADS_SLUG ); ?></h4>
23
  <p class="description"><?php _e( 'To use an ad placement with the ID skyscraper_left in content fields', ADVADS_SLUG ); ?></p>
24
  <pre><input type="text" onclick="this.select();" style="width: 400px;" value='[the_ad_placement id="skyscraper_left"]'/></pre>
advanced-ads.php CHANGED
@@ -12,7 +12,7 @@
12
  * Plugin Name: Advanced Ads
13
  * Plugin URI: https://wpadvancedads.com
14
  * Description: Manage and optimize your ads in WordPress
15
- * Version: 1.5.4.1
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.com
18
  * Text Domain: advanced-ads
@@ -38,7 +38,7 @@ define( 'ADVADS_BASE_DIR', dirname( plugin_basename( __FILE__ ) ) ); // director
38
  // general and global slug, e.g. to store options in WP, textdomain
39
  define( 'ADVADS_SLUG', 'advanced-ads' );
40
  define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
41
- define( 'ADVADS_VERSION', '1.5.4.1' );
42
 
43
  /*----------------------------------------------------------------------------*
44
  * Autoloading, modules and functions
12
  * Plugin Name: Advanced Ads
13
  * Plugin URI: https://wpadvancedads.com
14
  * Description: Manage and optimize your ads in WordPress
15
+ * Version: 1.5.5
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.com
18
  * Text Domain: advanced-ads
38
  // general and global slug, e.g. to store options in WP, textdomain
39
  define( 'ADVADS_SLUG', 'advanced-ads' );
40
  define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
41
+ define( 'ADVADS_VERSION', '1.5.5' );
42
 
43
  /*----------------------------------------------------------------------------*
44
  * Autoloading, modules and functions
classes/ad_group.php CHANGED
@@ -70,6 +70,13 @@ class Advanced_Ads_Group {
70
  */
71
  public $ad_count = 1;
72
 
 
 
 
 
 
 
 
73
  /**
74
  * containing ad weights
75
  */
@@ -129,6 +136,10 @@ class Advanced_Ads_Group {
129
  if(isset($all_groups[$this->id]['ad_count'])){
130
  $this->ad_count = ($all_groups[$this->id]['ad_count'] === 'all' ) ? 'all' : absint( $all_groups[$this->id]['ad_count'] );
131
  }
 
 
 
 
132
  }
133
 
134
  /**
@@ -165,8 +176,10 @@ class Advanced_Ads_Group {
165
  $ordered_ad_ids = $this->shuffle_ads($ads, $weights);
166
  }
167
 
 
 
168
  // load the ad output
169
- $output = '';
170
  $ads_displayed = 0;
171
  foreach ( $ordered_ad_ids as $_ad_id ) {
172
  // +TODO should use ad-selection interface to output actual ad
@@ -174,7 +187,7 @@ class Advanced_Ads_Group {
174
  // load the ad object
175
  $ad = new Advanced_Ads_Ad( $_ad_id );
176
  if ( $ad->can_display() ) {
177
- $output .= $ad->output();
178
  $ads_displayed++;
179
  if( $ads_displayed === $this->ad_count ) {
180
  break;
@@ -187,8 +200,10 @@ class Advanced_Ads_Group {
187
  $advads = Advanced_Ads::get_instance();
188
  $advads->current_ads[] = array('type' => 'group', 'id' => $this->id, 'title' => $this->name);
189
 
190
- // filter again, in case a developer wants to filter group output individually
191
- return apply_filters( 'advanced-ads-group-output', $output, $this );
 
 
192
  }
193
 
194
  /**
@@ -329,7 +344,7 @@ class Advanced_Ads_Group {
329
  */
330
  public function save($args = array()) {
331
 
332
- $defaults = array( 'type' => 'default', 'ad_count' => 1 );
333
  $args = wp_parse_args($args, $defaults);
334
 
335
  // get global ad group option
70
  */
71
  public $ad_count = 1;
72
 
73
+ /**
74
+ * contains other options
75
+ *
76
+ * @since 1.5.5
77
+ */
78
+ public $options = array();
79
+
80
  /**
81
  * containing ad weights
82
  */
136
  if(isset($all_groups[$this->id]['ad_count'])){
137
  $this->ad_count = ($all_groups[$this->id]['ad_count'] === 'all' ) ? 'all' : absint( $all_groups[$this->id]['ad_count'] );
138
  }
139
+
140
+ if(isset($all_groups[$this->id]['options'])){
141
+ $this->options = isset( $all_groups[$this->id]['options'] ) ? $all_groups[$this->id]['options'] : array();
142
+ }
143
  }
144
 
145
  /**
176
  $ordered_ad_ids = $this->shuffle_ads($ads, $weights);
177
  }
178
 
179
+ $ordered_ad_ids = apply_filters( 'advanced-ads-group-output-ad-ids', $ordered_ad_ids, $this->type, $ads, $weights );
180
+
181
  // load the ad output
182
+ $output = array();
183
  $ads_displayed = 0;
184
  foreach ( $ordered_ad_ids as $_ad_id ) {
185
  // +TODO should use ad-selection interface to output actual ad
187
  // load the ad object
188
  $ad = new Advanced_Ads_Ad( $_ad_id );
189
  if ( $ad->can_display() ) {
190
+ $output[] = $ad->output();
191
  $ads_displayed++;
192
  if( $ads_displayed === $this->ad_count ) {
193
  break;
200
  $advads = Advanced_Ads::get_instance();
201
  $advads->current_ads[] = array('type' => 'group', 'id' => $this->id, 'title' => $this->name);
202
 
203
+ // filter grouped ads output
204
+ $output_string = implode( '', apply_filters( 'advanced-ads-group-output-array', $output, $this ) );
205
+ // filter final group output
206
+ return apply_filters( 'advanced-ads-group-output', $output_string, $this );
207
  }
208
 
209
  /**
344
  */
345
  public function save($args = array()) {
346
 
347
+ $defaults = array( 'type' => 'default', 'ad_count' => 1, 'options' => array() );
348
  $args = wp_parse_args($args, $defaults);
349
 
350
  // get global ad group option
public/class-advanced-ads.php CHANGED
@@ -25,7 +25,7 @@ class Advanced_Ads {
25
  * @var string
26
  */
27
 
28
- const VERSION = '1.5.4.1';
29
 
30
  /**
31
  * post type slug
25
  * @var string
26
  */
27
 
28
+ const VERSION = '1.5.5';
29
 
30
  /**
31
  * post type slug
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.2.2
7
- Stable tag: 1.5.4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -174,6 +174,11 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
174
 
175
  == Changelog ==
176
 
 
 
 
 
 
177
  = 1.5.4.1 =
178
 
179
  * hotfix for new visitor conditions not showing up
@@ -296,7 +301,7 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
296
 
297
  = 1.4.2 =
298
 
299
- * COOL: [vote for and suggest features](http://wpadvancedads.com/advancedads/feature-requests/)
300
  * switching from an existing plain text ad with AdSense code into the AdSense ad type gets the right options automatically
301
  * added Advanced Ads Tutorials rss to dashboard widget
302
 
@@ -313,7 +318,7 @@ Need ad analytics and impression tracking? Try the [tracking add-on](http://wpad
313
 
314
  = 1.4.0 =
315
 
316
- * COOL: AdSense ad type, [manual](http://wpadvancedads.com/advancedads/manual/ad-types/adsense-ads/)
317
  * added multiple action hooks
318
  * fix translation of textdomain if the plugin folder is renamed
319
  * load pro module, if exists
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.2.2
7
+ Stable tag: 1.5.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
174
 
175
  == Changelog ==
176
 
177
+ = 1.5.5 =
178
+
179
+ * fixed outdated links to the manual and feature requests
180
+ * added hooks and options to be able to extend ad groups
181
+
182
  = 1.5.4.1 =
183
 
184
  * hotfix for new visitor conditions not showing up
301
 
302
  = 1.4.2 =
303
 
304
+ * COOL: [vote for and suggest features](http://wpadvancedads.com/feature-requests/)
305
  * switching from an existing plain text ad with AdSense code into the AdSense ad type gets the right options automatically
306
  * added Advanced Ads Tutorials rss to dashboard widget
307
 
318
 
319
  = 1.4.0 =
320
 
321
+ * COOL: AdSense ad type, [manual](http://wpadvancedads.com/manual/ad-types/adsense-ads/)
322
  * added multiple action hooks
323
  * fix translation of textdomain if the plugin folder is renamed
324
  * load pro module, if exists