Advanced Ads - Version 1.2

Version Description

  • added widget for ads or ad groups
  • added information on how to display ads, ad groups and ad placements
  • tested with WordPress 4.0
  • added filters and function to dynamically create a wrapper around the ad
  • ! ad injection works on posts and pages now
  • fixed excluded post types for ads
Download this release

Release Info

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

Code changes from version 1.1.3 to 1.2

admin/class-advanced-ads-admin.php CHANGED
@@ -359,7 +359,7 @@ class Advanced_Ads_Admin {
359
  if (!isset($post->post_type) || $post->post_type != $this->post_type) {
360
  return;
361
  }
362
- echo "<p>Ad Id: <strong>$post->ID</strong></p>";
363
  }
364
 
365
  /**
@@ -554,7 +554,7 @@ class Advanced_Ads_Admin {
554
  */
555
  public function update_global_injection_array(){
556
  // get all public ads
557
- $ad_posts = $this->get_ads();
558
 
559
  // merge ad injection settings by type (place => ad id)
560
  $all_injections = array();
@@ -575,36 +575,4 @@ class Advanced_Ads_Admin {
575
  // write documentation
576
  }
577
 
578
- /**
579
- * load all ads based on WP_Query conditions
580
- *
581
- * @since 1.1.0
582
- * @param arr $args WP_Query arguments that are more specific that default
583
- * @return arr $ads array with post objects
584
- */
585
- public function get_ads($args = array()){
586
- // add default WP_Query arguments
587
- $args['post_type'] = $this->post_type;
588
- $args['posts_per_page'] = -1;
589
- if(empty($args['post_status'])) $args['post_status'] = 'publish';
590
-
591
- $ads = new WP_Query($args);
592
- return $ads->posts;
593
- }
594
-
595
- /**
596
- * load all ad groups
597
- *
598
- * @since 1.1.0
599
- * @return arr $groups array with ad groups
600
- * @link http://codex.wordpress.org/Function_Reference/get_terms
601
- */
602
- public function get_ad_groups(){
603
- $args = array(
604
- 'hide_empty' => false // also display groups without any ads
605
- );
606
- return get_terms(Advanced_Ads::AD_GROUP_TAXONOMY, $args);
607
- }
608
-
609
-
610
  }
359
  if (!isset($post->post_type) || $post->post_type != $this->post_type) {
360
  return;
361
  }
362
+ require_once('views/ad_info.php');
363
  }
364
 
365
  /**
554
  */
555
  public function update_global_injection_array(){
556
  // get all public ads
557
+ $ad_posts = Advanced_Ads::get_ads();
558
 
559
  // merge ad injection settings by type (place => ad id)
560
  $all_injections = array();
575
  // write documentation
576
  }
577
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
  }
admin/views/ad-group.php CHANGED
@@ -58,7 +58,6 @@ if (isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) || isse
58
  }
59
  ?>
60
  </h2>
61
-
62
  <?php if ($message) : ?>
63
  <div id="message" class="updated"><p><?php echo $message; ?></p></div>
64
  <?php
@@ -66,6 +65,16 @@ if (isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) || isse
66
  endif;
67
  ?>
68
  <div id="ajax-response"></div>
 
 
 
 
 
 
 
 
 
 
69
 
70
  <div id="col-container">
71
  <div class="col-wrap">
58
  }
59
  ?>
60
  </h2>
 
61
  <?php if ($message) : ?>
62
  <div id="message" class="updated"><p><?php echo $message; ?></p></div>
63
  <?php
65
  endif;
66
  ?>
67
  <div id="ajax-response"></div>
