Advanced Ads - Version 1.6.16

Version Description

  • added link to manual for mobile devices visitor condition
  • added links to support and add-ons to plugin page
  • fixed potential issue for licenses on multisites
  • fixed missing wrapper for placements with a group
  • fixed missing index error for widget
  • fixed missing index error for display conditions
Download this release

Release Info

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

Code changes from version 1.6.15 to 1.6.16

admin/class-advanced-ads-admin.php CHANGED
@@ -146,6 +146,11 @@ class Advanced_Ads_Admin {
146
  // set 1 column layout on overview page as user and page option
147
  add_filter( 'screen_layout_columns', array('Advanced_Ads_Overview_Widgets_Callbacks', 'one_column_overview_page') );
148
  add_filter( 'get_user_option_screen_layout_toplevel_page_advanced', array( 'Advanced_Ads_Overview_Widgets_Callbacks', 'one_column_overview_page_user') );
 
 
 
 
 
149
  }
150
 
151
  /**
@@ -1676,8 +1681,8 @@ class Advanced_Ads_Admin {
1676
 
1677
  if( is_multisite() ){
1678
  // if multisite, get option from main blog
1679
- $main_blog_id = defined( 'BLOG_ID_CURRENT_SITE' ) ? BLOG_ID_CURRENT_SITE : 1;
1680
- $licenses = get_blog_option( $main_blog_id, ADVADS_SLUG . '-licenses', array() );
1681
 
1682
  } else {
1683
  $licenses = get_option( ADVADS_SLUG . '-licenses', array() );
@@ -1699,8 +1704,8 @@ class Advanced_Ads_Admin {
1699
 
1700
  if( is_multisite() ){
1701
  // if multisite, get option from main blog
1702
- $main_blog_id = defined( 'BLOG_ID_CURRENT_SITE' ) ? BLOG_ID_CURRENT_SITE : 1;
1703
- $status = get_blog_option( $main_blog_id, $slug . '-license-status', false);
1704
  } else {
1705
  $status = get_option( $slug . '-license-status', false);
1706
  }
@@ -1721,8 +1726,8 @@ class Advanced_Ads_Admin {
1721
 
1722
  if( is_multisite() ){
1723
  // if multisite, get option from main blog
1724
- $main_blog_id = defined( 'BLOG_ID_CURRENT_SITE' ) ? BLOG_ID_CURRENT_SITE : 1;
1725
- $date = get_blog_option( $main_blog_id, $slug . '-license-expires', false);
1726
  } else {
1727
  $date = get_option( $slug . '-license-expires', false);
1728
  }
@@ -1790,4 +1795,42 @@ class Advanced_Ads_Admin {
1790
  }
1791
  }
1792
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1793
  }
146
  // set 1 column layout on overview page as user and page option
147
  add_filter( 'screen_layout_columns', array('Advanced_Ads_Overview_Widgets_Callbacks', 'one_column_overview_page') );
148
  add_filter( 'get_user_option_screen_layout_toplevel_page_advanced', array( 'Advanced_Ads_Overview_Widgets_Callbacks', 'one_column_overview_page_user') );
149
+
150
+ // add links to plugin page
151
+ add_filter( 'plugin_action_links_' . ADVADS_BASE, array( $this, 'add_plugin_links' ) );
152
+ // display information when user is going to disable the plugin
153
+ // add_filter( 'after_plugin_row_' . ADVADS_BASE, array( $this, 'display_deactivation_message' ) );
154
  }
155
 
156
  /**
1681
 
1682
  if( is_multisite() ){
1683
  // if multisite, get option from main blog
1684
+ global $current_site;
1685
+ $licenses = get_blog_option( $current_site->blog_id, ADVADS_SLUG . '-licenses', array() );
1686
 
1687
  } else {
1688
  $licenses = get_option( ADVADS_SLUG . '-licenses', array() );
1704
 
1705
  if( is_multisite() ){
1706
  // if multisite, get option from main blog
1707
+ global $current_site;
1708
+ $status = get_blog_option( $current_site->blog_id, $slug . '-license-status', false);
1709
  } else {
1710
  $status = get_option( $slug . '-license-status', false);
1711
  }
1726
 
1727
  if( is_multisite() ){
1728
  // if multisite, get option from main blog
1729
+ global $current_site;
1730
+ $date = get_blog_option( $current_site->blog_id, $slug . '-license-expires', false);
1731
  } else {
1732
  $date = get_option( $slug . '-license-expires', false);
1733
  }
1795
  }
1796
  }
1797
  }
1798
+
1799
+ /**
1800
+ * add links to the plugins list
1801
+ *
1802
+ * @since 1.6.14
1803
+ * @param arr $links array of links for the plugins, adapted when the current plugin is found.
1804
+ * @param str $file the filename for the current plugin, which the filter loops through.
1805
+ * @return array $links
1806
+ */
1807
+ function add_plugin_links( $links ) {
1808
+ // add link to support page
1809
+ $support_link = '<a href="' . esc_url( admin_url( 'admin.php?page=advanced-ads-support' ) ) . '">' . __( 'Support', 'advanced-ads' ) . '</a>';
1810
+ array_unshift( $links, $support_link );
1811
+
1812
+ // add link to add-ons
1813
+ $extend_link = '<a href="' . ADVADS_URL . 'add-ons/#utm_source=wp-dashboard&amp;utm_medium=textlink&amp;utm_campaign=plugin-page" target="_blank">' . __( 'Add-Ons', 'advanced-ads' ) . '</a>';
1814
+ array_unshift( $links, $extend_link );
1815
+
1816
+ return $links;
1817
+ }
1818
+
1819
+ /**
1820
+ * display message when someone is going to disable the plugin
1821
+ *
1822
+ * @since 1.6.14
1823
+ */
1824
+ function display_deactivation_message(){
1825
+
1826
+ // get email address
1827
+ $current_user = wp_get_current_user();
1828
+ if ( !($current_user instanceof WP_User) ){
1829
+ $email = '';
1830
+ } else {
1831
+ $email = trim( $current_user->user_email );
1832
+ }
1833
+
1834
+ include ADVADS_BASE_PATH . 'admin/views/feedback_disable.php';
1835
+ }
1836
  }
