Advanced Ads - Version 1.6.13

Version Description

  • added responsive images as introduced in WordPress 4.4
  • tested with WordPress 4.4 beta 4
  • hide AdSense on 404 pages by default
  • fix add-on updates check in front ajax calls
  • noindex image ad attachment pages
  • fixed random bug where already existing class causes the plugin not to work
Download this release

Release Info

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

Code changes from version 1.6.12 to 1.6.13

admin/class-advanced-ads-admin.php CHANGED
@@ -112,6 +112,8 @@ class Advanced_Ads_Admin {
112
 
113
  // save ads post type
114
  add_action( 'save_post', array($this, 'save_ad') );
 
 
115
 
116
  // ad updated messages
117
  add_filter( 'post_updated_messages', array($this, 'ad_update_messages') );
@@ -124,7 +126,9 @@ class Advanced_Ads_Admin {
124
  add_action( 'admin_init', array($this, 'settings_init') );
125
  // update placements
126
  add_action( 'admin_init', array('Advanced_Ads_Placements', 'update_placements') );
127
-
 
 
128
  // check for update logic
129
  add_action( 'admin_notices', array($this, 'admin_notices') );
130
 
@@ -704,9 +708,40 @@ class Advanced_Ads_Admin {
704
  $ad->expiry_date = 0;
705
  }
706
 
 
 
 
 
 
 
 
 
 
707
  $ad->save();
708
  }
709
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
710
  /**
711
  * edit ad update messages
712
  *
@@ -1579,4 +1614,60 @@ class Advanced_Ads_Admin {
1579
 
1580
  return 1;
1581
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1582
  }
112
 
113
  // save ads post type
114
  add_action( 'save_post', array($this, 'save_ad') );
115
+ // delete ads post type
116
+ add_action( 'delete_post', array($this, 'delete_ad') );
117
 
118
  // ad updated messages
119
  add_filter( 'post_updated_messages', array($this, 'ad_update_messages') );
126
  add_action( 'admin_init', array($this, 'settings_init') );
127
  // update placements
128
  add_action( 'admin_init', array('Advanced_Ads_Placements', 'update_placements') );
129
+ // check for add-on updates
130
+ add_action( 'admin_init', array($this, 'add_on_updater'), 1 );
131
+
132
  // check for update logic
133
  add_action( 'admin_notices', array($this, 'admin_notices') );
134
 
708
  $ad->expiry_date = 0;
709
  }
710
 
711
+ $image_id = ( isset( $_POST['advanced_ad']['output']['image_id'] ) ) ? absint( $_POST['advanced_ad']['output']['image_id'] ) : 0;
712
+ if ( $image_id ) {
713
+ $all_posts_id = get_post_meta( $image_id, '_advanced-ads_parent_id' );
714
+
715
+ if ( ! in_array ( $post_id, $all_posts_id ) ) {
716
+ add_post_meta( $image_id, '_advanced-ads_parent_id', $post_id, false );
717
+ }
718
+ }
719
+
720
  $ad->save();
721
  }
722
 
723
+ /**
724
+ * prepare the ad post type to be removed
725
+ *
726
+ * @param int $post_id id of the post
727
+ */
728
+ public function delete_ad( $post_id ) {
729
+ global $wpdb;
730
+
731
+ if ( ! current_user_can( 'delete_posts' ) ) {
732
+ return;
733
+ }
734
+
735
+ if ( $post_id > 0 ) {
736
+ $post_type = get_post_type( $post_id );
737
+ if ( $post_type == $this->post_type ) {
738
+ $wpdb->query(
739
+ $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", '_advanced-ads_parent_id', $post_id )
740
+ );
741
+ }
742
+ }
743
+ }
744
+
745
  /**
746
  * edit ad update messages
747
  *
1614
 
1615
  return 1;
1616
  }
1617
+
1618
+ /*
1619
+ * add-on updater
1620
+ *
1621
+ * @since 1.5.7
1622
+ *
1623
+ */
1624
+ public function add_on_updater(){
1625
+
1626
+ /**
1627
+ * list of registered add ons
1628
+ * contains:
1629
+ * name
1630
+ * version
1631
+ * path
1632
+ * options_slug
1633
+ * short option slug (=key)
1634
+ */
1635
+ $add_ons = apply_filters( 'advanced-ads-add-ons', array() );
1636
+
1637
+ if( $add_ons === array() ) {
1638
+ return;
1639
+ }
1640
+
1641
+ foreach( $add_ons as $_add_on_key => $_add_on ){
1642
+
1643
+ // check if a license expired over time
1644
+ $expiry_date = get_option($_add_on['options_slug'] . '-license-expires', false);
1645
+ $now = time();
1646
+ if( $expiry_date && strtotime( $expiry_date ) < $now ){
1647
+ // remove license status
1648
+ delete_option( $_add_on['options_slug'] . '-license-status' );
1649
+ continue;
1650
+ }
1651
+
1652
+ // check status
1653
+ if( get_option($_add_on['options_slug'] . '-license-status', false) !== 'valid' ) {
1654
+ continue;
1655
+ }
1656
+
1657
+ // retrieve our license key from the DB
1658
+ $licenses = get_option(ADVADS_SLUG . '-licenses', array());
1659
+ $license_key = isset($licenses[$_add_on_key]) ? $licenses[$_add_on_key] : '';
1660
+
1661
+ // setup the updater
1662
+ if( $license_key ){
1663
+ new EDD_SL_Plugin_Updater( ADVADS_URL, $_add_on['path'], array(
1664
+ 'version' => $_add_on['version'],
1665
+ 'license' => $license_key,
1666
+ 'item_name' => $_add_on['name'],
1667
+ 'author' => 'Thomas Maier'
1668
+ )
1669
+ );
1670
+ }
1671
+ }
1672
+ }
1673
  }
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.6.12
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.6.12' );
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.6.13
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.6.13' );
42
 