68
+ <a onclick="advads_toggle('#advads-ad-group-display-info')"><?php _e('How to display an Ad Group?', ADVADS_SLUG); ?></a>
69
+ <div id="advads-ad-group-display-info" style="display: none;">
70
+ <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), 'http://wpadvancedads.com/advanced-ads/manual/ad-groups/'); ?></p>
71
+ <h4><?php _e('shortcode', ADVADS_SLUG); ?></h4>
72
+ <p class="description"><?php _e('To display an ad group with the ID 6 in content fields', ADVADS_SLUG); ?></p>
73
+ <pre><input type="text" onclick="this.select();" style="width: 200px;" value='[the_ad_group id="6"]'/></pre>
74
+ <h4><?php _e('template', ADVADS_SLUG); ?></h4>
75
+ <p class="description"><?php _e('To display an ad group with the ID 6 in template files', ADVADS_SLUG); ?></p>
76
+ <pre><input type="text" onclick="this.select();" value="the_ad_group(6);"/></pre>
77
+ </div>
78
 
79
  <div id="col-container">
80
  <div class="col-wrap">
admin/views/ad_info.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p><?php printf(__('Ad Id: %s', ADVADS_SLUG), "<strong>$post->ID</strong>"); ?>&nbsp;&nbsp;&nbsp;
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), 'http://wpadvancedads.com/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>
9
+ <h4><?php _e('template', ADVADS_SLUG); ?></h4>
10
+ <p class="description"><?php _e('To display an ad in template files', ADVADS_SLUG); ?></p>
11
+ <pre><input type="text" onclick="this.select();" value="the_ad(<?php echo $post->ID; ?>);"/></pre>
12
+ </div>
13
+
admin/views/placements.php CHANGED
@@ -26,6 +26,16 @@
26
  </form>
27
  <?php if(isset($placements) && is_array($placements)) : ?>
28
  <h2><?php _e('Placements', ADVADS_SLUG); ?></h2>
 
 
 
 
 
 
 
 
 
 
29
  <form method="POST" action="">
30
  <table class="advads-placements-table">
31
  <thead>
26
  </form>
27
  <?php if(isset($placements) && is_array($placements)) : ?>
28
  <h2><?php _e('Placements', ADVADS_SLUG); ?></h2>
29
+ <a onclick="advads_toggle('#advads-ad-place-display-info')"><?php _e('How to use an Ad Placement?', ADVADS_SLUG); ?></a>
30
+ <div id="advads-ad-place-display-info" style="display: none;">
31
+ <p><?php printf(__('Examples on how to use an ad placement? Find more help and examples in the <a href="%s" target="_blank">manual</a>', ADVADS_SLUG), 'http://wpadvancedads.com/advanced-ads/manual/placements/'); ?></p>
32
+ <h4><?php _e('shortcode', ADVADS_SLUG); ?></h4>
33
+ <p class="description"><?php _e('To use an ad placement with the ID skyscraper_left in content fields', ADVADS_SLUG); ?></p>
34
+ <pre><input type="text" onclick="this.select();" style="width: 400px;" value='[the_ad_placement id="skyscraper_left"]'/></pre>
35
+ <h4><?php _e('template', ADVADS_SLUG); ?></h4>
36
+ <p class="description"><?php _e('To use an ad placement with the ID skyscraper_left in template files', ADVADS_SLUG); ?></p>
37
+ <pre><input type="text" onclick="this.select();" style="width: 400px;" value='the_ad_placement("skyscraper_left");'/></pre>
38
+ </div>
39
  <form method="POST" action="">
40
  <table class="advads-placements-table">
41
  <thead>
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.1.3
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.com
18
  * Text Domain: advanced-ads
@@ -76,3 +76,11 @@ if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
76
 
77
  // load public functions
78
  require_once( plugin_dir_path( __FILE__ ) . 'public/functions.php' );
 
 
 
 
 
 
 
 
12
  * Plugin Name: Advanced Ads
13
  * Plugin URI: http://wpadvancedads.com
14
  * Description: Manage and optimize your ads in WordPress
15
+ * Version: 1.2
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.com
18
  * Text Domain: advanced-ads
76
 
77
  // load public functions
78
  require_once( plugin_dir_path( __FILE__ ) . 'public/functions.php' );