admin/views/feedback_disable.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <tr id="advanced-ads-feedback" class="active"><td colspan="3">
2
+ <form action="mailto:support@wpadvancedads.com">
3
+ <p><?php _e( 'Thank you for helping to improve Advanced Ads.', 'advanced-ads' ); ?></p>
4
+ <p><?php _e( 'Your feedback will motivates me to work harder towards a professional ad management solution.', 'advanced-ads' ); ?></p>
5
+ <p><?php _e( 'Why did you decide to disable Advanced Ads?', 'advanced-ads' ); ?></p>
6
+ <ul>
7
+ <li><input type="checkbox" name="advanced_ads_disable_reason[]"/><?php _e( 'I stopped showing ads on my site', 'advanced-ads' ); ?></li>
8
+ <li><input type="checkbox" name="advanced_ads_disable_reason[]"/><?php printf(__( 'I miss a feature or <a href="%s">add-on</a>', 'advanced-ads' ), ADVADS_URL . '/add-ons/' ); ?></li>
9
+ <li><input type="checkbox" name="advanced_ads_disable_reason[]"/><?php _e( 'I have a technical problem', 'advanced-ads' ); ?></li>
10
+ <li><input type="checkbox" name="advanced_ads_disable_reason[]"/><?php _e( 'other reason', 'advanced-ads' ); ?></li>
11
+ </ul>
12
+ <textarea name="advanced_ads_disable_reason_text" placeholder="<?php _e( 'Please specify, if possible', 'advanced-ads' ); ?>"></textarea>
13
+ <p><?php _e( 'What would be a reason to return to Advanced Ads?', 'advanced-ads' ); ?></p>
14
+ <textarea name="advanced_ads_return[]"></textarea>
15
+ <?php if( $email ) : ?>
16
+ <input type="submit" name="advanced_ads_disable_submit" value="submit as <?php echo $email; ?>"/>
17
+ <?php endif; ?>
18
+ <input type="submit" name="advanced_ads_disable_submit" value="submit anonymously"/>
19
+ </form>
20
+ </td></tr>
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.15
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.com
18
  * Text Domain: advanced-ads
@@ -32,13 +32,14 @@ if ( defined( 'ADVADS_BASE_PATH' ) ) {
32
  }
33
 
34
  // load basic path to the plugin
 
35
  define( 'ADVADS_BASE_PATH', plugin_dir_path( __FILE__ ) );
36
  define( 'ADVADS_BASE_URL', plugin_dir_url( __FILE__ ) );
37
- define( 'ADVADS_BASE_DIR', dirname( plugin_basename( __FILE__ ) ) ); // directory of the plugin without any paths
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.15' );
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.16
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.com
18
  * Text Domain: advanced-ads
32
  }
33
 
34
  // load basic path to the plugin
35
+ define( 'ADVADS_BASE', plugin_basename( __FILE__ ) ); // plugin base as used by WordPress to identify it
36
  define( 'ADVADS_BASE_PATH', plugin_dir_path( __FILE__ ) );
37
  define( 'ADVADS_BASE_URL', plugin_dir_url( __FILE__ ) );
