Advanced Ads - Version 1.0.3

Version Description

  • bugfix added missing file to repository
Download this release

Release Info

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

Code changes from version 1.0.1 to 1.0.3

admin/class-advanced-ads-admin.php CHANGED
@@ -124,7 +124,7 @@ class Advanced_Ads_Admin {
124
  public function enqueue_admin_styles() {
125
 
126
  global $post;
127
- if (!isset($this->plugin_screen_hook_suffix) && Advanced_Ads::POST_TYPE_SLUG != $post->type) {
128
  return;
129
  }
130
 
@@ -141,7 +141,7 @@ class Advanced_Ads_Admin {
141
  public function enqueue_admin_scripts() {
142
 
143
  global $post;
144
- if (!isset($this->plugin_screen_hook_suffix) && Advanced_Ads::POST_TYPE_SLUG != $post->type) {
145
  return;
146
  }
147
 
124
  public function enqueue_admin_styles() {
125
 
126
  global $post;
127
+ if (!isset($this->plugin_screen_hook_suffix) && isset($post) && Advanced_Ads::POST_TYPE_SLUG != $post->type) {
128
  return;
129
  }
130
 
141
  public function enqueue_admin_scripts() {
142
 
143
  global $post;
144
+ if (!isset($this->plugin_screen_hook_suffix) && isset($post) && Advanced_Ads::POST_TYPE_SLUG != $post->type) {
145
  return;
146
  }
147
 
admin/views/ad-group-ads-inline-form.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php if(count($ads)) : ?>
2
- <form method="get" action="" class="ad-group-ads-form">
3
  <table>
4
  <tbody>
5
  <?php foreach($ads as $_ad) : ?>
@@ -30,5 +30,5 @@
30
  </p>
31
  </form>
32
  <?php else : ?>
33
- <p><?php _e('There are no ads in this group', Advanced_Ads::plugin_slug); ?>
34
  <?php endif; ?>
1
  <?php if(count($ads)) : ?>
2
+ <p><form method="get" action="" class="ad-group-ads-form">
3
  <table>
4
  <tbody>
5
  <?php foreach($ads as $_ad) : ?>
30
  </p>
31
  </form>
32
  <?php else : ?>
33
+ <p><?php _e('There are no ads in this group', Advanced_Ads::TD); ?></p>
34
  <?php endif; ?>
advanced-ads.php CHANGED
@@ -6,13 +6,13 @@
6
  * @author Thomas Maier <thomas.maier@webgilde.com>
7
  * @license GPL-2.0+
8
  * @link http://webgilde.com
9
- * @copyright 2013 Thomas Maier, webgilde GmbH
10
  *
11
  * @wordpress-plugin
12
  * Plugin Name: Advanced Ads
13
- * Plugin URI: http://webgilde.com
14
  * Description: Manage and optimize your ads in WordPress
15
- * Version: 1.0.1
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.com
18
  * Text Domain: advanced-ads
@@ -26,26 +26,29 @@ if ( ! defined( 'WPINC' ) ) {
26
  die;
27
  }
28
 
29
- // only load if not already existing (maybe within another plugin I created)
30
- if(!class_exists('Advanced_Ads')) {
 
 
31
 
32
  // load basic path to the plugin
33
- DEFINE('ADVADS_BASE_PATH', plugin_dir_path(__FILE__));
34
  // general and global slug, e.g. to store options in WP
35
- DEFINE('ADVADS_SLUG', 'advancedads');
36
 
37
  /*----------------------------------------------------------------------------*
38
  * Autoloading Objects
39
  *----------------------------------------------------------------------------*/
40
- require_once( plugin_dir_path( __FILE__ ) . 'includes/autoloader.php' );
41
- spl_autoload_register(array('Advads_Autoloader', 'load'));
 
 
 
42
 
43
  /*----------------------------------------------------------------------------*
44
  * Public-Facing Functionality
45
  *----------------------------------------------------------------------------*/
46
 
47
- require_once( plugin_dir_path( __FILE__ ) . 'public/class-advanced-ads.php' );
48
-
49
  /*
50
  * Register hooks that are fired when the plugin is activated or deactivated.
51
  * When the plugin is deleted, the uninstall.php file is loaded.
@@ -61,19 +64,15 @@ add_action( 'plugins_loaded', array( 'Advanced_Ads', 'get_instance' ) );
61
  *----------------------------------------------------------------------------*/
62
 
63
  if( defined('DOING_AJAX') ) {
64
- require_once( plugin_dir_path( __FILE__ ) . 'includes/class_ajax_callbacks.php' );
65
  }
66
  // load ad conditions array
67
  require_once( plugin_dir_path( __FILE__ ) . 'includes/array_ad_conditions.php' );
68
 
69
  if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
70
-
71
  require_once( plugin_dir_path( __FILE__ ) . 'admin/class-advanced-ads-admin.php' );
72
  add_action( 'plugins_loaded', array( 'Advanced_Ads_Admin', 'get_instance' ) );
73
-
74
  }
75
 
76
  // load public functions
77
  require_once( plugin_dir_path( __FILE__ ) . 'public/functions.php' );
78
-
79
- }
6
  * @author Thomas Maier <thomas.maier@webgilde.com>
7
  * @license GPL-2.0+
8
  * @link http://webgilde.com
9
+ * @copyright 2013-2014 Thomas Maier, webgilde GmbH
10
  *
11
  * @wordpress-plugin
12
  * Plugin Name: Advanced Ads
13
+ * Plugin URI: http://wpadvancedads.com
14
  * Description: Manage and optimize your ads in WordPress
15
+ * Version: 1.0.3
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.com
18
  * Text Domain: advanced-ads
26
  die;
27
  }
28
 
29
+ // only load if not already existing (maybe included from another plugin)
30
+ if( defined('ADVADS_BASE_PATH') ) {
31
+ return ;
32
+ }
33
 
34
  // load basic path to the plugin
35
+ define('ADVADS_BASE_PATH', plugin_dir_path(__FILE__));
36
  // general and global slug, e.g. to store options in WP
37
+ define('ADVADS_SLUG', 'advancedads');
38
 
39
  /*----------------------------------------------------------------------------*
40
  * Autoloading Objects
41
  *----------------------------------------------------------------------------*/
42
+ if (!class_exists('Advanced_Ads', true)) {
43
+ require_once( plugin_dir_path( __FILE__ ) . 'includes/autoloader.php' );
44
+ require_once( plugin_dir_path( __FILE__ ) . 'public/class-advanced-ads.php' );
45
+ spl_autoload_register(array('Advads_Autoloader', 'load'));
46
+ }
47
 
48
  /*----------------------------------------------------------------------------*
49
  * Public-Facing Functionality
50
  *----------------------------------------------------------------------------*/
51
 
 
 
52
  /*
53
  * Register hooks that are fired when the plugin is activated or deactivated.
54
  * When the plugin is deleted, the uninstall.php file is loaded.
64
  *----------------------------------------------------------------------------*/
65
 
66
  if( defined('DOING_AJAX') ) {
67
+ new Advads_Ad_Ajax_Callbacks;
68
  }
69
  // load ad conditions array
70
  require_once( plugin_dir_path( __FILE__ ) . 'includes/array_ad_conditions.php' );
71
 
72
  if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
 
73
  require_once( plugin_dir_path( __FILE__ ) . 'admin/class-advanced-ads-admin.php' );
74
  add_action( 'plugins_loaded', array( 'Advanced_Ads_Admin', 'get_instance' ) );
 
75
  }
76
 
77
  // load public functions
78
  require_once( plugin_dir_path( __FILE__ ) . 'public/functions.php' );
 
 
classes/ad.php CHANGED
@@ -78,6 +78,7 @@ class Advads_Ad {
78
  if(!empty($id)) $this->load($id);
79
 
80
  // dynamically add sanitize filters for condition types
 
81
  foreach($advanced_ads_ad_conditions as $_condition) {
82
  $_types[] = $_condition['type'];
83
  }
78
  if(!empty($id)) $this->load($id);
79
 
80
  // dynamically add sanitize filters for condition types
81
+ $_types = array();
82
  foreach($advanced_ads_ad_conditions as $_condition) {
83
  $_types[] = $_condition['type'];
84
  }
classes/ad_ajax_callbacks.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Advanced Ads.
5
+ *
6
+ * @package Advanced_Ads
7
+ * @author Thomas Maier <thomas.maier@webgilde.com>
8
+ * @license GPL-2.0+
9
+ * @link http://webgilde.com
10
+ * @copyright 2013 Thomas Maier, webgilde GmbH
11
+ */
12
+
13
+ /**
14
+ * This class is used to bundle all ajax callbacks
15
+ *
16
+ * @package Advanced_Ads_Ajax_Callbacks
17
+ * @author Thomas Maier <thomas.maier@webgilde.com>
18
+ */
19
+ class Advads_Ad_Ajax_Callbacks {
20
+
21
+ public function __construct() {
22
+
23
+ add_action( 'wp_ajax_load_content_editor', array( $this, 'load_content_editor' ) );
24
+ add_action( 'wp_ajax_load_ad_parameters_metabox', array( $this, 'load_ad_parameters_metabox' ) );
25
+ add_action( 'wp_ajax_advads-ad-group-ads-form', array( $this, 'load_ad_groups_ad_form' ) );
26
+ add_action( 'wp_ajax_advads-ad-group-ads-form-save', array( $this, 'save_ad_groups_ad_form' ) );
27
+
28
+ }
29
+
30
+ /**
31
+ * load content of the ad parameter metabox
32
+ *
33
+ * @since 1.0.0
34
+ */
35
+ public function load_ad_parameters_metabox() {
36
+
37
+ $types = Advanced_Ads::get_instance()->ad_types;
38
+ $type = $_REQUEST['ad_type'];
39
+ $ad_id = absint($_REQUEST['ad_id']);
40
+ if(empty($ad_id)) wp_die();
41
+
42
+ $ad = new Advads_Ad($ad_id);
43
+
44
+ if(!empty($types[$type]) && method_exists($types[$type], 'render_parameters')) {
45
+ $types[$type]->render_parameters($ad);
46
+ }
47
+
48
+ wp_die();
49
+
50
+ }
51
+
52
+ /**
53
+ * load the form to edit ads in an ad group
54
+ *
55
+ * @since 1.0.0
56
+ */
57
+ public function load_ad_groups_ad_form(){
58
+ $id = absint($_POST['group_id']);
59
+ // load the group
60
+ $group = new Advads_Ad_Group($id);
61
+ // get weights
62
+ $weights = $group->get_ad_weights();
63
+ // get group ads
64
+ $ads = $group->get_all_ads();
65
+
66
+ include_once(ADVADS_BASE_PATH . 'admin/views/ad-group-ads-inline-form.php');
67
+ die();
68
+ }
69
+
70
+ /**
71
+ * save
72
+ *
73
+ * @since 1.0.0
74
+ */
75
+ public function save_ad_groups_ad_form(){
76
+
77
+ // load field values
78
+ $fields = array();
79
+ parse_str($_POST['fields'], $fields);
80
+
81
+ if(!wp_verify_nonce($fields['advads-ad-groups-inline-form-nonce'], 'ad-groups-inline-edit-nonce')) die();
82
+
83
+ // load the group
84
+ $id = absint($_POST['group_id']);
85
+ $group = new Advads_Ad_Group($id);
86
+
87
+ if(!isset($fields['weight'])) die();
88
+ $group->save_ad_weights($fields['weight']);
89
+
90
+ // returning the weights as an array
91
+ header('Content-Type: application/json');
92
+ echo json_encode($group->get_ad_weights());
93
+
94
+ die();
95
+ }
96
+
97
+ }
classes/ad_group.php CHANGED
@@ -160,7 +160,7 @@ class Advads_Ad_Group {
160
  * @since 1.0.0
161
  */
162
  public function get_all_ads() {
163
- if(count($this->ads) == 0)
164
  return $this->ads;
165
  else
166
  return $this->load_all_ads();
160
  * @since 1.0.0
161
  */
162
  public function get_all_ads() {
163
+ if(count($this->ads) > 0)
164
  return $this->ads;
165
  else
166
  return $this->load_all_ads();
composer.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "webgilde/advanced-ads",
3
+ "description": "Advanced Ads: Manage and optimize your ads in WordPress",
4
+ "keywords": ["wordpress", "ads", "plugin"],
5
+ "homepage": "http://webgilde.com",
6
+ "license": "GPL-2.0",
7
+ "authors": [
8
+ {
9
+ "name": "Thomas Maier",
10
+ "email": "thomas.maier@webgilde.com"
11
+ }
12
+ ],
13
+ "type": "wordpress-plugin",
14
+ "require": {
15
+ "composer/installers": "~1.0"
16
+ },
17
+ "autoload": {
18
+ "classmap": [ "classes/", "includes/", "public/class-advanced-ads.php" ]
19
+ },
20
+ "extra": {
21
+ "branch-alias": {
22
+ "dev-master": "1.x-dev"
23
+ }
24
+ }
25
+ }
README.txt → readme.txt RENAMED
@@ -1,10 +1,9 @@
1
  === Advanced Ads ===
2
  Contributors: webzunft
3
- Donate link: http://webgilde.com/
4
  Tags: ads, ad, adsense
5
  Requires at least: 3.5
6
- Tested up to: 3.9.1
7
- Stable tag: 1.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -30,6 +29,8 @@ Manage and optimize your ads in WordPress with this easy to use and extendable p
30
  * e.g. add your own ad types and display conditions using the api
31
  * an extended online manual is in progress
32
 
 
 
33
  == Installation ==
34
 
35
  This section describes how to install the plugin and get it working.
@@ -87,12 +88,21 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
87
 
88
  == Changelog ==
89
 
 
 
 
 
 
 
 
 
 
90
  = 1.0.1 =
91
 
92
  * several new hooks
93
  * seperated settings and debug page
94
  * few internal optimizations
95
- * few bug fixes for php < 5.3
96
 
97
  = 1.0 =
98
  * first release
1
  === Advanced Ads ===
2
  Contributors: webzunft
 
3
  Tags: ads, ad, adsense
4
  Requires at least: 3.5
5
+ Tested up to: 3.9.2
6
+ Stable tag: 1.0.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
29
  * e.g. add your own ad types and display conditions using the api
30
  * an extended online manual is in progress
31
 
32
+ learn more on the [plugin homepage](http://wpadvancedads.com).
33
+
34
  == Installation ==
35
 
36
  This section describes how to install the plugin and get it working.
88
 
89
  == Changelog ==
90
 
91
+ = 1.0.3 =
92
+
93
+ * bugfix added missing file to repository
94
+
95
+ = 1.0.2 =
96
+
97
+ * bugfix for editing ad weights in ad groups
98
+ * bugfix for autoloader
99
+
100
  = 1.0.1 =
101
 
102
  * several new hooks
103
  * seperated settings and debug page
104
  * few internal optimizations
105
+ * few bugfixes for php < 5.3
106
 
107
  = 1.0 =
108
  * first release
uninstall.php CHANGED
@@ -2,11 +2,11 @@
2
  /**
3
  * Fired when the plugin is uninstalled.
4
  *
5
- * @package Plugin_Name
6
- * @author Your Name <email@example.com>
7
  * @license GPL-2.0+
8
- * @link http://example.com
9
- * @copyright 2013 Your Name or Company Name
10
  */
11
 
12
  // If uninstall not called from WordPress, then exit
2
  /**
3
  * Fired when the plugin is uninstalled.
4
  *
5
+ * @package Advanced_Ads_Admin
6
+ * @author Thomas Maier <thomas.maier@webgilde.com>
7
  * @license GPL-2.0+
8
+ * @link http://webgilde.com
9
+ * @copyright 2013 Thomas Maier, webgilde GmbH
10
  */
11
 
12
  // If uninstall not called from WordPress, then exit