79
+
80
+ // load widget
81
+ require_once( plugin_dir_path( __FILE__ ) . 'classes/widget.php' );
82
+ function advads_widget_init() {
83
+ register_widget('Advads_Widget');
84
+ }
85
+
86
+ add_action('widgets_init', 'advads_widget_init');
classes/ad.php CHANGED
@@ -65,6 +65,12 @@ class Advads_Ad {
65
  */
66
  static $options_meta_field = 'advanced_ads_ad_options';
67
 
 
 
 
 
 
 
68
  /**
69
  * init ad object
70
  *
@@ -126,6 +132,14 @@ class Advads_Ad {
126
 
127
  // load content based on ad type
128
  $this->content = $this->type_obj->load_content($_data);
 
 
 
 
 
 
 
 
129
  }
130
 
131
  /**
@@ -298,7 +312,7 @@ class Advads_Ad {
298
  }
299
  }
300
  // check for excluded post types
301
- if(!empty($_cond_value['include'])){
302
  $post_types = explode(',', $_cond_value['exclude']);
303
  // check if currently in a post (not post page, but also posts in loops)
304
  if(is_array($post_types) && in_array(get_post_type(), $post_types)) {
@@ -459,6 +473,9 @@ class Advads_Ad {
459
  // load ad type specific content filter
460
  $output = $this->type_obj->prepare_output($this);
461
 
 
 
 
462
  // apply a custom filter by ad type
463
  $output = apply_filters('advanced-ads-ad-output', $output, $this);
464
 
@@ -643,4 +660,65 @@ class Advads_Ad {
643
  return $conditions;
644
  }
645
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
646
  }
65
  */
66
  static $options_meta_field = 'advanced_ads_ad_options';
67
 
68
+ /**
69
+ * multidimensional array contains information about the wrapper
70
+ * each possible html attribute is an array with possible multiple elements
71
+ */
72
+ public $wrapper = array();
73
+
74
  /**
75
  * init ad object
76
  *
132
 
133
  // load content based on ad type
134
  $this->content = $this->type_obj->load_content($_data);
135
+
136
+ // set wrapper conditions
137
+ $this->wrapper = apply_filters('advanced-ads-set-wrapper', $this->wrapper, $this);
138
+ // add unique wrapper id, if options given
139
+ if(!empty($this->wrapper) && empty($wrapper_options['id'])){
140
+ // create unique id if not yet given
141
+ $this->wrapper['id'] = $this->create_wrapper_id();
142
+ }
143
  }
144
 
145
  /**
312
  }
313
  }
314
  // check for excluded post types
315
+ if(!empty($_cond_value['exclude'])){
316
  $post_types = explode(',', $_cond_value['exclude']);
317
  // check if currently in a post (not post page, but also posts in loops)
318
  if(is_array($post_types) && in_array(get_post_type(), $post_types)) {
473
  // load ad type specific content filter
474
  $output = $this->type_obj->prepare_output($this);
475
 
476
+ // build wrapper around the ad
477
+ $output = $this->add_wrapper($output);
478
+
479
  // apply a custom filter by ad type
480
  $output = apply_filters('advanced-ads-ad-output', $output, $this);
481
 
660
  return $conditions;
661
  }
662
 
663
+ /**
664
+ * add a wrapper arount the ad content if wrapper information are given
665
+ *
666
+ * @since 1.1.4
667
+ * @param str $ad_content content of the ad
668
+ * @return str $wrapper ad within the wrapper
669
+ */
670
+ protected function add_wrapper($ad_content = ''){
671
+
672
+ $wrapper_options = apply_filters('advanced-ads-output-wrapper-options', $this->wrapper, $this);
673
+
674
+ if($wrapper_options == array() || !is_array($wrapper_options) || empty($wrapper_options)) return $ad_content;
675
+
676
+ $wrapper = $ad_content;
677
+
678
+ // create unique id if not yet given
679
+ if(empty($wrapper_options['id'])){
680
+ $wrapper_options['id'] = $this->create_wrapper_id();
681
+ }
682
+
683
+ // build the box
684
+ $wrapper = "<div";
685
+ foreach($wrapper_options as $_html_attr => $_values){
686
+ if($_html_attr == 'style'){
687
+ $_style_values_string = '';
688
+ foreach($_values as $_style_attr => $_style_values){
689
+ if(is_array($_style_values))
690
+ $_style_values_string .= $_style_attr . ': ' .implode(' ', $_style_values). '; ';
691
+ else
692
+ $_style_values_string .= $_style_attr . ': ' .$_style_values. '; ';
693
+ }
694
+ $wrapper .= " style=\"$_style_values_string\"";
695
+ } else {
696
+ if(is_array($_values))
697
+ $_values_string = implode(' ', $_values);
698
+ else
699
+ $_values_string = sanitize_title($_values);
700
+ $wrapper .= " $_html_attr=\"$_values_string\"";
701
+ }
702
+
703
+
704
+ }
705
+ $wrapper .= '>';
706
+ $wrapper .= apply_filters('advanced-ads-output-wrapper-before-content', '', $this);
707
+ $wrapper .= $ad_content;
708
+ $wrapper .= apply_filters('advanced-ads-output-wrapper-after-content', '', $this);
709
+ $wrapper .= '</div>';
710
+
711
+ return $wrapper;
712
+ }
713
+
714
+ /**
715
+ * create a random wrapper id
716
+ *
717
+ * @since 1.1.4
718
+ * @return string $id random id string
719
+ */
720
+ private function create_wrapper_id(){
721
+ return 'advads-' . mt_rand();
722
+ }
723
+
724
  }