38
+ define( 'ADVADS_BASE_DIR', dirname( ADVADS_BASE ) ); // directory of the plugin without any paths
39
  // general and global slug, e.g. to store options in WP, textdomain
40
  define( 'ADVADS_SLUG', 'advanced-ads' );
41
  define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
42
+ define( 'ADVADS_VERSION', '1.6.16' );
43
 
44
  /*----------------------------------------------------------------------------*
45
  * Autoloading, modules and functions
classes/ad_placements.php CHANGED
@@ -252,7 +252,7 @@ class Advanced_Ads_Placements {
252
  // return either ad or group content
253
  switch ( $_item[0] ) {
254
  case 'ad':
255
- case Advanced_Ads_Select::AD:
256
  // create class from placement id (not if header injection)
257
  if ( ! isset( $placements[ $id ]['type'] ) || $placements[ $id ]['type'] !== 'header' ) {
258
  if ( ! isset( $args['output'] ) ) {
@@ -274,10 +274,17 @@ class Advanced_Ads_Placements {
274
  break;
275
 
276
  // avoid loops (programmatical error)
277
- case Advanced_Ads_Select::PLACEMENT:
278
  return;
279
 
280
- case Advanced_Ads_Select::GROUP:
 
 
 
 
 
 
 
281
  default:
282
  }
283
 
252
  // return either ad or group content
253
  switch ( $_item[0] ) {
254
  case 'ad':
255
+ case Advanced_Ads_Select::AD :
256
  // create class from placement id (not if header injection)
257
  if ( ! isset( $placements[ $id ]['type'] ) || $placements[ $id ]['type'] !== 'header' ) {
258
  if ( ! isset( $args['output'] ) ) {
274
  break;
275
 
276
  // avoid loops (programmatical error)
277
+ case Advanced_Ads_Select::PLACEMENT :
278
  return;
279
 
280
+ case Advanced_Ads_Select::GROUP :
281
+ $class = $prefix . $id;
282
+ if ( ( isset( $placements[ $id ]['type'] ) && $placements[ $id ]['type'] !== 'header' )
283
+ && ( !isset( $args['output']['class'] )
284
+ || !is_array( $args['output']['class'] )
285
+ || !in_array( $class, $args['output']['class'] ) ) ) {
286
+ $args['output']['class'][] = $class;
287
+ }
288
  default:
289
  }
290
 
classes/visitor-conditions.php CHANGED
@@ -32,7 +32,8 @@ class Advanced_Ads_Visitor_Conditions {
32
  'label' => __( 'mobile device', 'advanced-ads' ),
33
  'description' => __( 'Display ads only on mobile devices or hide them.', 'advanced-ads' ),
34
  'metabox' => array( 'Advanced_Ads_Visitor_Conditions', 'mobile_is_or_not' ), // callback to generate the metabox
35
- 'check' => array( 'Advanced_Ads_Visitor_Conditions', 'check_mobile' ) // callback for frontend check
 
36
  ),
37
  'loggedin' => array(
38
  'label' => __( 'logged in visitor', 'advanced-ads' ),
@@ -102,7 +103,11 @@ class Advanced_Ads_Visitor_Conditions {
102
  <option value="is" <?php selected( 'is', $operator ); ?>><?php _e( 'is' ); ?></option>
103
  <option value="is_not" <?php selected( 'is_not', $operator ); ?>><?php _e( 'is not' ); ?></option>
104
  </select>
105
- <p class="description"><?php echo $type_options[ $options['type'] ]['description']; ?></p><?php
 
 
 
 
106
  }
107
 
108
  /**
32
  'label' => __( 'mobile device', 'advanced-ads' ),
33
  'description' => __( 'Display ads only on mobile devices or hide them.', 'advanced-ads' ),
34
  'metabox' => array( 'Advanced_Ads_Visitor_Conditions', 'mobile_is_or_not' ), // callback to generate the metabox
35
+ 'check' => array( 'Advanced_Ads_Visitor_Conditions', 'check_mobile' ), // callback for frontend check
36
+ 'helplink' => ADVADS_URL . 'manual/display-ads-either-on-mobile-or-desktop/' // link to help section
37
  ),
38
  'loggedin' => array(
39
  'label' => __( 'logged in visitor', 'advanced-ads' ),
103
  <option value="is" <?php selected( 'is', $operator ); ?>><?php _e( 'is' ); ?></option>
104
  <option value="is_not" <?php selected( 'is_not', $operator ); ?>><?php _e( 'is not' ); ?></option>
105
  </select>
106
+ <p class="description"><?php echo $type_options[ $options['type'] ]['description'];
107
+ if( isset( $type_options[ $options['type'] ]['helplink'] ) ) : ?>
108
+ <a href="<?php echo $type_options[ $options['type'] ]['helplink']; ?>" target="_blank"><?php
109
+ _e( 'Manual and Troubleshooting', 'advanced-ads' );
110
+ ?></a><?php endif; ?></p><?php
111
  }
112
 
113
  /**
classes/widget.php CHANGED
@@ -131,7 +131,7 @@ class Advanced_Ads_Widget extends WP_Widget {
131
  $placements = Advanced_Ads::get_ad_placements_array();
132
 
133
  foreach( $placements as $_placement_slug => $_placement ){
134
- if( 'sidebar_widget' === $_placement['type'] ){
135
  $select['placements']['placement_' . $_placement_slug ] = $_placement['name'];
136
  }
137
  }
131
  $placements = Advanced_Ads::get_ad_placements_array();
132
 
133
  foreach( $placements as $_placement_slug => $_placement ){
134
+ if( isset( $_placement['type'] ) && 'sidebar_widget' === $_placement['type'] ){
135
  $select['placements']['placement_' . $_placement_slug ] = $_placement['name'];
136
  }
137
  }
modules/ad-blocker/classes/plugin.php CHANGED
@@ -123,7 +123,8 @@ class Advanced_Ads_Ad_Blocker
123
  {
124
  if ( ! isset( $this->options ) ) {
125
  if ( function_exists( 'is_multisite' ) && is_multisite() ) {
126
- $this->options = get_blog_option( BLOG_ID_CURRENT_SITE, ADVADS_AB_SLUG, array() );
 
127
  } else {
128
  $this->options = get_option( ADVADS_AB_SLUG, array() );
129
  }
@@ -144,7 +145,8 @@ class Advanced_Ads_Ad_Blocker
144
  {
145
  if ( ! isset( $this->upload_dir ) ) {
146
  if ( function_exists( 'is_multisite' ) && is_multisite() ) {
147
- switch_to_blog( BLOG_ID_CURRENT_SITE );
 
148
  $upload_dir = wp_upload_dir();
149
  restore_current_blog();
150
  } else {
123
  {
124
  if ( ! isset( $this->options ) ) {
125
  if ( function_exists( 'is_multisite' ) && is_multisite() ) {
126
+ global $current_site;
127
+ $this->options = get_blog_option( $current_site->blog_id, ADVADS_AB_SLUG, array() );
128
  } else {
129
  $this->options = get_option( ADVADS_AB_SLUG, array() );
130
  }
145
  {
146
  if ( ! isset( $this->upload_dir ) ) {
147
  if ( function_exists( 'is_multisite' ) && is_multisite() ) {
148
+ global $current_site;
149
+ switch_to_blog( $current_site->blog_id );
150
  $upload_dir = wp_upload_dir();
151
  restore_current_blog();
152
  } else {
modules/display-by-query/display-by-query.class.php CHANGED
@@ -104,7 +104,7 @@ class Advanced_Ads_Module_Display_By_Query {
104
  }
105
 
106
  // included posts
107
- if ( isset( $_cond_value['method'] ) && is_array( $_cond_value['ids'] ) ) {
108
  switch ( $_cond_value['method'] ) {
109
  case 'include' :
110
  if ( $this->in_array( $post, $_cond_value['ids'] ) === false ) {
104
  }
105
 
106
  // included posts
107
+ if ( isset( $_cond_value['method'] ) && isset( $_cond_value['ids'] ) && is_array( $_cond_value['ids'] ) ) {
108
  switch ( $_cond_value['method'] ) {
109
  case 'include' :
110
  if ( $this->in_array( $post, $_cond_value['ids'] ) === false ) {
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.4
7
- Stable tag: 1.6.15
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -193,6 +193,15 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
193
 
194
  == Changelog ==
195
 
 
 
 
 
 
 
 
 
 
196
  = 1.6.15 =
197
 
198
  * added overview widget for [Geo Targeting add-on](https://wpadvancedads.com/add-ons/geo-targeting/)
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.1
7
+ Stable tag: 1.6.16
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
193
 
194
  == Changelog ==
195
 
196
+ = 1.6.16 =
197
+
198
+ * added link to manual for mobile devices visitor condition
199
+ * added links to support and add-ons to plugin page
200
+ * fixed potential issue for licenses on multisites
201
+ * fixed missing wrapper for placements with a group
202
+ * fixed missing index error for widget
203
+ * fixed missing index error for display conditions
204
+
205
  = 1.6.15 =
206
 
207
  * added overview widget for [Geo Targeting add-on](https://wpadvancedads.com/add-ons/geo-targeting/)