43
  /*----------------------------------------------------------------------------*
44
  * Autoloading, modules and functions
classes/ad.php CHANGED
@@ -16,10 +16,14 @@
16
  * @package Advanced_Ads_Ad
17
  * @author Thomas Maier <thomas.maier@webgilde.com>
18
  * @deprecated since version 1.5.3 (May 6th 2015)
 
19
  */
20
- class Advads_Ad extends Advanced_Ads_Ad {
 
21
 
 
22
  }
 
23
  /**
24
  * an ad object
25
  *
16
  * @package Advanced_Ads_Ad
17
  * @author Thomas Maier <thomas.maier@webgilde.com>
18
  * @deprecated since version 1.5.3 (May 6th 2015)
19
+ * might still be needed if some old add-ons are running somewhere
20
  */
21
+ if( ! class_exists ( 'Advads_Ad', false ) ){
22
+ class Advads_Ad extends Advanced_Ads_Ad {
23
 
24
+ }
25
  }
26
+
27
  /**
28
  * an ad object
29
  *
classes/ad_type_content.php CHANGED
@@ -110,6 +110,10 @@ class Advanced_Ads_Ad_Type_Content extends Advanced_Ads_Ad_Type_Abstract{
110
  $output = shortcode_unautop( $output );
111
  $output = do_shortcode( $output );
112
  $output = prepend_attachment( $output );
 
 
 
 
113
 
114
  return $output;
115
  }
110
  $output = shortcode_unautop( $output );
111
  $output = do_shortcode( $output );
112
  $output = prepend_attachment( $output );
113
+ // make included images responsive, since WordPress 4.4
114
+ if( ! defined( 'ADVADS_DISABLE_RESPONSIVE_IMAGES' ) && function_exists( 'wp_make_content_images_responsive' ) ){
115
+ $output = wp_make_content_images_responsive( $output );
116
+ }
117
 
118
  return $output;
119
  }
classes/ad_type_image.php CHANGED
@@ -82,8 +82,23 @@ class Advanced_Ads_Ad_Type_Image extends Advanced_Ads_Ad_Type_Abstract{
82
  $attachment = get_post($attachment_id);
83
  $alt = trim(strip_tags( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) ));
84
  $title = trim(strip_tags( $attachment->post_title )); // Finally, use the title
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
- echo rtrim("<img $hwstring") . " src='$src' alt='$alt' title='$title' />";
87
  }
88
  }
89
 
82
  $attachment = get_post($attachment_id);
83
  $alt = trim(strip_tags( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) ));
84
  $title = trim(strip_tags( $attachment->post_title )); // Finally, use the title
85
+
86
+ global $wp_current_filter;
87
+
88
+ $more_attributes = '';
89
+ // create srcset and sizes attributes if we are in the the_content filter and in WordPress 4.4
90
+ if( isset( $wp_current_filter )
91
+ && in_array( 'the_content', $wp_current_filter )
92
+ && ! defined( 'ADVADS_DISABLE_RESPONSIVE_IMAGES' )){
93
+ if( function_exists( 'wp_get_attachment_image_srcset' ) ){
94
+ $more_attributes .= ' srcset=\'' . wp_get_attachment_image_srcset( $attachment_id, 'full' ) . '\'';
95
+ }
96
+ if( function_exists( 'wp_get_attachment_image_sizes' ) ){
97
+ $more_attributes .= ' sizes=\'' . wp_get_attachment_image_sizes( $attachment_id, 'full' ) . '\'';
98
+ }
99
+ }
100
 
101
+ echo rtrim("<img $hwstring") . " src='$src' alt='$alt' title='$title' $more_attributes/>";
102
  }
103
  }
104
 
classes/plugin.php CHANGED
@@ -96,10 +96,6 @@ class Advanced_Ads_Plugin {
96
  add_action( 'admin_menu', array( $this, 'remove_taxonomy_menu_item' ) );
97
  // load widgets
98
  add_action( 'widgets_init', array( $this, 'widget_init' ) );
99
-
100
- // update add-ons
101
- add_action( 'admin_init', array($this, 'add_on_updater'), 1 );
102
-
103
  }
104
 
105
  /**
@@ -395,62 +391,6 @@ class Advanced_Ads_Plugin {
395
  update_option( ADVADS_SLUG . '-internal', $options );
396
  }
397
 
398
- /*
399
- * add-on updater
400
- *
401
- * @since 1.5.7
402
- *
403
- */
404
- public function add_on_updater(){
405
-
406
- /**
407
- * list of registered add ons
408
- * contains:
409
- * name
410
- * version
411
- * path
412
- * options_slug
413
- * short option slug (=key)
414
- */
415
- $add_ons = apply_filters( 'advanced-ads-add-ons', array() );
416
-
417
- if( $add_ons === array() ) {
418
- return;
419
- }
420
-
421
- foreach( $add_ons as $_add_on_key => $_add_on ){
422
-
423
- // check if a license expired over time
424
- $expiry_date = get_option($_add_on['options_slug'] . '-license-expires', false);
425
- $now = time();
426
- if( $expiry_date && strtotime( $expiry_date ) < $now ){
427
- // remove license status
428
- delete_option( $_add_on['options_slug'] . '-license-status' );
429
- continue;
430
- }
431
-
432
- // check status
433
- if( get_option($_add_on['options_slug'] . '-license-status', false) !== 'valid' ) {
434
- continue;
435
- }
436
-
437
- // retrieve our license key from the DB
438
- $licenses = get_option(ADVADS_SLUG . '-licenses', array());
439
- $license_key = isset($licenses[$_add_on_key]) ? $licenses[$_add_on_key] : '';
440
-
441
- // setup the updater
442
- if( $license_key ){
443
- new EDD_SL_Plugin_Updater( ADVADS_URL, $_add_on['path'], array(
444
- 'version' => $_add_on['version'],
445
- 'license' => $license_key,
446
- 'item_name' => $_add_on['name'],
447
- 'author' => 'Thomas Maier'
448
- )
449
- );
450
- }
451
- }
452
- }
453
-
454
  /**
455
  * get prefix used for frontend elements
456
  *
96
  add_action( 'admin_menu', array( $this, 'remove_taxonomy_menu_item' ) );
97
  // load widgets
98
  add_action( 'widgets_init', array( $this, 'widget_init' ) );
 
 
 
 
99
  }
100
 
101
  /**
391
  update_option( ADVADS_SLUG . '-internal', $options );
392
  }
393
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
394
  /**
395
  * get prefix used for frontend elements
396
  *
modules/gadsense/includes/class-ad-type-adsense.php CHANGED
@@ -141,6 +141,13 @@ class Advanced_Ads_Ad_Type_Adsense extends Advanced_Ads_Ad_Type_Abstract {
141
  global $gadsense;
142
 
143
  $content = json_decode( stripslashes( $ad->content ) );
 
 
 
 
 
 
 
144
  $output = '';
145
  $db = Advanced_Ads_AdSense_Data::get_instance();
146
  $pub_id = $db->get_adsense_id();
141
  global $gadsense;
142
 
143
  $content = json_decode( stripslashes( $ad->content ) );
144
+
145
+ if( isset( $ad->args['wp_the_query']['is_404'] )
146
+ && $ad->args['wp_the_query']['is_404']
147
+ && ! defined( 'ADVADS_ALLOW_ADSENSE_ON_404' ) ){
148
+ return '';
149
+ }
150
+
151
  $output = '';
152
  $db = Advanced_Ads_AdSense_Data::get_instance();
153
  $pub_id = $db->get_adsense_id();
public/class-advanced-ads.php CHANGED
@@ -163,6 +163,9 @@ class Advanced_Ads {
163
 
164
  // manipulate sidebar widget
165
  add_filter( 'dynamic_sidebar_params', array( $this, 'manipulate_widget_output' ) );
 
 
 
166
  }
167
 
168
  /**
@@ -609,4 +612,18 @@ class Advanced_Ads {
609
 
610
  return $params;
611
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612
  }
163
 
164
  // manipulate sidebar widget
165
  add_filter( 'dynamic_sidebar_params', array( $this, 'manipulate_widget_output' ) );
166
+
167
+ // add meta robots noindex, nofollow to images, which are part of 'Image ad' ad type
168
+ add_action( 'wp_head', array( $this, 'noindex_attachment_images' ) );
169
  }
170
 
171
  /**
612
 
613
  return $params;
614
  }
615
+
616
+ /**
617
+ * Add meta robots noindex, nofollow to images, which are part of 'Image ad' ad type
618
+ */
619
+ function noindex_attachment_images() {
620
+ global $post;
621
+ // if the image was not attached to any post
622
+ if ( is_attachment() && is_object( $post ) && isset( $post->post_parent ) && $post->post_parent === 0 ) {
623
+ // if at least one ad contains the image
624
+ if ( get_post_meta( get_the_ID(), '_advanced-ads_parent_id', true ) > 0 ) {
625
+ echo '<meta name="robots" content="noindex, nofollow" />';
626
+ }
627
+ }
628
+ }
629
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: webzunft
3
  Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RRRCEBGN3UT2