classes/ad_placements.php CHANGED
@@ -84,17 +84,16 @@ class Advads_Ad_Placements {
84
  * @return arr $select items for select field
85
  */
86
  static function items_for_select(){
87
- $advads_admin = Advanced_Ads_Admin::get_instance();
88
  $select = array();
89
 
90
  // load all ads
91
- $ads = $advads_admin->get_ads();
92
  foreach($ads as $_ad){
93
  $select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
94
  }
95
 
96
  // load all ad groups
97
- $groups = $advads_admin->get_ad_groups();
98
  foreach($groups as $_group){
99
  $select['groups']['group_' . $_group->term_id] = $_group->name;
100
  }
84
  * @return arr $select items for select field
85
  */
86
  static function items_for_select(){
 
87
  $select = array();
88
 
89
  // load all ads
90
+ $ads = Advanced_Ads::get_ads();
91
  foreach($ads as $_ad){
92
  $select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
93
  }
94
 
95
  // load all ad groups
96
+ $groups = Advanced_Ads::get_ad_groups();
97
  foreach($groups as $_group){
98
  $select['groups']['group_' . $_group->term_id] = $_group->name;
99
  }
classes/widget.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Advanced Ads Widget
4
+ *
5
+ * @package Advads_Widget
6
+ * @author Thomas Maier <thomas.maier@webgilde.com>
7
+ * @license GPL-2.0+
8
+ * @link http://webgilde.com
9
+ * @copyright 2014 Thomas Maier, webgilde GmbH
10
+ */
11
+
12
+ /**
13
+ * Ad widget
14
+ *
15
+ */
16
+ class Advads_Widget extends WP_Widget {
17
+
18
+ function __construct() {
19
+ $widget_ops = array('classname' => 'advads_widget', 'description' => __('Display Ads and Ad Groups.', ADVADS_SLUG));
20
+ $control_ops = array();
21
+ parent::__construct('advads_ad_widget', __('Advanced Ads', ADVADS_SLUG), $widget_ops, $control_ops);
22
+ }
23
+
24
+ function widget($args, $instance) {
25
+ extract($args);
26
+ $item_id = empty($instance['item_id']) ? '' : $instance['item_id'];
27
+ echo $before_widget;
28
+ echo self::output($item_id);
29
+ echo $after_widget;
30
+ }
31
+
32
+ function update($new_instance, $old_instance) {
33
+ $instance = $old_instance;
34
+ $instance['item_id'] = $new_instance['item_id'];
35
+ return $instance;
36
+ }
37
+
38
+ function form($instance) {
39
+ $instance = wp_parse_args((array) $instance, array('title' => '', 'item_id' => ''));
40
+ $elementid = sanitize_title($instance['item_id']);
41
+
42
+ $items = self::items_for_select();
43
+ ?>
44
+ <select id="<?php echo $this->get_field_id('item_id'); ?>" name="<?php echo $this->get_field_name('item_id'); ?>">
45
+ <option value=""><?php _e('--empty--', ADVADS_SLUG); ?></option>
46
+ <?php if(isset($items['ads'])) : ?>
47
+ <optgroup label="<?php _e('Ads', ADVADS_SLUG); ?>">
48
+ <?php foreach($items['ads'] as $_item_id => $_item_title) : ?>
49
+ <option value="<?php echo $_item_id; ?>" <?php selected($_item_id, $elementid); ?>><?php echo $_item_title; ?></option>
50
+ <?php endforeach; ?>
51
+ </optgroup>
52
+ <?php endif; ?>
53
+ <?php if(isset($items['groups'])) : ?>
54
+ <optgroup label="<?php _e('Ad Groups', ADVADS_SLUG); ?>">
55
+ <?php foreach($items['groups'] as $_item_id => $_item_title) : ?>
56
+ <option value="<?php echo $_item_id; ?>" <?php selected($_item_id, $elementid); ?>><?php echo $_item_title; ?></option>
57
+ <?php endforeach; ?>
58
+ </optgroup>
59
+ <?php endif; ?>
60
+ </select><?php
61
+ }
62
+
63
+ /**
64
+ * get items for widget select field
65
+ *
66
+ * @since 1.2
67
+ * @return arr $select items for select field
68
+ */
69
+ static function items_for_select(){
70
+ $select = array();
71
+
72
+ // load all ads
73
+ $ads = Advanced_Ads::get_ads();
74
+ foreach($ads as $_ad){
75
+ $select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
76
+ }
77
+
78
+ // load all ad groups
79
+ $groups = Advanced_Ads::get_ad_groups();
80
+ foreach($groups as $_group){
81
+ $select['groups']['group_' . $_group->term_id] = $_group->name;
82
+ }
83
+
84
+ return $select;
85
+ }
86
+
87
+ /**
88
+ * return content of an in a widget
89
+ *
90
+ * @since 1.2
91
+ * @param string $id slug of the display
92
+ */
93
+ static function output($id = ''){
94
+ // get placement data for the slug
95
+ if(empty($id)) return;
96
+
97
+ $item = explode('_', $id);
98
+
99
+ if(isset($item[1]))
100
+ $item_id = absint($item[1]);
101
+ elseif(empty($item_id)) return;
102
+
103
+ // return either ad or group content
104
+ if($item[0] == 'ad'){
105
+ return get_ad($item_id);
106
+ } elseif($item[0] == 'group'){
107
+ return get_ad_group($item_id);
108
+ }
109
+
110
+ return;
111
+ }
112
+
113
+ }
public/assets/js/public.js CHANGED
@@ -1,10 +1,42 @@
1
- (function ( $ ) {
2
- "use strict";
3
 
4
- $(function () {
 
 
 
 
 
5
 
6
- // Place your public-facing JavaScript here
7
 
8
- });
 
 
 
 
 
 
 
 
 
9
 
10
- }(jQuery));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery('document').ready(function($) {
 
2
 
3
+ "use strict";
4
+ // check all banners with item conditions on load page load
5
+ $.each(advads_items.conditions, function(key, value) {
6
+ // iterate through conditions
7
+ advads_check_item_conditions(key);
8
+ });
9
 
10
+ });
11
 
12
+ /**
13
+ * check item conditions and display the ad if all conditions are true
14
+ *
15
+ * @param {string} id id of the ad, without #
16
+ * @returns {undefined}
17
+ */
18
+ function advads_check_item_conditions(id) {
19
+ var item = jQuery('#' + id);
20
+ if (item.length == 0)
21
+ return;
22
 
23
+ var display = true;
24
+ jQuery.each(advads_items.conditions[id], function(method, flag) {
25
+ if (flag === false) {
26
+ // display the banner
27
+ display = false;
28
+ }
29
+ });
30
+ if (display) {
31
+ var ad = jQuery('#' + id);
32
+ // iterate through display callbacks
33
+ jQuery.each(advads_items.display_callbacks, function(adid, callbacks){
34
+ // iterate through all callback function and call them
35
+ jQuery.each(callbacks, function(key, funcname){
36
+ var callback = window[funcname];
37
+ callback(adid);
38
+ })
39
+ })
40
+ ad.show();
41
+ }
42
+ }
public/class-advanced-ads.php CHANGED
@@ -25,7 +25,7 @@ class Advanced_Ads {
25
  * @var string
26
  */
27
 
28
- const VERSION = '1.1.3';
29
 
30
  /**
31
  * post type slug
@@ -663,7 +663,7 @@ class Advanced_Ads {
663
  */
664
  public function header_output(){
665
  // inject js array for banner conditions
666
- echo '<script>advads_item_conditions = {};</script>';
667
  }
668
 
669
  /**
@@ -675,7 +675,7 @@ class Advanced_Ads {
675
  */
676
  public function inject_content($content = ''){
677
  // run only on single pages
678
- if(!is_single()) return $content;
679
 
680
  // get information about injected ads
681
  $injections = get_option('advads-ads-injections', array());
@@ -714,4 +714,35 @@ class Advanced_Ads {
714
 
715
  return $content;
716
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
717
  }
25
  * @var string
26
  */
27
 
28
+ const VERSION = '1.2';
29
 
30
  /**
31
  * post type slug
663
  */
664
  public function header_output(){
665
  // inject js array for banner conditions
666
+ echo '<script>advads_items = { conditions: {}, display_callbacks: {}, hide_callbacks: {}};</script>';
667
  }
668
 
669
  /**
675
  */
676
  public function inject_content($content = ''){
677
  // run only on single pages
678
+ if(!is_singular(array('post', 'page'))) return $content;
679
 
680
  // get information about injected ads
681
  $injections = get_option('advads-ads-injections', array());
714
 
715
  return $content;
716
  }
717
+
718
+ /**
719
+ * load all ads based on WP_Query conditions
720
+ *
721
+ * @since 1.1.0
722
+ * @param arr $args WP_Query arguments that are more specific that default
723
+ * @return arr $ads array with post objects
724
+ */
725
+ static function get_ads($args = array()){
726
+ // add default WP_Query arguments
727
+ $args['post_type'] = self::POST_TYPE_SLUG;
728
+ $args['posts_per_page'] = -1;
729
+ if(empty($args['post_status'])) $args['post_status'] = 'publish';
730
+
731
+ $ads = new WP_Query($args);
732
+ return $ads->posts;
733
+ }
734
+
735
+ /**
736
+ * load all ad groups
737
+ *
738
+ * @since 1.1.0
739
+ * @return arr $groups array with ad groups
740
+ * @link http://codex.wordpress.org/Function_Reference/get_terms
741
+ */
742
+ static function get_ad_groups(){
743
+ $args = array(
744
+ 'hide_empty' => false // also display groups without any ads
745
+ );
746
+ return get_terms(Advanced_Ads::AD_GROUP_TAXONOMY, $args);
747
+ }
748
  }
readme.txt CHANGED
@@ -1,9 +1,9 @@
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.1.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -25,6 +25,7 @@ Learn more on the [plugin homepage](http://wpadvancedads.com).
25
  * auto inject ads into header, footer and posts
26
  * display ad in template files (with functions)
27
  * display ad in post content (with shortcodes)
 
28
  * display grouped ads based on customizable ad weight
29
  * use placements in your theme to change ads and groups in template files without coding
30
 
@@ -52,37 +53,37 @@ display ads by conditions based on the visitor
52
 
53
  Learn more on the [plugin homepage](http://wpadvancedads.com).
54
 
55
- = AddOns =
56
 
57
- * increase click rates with fixed, sticky and anchor ads with Sticky Ads - [Demo](http://wpadvancedads.com/sticky-ads/demo/)
 
 
58
 
59
  == Installation ==
60
 
61
- This section describes how to install the plugin and get it working.
62
-
63
- e.g.
64
 
65
  = Using The WordPress Dashboard =
66
 
67
  1. Navigate to the 'Add New' in the plugins dashboard
68
- 2. Search for 'plugin-name'
69
  3. Click 'Install Now'
70
- 4. Activate the plugin on the Plugin dashboard
71
 
72
  = Uploading in WordPress Dashboard =
73
 
74
  1. Navigate to the 'Add New' in the plugins dashboard
75
  2. Navigate to the 'Upload' area
76
- 3. Select `plugin-name.zip` from your computer
77
  4. Click 'Install Now'
78
- 5. Activate the plugin in the Plugin dashboard
79
 
80
  = Using FTP =
81
 
82
- 1. Download `plugin-name.zip`
83
- 2. Extract the `plugin-name` directory to your computer
84
- 3. Upload the `plugin-name` directory to the `/wp-content/plugins/` directory
85
- 4. Activate the plugin in the Plugin dashboard
86
 
87
  == Displaying Ads ==
88
 
@@ -118,6 +119,15 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
118
 
119
  == Changelog ==
120
 
 
 
 
 
 
 
 
 
 
121
  = 1.1.3 =
122
 
123
  * minor changes for better extendability for the [sticky ads addon](http://wpadvancedads.com/sticky-ads/)
1
  === Advanced Ads ===
2
  Contributors: webzunft
3
+ Tags: ads, ad, adsense, display, banner, advertisements, adverts, advert, monetization
4
  Requires at least: 3.5
5
+ Tested up to: 4.0.0
6
+ Stable tag: 1.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
25
  * auto inject ads into header, footer and posts
26
  * display ad in template files (with functions)
27
  * display ad in post content (with shortcodes)
28
+ * widget to display ads in widget areas (sidebars)
29
  * display grouped ads based on customizable ad weight
30
  * use placements in your theme to change ads and groups in template files without coding
31
 
53
 
54
  Learn more on the [plugin homepage](http://wpadvancedads.com).
55
 
56
+ = Add-Ons =
57
 
58
+ * Responsive Ads load and display ads only for specific browser sizes - [Demo](http://wpadvancedads.com/responsive-ads/)
59
+ * PopUp and Layer Ads – display ads and any other content in layers and popups - [Demo](http://wpadvancedads.com/layer-ads/)
60
+ * Sticky Ads – increase click rates with fixed, sticky and anchor ads - [Demo](http://wpadvancedads.com/sticky-ads/demo/)
61
 
62
  == Installation ==
63
 
64
+ How to install the plugin and get it working?
 
 
65
 
66
  = Using The WordPress Dashboard =
67
 
68
  1. Navigate to the 'Add New' in the plugins dashboard
69
+ 2. Search for 'advanced ads'
70
  3. Click 'Install Now'
71
+ 4. Activate Advanced Ads on the Plugin dashboard
72
 
73
  = Uploading in WordPress Dashboard =
74
 
75
  1. Navigate to the 'Add New' in the plugins dashboard
76
  2. Navigate to the 'Upload' area
77
+ 3. Select `advanced-ads.zip` from your computer
78
  4. Click 'Install Now'
79
+ 5. Activate Advanced Ads in the Plugin dashboard
80
 
81
  = Using FTP =
82
 
83
+ 1. Download `advanced-ads.zip`
84
+ 2. Extract the `advanced-ads` directory to your computer
85
+ 3. Upload the `advanced-ads` directory to the `/wp-content/plugins/` directory
86
+ 4. Activate Advanced Ads in the Plugin dashboard
87
 
88
  == Displaying Ads ==
89
 
119
 
120
  == Changelog ==
121
 
122
+ = 1.2 =
123
+
124
+ * added widget for ads or ad groups
125
+ * added information on how to display ads, ad groups and ad placements
126
+ * tested with WordPress 4.0
127
+ * added filters and function to dynamically create a wrapper around the ad
128
+ * ! ad injection works on posts and pages now
129
+ * fixed excluded post types for ads
130
+
131
  = 1.1.3 =
132
 
133
  * minor changes for better extendability for the [sticky ads addon](http://wpadvancedads.com/sticky-ads/)