Advanced Ads - Version 1.4.2

Version Description

  • COOL: vote for and suggest features
  • switching from an existing plain text ad with AdSense code into the AdSense ad type gets the right options automatically
  • added Advanced Ads Tutorials rss to dashboard widget

Need ad analytics and impression tracking? Try the tracking add-on.

Download this release

Release Info

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

Code changes from version 1.4.1 to 1.4.2

admin/assets/css/admin.css CHANGED
@@ -1,6 +1,7 @@
1
  /**
2
  * DASHBOARD WIDGET
3
  */
 
4
  #advads_dashboard_widget a.rsswidget { font-weight: 400; }
5
  #advads_dashboard_widget .rss-widget ul li { margin-bottom: 6px; }
6
 
1
  /**
2
  * DASHBOARD WIDGET
3
  */
4
+ #advads_dashboard_widget h4 { margin-top: .5em; }
5
  #advads_dashboard_widget a.rsswidget { font-weight: 400; }
6
  #advads_dashboard_widget .rss-widget ul li { margin-bottom: 6px; }
7
 
admin/class-advanced-ads-admin.php CHANGED
@@ -883,14 +883,25 @@ class Advanced_Ads_Admin {
883
  */
884
  public function dashboard_widget_function($post, $callback_args){
885
  // load ad optimization feed
886
- $feed = array(
887
- 'link' => 'http://webgilde.com/en/ad-optimization/',
888
- 'url' => 'http://webgilde.com/en/ad-optimization/feed/',
889
- 'title' => __('Tutorials and News'),
890
- 'items' => 3,
891
- 'show_summary' => 0,
892
- 'show_author' => 0,
893
- 'show_date' => 0,
 
 
 
 
 
 
 
 
 
 
 
894
  );
895
 
896
  // get number of ads
@@ -911,9 +922,8 @@ class Advanced_Ads_Admin {
911
  }
912
 
913
  // rss feed
914
- echo '<h4>' . __('From the ad optimization universe', ADVADS_SLUG) . '</h4>';
915
  // $this->dashboard_widget_function_output('advads_dashboard_widget', $feed);
916
- $this->dashboard_cached_rss_widget( 'advads_dashboard_widget', array($this, 'dashboard_widget_function_output'), array('advads' => $feed) );
917
  }
918
 
919
  /**
@@ -926,20 +936,20 @@ class Advanced_Ads_Admin {
926
  * @param array $check_urls RSS feeds
927
  * @return bool False on failure. True on success.
928
  */
929
- function dashboard_cached_rss_widget( $widget_id, $callback, $feed = array() ) {
930
- if ( empty($feed) ) {
931
  return;
932
  }
933
 
934
  $cache_key = 'dash_' . md5( $widget_id );
935
- if ( false !== ( $output = get_transient( $cache_key ) ) ) {
936
  echo $output;
937
  return true;
938
- }
939
 
940
  if ( $callback && is_callable( $callback ) ) {
941
  ob_start();
942
- call_user_func_array( $callback, $feed );
943
  set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
944
  }
945
 
@@ -952,11 +962,13 @@ class Advanced_Ads_Admin {
952
  * @param string $widget_id Widget ID.
953
  * @param array $feeds Array of RSS feeds.
954
  */
955
- function dashboard_widget_function_output( $feed ) {
956
-
957
- echo '<div class="rss-widget">';
958
- wp_widget_rss_output( $feed['url'], $feed );
959
- echo "</div>";
 
 
960
  }
961
 
962
  }
883
  */
884
  public function dashboard_widget_function($post, $callback_args){
885
  // load ad optimization feed
886
+ $feeds = array(
887
+ array(
888
+ 'link' => 'http://webgilde.com/en/ad-optimization/',
889
+ 'url' => 'http://webgilde.com/en/ad-optimization/feed/',
890
+ 'title' => __('From the ad optimization universe', ADVADS_SLUG),
891
+ 'items' => 3,
892
+ 'show_summary' => 0,
893
+ 'show_author' => 0,
894
+ 'show_date' => 0,
895
+ ),
896
+ array(
897
+ 'link' => 'http://wpadvancedads.com/',
898
+ 'url' => 'http://wpadvancedads.com/feed/',
899
+ 'title' => __('Advanced Ads Tutorials', ADVADS_SLUG),
900
+ 'items' => 2,
901
+ 'show_summary' => 0,
902
+ 'show_author' => 0,
903
+ 'show_date' => 0,
904
+ ),
905
  );
906
 
907
  // get number of ads
922
  }
923
 
924
  // rss feed
 
925
  // $this->dashboard_widget_function_output('advads_dashboard_widget', $feed);
926
+ $this->dashboard_cached_rss_widget( 'advads_dashboard_widget', array($this, 'dashboard_widget_function_output'), array('advads' => $feeds) );
927
  }
928
 
929
  /**
936
  * @param array $check_urls RSS feeds
937
  * @return bool False on failure. True on success.
938
  */
939
+ function dashboard_cached_rss_widget( $widget_id, $callback, $feeds = array() ) {
940
+ if ( empty($feeds) ) {
941
  return;
942
  }
943
 
944
  $cache_key = 'dash_' . md5( $widget_id );
945
+ /*if ( false !== ( $output = get_transient( $cache_key ) ) ) {
946
  echo $output;
947
  return true;
948
+ }*/
949
 
950
  if ( $callback && is_callable( $callback ) ) {
951
  ob_start();
952
+ call_user_func_array( $callback, $feeds );
953
  set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
954
  }
955
 
962
  * @param string $widget_id Widget ID.
963
  * @param array $feeds Array of RSS feeds.
964
  */
965
+ function dashboard_widget_function_output( $feeds ) {
966
+ foreach($feeds as $_feed){
967
+ echo '<div class="rss-widget">';
968
+ echo '<h4>'.$_feed['title'].'</h4>';
969
+ wp_widget_rss_output( $_feed['url'], $_feed );
970
+ echo "</div>";
971
+ }
972
  }
973
 
974
  }
admin/views/overview.php CHANGED
@@ -93,16 +93,18 @@
93
  <h3><?php _e('Manual and Support', ADVADS_SLUG); ?></h3>
94
  <p><?php _e('Need some help? These are your options', ADVADS_SLUG); ?></p>
95
  <ul>
96
- <li><?php printf(__('Visit the <a href="%s">plugin homepage</a>', ADVADS_SLUG), 'http://wpadvancedads.com/advancedads/'); ?></li>
97
- <li><?php printf(__('Have a look into the <a href="%s">manual</a>', ADVADS_SLUG), 'http://wpadvancedads.com/advancedads/manual/'); ?></li>
98
- <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>
99
- <li><?php printf(__('<a href="%s">Hire the developer</a>', ADVADS_SLUG), 'http://webgilde.com/en/contact/'); ?></li>
 
100
  </ul>
101
  </div>
102
  <div class="advads-box">
103
  <h3><?php _e('Add-ons', ADVADS_SLUG); ?></h3>
104
  <p><?php _e('Want to boost your ad income? Try these add-ons', ADVADS_SLUG); ?></p>
105
  <ul>
 
106
  <li><a href="http://wpadvancedads.com/responsive-ads/?utm_campaign=advads&utm_medium=plugin&utm_source=overview" target="_blank">Responsive Ads</a></li>
107
  <li><a href="http://wpadvancedads.com/layer-ads/?utm_campaign=advads&utm_medium=plugin&utm_source=overview" target="_blank">PopUp and Layer Ads</a></li>
108
  <li><a href="http://wpadvancedads.com/sticky-ads/?utm_campaign=advads&utm_medium=plugin&utm_source=overview" target="_blank">Sticky Ads</a></li>
93
  <h3><?php _e('Manual and Support', ADVADS_SLUG); ?></h3>
94
  <p><?php _e('Need some help? These are your options', ADVADS_SLUG); ?></p>
95
  <ul>
96
+ <li><?php printf(__('Visit the <a href="%s" target="_blank">plugin homepage</a>', ADVADS_SLUG), 'http://wpadvancedads.com/advancedads/'); ?></li>
97
+ <li><?php printf(__('Have a look into the <a href="%s" target="_blank">manual</a>', ADVADS_SLUG), 'http://wpadvancedads.com/advancedads/manual/'); ?></li>
98
+ <li><?php printf(__('Ask a question to other users in the <a href="%s" target="_blank">wordpress.org forum</a>', ADVADS_SLUG), 'http://wordpress.org/plugins/advanced-ads/'); ?></li>
99
+ <li><?php printf(__('<a href="%s" target="_blank">Hire the developer</a>', ADVADS_SLUG), 'http://webgilde.com/en/contact/'); ?></li>
100
+ <li><?php printf(__('Vote for a <a href="%s" target="_blank">feature</a>', ADVADS_SLUG), 'http://wpadvancedads.com/advancedads/feature-requests/'); ?></li>
101
  </ul>
102
  </div>
103
  <div class="advads-box">
104
  <h3><?php _e('Add-ons', ADVADS_SLUG); ?></h3>
105
  <p><?php _e('Want to boost your ad income? Try these add-ons', ADVADS_SLUG); ?></p>
106
  <ul>
107
+ <li><a href="http://wpadvancedads.com/ad-tracking/?utm_campaign=advads&utm_medium=plugin&utm_source=overview" target="_blank">Ad Tracking and Analytics</a></li>
108
  <li><a href="http://wpadvancedads.com/responsive-ads/?utm_campaign=advads&utm_medium=plugin&utm_source=overview" target="_blank">Responsive Ads</a></li>
109
  <li><a href="http://wpadvancedads.com/layer-ads/?utm_campaign=advads&utm_medium=plugin&utm_source=overview" target="_blank">PopUp and Layer Ads</a></li>
110
  <li><a href="http://wpadvancedads.com/sticky-ads/?utm_campaign=advads&utm_medium=plugin&utm_source=overview" target="_blank">Sticky Ads</a></li>
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.4.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.4.2
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.com
18
  * Text Domain: advanced-ads
classes/ad_placements.php CHANGED
@@ -242,7 +242,6 @@ class Advads_Ad_Placements {
242
  }
243
 
244
  $paragraph_id = isset($options['index']) ? $options['index'] : 1;
245
- $ad_content = Advads_Ad_Placements::output($placement_id);
246
  $paragraphs = explode($tag, $content);
247
 
248
  $offset = 0;
@@ -267,6 +266,7 @@ class Advads_Ad_Placements {
267
 
268
  // insert ad content
269
  if ($paragraph_id + $offset == $index + 1) {
 
270
  $paragraphs[$index] .= $ad_content;
271
  $running = false;
272
  }
242
  }
243
 
244
  $paragraph_id = isset($options['index']) ? $options['index'] : 1;
 
245
  $paragraphs = explode($tag, $content);
246
 
247
  $offset = 0;
266
 
267
  // insert ad content
268
  if ($paragraph_id + $offset == $index + 1) {
269
+ $ad_content = Advads_Ad_Placements::output($placement_id);
270
  $paragraphs[$index] .= $ad_content;
271
  $running = false;
272
  }
modules/gadsense/admin/assets/js/new-ad.js CHANGED
@@ -15,41 +15,27 @@
15
  $(document).on('click', '#submit-pastecode', function(ev){
16
  ev.preventDefault();
17
  var rawContent = $('#pastecode-content').val();
18
- rawContent = rawContent.trim();
19
- var theAd = {};
20
- var theContent = $('<div />').html(rawContent);
21
- var adByGoogle = theContent.find('ins');
22
- theAd.slotId = adByGoogle.attr('data-ad-slot');
23
- theAd.pubId = '';
24
- if ('undefined' != typeof(adByGoogle.attr('data-ad-client'))) {
25
- theAd.pubId = adByGoogle.attr('data-ad-client').substr(3);
26
- }
27
- if ('' != theAd.slotId && '' != theAd.pubId) {
28
- theAd.display = adByGoogle.css('display');
29
- theAd.format = adByGoogle.attr('data-ad-format');
30
- theAd.style = adByGoogle.attr('style');
31
-
32
- if ('undefined' == typeof(theAd.format) && -1 != theAd.style.indexOf('width')) {
33
- /* normal ad */
34
- theAd.type = 'normal';
35
- theAd.width = adByGoogle.css('width').replace('px', '');
36
- theAd.height = adByGoogle.css('height').replace('px', '');
37
- setDetailsFromAdCode(theAd);
38
- return;
39
- }
40
-
41
- if ('undefined' != typeof(theAd.format) && 'auto' == theAd.format) {
42
- /* Responsive ad, auto resize */
43
- theAd.type = 'responsive';
44
- setDetailsFromAdCode(theAd)
45
- return;
46
- }
47
  }
48
- // Not recognized ad code
49
- $('#pastecode-msg').append($('<p />').css('color', 'red').html(gadsenseData.msg.unknownAd));
50
 
51
  });
52
 
 
 
 
 
 
 
 
 
 
 
53
  $(document).on('change', '#unit-type, #unit-code', function (ev) {
54
  var type = $('#unit-type').val();
55
  if ('responsive' == type) {
@@ -72,7 +58,39 @@
72
  $('#pastecode-content').val('');
73
  $('#pastecode-msg').empty();
74
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  /**
77
  * Set ad parameters fields from the result of parsing ad code
78
  */
15
  $(document).on('click', '#submit-pastecode', function(ev){
16
  ev.preventDefault();
17
  var rawContent = $('#pastecode-content').val();
18
+
19
+ var parseResult = parseAdContent(rawContent);
20
+ if (false === parseResult) {
21
+ // Not recognized ad code
22
+ $('#pastecode-msg').append($('<p />').css('color', 'red').html(gadsenseData.msg.unknownAd));
23
+ } else {
24
+ setDetailsFromAdCode(parseResult);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  }
 
 
26
 
27
  });
28
 
29
+ $(document).on('click', '#advanced-ad-type-adsense', function(){
30
+ $('#advanced-ads-ad-parameters').on('paramloaded', function(){
31
+ var content = $('#advanced-ads-ad-parameters input[name="advanced_ad[content]"]').val();
32
+ var parseResult = parseAdContent(content);
33
+ if (false !== parseResult) {
34
+ setDetailsFromAdCode(parseResult);
35
+ }
36
+ });
37
+ });
38
+
39
  $(document).on('change', '#unit-type, #unit-code', function (ev) {
40
  var type = $('#unit-type').val();
41
  if ('responsive' == type) {
58
  $('#pastecode-content').val('');
59
  $('#pastecode-msg').empty();
60
  });
61
+
62
+ function parseAdContent(content) {
63
+ var rawContent = ('undefined' != typeof(content))? content.trim() : '';
64
+ var theAd = {};
65
+ var theContent = $('<div />').html(rawContent);
66
+ var adByGoogle = theContent.find('ins');
67
+ theAd.slotId = adByGoogle.attr('data-ad-slot');
68
+ theAd.pubId = '';
69
+ if ('undefined' != typeof(adByGoogle.attr('data-ad-client'))) {
70
+ theAd.pubId = adByGoogle.attr('data-ad-client').substr(3);
71
+ }
72
+ if ('' != theAd.slotId && '' != theAd.pubId) {
73
+ theAd.display = adByGoogle.css('display');
74
+ theAd.format = adByGoogle.attr('data-ad-format');
75
+ theAd.style = adByGoogle.attr('style');
76
 
77
+ if ('undefined' == typeof(theAd.format) && -1 != theAd.style.indexOf('width')) {
78
+ /* normal ad */
79
+ theAd.type = 'normal';
80
+ theAd.width = adByGoogle.css('width').replace('px', '');
81
+ theAd.height = adByGoogle.css('height').replace('px', '');
82
+ return theAd;
83
+ }
84
+
85
+ if ('undefined' != typeof(theAd.format) && 'auto' == theAd.format) {
86
+ /* Responsive ad, auto resize */
87
+ theAd.type = 'responsive';
88
+ return theAd;
89
+ }
90
+ }
91
+ return false;
92
+ }
93
+
94
  /**
95
  * Set ad parameters fields from the result of parsing ad code
96
  */
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.1
7
- Stable tag: 1.4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -166,6 +166,14 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
166
 
167
  == Changelog ==
168
 
 
 
 
 
 
 
 
 
169
  = 1.4.1 =
170
 
171
  * COOL: limitation of AdSense ads prevents you from breaking the AdSense terms of service (can be disabled)
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.1
7
+ Stable tag: 1.4.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
166
 
167
  == Changelog ==
168
 
169
+ = 1.4.2 =
170
+
171
+ * COOL: [vote for and suggest features](http://wpadvancedads.com/advancedads/feature-requests/)
172
+ * switching from an existing plain text ad with AdSense code into the AdSense ad type gets the right options automatically
173
+ * added Advanced Ads Tutorials rss to dashboard widget
174
+
175
+ Need ad analytics and impression tracking? Try the [tracking add-on](http://wpadvancedads.com/ad-tracking/).
176
+
177
  = 1.4.1 =
178
 
179
  * COOL: limitation of AdSense ads prevents you from breaking the AdSense terms of service (can be disabled)