4
  Tags: ads, ad, adsense, display, banner, advertisements, adverts, advert, monetization
5
  Requires at least: WP 4.2, PHP 5.3
6
- Tested up to: 4.3.1
7
- Stable tag: 1.6.12
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -93,11 +93,18 @@ Placements to inject ads in pre-defined positions in your theme and content:
93
  Advanced Ads is compatible with all ad networks and banners from affiliate programs like Google AdSense, Chitika, Clickbank, Amazon, etc.
94
  You can also use it to add additional ad network tags into header or footer of your site without additional coding)
95
 
 
 
 
 
 
 
96
  = Google AdSense =
97
 
98
  * switch sizes of an ad
99
  * switch between normal and responsive ads
100
  * automatic limit 3 AdSense ads according to AdSense terms of service (can be disabled)
 
101
  * insert Page-Level ads code globally
102
  * assistant for exact sizes of responsive ads with the [Responsive add-on](https://wpadvancedads.com/add-ons/responsive-ads/)
103
 
@@ -118,7 +125,7 @@ Localizations: English, German, Dutch, Italian, Portuguese
118
  >
119
  > * [Advanced Ads Pro](https://wpadvancedads.com/add-ons/advanced-ads-pro/) – powerful tools for ad optimizations: cache-busting, more placements, etc.
120
  > * [Tracking](https://wpadvancedads.com/add-ons/tracking/) – ad tracking and statistics
121
- > * [Responsive Ads ](https://wpadvancedads.com/add-ons/responsive-ads/) – create mobile ads or ads for specific browser sizes
122
  > * [Sticky Ads](https://wpadvancedads.com/sticky-ads/demo/) – increase click rates with fixed, sticky, and anchor ads
123
  > * [PopUp and Layer Ads](https://wpadvancedads.com/add-ons/popup-and-layer-ads/) – display ads and other content in layers and popups
124
  > * [Slider](https://wpadvancedads.com/add-ons/slider/) – create a simple slider from your ads
@@ -185,6 +192,15 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
185
 
186
  == Changelog ==
187
 
 
 
 
 
 
 
 
 
 
188
  = 1.6.12 =
189
 
190
  * added filters to ad list
3
  Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RRRCEBGN3UT2
4
  Tags: ads, ad, adsense, display, banner, advertisements, adverts, advert, monetization
5
  Requires at least: WP 4.2, PHP 5.3
6
+ Tested up to: 4.4
7
+ Stable tag: 1.6.13
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
93
  Advanced Ads is compatible with all ad networks and banners from affiliate programs like Google AdSense, Chitika, Clickbank, Amazon, etc.
94
  You can also use it to add additional ad network tags into header or footer of your site without additional coding)
95
 
96
+ = best support for mobile devices =
97
+
98
+ * display ads for mobile or desktop only
99
+ * display responsive image ads (WordPress 4.4 and later)
100
+ * ads for specific browser sizes only using [Responsive Ads](https://wpadvancedads.com/add-ons/responsive-ads/)
101
+
102
  = Google AdSense =
103
 
104
  * switch sizes of an ad
105
  * switch between normal and responsive ads
106
  * automatic limit 3 AdSense ads according to AdSense terms of service (can be disabled)
107
+ * hide AdSense on 404 pages by default (to comply with AdSense terms)
108
  * insert Page-Level ads code globally
109
  * assistant for exact sizes of responsive ads with the [Responsive add-on](https://wpadvancedads.com/add-ons/responsive-ads/)
110
 
125
  >
126
  > * [Advanced Ads Pro](https://wpadvancedads.com/add-ons/advanced-ads-pro/) – powerful tools for ad optimizations: cache-busting, more placements, etc.
127
  > * [Tracking](https://wpadvancedads.com/add-ons/tracking/) – ad tracking and statistics
128
+ > * [Responsive Ads](https://wpadvancedads.com/add-ons/responsive-ads/) – create mobile ads or ads for specific browser sizes
129
  > * [Sticky Ads](https://wpadvancedads.com/sticky-ads/demo/) – increase click rates with fixed, sticky, and anchor ads
130
  > * [PopUp and Layer Ads](https://wpadvancedads.com/add-ons/popup-and-layer-ads/) – display ads and other content in layers and popups
131
  > * [Slider](https://wpadvancedads.com/add-ons/slider/) – create a simple slider from your ads
192
 
193
  == Changelog ==
194
 
195
+ = 1.6.13 =
196
+
197
+ * added responsive images as introduced in WordPress 4.4
198
+ * tested with WordPress 4.4 beta 4
199
+ * hide AdSense on 404 pages by default
200
+ * fix add-on updates check in front ajax calls
201
+ * noindex image ad attachment pages
202
+ * fixed random bug where already existing class causes the plugin not to work
203
+
204
  = 1.6.12 =
205
 
206
  * added filters to ad list