Version Description
- added filter to be able to add own checks whether to display an ad or not
- added action to add content to the visitor metabox
- option to hide/disable ad conditions
- option to hide all ads from logged in users based on user roles
Download this release
Release Info
Developer | webzunft |
Plugin | Advanced Ads |
Version | 1.1.1 |
Comparing to | |
See all releases |
Code changes from version 1.1.0 to 1.1.1
- admin/assets/js/admin.js +18 -37
- admin/class-advanced-ads-admin.php +56 -5
- admin/views/ad-display-metabox.php +6 -0
- admin/views/ad-visitor-metabox.php +2 -1
- admin/views/settings.php +4 -13
- advanced-ads.php +1 -1
- assets/index.php +0 -1
- assets/screenshot-1.png +0 -0
- assets/screenshot-2.png +0 -0
- classes/ad.php +25 -5
- {trunk/classes → classes}/ad_placements.php +0 -0
- public/class-advanced-ads.php +1 -1
- readme.txt +11 -1
- trunk/LICENSE.txt +0 -339
- trunk/admin/assets/css/admin.css +0 -60
- trunk/admin/assets/css/index.php +0 -1
- trunk/admin/assets/js/admin.js +0 -84
- trunk/admin/assets/js/index.php +0 -1
- trunk/admin/assets/js/inline-edit-group-ads.js +0 -101
- trunk/admin/class-advanced-ads-admin.php +0 -554
- trunk/admin/includes/class-ad-groups-list-table.php +0 -290
- trunk/admin/includes/class-list-table.php +0 -969
- trunk/admin/includes/index.php +0 -1
- trunk/admin/views/ad-display-metabox.php +0 -42
- trunk/admin/views/ad-group-ads-inline-form.php +0 -34
- trunk/admin/views/ad-group-edit.php +0 -80
- trunk/admin/views/ad-group.php +0 -101
- trunk/admin/views/ad-inject-metabox.php +0 -29
- trunk/admin/views/ad-main-metabox.php +0 -21
- trunk/admin/views/ad-parameters-metabox.php +0 -15
- trunk/admin/views/ad-visitor-metabox.php +0 -19
- trunk/admin/views/admin.php +0 -25
- trunk/admin/views/debug.php +0 -19
- trunk/admin/views/index.php +0 -1
- trunk/admin/views/placements.php +0 -72
- trunk/admin/views/settings.php +0 -37
- trunk/advanced-ads.php +0 -78
- trunk/assets/index.php +0 -1
- trunk/assets/screenshot-1.png +0 -0
- trunk/assets/screenshot-2.png +0 -0
- trunk/classes/ad.php +0 -626
- trunk/classes/ad_ajax_callbacks.php +0 -97
- trunk/classes/ad_group.php +0 -347
- trunk/classes/ad_type_abstract.php +0 -124
- trunk/classes/ad_type_content.php +0 -83
- trunk/classes/ad_type_plain.php +0 -75
- trunk/composer.json +0 -25
- trunk/includes/array_ad_conditions.php +0 -77
- trunk/includes/autoloader.php +0 -31
- trunk/includes/index.php +0 -1
- trunk/index.php +0 -1
- trunk/languages/index.php +0 -1
- trunk/languages/plugin-name.pot +0 -31
- trunk/public/assets/css/index.php +0 -1
- trunk/public/assets/css/public.css +0 -1
- trunk/public/assets/index.php +0 -1
- trunk/public/assets/js/index.php +0 -1
- trunk/public/assets/js/public.js +0 -10
- trunk/public/class-advanced-ads.php +0 -706
- trunk/public/functions.php +0 -91
- trunk/public/includes/index.php +0 -1
- trunk/public/views/index.php +0 -1
- trunk/public/views/public.php +0 -16
- trunk/readme.txt +0 -144
- trunk/uninstall.php +0 -17
admin/assets/js/admin.js
CHANGED
@@ -1,42 +1,5 @@
|
|
1 |
jQuery(document).ready(function($) {
|
2 |
"use strict";
|
3 |
-
/*
|
4 |
-
function load_content_editor( ad_type ) {
|
5 |
-
$.ajax({
|
6 |
-
type: 'POST',
|
7 |
-
url: ajaxurl,
|
8 |
-
data: {
|
9 |
-
'action': 'load_content_editor',
|
10 |
-
'type' : ad_type,
|
11 |
-
'ad_id' : $('#post_ID').val()
|
12 |
-
},
|
13 |
-
success:function(data, textStatus, XMLHttpRequest){
|
14 |
-
// toggle main content field
|
15 |
-
if(data == 'content') {
|
16 |
-
$('#advanced_ad_content_others').html(''); // clear other editors
|
17 |
-
$('#advanced_ad_content').show();
|
18 |
-
} else {
|
19 |
-
$('#advanced_ad_content').hide();
|
20 |
-
$('#advanced_ad_content_others').html(data);
|
21 |
-
}
|
22 |
-
},
|
23 |
-
error: function(MLHttpRequest, textStatus, errorThrown){
|
24 |
-
$('#advanced_ad_content_others').html(errorThrown);
|
25 |
-
}
|
26 |
-
});
|
27 |
-
};
|
28 |
-
|
29 |
-
// load content editor on page load
|
30 |
-
if($('#advanced_ad_type input').length > 0) {
|
31 |
-
var ad_type = $('#advanced_ad_type input').val();
|
32 |
-
load_content_editor(ad_type);
|
33 |
-
}
|
34 |
-
|
35 |
-
$(document).on('change', '#advanced_ad_type input', function(){
|
36 |
-
var ad_type = $(this).val()
|
37 |
-
load_content_editor( ad_type );
|
38 |
-
});
|
39 |
-
*/
|
40 |
|
41 |
function advads_load_ad_type_parameter_metabox(ad_type) {
|
42 |
$('#advanced-ads-ad-parameters').html('<span class="spinner advads-ad-parameters-spinner"></span>');
|
@@ -72,6 +35,12 @@ jQuery(document).ready(function($) {
|
|
72 |
$(this).closest('tr').find('input[type="text"]').val('');
|
73 |
});
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
})
|
76 |
|
77 |
/**
|
@@ -81,4 +50,16 @@ jQuery(document).ready(function($) {
|
|
81 |
*/
|
82 |
function advads_toggle(selector) {
|
83 |
jQuery(selector).slideToggle();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
}
|
1 |
jQuery(document).ready(function($) {
|
2 |
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
function advads_load_ad_type_parameter_metabox(ad_type) {
|
5 |
$('#advanced-ads-ad-parameters').html('<span class="spinner advads-ad-parameters-spinner"></span>');
|
35 |
$(this).closest('tr').find('input[type="text"]').val('');
|
36 |
});
|
37 |
|
38 |
+
// toggle display conditions
|
39 |
+
$('#advanced-ad-conditions-enable input').click(function(){
|
40 |
+
advads_toggle_display_conditions(this.value);
|
41 |
+
})
|
42 |
+
// display on load
|
43 |
+
advads_toggle_display_conditions($('#advanced-ad-conditions-enable input:checked').val());
|
44 |
})
|
45 |
|
46 |
/**
|
50 |
*/
|
51 |
function advads_toggle(selector) {
|
52 |
jQuery(selector).slideToggle();
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* toggle display conditions
|
57 |
+
* @param {bool} value
|
58 |
+
*/
|
59 |
+
function advads_toggle_display_conditions(value){
|
60 |
+
if(value == 1){
|
61 |
+
jQuery('#advanced-ad-conditions').fadeIn();
|
62 |
+
} else {
|
63 |
+
jQuery('#advanced-ad-conditions').fadeOut();
|
64 |
+
}
|
65 |
}
|
admin/class-advanced-ads-admin.php
CHANGED
@@ -286,7 +286,7 @@ class Advanced_Ads_Admin {
|
|
286 |
$forced_message = 2;
|
287 |
}
|
288 |
|
289 |
-
//
|
290 |
switch ($action) {
|
291 |
case 'edit' :
|
292 |
$title = $tax->labels->edit_item;
|
@@ -363,8 +363,6 @@ class Advanced_Ads_Admin {
|
|
363 |
* @since 1.0.0
|
364 |
*/
|
365 |
public function add_meta_boxes() {
|
366 |
-
global $_wp_post_type_features;
|
367 |
-
|
368 |
add_meta_box(
|
369 |
'ad-main-box', __('Ad Main', $this->plugin_slug), array($this, 'markup_meta_boxes'), Advanced_Ads::POST_TYPE_SLUG, 'normal', 'high'
|
370 |
);
|
@@ -484,10 +482,63 @@ class Advanced_Ads_Admin {
|
|
484 |
*/
|
485 |
public function settings_init(){
|
486 |
|
487 |
-
//
|
|
|
488 |
|
489 |
// register settings
|
490 |
-
register_setting($
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
}
|
492 |
|
493 |
/**
|
286 |
$forced_message = 2;
|
287 |
}
|
288 |
|
289 |
+
// handle views
|
290 |
switch ($action) {
|
291 |
case 'edit' :
|
292 |
$title = $tax->labels->edit_item;
|
363 |
* @since 1.0.0
|
364 |
*/
|
365 |
public function add_meta_boxes() {
|
|
|
|
|
366 |
add_meta_box(
|
367 |
'ad-main-box', __('Ad Main', $this->plugin_slug), array($this, 'markup_meta_boxes'), Advanced_Ads::POST_TYPE_SLUG, 'normal', 'high'
|
368 |
);
|
482 |
*/
|
483 |
public function settings_init(){
|
484 |
|
485 |
+
// get settings page hook
|
486 |
+
$hook = $this->plugin_screen_hook_suffix;
|
487 |
|
488 |
// register settings
|
489 |
+
register_setting($hook, 'advancedads');
|
490 |
+
|
491 |
+
// add new section
|
492 |
+
add_settings_section(
|
493 |
+
'advanced_ads_setting_section',
|
494 |
+
__('General', ADVADS_SLUG),
|
495 |
+
array($this, 'render_settings_section_callback'),
|
496 |
+
$hook
|
497 |
+
);
|
498 |
+
|
499 |
+
// add setting fields
|
500 |
+
add_settings_field(
|
501 |
+
'hide-for-user-role',
|
502 |
+
__('Hide ads for logged in users', ADVADS_SLUG),
|
503 |
+
array($this, 'render_settings_hide_for_users'),
|
504 |
+
$hook,
|
505 |
+
'advanced_ads_setting_section'
|
506 |
+
);
|
507 |
+
}
|
508 |
+
|
509 |
+
/**
|
510 |
+
* render settings section
|
511 |
+
*
|
512 |
+
* @since 1.1.1
|
513 |
+
*/
|
514 |
+
public function render_settings_section_callback(){
|
515 |
+
// for whatever purpose there might come
|
516 |
+
}
|
517 |
+
|
518 |
+
/**
|
519 |
+
* render setting to hide ads from logged in users
|
520 |
+
*
|
521 |
+
* @since 1.1.1
|
522 |
+
*/
|
523 |
+
public function render_settings_hide_for_users(){
|
524 |
+
$options = Advanced_Ads::get_instance()->options();
|
525 |
+
$current_capability_role = isset($options['hide-for-user-role']) ? $options['hide-for-user-role'] : 0;
|
526 |
+
|
527 |
+
$capability_roles = array(
|
528 |
+
'' => __('(display to all)', ADVADS_SLUG),
|
529 |
+
'read' => __('Subscriber', ADVADS_SLUG),
|
530 |
+
'delete_posts' => __('Contributor', ADVADS_SLUG),
|
531 |
+
'edit_posts' => __('Author', ADVADS_SLUG),
|
532 |
+
'edit_pages' => __('Editor', ADVADS_SLUG),
|
533 |
+
'activate_plugins' => __('Admin', ADVADS_SLUG),
|
534 |
+
);
|
535 |
+
echo '<select name="advancedads[hide-for-user-role]">';
|
536 |
+
foreach($capability_roles as $_capability => $_role) {
|
537 |
+
echo '<option value="'.$_capability.'" '.selected($_capability, $current_capability_role, false).'>'.$_role.'</option>';
|
538 |
+
}
|
539 |
+
echo '</select>';
|
540 |
+
|
541 |
+
echo '<p class="description">'. __('Choose the lowest role a user must have in order to not see any ads.', ADVADS_SLUG) .'</p>';
|
542 |
}
|
543 |
|
544 |
/**
|
admin/views/ad-display-metabox.php
CHANGED
@@ -1,6 +1,11 @@
|
|
1 |
<?php $types = Advanced_Ads::get_instance()->ad_types; ?>
|
2 |
<h4><?php _e('Display conditions', $this->plugin_slug); ?></h4>
|
3 |
<p class="description"><?php _e('Display conditions that are based on the content type.', ADVADS_SLUG); ?></p>
|
|
|
|
|
|
|
|
|
|
|
4 |
<p class="advads-toggle-link" onclick="advads_toggle('#advads-how-it-works')">>>><?php _e('Click to see Help', $this->plugin_slug); ?><<<</p>
|
5 |
<ul id="advads-how-it-works" style="display: none;">
|
6 |
<li><?php _e('If you want to display the ad everywhere, don’t do anything here. ', $this->plugin_slug); ?></li>
|
@@ -10,6 +15,7 @@
|
|
10 |
<li><?php _e('When using one of the two choices on checkbox conditions, the rule is binding. E.g. "Front Page: show here" will result on the ad being only visible on the front page.', $this->plugin_slug); ?></li>
|
11 |
<li><?php _e('If there is nothing in the row, there won’t be any check. Meaning, if you leave everything empty, the ad will be displayed everywhere.', $this->plugin_slug); ?></li>
|
12 |
</ul>
|
|
|
13 |
<table id="advanced-ad-conditions">
|
14 |
<thead>
|
15 |
<tr>
|
1 |
<?php $types = Advanced_Ads::get_instance()->ad_types; ?>
|
2 |
<h4><?php _e('Display conditions', $this->plugin_slug); ?></h4>
|
3 |
<p class="description"><?php _e('Display conditions that are based on the content type.', ADVADS_SLUG); ?></p>
|
4 |
+
<div id="advanced-ad-conditions-enable">
|
5 |
+
<?php $conditions_enabled = (empty($ad->conditions['enabled'])) ? 0 : 1; ?>
|
6 |
+
<label><input type="radio" name="advanced_ad[conditions][enabled]" value="0" <?php checked($conditions_enabled, 0); ?>/><?php _e('Display ad everywhere', ADVADS_SLUG); ?></label>
|
7 |
+
<label><input type="radio" name="advanced_ad[conditions][enabled]" value="1" <?php checked($conditions_enabled, 1); ?>/><?php _e('Set display conditions', ADVADS_SLUG); ?></label>
|
8 |
+
</div>
|
9 |
<p class="advads-toggle-link" onclick="advads_toggle('#advads-how-it-works')">>>><?php _e('Click to see Help', $this->plugin_slug); ?><<<</p>
|
10 |
<ul id="advads-how-it-works" style="display: none;">
|
11 |
<li><?php _e('If you want to display the ad everywhere, don’t do anything here. ', $this->plugin_slug); ?></li>
|
15 |
<li><?php _e('When using one of the two choices on checkbox conditions, the rule is binding. E.g. "Front Page: show here" will result on the ad being only visible on the front page.', $this->plugin_slug); ?></li>
|
16 |
<li><?php _e('If there is nothing in the row, there won’t be any check. Meaning, if you leave everything empty, the ad will be displayed everywhere.', $this->plugin_slug); ?></li>
|
17 |
</ul>
|
18 |
+
|
19 |
<table id="advanced-ad-conditions">
|
20 |
<thead>
|
21 |
<tr>
|
admin/views/ad-visitor-metabox.php
CHANGED
@@ -16,4 +16,5 @@
|
|
16 |
<?php checked($options['mobile'], 'no'); ?>/>
|
17 |
<label for="advanced-ad-visitor-mobile-no"><?php _e('not on mobile devices', ADVADS_SLUG); ?></label>
|
18 |
</li>
|
19 |
-
</ul>
|
|
16 |
<?php checked($options['mobile'], 'no'); ?>/>
|
17 |
<label for="advanced-ad-visitor-mobile-no"><?php _e('not on mobile devices', ADVADS_SLUG); ?></label>
|
18 |
</li>
|
19 |
+
</ul>
|
20 |
+
<?php do_action('advanced-ads-visitor-conditions-after', $ad);
|
admin/views/settings.php
CHANGED
@@ -9,21 +9,12 @@
|
|
9 |
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
|
10 |
<form method="POST" action="options.php">
|
11 |
<?php
|
12 |
-
/**
|
13 |
-
* only display setting field if any registered
|
14 |
-
* @TODO remove when base plugin has its own settings
|
15 |
-
*/
|
16 |
-
global $wp_settings_fields;
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
do_settings_sections( $this->plugin_screen_hook_suffix);
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
} else {
|
25 |
-
echo '<p>'.__('No settings available yet', $this->plugin_slug).'</p>';
|
26 |
-
}
|
27 |
|
28 |
?>
|
29 |
</form>
|
9 |
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
|
10 |
<form method="POST" action="options.php">
|
11 |
<?php
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
settings_fields($this->plugin_screen_hook_suffix);
|
14 |
+
do_settings_sections( $this->plugin_screen_hook_suffix);
|
|
|
15 |
|
16 |
+
do_action('advanced-ads-settings-form');
|
17 |
+
submit_button();
|
|
|
|
|
|
|
18 |
|
19 |
?>
|
20 |
</form>
|
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.
|
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.1.1
|
16 |
* Author: Thomas Maier
|
17 |
* Author URI: http://webgilde.com
|
18 |
* Text Domain: advanced-ads
|
assets/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
assets/screenshot-1.png
DELETED
Binary file
|
assets/screenshot-2.png
DELETED
Binary file
|
classes/ad.php
CHANGED
@@ -176,6 +176,9 @@ class Advads_Ad {
|
|
176 |
|
177 |
/**
|
178 |
* return ad content for frontend output
|
|
|
|
|
|
|
179 |
*/
|
180 |
public function output(){
|
181 |
if(!$this->is_ad) return '';
|
@@ -187,14 +190,28 @@ class Advads_Ad {
|
|
187 |
/**
|
188 |
* check if the ad can be displayed in frontend due to its conditions
|
189 |
*
|
|
|
190 |
* @return bool $can_display true if can be displayed in frontend
|
191 |
*/
|
192 |
public function can_display(){
|
193 |
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
}
|
199 |
|
200 |
/**
|
@@ -209,6 +226,9 @@ class Advads_Ad {
|
|
209 |
if(empty($this->options['conditions']) ||
|
210 |
!is_array($this->options['conditions'])) return true;
|
211 |
|
|
|
|
|
|
|
212 |
$conditions = $this->options['conditions'];
|
213 |
foreach($conditions as $_cond_key => $_cond_value) {
|
214 |
switch($_cond_key){
|
@@ -465,7 +485,7 @@ class Advads_Ad {
|
|
465 |
$conditions[$_key] = $_condition;
|
466 |
continue;
|
467 |
}
|
468 |
-
$type = $advanced_ads_ad_conditions[$_key]['type'];
|
469 |
if(empty($type)) continue;
|
470 |
|
471 |
// dynamically apply filters for each condition used
|
176 |
|
177 |
/**
|
178 |
* return ad content for frontend output
|
179 |
+
*
|
180 |
+
* @since 1.0.0
|
181 |
+
* @return string $output ad output
|
182 |
*/
|
183 |
public function output(){
|
184 |
if(!$this->is_ad) return '';
|
190 |
/**
|
191 |
* check if the ad can be displayed in frontend due to its conditions
|
192 |
*
|
193 |
+
* @since 1.0.0
|
194 |
* @return bool $can_display true if can be displayed in frontend
|
195 |
*/
|
196 |
public function can_display(){
|
197 |
|
198 |
+
$can_display = false;
|
199 |
+
$options = Advanced_Ads::get_instance()->options();
|
200 |
+
$see_ads_capability = (!empty($options['hide-for-user-role'])) ? $options['hide-for-user-role'] : 0;
|
201 |
+
|
202 |
+
// check if user is logged in and if so if users with his rights can see ads
|
203 |
+
if(is_user_logged_in() && $see_ads_capability && current_user_can($see_ads_capability)) return false;
|
204 |
+
|
205 |
+
if($this->can_display_by_conditions() && $this->can_display_by_visitor()) {
|
206 |
+
$can_display = true;
|
207 |
+
} else {
|
208 |
+
return false;
|
209 |
+
}
|
210 |
+
|
211 |
+
// add own conditions to flag output as possible or not
|
212 |
+
$can_display = apply_filters('advanced-ads-can-display', $can_display, $this);
|
213 |
+
|
214 |
+
return $can_display;
|
215 |
}
|
216 |
|
217 |
/**
|
226 |
if(empty($this->options['conditions']) ||
|
227 |
!is_array($this->options['conditions'])) return true;
|
228 |
|
229 |
+
// display ad if conditions are explicitely disabled
|
230 |
+
if(isset($this->options['conditions']['enabled']) && !$this->options['conditions']['enabled']) return true;
|
231 |
+
|
232 |
$conditions = $this->options['conditions'];
|
233 |
foreach($conditions as $_cond_key => $_cond_value) {
|
234 |
switch($_cond_key){
|
485 |
$conditions[$_key] = $_condition;
|
486 |
continue;
|
487 |
}
|
488 |
+
$type = !empty($advanced_ads_ad_conditions[$_key]['type']) ? $advanced_ads_ad_conditions[$_key]['type'] : 0;
|
489 |
if(empty($type)) continue;
|
490 |
|
491 |
// dynamically apply filters for each condition used
|
{trunk/classes → classes}/ad_placements.php
RENAMED
File without changes
|
public/class-advanced-ads.php
CHANGED
@@ -25,7 +25,7 @@ class Advanced_Ads {
|
|
25 |
* @var string
|
26 |
*/
|
27 |
|
28 |
-
const VERSION = '1.
|
29 |
|
30 |
/**
|
31 |
* post type slug
|
25 |
* @var string
|
26 |
*/
|
27 |
|
28 |
+
const VERSION = '1.1.1';
|
29 |
|
30 |
/**
|
31 |
* post type slug
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ 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.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -31,6 +31,7 @@ Learn more on the [plugin homepage](http://wpadvancedads.com).
|
|
31 |
= display conditions =
|
32 |
|
33 |
deliver ads based on conditions like
|
|
|
34 |
* post type
|
35 |
* post id
|
36 |
* category
|
@@ -40,7 +41,9 @@ deliver ads based on conditions like
|
|
40 |
= visitor conditions =
|
41 |
|
42 |
display ads by conditions based on the visitor
|
|
|
43 |
* all devices, mobile only or exclude mobile users
|
|
|
44 |
|
45 |
= based on WordPress standards =
|
46 |
|
@@ -115,6 +118,13 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
|
|
115 |
|
116 |
== Changelog ==
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
= 1.1.0 =
|
119 |
|
120 |
* allow displaying ads on mobile devices only or exclude from mobile devices
|
3 |
Tags: ads, ad, adsense
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 3.9.2
|
6 |
+
Stable tag: 1.1.1
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
31 |
= display conditions =
|
32 |
|
33 |
deliver ads based on conditions like
|
34 |
+
|
35 |
* post type
|
36 |
* post id
|
37 |
* category
|
41 |
= visitor conditions =
|
42 |
|
43 |
display ads by conditions based on the visitor
|
44 |
+
|
45 |
* all devices, mobile only or exclude mobile users
|
46 |
+
* hide all ads from logged in users based on their role
|
47 |
|
48 |
= based on WordPress standards =
|
49 |
|
118 |
|
119 |
== Changelog ==
|
120 |
|
121 |
+
= 1.1.1 =
|
122 |
+
|
123 |
+
* added filter to be able to add own checks whether to display an ad or not
|
124 |
+
* added action to add content to the visitor metabox
|
125 |
+
* option to hide/disable ad conditions
|
126 |
+
* option to hide all ads from logged in users based on user roles
|
127 |
+
|
128 |
= 1.1.0 =
|
129 |
|
130 |
* allow displaying ads on mobile devices only or exclude from mobile devices
|
trunk/LICENSE.txt
DELETED
@@ -1,339 +0,0 @@
|
|
1 |
-
GNU GENERAL PUBLIC LICENSE
|
2 |
-
Version 2, June 1991
|
3 |
-
|
4 |
-
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
5 |
-
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
-
Everyone is permitted to copy and distribute verbatim copies
|
7 |
-
of this license document, but changing it is not allowed.
|
8 |
-
|
9 |
-
Preamble
|
10 |
-
|
11 |
-
The licenses for most software are designed to take away your
|
12 |
-
freedom to share and change it. By contrast, the GNU General Public
|
13 |
-
License is intended to guarantee your freedom to share and change free
|
14 |
-
software--to make sure the software is free for all its users. This
|
15 |
-
General Public License applies to most of the Free Software
|
16 |
-
Foundation's software and to any other program whose authors commit to
|
17 |
-
using it. (Some other Free Software Foundation software is covered by
|
18 |
-
the GNU Lesser General Public License instead.) You can apply it to
|
19 |
-
your programs, too.
|
20 |
-
|
21 |
-
When we speak of free software, we are referring to freedom, not
|
22 |
-
price. Our General Public Licenses are designed to make sure that you
|
23 |
-
have the freedom to distribute copies of free software (and charge for
|
24 |
-
this service if you wish), that you receive source code or can get it
|
25 |
-
if you want it, that you can change the software or use pieces of it
|
26 |
-
in new free programs; and that you know you can do these things.
|
27 |
-
|
28 |
-
To protect your rights, we need to make restrictions that forbid
|
29 |
-
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
-
These restrictions translate to certain responsibilities for you if you
|
31 |
-
distribute copies of the software, or if you modify it.
|
32 |
-
|
33 |
-
For example, if you distribute copies of such a program, whether
|
34 |
-
gratis or for a fee, you must give the recipients all the rights that
|
35 |
-
you have. You must make sure that they, too, receive or can get the
|
36 |
-
source code. And you must show them these terms so they know their
|
37 |
-
rights.
|
38 |
-
|
39 |
-
We protect your rights with two steps: (1) copyright the software, and
|
40 |
-
(2) offer you this license which gives you legal permission to copy,
|
41 |
-
distribute and/or modify the software.
|
42 |
-
|
43 |
-
Also, for each author's protection and ours, we want to make certain
|
44 |
-
that everyone understands that there is no warranty for this free
|
45 |
-
software. If the software is modified by someone else and passed on, we
|
46 |
-
want its recipients to know that what they have is not the original, so
|
47 |
-
that any problems introduced by others will not reflect on the original
|
48 |
-
authors' reputations.
|
49 |
-
|
50 |
-
Finally, any free program is threatened constantly by software
|
51 |
-
patents. We wish to avoid the danger that redistributors of a free
|
52 |
-
program will individually obtain patent licenses, in effect making the
|
53 |
-
program proprietary. To prevent this, we have made it clear that any
|
54 |
-
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
-
|
56 |
-
The precise terms and conditions for copying, distribution and
|
57 |
-
modification follow.
|
58 |
-
|
59 |
-
GNU GENERAL PUBLIC LICENSE
|
60 |
-
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
-
|
62 |
-
0. This License applies to any program or other work which contains
|
63 |
-
a notice placed by the copyright holder saying it may be distributed
|
64 |
-
under the terms of this General Public License. The "Program", below,
|
65 |
-
refers to any such program or work, and a "work based on the Program"
|
66 |
-
means either the Program or any derivative work under copyright law:
|
67 |
-
that is to say, a work containing the Program or a portion of it,
|
68 |
-
either verbatim or with modifications and/or translated into another
|
69 |
-
language. (Hereinafter, translation is included without limitation in
|
70 |
-
the term "modification".) Each licensee is addressed as "you".
|
71 |
-
|
72 |
-
Activities other than copying, distribution and modification are not
|
73 |
-
covered by this License; they are outside its scope. The act of
|
74 |
-
running the Program is not restricted, and the output from the Program
|
75 |
-
is covered only if its contents constitute a work based on the
|
76 |
-
Program (independent of having been made by running the Program).
|
77 |
-
Whether that is true depends on what the Program does.
|
78 |
-
|
79 |
-
1. You may copy and distribute verbatim copies of the Program's
|
80 |
-
source code as you receive it, in any medium, provided that you
|
81 |
-
conspicuously and appropriately publish on each copy an appropriate
|
82 |
-
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
-
notices that refer to this License and to the absence of any warranty;
|
84 |
-
and give any other recipients of the Program a copy of this License
|
85 |
-
along with the Program.
|
86 |
-
|
87 |
-
You may charge a fee for the physical act of transferring a copy, and
|
88 |
-
you may at your option offer warranty protection in exchange for a fee.
|
89 |
-
|
90 |
-
2. You may modify your copy or copies of the Program or any portion
|
91 |
-
of it, thus forming a work based on the Program, and copy and
|
92 |
-
distribute such modifications or work under the terms of Section 1
|
93 |
-
above, provided that you also meet all of these conditions:
|
94 |
-
|
95 |
-
a) You must cause the modified files to carry prominent notices
|
96 |
-
stating that you changed the files and the date of any change.
|
97 |
-
|
98 |
-
b) You must cause any work that you distribute or publish, that in
|
99 |
-
whole or in part contains or is derived from the Program or any
|
100 |
-
part thereof, to be licensed as a whole at no charge to all third
|
101 |
-
parties under the terms of this License.
|
102 |
-
|
103 |
-
c) If the modified program normally reads commands interactively
|
104 |
-
when run, you must cause it, when started running for such
|
105 |
-
interactive use in the most ordinary way, to print or display an
|
106 |
-
announcement including an appropriate copyright notice and a
|
107 |
-
notice that there is no warranty (or else, saying that you provide
|
108 |
-
a warranty) and that users may redistribute the program under
|
109 |
-
these conditions, and telling the user how to view a copy of this
|
110 |
-
License. (Exception: if the Program itself is interactive but
|
111 |
-
does not normally print such an announcement, your work based on
|
112 |
-
the Program is not required to print an announcement.)
|
113 |
-
|
114 |
-
These requirements apply to the modified work as a whole. If
|
115 |
-
identifiable sections of that work are not derived from the Program,
|
116 |
-
and can be reasonably considered independent and separate works in
|
117 |
-
themselves, then this License, and its terms, do not apply to those
|
118 |
-
sections when you distribute them as separate works. But when you
|
119 |
-
distribute the same sections as part of a whole which is a work based
|
120 |
-
on the Program, the distribution of the whole must be on the terms of
|
121 |
-
this License, whose permissions for other licensees extend to the
|
122 |
-
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
-
|
124 |
-
Thus, it is not the intent of this section to claim rights or contest
|
125 |
-
your rights to work written entirely by you; rather, the intent is to
|
126 |
-
exercise the right to control the distribution of derivative or
|
127 |
-
collective works based on the Program.
|
128 |
-
|
129 |
-
In addition, mere aggregation of another work not based on the Program
|
130 |
-
with the Program (or with a work based on the Program) on a volume of
|
131 |
-
a storage or distribution medium does not bring the other work under
|
132 |
-
the scope of this License.
|
133 |
-
|
134 |
-
3. You may copy and distribute the Program (or a work based on it,
|
135 |
-
under Section 2) in object code or executable form under the terms of
|
136 |
-
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
-
|
138 |
-
a) Accompany it with the complete corresponding machine-readable
|
139 |
-
source code, which must be distributed under the terms of Sections
|
140 |
-
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
-
|
142 |
-
b) Accompany it with a written offer, valid for at least three
|
143 |
-
years, to give any third party, for a charge no more than your
|
144 |
-
cost of physically performing source distribution, a complete
|
145 |
-
machine-readable copy of the corresponding source code, to be
|
146 |
-
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
-
customarily used for software interchange; or,
|
148 |
-
|
149 |
-
c) Accompany it with the information you received as to the offer
|
150 |
-
to distribute corresponding source code. (This alternative is
|
151 |
-
allowed only for noncommercial distribution and only if you
|
152 |
-
received the program in object code or executable form with such
|
153 |
-
an offer, in accord with Subsection b above.)
|
154 |
-
|
155 |
-
The source code for a work means the preferred form of the work for
|
156 |
-
making modifications to it. For an executable work, complete source
|
157 |
-
code means all the source code for all modules it contains, plus any
|
158 |
-
associated interface definition files, plus the scripts used to
|
159 |
-
control compilation and installation of the executable. However, as a
|
160 |
-
special exception, the source code distributed need not include
|
161 |
-
anything that is normally distributed (in either source or binary
|
162 |
-
form) with the major components (compiler, kernel, and so on) of the
|
163 |
-
operating system on which the executable runs, unless that component
|
164 |
-
itself accompanies the executable.
|
165 |
-
|
166 |
-
If distribution of executable or object code is made by offering
|
167 |
-
access to copy from a designated place, then offering equivalent
|
168 |
-
access to copy the source code from the same place counts as
|
169 |
-
distribution of the source code, even though third parties are not
|
170 |
-
compelled to copy the source along with the object code.
|
171 |
-
|
172 |
-
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
-
except as expressly provided under this License. Any attempt
|
174 |
-
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
-
void, and will automatically terminate your rights under this License.
|
176 |
-
However, parties who have received copies, or rights, from you under
|
177 |
-
this License will not have their licenses terminated so long as such
|
178 |
-
parties remain in full compliance.
|
179 |
-
|
180 |
-
5. You are not required to accept this License, since you have not
|
181 |
-
signed it. However, nothing else grants you permission to modify or
|
182 |
-
distribute the Program or its derivative works. These actions are
|
183 |
-
prohibited by law if you do not accept this License. Therefore, by
|
184 |
-
modifying or distributing the Program (or any work based on the
|
185 |
-
Program), you indicate your acceptance of this License to do so, and
|
186 |
-
all its terms and conditions for copying, distributing or modifying
|
187 |
-
the Program or works based on it.
|
188 |
-
|
189 |
-
6. Each time you redistribute the Program (or any work based on the
|
190 |
-
Program), the recipient automatically receives a license from the
|
191 |
-
original licensor to copy, distribute or modify the Program subject to
|
192 |
-
these terms and conditions. You may not impose any further
|
193 |
-
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
-
You are not responsible for enforcing compliance by third parties to
|
195 |
-
this License.
|
196 |
-
|
197 |
-
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
-
infringement or for any other reason (not limited to patent issues),
|
199 |
-
conditions are imposed on you (whether by court order, agreement or
|
200 |
-
otherwise) that contradict the conditions of this License, they do not
|
201 |
-
excuse you from the conditions of this License. If you cannot
|
202 |
-
distribute so as to satisfy simultaneously your obligations under this
|
203 |
-
License and any other pertinent obligations, then as a consequence you
|
204 |
-
may not distribute the Program at all. For example, if a patent
|
205 |
-
license would not permit royalty-free redistribution of the Program by
|
206 |
-
all those who receive copies directly or indirectly through you, then
|
207 |
-
the only way you could satisfy both it and this License would be to
|
208 |
-
refrain entirely from distribution of the Program.
|
209 |
-
|
210 |
-
If any portion of this section is held invalid or unenforceable under
|
211 |
-
any particular circumstance, the balance of the section is intended to
|
212 |
-
apply and the section as a whole is intended to apply in other
|
213 |
-
circumstances.
|
214 |
-
|
215 |
-
It is not the purpose of this section to induce you to infringe any
|
216 |
-
patents or other property right claims or to contest validity of any
|
217 |
-
such claims; this section has the sole purpose of protecting the
|
218 |
-
integrity of the free software distribution system, which is
|
219 |
-
implemented by public license practices. Many people have made
|
220 |
-
generous contributions to the wide range of software distributed
|
221 |
-
through that system in reliance on consistent application of that
|
222 |
-
system; it is up to the author/donor to decide if he or she is willing
|
223 |
-
to distribute software through any other system and a licensee cannot
|
224 |
-
impose that choice.
|
225 |
-
|
226 |
-
This section is intended to make thoroughly clear what is believed to
|
227 |
-
be a consequence of the rest of this License.
|
228 |
-
|
229 |
-
8. If the distribution and/or use of the Program is restricted in
|
230 |
-
certain countries either by patents or by copyrighted interfaces, the
|
231 |
-
original copyright holder who places the Program under this License
|
232 |
-
may add an explicit geographical distribution limitation excluding
|
233 |
-
those countries, so that distribution is permitted only in or among
|
234 |
-
countries not thus excluded. In such case, this License incorporates
|
235 |
-
the limitation as if written in the body of this License.
|
236 |
-
|
237 |
-
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
-
of the General Public License from time to time. Such new versions will
|
239 |
-
be similar in spirit to the present version, but may differ in detail to
|
240 |
-
address new problems or concerns.
|
241 |
-
|
242 |
-
Each version is given a distinguishing version number. If the Program
|
243 |
-
specifies a version number of this License which applies to it and "any
|
244 |
-
later version", you have the option of following the terms and conditions
|
245 |
-
either of that version or of any later version published by the Free
|
246 |
-
Software Foundation. If the Program does not specify a version number of
|
247 |
-
this License, you may choose any version ever published by the Free Software
|
248 |
-
Foundation.
|
249 |
-
|
250 |
-
10. If you wish to incorporate parts of the Program into other free
|
251 |
-
programs whose distribution conditions are different, write to the author
|
252 |
-
to ask for permission. For software which is copyrighted by the Free
|
253 |
-
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
-
make exceptions for this. Our decision will be guided by the two goals
|
255 |
-
of preserving the free status of all derivatives of our free software and
|
256 |
-
of promoting the sharing and reuse of software generally.
|
257 |
-
|
258 |
-
NO WARRANTY
|
259 |
-
|
260 |
-
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
-
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
-
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
-
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
-
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
-
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
-
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
-
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
-
REPAIR OR CORRECTION.
|
269 |
-
|
270 |
-
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
-
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
-
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
-
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
-
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
-
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
-
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
-
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
-
POSSIBILITY OF SUCH DAMAGES.
|
279 |
-
|
280 |
-
END OF TERMS AND CONDITIONS
|
281 |
-
|
282 |
-
How to Apply These Terms to Your New Programs
|
283 |
-
|
284 |
-
If you develop a new program, and you want it to be of the greatest
|
285 |
-
possible use to the public, the best way to achieve this is to make it
|
286 |
-
free software which everyone can redistribute and change under these terms.
|
287 |
-
|
288 |
-
To do so, attach the following notices to the program. It is safest
|
289 |
-
to attach them to the start of each source file to most effectively
|
290 |
-
convey the exclusion of warranty; and each file should have at least
|
291 |
-
the "copyright" line and a pointer to where the full notice is found.
|
292 |
-
|
293 |
-
<one line to give the program's name and a brief idea of what it does.>
|
294 |
-
Copyright (C) <year> <name of author>
|
295 |
-
|
296 |
-
This program is free software; you can redistribute it and/or modify
|
297 |
-
it under the terms of the GNU General Public License as published by
|
298 |
-
the Free Software Foundation; either version 2 of the License, or
|
299 |
-
(at your option) any later version.
|
300 |
-
|
301 |
-
This program is distributed in the hope that it will be useful,
|
302 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
-
GNU General Public License for more details.
|
305 |
-
|
306 |
-
You should have received a copy of the GNU General Public License along
|
307 |
-
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
-
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
-
|
310 |
-
Also add information on how to contact you by electronic and paper mail.
|
311 |
-
|
312 |
-
If the program is interactive, make it output a short notice like this
|
313 |
-
when it starts in an interactive mode:
|
314 |
-
|
315 |
-
Gnomovision version 69, Copyright (C) year name of author
|
316 |
-
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
-
This is free software, and you are welcome to redistribute it
|
318 |
-
under certain conditions; type `show c' for details.
|
319 |
-
|
320 |
-
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
-
parts of the General Public License. Of course, the commands you use may
|
322 |
-
be called something other than `show w' and `show c'; they could even be
|
323 |
-
mouse-clicks or menu items--whatever suits your program.
|
324 |
-
|
325 |
-
You should also get your employer (if you work as a programmer) or your
|
326 |
-
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
-
necessary. Here is a sample; alter the names:
|
328 |
-
|
329 |
-
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
-
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
-
|
332 |
-
<signature of Ty Coon>, 1 April 1989
|
333 |
-
Ty Coon, President of Vice
|
334 |
-
|
335 |
-
This General Public License does not permit incorporating your program into
|
336 |
-
proprietary programs. If your program is a subroutine library, you may
|
337 |
-
consider it more useful to permit linking proprietary applications with the
|
338 |
-
library. If this is what you want to do, use the GNU Lesser General
|
339 |
-
Public License instead of this License.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/assets/css/admin.css
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* AD EDIT PAGE
|
3 |
-
*/
|
4 |
-
#ad-main-box { overflow: hidden; }
|
5 |
-
.post-type-advanced_ads .meta-box-sortables .hndle { display: none; }
|
6 |
-
.post-type-advanced_ads .meta-box-sortables .handlediv { display: none; }
|
7 |
-
.post-type-advanced_ads #poststuff .meta-box-sortables .inside {
|
8 |
-
margin: 0;
|
9 |
-
padding: 0;
|
10 |
-
}
|
11 |
-
.post-type-advanced_ads .meta-box-sortables .inside > * {
|
12 |
-
margin: 20px 10px;
|
13 |
-
}
|
14 |
-
.post-type-advanced_ads .meta-box-sortables .inside h4 {
|
15 |
-
background: linear-gradient(to top, #ECECEC, #F9F9F9) repeat scroll 0 0 #F1F1F1;
|
16 |
-
font-size: 15px;
|
17 |
-
font-weight: 400;
|
18 |
-
line-height: 1;
|
19 |
-
margin: 0;
|
20 |
-
padding: 10px 10px 5px;
|
21 |
-
}
|
22 |
-
#advanced-ad-type .description {
|
23 |
-
display: block;
|
24 |
-
margin-left: 24px;
|
25 |
-
}
|
26 |
-
.post-type-advanced_ads #advanced_ad_content_others textarea {
|
27 |
-
width: 100%;
|
28 |
-
height: 20em;
|
29 |
-
}
|
30 |
-
|
31 |
-
.post-type-advanced_ads #advanced-ad-conditions {
|
32 |
-
text-align: left;
|
33 |
-
}
|
34 |
-
.post-type-advanced_ads #advads-ad-content-plain {
|
35 |
-
width: 100%;
|
36 |
-
}
|
37 |
-
.post-type-advanced_ads #ad-parameters-box .advads-ad-parameters-spinner { display: block; float: none; }
|
38 |
-
|
39 |
-
/**
|
40 |
-
AD GROUP LIST
|
41 |
-
*/
|
42 |
-
.advads-groups-ads-list { margin: 0; }
|
43 |
-
.ad-group-ads-form table td { margin: 0; padding: 3px 5px 3px 0; }
|
44 |
-
.ad-group-ads-form table td:first-child { font-weight: bold; }
|
45 |
-
.ad-group-ads-form table td.ad-group-ads-weight input { width: 3em; }
|
46 |
-
|
47 |
-
/**
|
48 |
-
AD PLACEMENTS
|
49 |
-
*/
|
50 |
-
.advads-placements-new-form label { display: inline-block; width: 10em; }
|
51 |
-
.advads-placements-new-form input { display: inline-block; }
|
52 |
-
.advads-placements-table { min-width: 80%; }
|
53 |
-
.advads-placements-table thead tr { background: #fff; }
|
54 |
-
.advads-placements-table tbody tr:nth-child(even) { background: #fff; }
|
55 |
-
.advads-placements-table th { margin: 0; padding: 10px; text-align: left; }
|
56 |
-
.advads-placements-table td { margin: 0; padding: 10px; text-align: left; }
|
57 |
-
/**
|
58 |
-
GENERAL ELEMENTS
|
59 |
-
*/
|
60 |
-
.advads-toggle-link { cursor: pointer; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/assets/css/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
trunk/admin/assets/js/admin.js
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
jQuery(document).ready(function($) {
|
2 |
-
"use strict";
|
3 |
-
/*
|
4 |
-
function load_content_editor( ad_type ) {
|
5 |
-
$.ajax({
|
6 |
-
type: 'POST',
|
7 |
-
url: ajaxurl,
|
8 |
-
data: {
|
9 |
-
'action': 'load_content_editor',
|
10 |
-
'type' : ad_type,
|
11 |
-
'ad_id' : $('#post_ID').val()
|
12 |
-
},
|
13 |
-
success:function(data, textStatus, XMLHttpRequest){
|
14 |
-
// toggle main content field
|
15 |
-
if(data == 'content') {
|
16 |
-
$('#advanced_ad_content_others').html(''); // clear other editors
|
17 |
-
$('#advanced_ad_content').show();
|
18 |
-
} else {
|
19 |
-
$('#advanced_ad_content').hide();
|
20 |
-
$('#advanced_ad_content_others').html(data);
|
21 |
-
}
|
22 |
-
},
|
23 |
-
error: function(MLHttpRequest, textStatus, errorThrown){
|
24 |
-
$('#advanced_ad_content_others').html(errorThrown);
|
25 |
-
}
|
26 |
-
});
|
27 |
-
};
|
28 |
-
|
29 |
-
// load content editor on page load
|
30 |
-
if($('#advanced_ad_type input').length > 0) {
|
31 |
-
var ad_type = $('#advanced_ad_type input').val();
|
32 |
-
load_content_editor(ad_type);
|
33 |
-
}
|
34 |
-
|
35 |
-
$(document).on('change', '#advanced_ad_type input', function(){
|
36 |
-
var ad_type = $(this).val()
|
37 |
-
load_content_editor( ad_type );
|
38 |
-
});
|
39 |
-
*/
|
40 |
-
|
41 |
-
function advads_load_ad_type_parameter_metabox(ad_type) {
|
42 |
-
$('#advanced-ads-ad-parameters').html('<span class="spinner advads-ad-parameters-spinner"></span>');
|
43 |
-
$.ajax({
|
44 |
-
type: 'POST',
|
45 |
-
url: ajaxurl,
|
46 |
-
data: {
|
47 |
-
'action': 'load_ad_parameters_metabox',
|
48 |
-
'ad_type': ad_type,
|
49 |
-
'ad_id': $('#post_ID').val()
|
50 |
-
},
|
51 |
-
success: function(data, textStatus, XMLHttpRequest) {
|
52 |
-
// toggle main content field
|
53 |
-
if (data) {
|
54 |
-
$('#advanced-ads-ad-parameters').html(data);
|
55 |
-
}
|
56 |
-
},
|
57 |
-
error: function(MLHttpRequest, textStatus, errorThrown) {
|
58 |
-
$('#advanced-ads-ad-parameters').html(errorThrown);
|
59 |
-
}
|
60 |
-
});
|
61 |
-
}
|
62 |
-
;
|
63 |
-
|
64 |
-
$(document).on('change', '#advanced-ad-type input', function() {
|
65 |
-
var ad_type = $(this).val()
|
66 |
-
advads_load_ad_type_parameter_metabox(ad_type);
|
67 |
-
});
|
68 |
-
|
69 |
-
// empty / clear input condition fields in the same row as the clear button
|
70 |
-
$('#advanced-ad-conditions .clear-radio').click(function() {
|
71 |
-
$(this).closest('tr').find('input[type="radio"]').prop('checked', false);
|
72 |
-
$(this).closest('tr').find('input[type="text"]').val('');
|
73 |
-
});
|
74 |
-
|
75 |
-
})
|
76 |
-
|
77 |
-
/**
|
78 |
-
* toggle content elements (hide/show)
|
79 |
-
*
|
80 |
-
* @param selector jquery selector
|
81 |
-
*/
|
82 |
-
function advads_toggle(selector) {
|
83 |
-
jQuery(selector).slideToggle();
|
84 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/assets/js/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
trunk/admin/assets/js/inline-edit-group-ads.js
DELETED
@@ -1,101 +0,0 @@
|
|
1 |
-
/* saving ad group ad settings */
|
2 |
-
|
3 |
-
var inlineEditAdGroupAds;
|
4 |
-
(function($) {
|
5 |
-
inlineEditAdGroupAds = {
|
6 |
-
init: function() {
|
7 |
-
var t = this;
|
8 |
-
$('#the-list').on('click', 'a.edit-ad-group-ads', function() {
|
9 |
-
inlineEditAdGroupAds.edit(this);
|
10 |
-
return false;
|
11 |
-
});
|
12 |
-
$('#the-list').on('click', 'a.cancel', function() {
|
13 |
-
return inlineEditAdGroupAds.revert();
|
14 |
-
});
|
15 |
-
$('#the-list').on('click', 'a.save', function() {
|
16 |
-
return inlineEditAdGroupAds.save(this);
|
17 |
-
});
|
18 |
-
$('#the-list').on('keydown', 'input, select', function() {
|
19 |
-
if (e.which === 13) {
|
20 |
-
return inlineEditAdGroupAds.save(this);
|
21 |
-
}
|
22 |
-
});
|
23 |
-
$('#posts-filter input[type="submit"]').mousedown(function() {
|
24 |
-
t.revert();
|
25 |
-
});
|
26 |
-
},
|
27 |
-
edit: function(link) {
|
28 |
-
var td, id, t = this;
|
29 |
-
// get group id
|
30 |
-
id = t.getId(link);
|
31 |
-
// get container
|
32 |
-
td = $(link).parents('td');
|
33 |
-
// load form with information
|
34 |
-
params = {
|
35 |
-
action: 'advads-ad-group-ads-form',
|
36 |
-
group_id: id,
|
37 |
-
};
|
38 |
-
$.post(ajaxurl, params,
|
39 |
-
// append return
|
40 |
-
function(r) {
|
41 |
-
if (r) {
|
42 |
-
// hide all child elements
|
43 |
-
td.children('*').hide();
|
44 |
-
// display the form
|
45 |
-
$(r).appendTo(td);
|
46 |
-
}
|
47 |
-
}
|
48 |
-
);
|
49 |
-
return false;
|
50 |
-
},
|
51 |
-
save: function(link) {
|
52 |
-
var params, td, id, t = this;
|
53 |
-
// get group id
|
54 |
-
id = t.getId(link);
|
55 |
-
// get container
|
56 |
-
td = $(link).parents('td');
|
57 |
-
td.find('.ad-group-ads-form .spinner').show();
|
58 |
-
params = {
|
59 |
-
action: 'advads-ad-group-ads-form-save',
|
60 |
-
group_id: id,
|
61 |
-
fields: ''
|
62 |
-
};
|
63 |
-
params.fields = td.find(':input').serialize();
|
64 |
-
// make ajax request
|
65 |
-
$.post(ajaxurl, params, function(r) {
|
66 |
-
td.find('.ad-group-ads-form .spinner').hide();
|
67 |
-
if (r) {
|
68 |
-
t.revert(); // show normal table
|
69 |
-
|
70 |
-
$.each(r, function(key, value){
|
71 |
-
// search the field with the ad weight and change the value
|
72 |
-
td.find('.ad-weight-' + key).html(value);
|
73 |
-
})
|
74 |
-
}
|
75 |
-
|
76 |
-
}, "json"
|
77 |
-
);
|
78 |
-
return false;
|
79 |
-
},
|
80 |
-
// remove edit form and display the other elements again
|
81 |
-
revert: function() {
|
82 |
-
var td = $('table.widefat .ad-group-ads-form').parents('td');
|
83 |
-
if (td) {
|
84 |
-
$('table.widefat .spinner').hide();
|
85 |
-
td.find('.ad-group-ads-form').remove();
|
86 |
-
td.find('*').show();
|
87 |
-
}
|
88 |
-
|
89 |
-
return false;
|
90 |
-
},
|
91 |
-
// get the id of the group from the link clicked
|
92 |
-
getId: function(link) {
|
93 |
-
groupid = $(link).parents('td').find('.ad-group-id').val();
|
94 |
-
return parseInt(groupid);
|
95 |
-
;
|
96 |
-
}
|
97 |
-
};
|
98 |
-
$(document).ready(function() {
|
99 |
-
inlineEditAdGroupAds.init();
|
100 |
-
});
|
101 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/class-advanced-ads-admin.php
DELETED
@@ -1,554 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Advanced Ads.
|
5 |
-
*
|
6 |
-
* @package Advanced_Ads_Admin
|
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 |
-
* Plugin class. This class should ideally be used to work with the
|
15 |
-
* administrative side of the WordPress site.
|
16 |
-
*
|
17 |
-
* *
|
18 |
-
* @package Advanced_Ads_Admin
|
19 |
-
* @author Thomas Maier <thomas.maier@webgilde.com>
|
20 |
-
*/
|
21 |
-
class Advanced_Ads_Admin {
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Instance of this class.
|
25 |
-
*
|
26 |
-
* @since 1.0.0
|
27 |
-
* @var object
|
28 |
-
*/
|
29 |
-
protected static $instance = null;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Slug of the settings page
|
33 |
-
*
|
34 |
-
* @since 1.0.0
|
35 |
-
* @var string
|
36 |
-
*/
|
37 |
-
public $plugin_screen_hook_suffix = null;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Slug of the ad group page
|
41 |
-
*
|
42 |
-
* @since 1.0.0
|
43 |
-
* @var string
|
44 |
-
*/
|
45 |
-
protected $ad_group_hook_suffix = null;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* general plugin slug
|
49 |
-
*
|
50 |
-
* @since 1.0.0
|
51 |
-
* @var string
|
52 |
-
*/
|
53 |
-
protected $plugin_slug = '';
|
54 |
-
|
55 |
-
/**
|
56 |
-
* post type slug
|
57 |
-
*
|
58 |
-
* @since 1.0.0
|
59 |
-
* @var string
|
60 |
-
*/
|
61 |
-
protected $post_type = '';
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Initialize the plugin by loading admin scripts & styles and adding a
|
65 |
-
* settings page and menu.
|
66 |
-
*
|
67 |
-
* @since 1.0.0
|
68 |
-
*/
|
69 |
-
private function __construct() {
|
70 |
-
|
71 |
-
/*
|
72 |
-
* Call $plugin_slug from public plugin class.
|
73 |
-
*
|
74 |
-
*/
|
75 |
-
$plugin = Advanced_Ads::get_instance();
|
76 |
-
$this->plugin_slug = $plugin->get_plugin_slug();
|
77 |
-
$this->post_type = constant("Advanced_Ads::POST_TYPE_SLUG");
|
78 |
-
|
79 |
-
// Load admin style sheet and JavaScript.
|
80 |
-
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles'));
|
81 |
-
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
|
82 |
-
|
83 |
-
// Add menu items
|
84 |
-
add_action('admin_menu', array($this, 'add_ad_group_menu'));
|
85 |
-
add_action('admin_menu', array($this, 'add_plugin_admin_menu'));
|
86 |
-
|
87 |
-
// on post/ad edit screen
|
88 |
-
add_action('edit_form_after_title', array($this, 'edit_form_below_title'));
|
89 |
-
add_action('admin_init', array($this, 'add_meta_boxes'));
|
90 |
-
|
91 |
-
// save ads post type
|
92 |
-
add_action('save_post', array($this, 'save_ad'));
|
93 |
-
|
94 |
-
// settings handling
|
95 |
-
add_action('admin_init', array($this, 'settings_init'));
|
96 |
-
|
97 |
-
// Add an action link pointing to the options page.
|
98 |
-
$plugin_basename = plugin_basename(plugin_dir_path('__DIR__') . $this->plugin_slug . '.php');
|
99 |
-
add_filter('plugin_action_links_' . $plugin_basename, array($this, 'add_action_links'));
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Return an instance of this class.
|
105 |
-
*
|
106 |
-
* @since 1.0.0
|
107 |
-
*
|
108 |
-
* @return object A single instance of this class.
|
109 |
-
*/
|
110 |
-
public static function get_instance() {
|
111 |
-
|
112 |
-
// If the single instance hasn't been set, set it now.
|
113 |
-
if (null == self::$instance) {
|
114 |
-
self::$instance = new self;
|
115 |
-
}
|
116 |
-
|
117 |
-
return self::$instance;
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Register and enqueue admin-specific style sheet.
|
122 |
-
*
|
123 |
-
* @since 1.0.0
|
124 |
-
*
|
125 |
-
* @return null Return early if no settings page is registered.
|
126 |
-
*/
|
127 |
-
public function enqueue_admin_styles() {
|
128 |
-
|
129 |
-
global $post;
|
130 |
-
if (!isset($this->plugin_screen_hook_suffix) && isset($post) && Advanced_Ads::POST_TYPE_SLUG != $post->type) {
|
131 |
-
return;
|
132 |
-
}
|
133 |
-
|
134 |
-
wp_enqueue_style($this->plugin_slug . '-admin-styles', plugins_url('assets/css/admin.css', __FILE__), array(), Advanced_Ads::VERSION);
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Register and enqueue admin-specific JavaScript.
|
139 |
-
*
|
140 |
-
* @since 1.0.0
|
141 |
-
*
|
142 |
-
* @return null Return early if no settings page is registered.
|
143 |
-
*/
|
144 |
-
public function enqueue_admin_scripts() {
|
145 |
-
|
146 |
-
global $post;
|
147 |
-
if (!isset($this->plugin_screen_hook_suffix) && isset($post) && Advanced_Ads::POST_TYPE_SLUG != $post->type) {
|
148 |
-
return;
|
149 |
-
}
|
150 |
-
|
151 |
-
wp_enqueue_script($this->plugin_slug . '-admin-script', plugins_url('assets/js/admin.js', __FILE__), array('jquery'), Advanced_Ads::VERSION);
|
152 |
-
|
153 |
-
// just register this script for later inclusion on ad group list page
|
154 |
-
wp_register_script('inline-edit-group-ads', plugins_url('assets/js/inline-edit-group-ads.js', __FILE__), array('jquery'), Advanced_Ads::VERSION);
|
155 |
-
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* Register the administration menu for this plugin into the WordPress Dashboard menu.
|
160 |
-
*
|
161 |
-
* @since 1.0.0
|
162 |
-
*/
|
163 |
-
public function add_plugin_admin_menu() {
|
164 |
-
|
165 |
-
// add placements page
|
166 |
-
add_submenu_page(
|
167 |
-
'edit.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG, __('Ad Placements', $this->plugin_slug), __('Placements', $this->plugin_slug), 'manage_options', $this->plugin_slug . '-placements', array($this, 'display_placements_page')
|
168 |
-
);
|
169 |
-
// add settings page
|
170 |
-
$this->plugin_screen_hook_suffix = add_submenu_page(
|
171 |
-
'edit.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG, __('Advanced Ads Settings', $this->plugin_slug), __('Settings', $this->plugin_slug), 'manage_options', $this->plugin_slug . '-settings', array($this, 'display_plugin_settings_page')
|
172 |
-
);
|
173 |
-
add_submenu_page(
|
174 |
-
null, __('Advanced Ads Debugging', $this->plugin_slug), __('Debug', $this->plugin_slug), 'manage_options', $this->plugin_slug . '-debug', array($this, 'display_plugin_debug_page')
|
175 |
-
);
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Render the settings page
|
180 |
-
*
|
181 |
-
* @since 1.0.0
|
182 |
-
*/
|
183 |
-
public function display_plugin_settings_page() {
|
184 |
-
include_once( 'views/settings.php' );
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Render the placements page
|
189 |
-
*
|
190 |
-
* @since 1.1.0
|
191 |
-
*/
|
192 |
-
public function display_placements_page() {
|
193 |
-
// sace new placement
|
194 |
-
if(isset($_POST['advads']['placement'])){
|
195 |
-
$return = Advads_Ad_Placements::save_new_placement($_POST['advads']['placement']);
|
196 |
-
}
|
197 |
-
// save placement data
|
198 |
-
if(isset($_POST['advads']['placements'])){
|
199 |
-
$return = Advads_Ad_Placements::save_placements($_POST['advads']['placements']);
|
200 |
-
}
|
201 |
-
$error = false;
|
202 |
-
if(isset($return) && $return !== true) $error = $return;
|
203 |
-
$placements = Advanced_Ads::get_ad_placements_array();
|
204 |
-
// load ads and groups for select field
|
205 |
-
|
206 |
-
// display view
|
207 |
-
include_once( 'views/placements.php' );
|
208 |
-
}
|
209 |
-
|
210 |
-
/**
|
211 |
-
* Render the debug page
|
212 |
-
*
|
213 |
-
* @since 1.0.1
|
214 |
-
*/
|
215 |
-
public function display_plugin_debug_page() {
|
216 |
-
// load array with ads by condition
|
217 |
-
$plugin = Advanced_Ads::get_instance();
|
218 |
-
$ads_by_conditions = $plugin->get_ads_by_conditions_array();
|
219 |
-
$ad_injections = $plugin->get_ad_injections_array();
|
220 |
-
|
221 |
-
include_once( 'views/debug.php' );
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* Register ad group taxonomy page
|
226 |
-
*
|
227 |
-
* @since 1.0.0
|
228 |
-
*/
|
229 |
-
public function add_ad_group_menu() {
|
230 |
-
|
231 |
-
$this->ad_group_hook_suffix = add_submenu_page(
|
232 |
-
'edit.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG, __('Ad Groups', $this->plugin_slug), __('Ad Groups', $this->plugin_slug), 'manage_options', $this->plugin_slug . '-groups', array($this, 'ad_group_admin_page')
|
233 |
-
);
|
234 |
-
}
|
235 |
-
|
236 |
-
/**
|
237 |
-
* Render the ad group page
|
238 |
-
*
|
239 |
-
* @since 1.0.0
|
240 |
-
*/
|
241 |
-
public function ad_group_admin_page() {
|
242 |
-
|
243 |
-
$taxonomy = Advanced_Ads::AD_GROUP_TAXONOMY;
|
244 |
-
$post_type = Advanced_Ads::POST_TYPE_SLUG;
|
245 |
-
$tax = get_taxonomy($taxonomy);
|
246 |
-
|
247 |
-
$action = $this->current_action();
|
248 |
-
|
249 |
-
// handle new and updated groups
|
250 |
-
if ($action == 'editedgroup') {
|
251 |
-
$group_id = (int) $_POST['group_id'];
|
252 |
-
check_admin_referer('update-group_' . $group_id);
|
253 |
-
|
254 |
-
if (!current_user_can($tax->cap->edit_terms))
|
255 |
-
wp_die(__('Cheatin’ uh?'));
|
256 |
-
|
257 |
-
// handle new groups
|
258 |
-
if ($group_id == 0) {
|
259 |
-
$ret = wp_insert_term($_POST['name'], $taxonomy, $_POST);
|
260 |
-
if ($ret && !is_wp_error($ret))
|
261 |
-
$forced_message = 1;
|
262 |
-
else
|
263 |
-
$forced_message = 4;
|
264 |
-
// handle group updates
|
265 |
-
} else {
|
266 |
-
$tag = get_term($group_id, $taxonomy);
|
267 |
-
if (!$tag)
|
268 |
-
wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?'));
|
269 |
-
|
270 |
-
$ret = wp_update_term($group_id, $taxonomy, $_POST);
|
271 |
-
if ($ret && !is_wp_error($ret))
|
272 |
-
$forced_message = 3;
|
273 |
-
else
|
274 |
-
$forced_message = 5;
|
275 |
-
}
|
276 |
-
// deleting items
|
277 |
-
} elseif($action == 'delete'){
|
278 |
-
$group_id = (int) $_REQUEST['group_id'];
|
279 |
-
check_admin_referer('delete-tag_' . $group_id);
|
280 |
-
|
281 |
-
if (!current_user_can($tax->cap->delete_terms))
|
282 |
-
wp_die(__('Cheatin’ uh?'));
|
283 |
-
|
284 |
-
wp_delete_term($group_id, $taxonomy);
|
285 |
-
|
286 |
-
$forced_message = 2;
|
287 |
-
}
|
288 |
-
|
289 |
-
// handly views
|
290 |
-
switch ($action) {
|
291 |
-
case 'edit' :
|
292 |
-
$title = $tax->labels->edit_item;
|
293 |
-
if (isset($_REQUEST['group_id'])) {
|
294 |
-
$group_id = absint($_REQUEST['group_id']);
|
295 |
-
$tag = get_term($group_id, $taxonomy, OBJECT, 'edit');
|
296 |
-
} else {
|
297 |
-
$group_id = 0;
|
298 |
-
$tag = false;
|
299 |
-
}
|
300 |
-
|
301 |
-
require_once( 'views/ad-group-edit.php' );
|
302 |
-
break;
|
303 |
-
|
304 |
-
default :
|
305 |
-
$title = $tax->labels->name;
|
306 |
-
// load needed classes
|
307 |
-
include_once( 'includes/class-list-table.php' );
|
308 |
-
include_once( 'includes/class-ad-groups-list-table.php' );
|
309 |
-
// load template
|
310 |
-
include_once( 'views/ad-group.php' );
|
311 |
-
}
|
312 |
-
}
|
313 |
-
|
314 |
-
/**
|
315 |
-
* returns a link to the ad group list page
|
316 |
-
*
|
317 |
-
* @since 1.0.0
|
318 |
-
* @param arr $args additional arguments, e.g. action or group_id
|
319 |
-
* @return string admin url
|
320 |
-
*/
|
321 |
-
static function group_page_url($args = array()) {
|
322 |
-
$plugin = Advanced_Ads::get_instance();
|
323 |
-
|
324 |
-
$defaultargs = array(
|
325 |
-
'post_type' => constant("Advanced_Ads::POST_TYPE_SLUG"),
|
326 |
-
'page' => 'advanced-ads-groups',
|
327 |
-
);
|
328 |
-
$args = $args + $defaultargs;
|
329 |
-
|
330 |
-
return add_query_arg($args, admin_url('edit.php'));
|
331 |
-
}
|
332 |
-
|
333 |
-
/**
|
334 |
-
* Add settings action link to the plugins page.
|
335 |
-
*
|
336 |
-
* @since 1.0.0
|
337 |
-
*/
|
338 |
-
public function add_action_links($links) {
|
339 |
-
|
340 |
-
return array_merge(
|
341 |
-
array(
|
342 |
-
'settings' => '<a href="' . admin_url('edit.php?post_type=advanced_ads&page=advanced-ads-settings') . '">' . __('Settings', $this->plugin_slug) . '</a>'
|
343 |
-
), $links
|
344 |
-
);
|
345 |
-
}
|
346 |
-
|
347 |
-
/**
|
348 |
-
* add information about the ad below the ad title
|
349 |
-
*
|
350 |
-
* @since 1.1.0
|
351 |
-
* @param obj $post
|
352 |
-
*/
|
353 |
-
public function edit_form_below_title($post){
|
354 |
-
if (!isset($post->post_type) || $post->post_type != $this->post_type) {
|
355 |
-
return;
|
356 |
-
}
|
357 |
-
echo "<p>Ad Id: <strong>$post->ID</strong></p>";
|
358 |
-
}
|
359 |
-
|
360 |
-
/**
|
361 |
-
* Add meta boxes
|
362 |
-
*
|
363 |
-
* @since 1.0.0
|
364 |
-
*/
|
365 |
-
public function add_meta_boxes() {
|
366 |
-
global $_wp_post_type_features;
|
367 |
-
|
368 |
-
add_meta_box(
|
369 |
-
'ad-main-box', __('Ad Main', $this->plugin_slug), array($this, 'markup_meta_boxes'), Advanced_Ads::POST_TYPE_SLUG, 'normal', 'high'
|
370 |
-
);
|
371 |
-
add_meta_box(
|
372 |
-
'ad-parameters-box', __('Fine tune your ad', $this->plugin_slug), array($this, 'markup_meta_boxes'), Advanced_Ads::POST_TYPE_SLUG, 'normal', 'high'
|
373 |
-
);
|
374 |
-
add_meta_box(
|
375 |
-
'ad-display-box', __('Where to display this ads', $this->plugin_slug), array($this, 'markup_meta_boxes'), Advanced_Ads::POST_TYPE_SLUG, 'normal', 'high'
|
376 |
-
);
|
377 |
-
add_meta_box(
|
378 |
-
'ad-visitor-box', __('For whom to display this ads', $this->plugin_slug), array($this, 'markup_meta_boxes'), Advanced_Ads::POST_TYPE_SLUG, 'normal', 'high'
|
379 |
-
);
|
380 |
-
add_meta_box(
|
381 |
-
'ad-inject-box', __('Auto injection of ads', $this->plugin_slug), array($this, 'markup_meta_boxes'), Advanced_Ads::POST_TYPE_SLUG, 'normal', 'high'
|
382 |
-
);
|
383 |
-
}
|
384 |
-
|
385 |
-
/**
|
386 |
-
* load templates for all meta boxes
|
387 |
-
*
|
388 |
-
* @since 1.0.0
|
389 |
-
* @param obj $post
|
390 |
-
* @param array $box
|
391 |
-
* @todo move ad initialization to main function and just global it
|
392 |
-
*/
|
393 |
-
public function markup_meta_boxes($post, $box) {
|
394 |
-
$ad = new Advads_Ad($post->ID);
|
395 |
-
|
396 |
-
switch ($box['id']) {
|
397 |
-
case 'ad-main-box':
|
398 |
-
$view = 'ad-main-metabox.php';
|
399 |
-
break;
|
400 |
-
case 'ad-parameters-box':
|
401 |
-
$view = 'ad-parameters-metabox.php';
|
402 |
-
break;
|
403 |
-
case 'ad-display-box':
|
404 |
-
$view = 'ad-display-metabox.php';
|
405 |
-
break;
|
406 |
-
case 'ad-visitor-box':
|
407 |
-
$view = 'ad-visitor-metabox.php';
|
408 |
-
break;
|
409 |
-
case 'ad-inject-box':
|
410 |
-
$view = 'ad-inject-metabox.php';
|
411 |
-
break;
|
412 |
-
}
|
413 |
-
|
414 |
-
if (empty($view))
|
415 |
-
return;
|
416 |
-
$view = plugin_dir_path(__FILE__) . 'views/' . $view;
|
417 |
-
if (is_file($view)) {
|
418 |
-
require_once( $view );
|
419 |
-
}
|
420 |
-
}
|
421 |
-
|
422 |
-
/**
|
423 |
-
* prepare the ad post type to be saved
|
424 |
-
*
|
425 |
-
* @since 1.0.0
|
426 |
-
* @param int $post_id id of the post
|
427 |
-
* @todo handling this more dynamic based on ad type
|
428 |
-
*/
|
429 |
-
public function save_ad($post_id) {
|
430 |
-
|
431 |
-
// only use for ads, no other post type
|
432 |
-
if (!isset($_POST['post_type']) || $this->post_type != $_POST['post_type'] || !isset($_POST['advanced_ad']['type'])) {
|
433 |
-
return;
|
434 |
-
}
|
435 |
-
|
436 |
-
// don’t do this on revisions
|
437 |
-
if ( wp_is_post_revision( $post_id ) )
|
438 |
-
return;
|
439 |
-
|
440 |
-
// get ad object
|
441 |
-
$ad = new Advads_Ad($post_id);
|
442 |
-
if (!$ad instanceof Advads_Ad)
|
443 |
-
return;
|
444 |
-
|
445 |
-
$ad->type = $_POST['advanced_ad']['type'];
|
446 |
-
if(isset($_POST['advanced_ad']['visitor'])) {
|
447 |
-
$ad->set_option('visitor', $_POST['advanced_ad']['visitor']);
|
448 |
-
} else {
|
449 |
-
$ad->set_option('visitor', array());
|
450 |
-
}
|
451 |
-
if(isset($_POST['advanced_ad']['injection'])) {
|
452 |
-
$ad->set_option('injection', $_POST['advanced_ad']['injection']);
|
453 |
-
} else {
|
454 |
-
$ad->set_option('injection', array());
|
455 |
-
}
|
456 |
-
|
457 |
-
if(!empty($_POST['advanced_ad']['content']))
|
458 |
-
$ad->content = $_POST['advanced_ad']['content'];
|
459 |
-
else $ad->content = '';
|
460 |
-
$ad->conditions = $_POST['advanced_ad']['conditions'];
|
461 |
-
|
462 |
-
$ad->save();
|
463 |
-
|
464 |
-
// update global ad information
|
465 |
-
$this->update_global_injection_array();
|
466 |
-
}
|
467 |
-
|
468 |
-
/**
|
469 |
-
* get action from the params
|
470 |
-
*
|
471 |
-
* @since 1.0.0
|
472 |
-
*/
|
473 |
-
public function current_action() {
|
474 |
-
if (isset($_REQUEST['action']) && -1 != $_REQUEST['action'])
|
475 |
-
return $_REQUEST['action'];
|
476 |
-
|
477 |
-
return false;
|
478 |
-
}
|
479 |
-
|
480 |
-
/**
|
481 |
-
* initialize settings
|
482 |
-
*
|
483 |
-
* @since 1.0.1
|
484 |
-
*/
|
485 |
-
public function settings_init(){
|
486 |
-
|
487 |
-
// no additional settings registered yet, but some addons might need this
|
488 |
-
|
489 |
-
// register settings
|
490 |
-
register_setting($this->plugin_screen_hook_suffix, 'advancedads');
|
491 |
-
}
|
492 |
-
|
493 |
-
/**
|
494 |
-
* save a global array with ad injection information
|
495 |
-
* runs every time for all ads a single ad is saved (but not on autosave)
|
496 |
-
*
|
497 |
-
* @since 1.1.0
|
498 |
-
*/
|
499 |
-
public function update_global_injection_array(){
|
500 |
-
// get all public ads
|
501 |
-
$ad_posts = $this->get_ads();
|
502 |
-
|
503 |
-
// merge ad injection settings by type (place => ad id)
|
504 |
-
$all_injections = array();
|
505 |
-
if(is_array($ad_posts)) foreach($ad_posts as $_ad){
|
506 |
-
// load the ad
|
507 |
-
$ad = new Advads_Ad($_ad->ID);
|
508 |
-
// get injection post meta
|
509 |
-
$injection_options = $ad->options('injection');
|
510 |
-
// add injection settings to global array
|
511 |
-
if(isset($injection_options)) foreach($injection_options as $_iokey => $_io){
|
512 |
-
$all_injections[$_iokey][] = $_ad->ID;
|
513 |
-
}
|
514 |
-
}
|
515 |
-
|
516 |
-
// save global injection array to WP options table
|
517 |
-
update_option('advads-ads-injections', $all_injections);
|
518 |
-
|
519 |
-
// write documentation
|
520 |
-
}
|
521 |
-
|
522 |
-
/**
|
523 |
-
* load all ads based on WP_Query conditions
|
524 |
-
*
|
525 |
-
* @since 1.1.0
|
526 |
-
* @param arr $args WP_Query arguments that are more specific that default
|
527 |
-
* @return arr $ads array with post objects
|
528 |
-
*/
|
529 |
-
public function get_ads($args = array()){
|
530 |
-
// add default WP_Query arguments
|
531 |
-
$args['post_type'] = $this->post_type;
|
532 |
-
$args['posts_per_page'] = -1;
|
533 |
-
if(empty($args['post_status'])) $args['post_status'] = 'publish';
|
534 |
-
|
535 |
-
$ads = new WP_Query($args);
|
536 |
-
return $ads->posts;
|
537 |
-
}
|
538 |
-
|
539 |
-
/**
|
540 |
-
* load all ad groups
|
541 |
-
*
|
542 |
-
* @since 1.1.0
|
543 |
-
* @return arr $groups array with ad groups
|
544 |
-
* @link http://codex.wordpress.org/Function_Reference/get_terms
|
545 |
-
*/
|
546 |
-
public function get_ad_groups(){
|
547 |
-
$args = array(
|
548 |
-
'hide_empty' => false // also display groups without any ads
|
549 |
-
);
|
550 |
-
return get_terms(Advanced_Ads::AD_GROUP_TAXONOMY, $args);
|
551 |
-
}
|
552 |
-
|
553 |
-
|
554 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/includes/class-ad-groups-list-table.php
DELETED
@@ -1,290 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Groups List Table class.
|
5 |
-
*
|
6 |
-
* derrived from WP_Terms_List_Table
|
7 |
-
*
|
8 |
-
* @package WordPress
|
9 |
-
* @subpackage List_Table
|
10 |
-
* @since 3.1.0
|
11 |
-
* @access private
|
12 |
-
*/
|
13 |
-
class AdvAds_Groups_List_Table extends AdvAds_List_Table {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* constructor
|
17 |
-
*
|
18 |
-
* @since 1.0.0
|
19 |
-
* @global type $status
|
20 |
-
* @global type $page
|
21 |
-
*/
|
22 |
-
function __construct() {
|
23 |
-
global $status, $page;
|
24 |
-
|
25 |
-
parent::__construct(array(
|
26 |
-
'plural' => 'adgroups',
|
27 |
-
'singular' => 'adgroup',
|
28 |
-
));
|
29 |
-
|
30 |
-
$this->post_type = Advanced_Ads::POST_TYPE_SLUG;
|
31 |
-
$this->taxonomy = Advanced_Ads::AD_GROUP_TAXONOMY;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* default column handling
|
36 |
-
*
|
37 |
-
* @since 1.0.0
|
38 |
-
* @param type $item
|
39 |
-
* @param type $column_name
|
40 |
-
* @return output for the column
|
41 |
-
*/
|
42 |
-
function column_default($item, $column_name) {
|
43 |
-
return apply_filters("manage_{$this->taxonomy}_{$column_name}_column", '', $column_name, $item->term_id);
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* handle checkbox column
|
48 |
-
*
|
49 |
-
* @since 1.0.ß
|
50 |
-
* @see WP_List_Table::::single_row_columns()
|
51 |
-
* @param array $item A singular item (one full row's worth of data)
|
52 |
-
* @return string Text to be placed inside the column <td> (movie title only)
|
53 |
-
*/
|
54 |
-
function column_cb($tag) {
|
55 |
-
$default_term = get_option('default_' . $this->screen->taxonomy);
|
56 |
-
|
57 |
-
return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf(__('Select %s', Advanced_Ads::TD), $tag->name) . '</label>'
|
58 |
-
. '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />';
|
59 |
-
|
60 |
-
return ' ';
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* column with the ad group id
|
65 |
-
* @since 1.0.0
|
66 |
-
* @param type $tag
|
67 |
-
* @return string
|
68 |
-
*/
|
69 |
-
function column_id($tag) {
|
70 |
-
return $tag->term_id;
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* render the basic ad group information
|
75 |
-
*
|
76 |
-
* @since 1.0.0
|
77 |
-
* @param obj $tag
|
78 |
-
* @return string
|
79 |
-
*/
|
80 |
-
function column_name($tag) {
|
81 |
-
$tax = get_taxonomy($this->taxonomy);
|
82 |
-
|
83 |
-
$default_term = get_option('default_' . $this->taxonomy);
|
84 |
-
|
85 |
-
$name = apply_filters('term_name', $tag->name, $tag);
|
86 |
-
$qe_data = get_term($tag->term_id, $this->taxonomy, OBJECT, 'edit');
|
87 |
-
// $edit_link = esc_url(get_edit_term_link($tag->term_id, $this->taxonomy, $this->screen->post_type));
|
88 |
-
$args = array(
|
89 |
-
'action' => 'edit',
|
90 |
-
'group_id' => $tag->term_id
|
91 |
-
);
|
92 |
-
$edit_link = Advanced_Ads_Admin::group_page_url($args);
|
93 |
-
|
94 |
-
$out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit “%s”', Advanced_Ads::TD), $name)) . '">' . $name . '</a></strong><br />';
|
95 |
-
$out .= '<p class="description">' . $tag->description . '</p>';
|
96 |
-
|
97 |
-
$actions = array();
|
98 |
-
if (current_user_can($tax->cap->edit_terms)) {
|
99 |
-
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit', Advanced_Ads::TD) . '</a>';
|
100 |
-
// $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
|
101 |
-
}
|
102 |
-
if (current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term){
|
103 |
-
$args = array(
|
104 |
-
'action' => 'delete',
|
105 |
-
'group_id' => $tag->term_id
|
106 |
-
);
|
107 |
-
$delete_link = Advanced_Ads_Admin::group_page_url($args);
|
108 |
-
$actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url($delete_link, 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";
|
109 |
-
}
|
110 |
-
|
111 |
-
$actions = apply_filters("{$this->taxonomy}_row_actions", $actions, $tag);
|
112 |
-
|
113 |
-
$out .= $this->row_actions($actions);
|
114 |
-
$out .= '</div>';
|
115 |
-
|
116 |
-
return $out;
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* render the slug column
|
121 |
-
*
|
122 |
-
* @since 1.0.0
|
123 |
-
* @param obj $tag
|
124 |
-
* @return string
|
125 |
-
*/
|
126 |
-
function column_slug($tag) {
|
127 |
-
return apply_filters('editable_slug', $tag->slug);
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* render the ads column (number of ads belonging to this group)
|
132 |
-
*
|
133 |
-
* @since 1.0.0
|
134 |
-
* @updated 1.1.0 only display published ads
|
135 |
-
* @param obj $tag
|
136 |
-
* @return string
|
137 |
-
*/
|
138 |
-
function column_ads($tag) {
|
139 |
-
$count = number_format_i18n($tag->count);
|
140 |
-
|
141 |
-
$tax = get_taxonomy($this->taxonomy);
|
142 |
-
$args = array(
|
143 |
-
'post_type' => $this->post_type,
|
144 |
-
'post_status' => 'publish',
|
145 |
-
$this->taxonomy => $tag->slug
|
146 |
-
);
|
147 |
-
$ads = new WP_Query($args);
|
148 |
-
|
149 |
-
$group = new Advads_Ad_Group($tag->term_id);
|
150 |
-
$weights = $group->get_ad_weights();
|
151 |
-
|
152 |
-
$out = '';
|
153 |
-
$actions = array();
|
154 |
-
// The Loop
|
155 |
-
if ( $ads->have_posts() ) {
|
156 |
-
$out .= '<table class="advads-groups-ads-list">';
|
157 |
-
while ( $ads->have_posts() ) {
|
158 |
-
$ads->the_post();
|
159 |
-
$out .= '<tr><td><a href="' . get_edit_post_link(get_the_ID()) . '">' . get_the_title() . '</a>';
|
160 |
-
$_weight = (isset($weights[get_the_ID()])) ? $weights[get_the_ID()] : Advads_Ad_Group::MAX_AD_GROUP_WEIGHT;
|
161 |
-
$out .= '<td class="ad-weight ad-weight-' . get_the_ID() . '" title="'.__('Ad weight', Advanced_Ads::TD).'">' . $_weight . '</td></tr>';
|
162 |
-
$out .= '</tr>';
|
163 |
-
}
|
164 |
-
$out .= '</table>';
|
165 |
-
// include actions
|
166 |
-
$actions['edit'] = '<a href="#" class="edit-ad-group-ads">' . __('Edit', Advanced_Ads::TD) . '</a>';
|
167 |
-
$out .= $this->row_actions($actions);
|
168 |
-
// row with the group id
|
169 |
-
$out .= '<input type="hidden" class="ad-group-id" value="'. $tag->term_id .'"/>';
|
170 |
-
}
|
171 |
-
// Restore original Post Data
|
172 |
-
wp_reset_postdata();
|
173 |
-
|
174 |
-
return $out;
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* load the column names
|
179 |
-
*
|
180 |
-
* @since 1.0.0
|
181 |
-
* @see WP_List_Table::::single_row_columns()
|
182 |
-
* @return array An associative array containing column information: 'slugs'=>'Visible Titles'
|
183 |
-
* ************************************************************************ */
|
184 |
-
function get_columns() {
|
185 |
-
$columns = array(
|
186 |
-
// 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
|
187 |
-
'id' => __('ID', $this->textdomain),
|
188 |
-
'name' => __('Ad Group', $this->textdomain),
|
189 |
-
'slug' => __('Slug', $this->textdomain),
|
190 |
-
'ads' => __('Ads', $this->textdomain),
|
191 |
-
);
|
192 |
-
return $columns;
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* contains sortable columns
|
197 |
-
*
|
198 |
-
* @since 1.0.0
|
199 |
-
* @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
|
200 |
-
* ************************************************************************ */
|
201 |
-
function get_sortable_columns() {
|
202 |
-
$sortable_columns = array(
|
203 |
-
'id' => array('id', true), //true means it's already sorted
|
204 |
-
'name' => array('name', false),
|
205 |
-
'description' => array('description', false),
|
206 |
-
'slug' => array('slug', false)
|
207 |
-
);
|
208 |
-
return $sortable_columns;
|
209 |
-
}
|
210 |
-
|
211 |
-
/**
|
212 |
-
* define bulk actions
|
213 |
-
*
|
214 |
-
* @since 1.0.0
|
215 |
-
* @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
|
216 |
-
* ************************************************************************ */
|
217 |
-
function get_bulk_actions() {
|
218 |
-
$actions = array(
|
219 |
-
// 'delete' => __('Delete', $this->textdomain)
|
220 |
-
);
|
221 |
-
return $actions;
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* handle bulk actions here
|
226 |
-
*
|
227 |
-
* @since 1.0.0
|
228 |
-
* @see $this->prepare_items()
|
229 |
-
* ************************************************************************ */
|
230 |
-
function process_bulk_action() {
|
231 |
-
|
232 |
-
//Detect when a bulk action is being triggered...
|
233 |
-
if ('delete' === $this->current_action()) {
|
234 |
-
|
235 |
-
}
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* load items for output
|
240 |
-
*
|
241 |
-
* @since 1.0.0
|
242 |
-
*/
|
243 |
-
function prepare_items() {
|
244 |
-
// how many items per page
|
245 |
-
// get_items_per_page basically uses a filter
|
246 |
-
$per_page = $this->get_items_per_page('edit_' . $this->taxonomy . '_per_page');
|
247 |
-
|
248 |
-
// set columns
|
249 |
-
$columns = $this->get_columns();
|
250 |
-
$hidden = array();
|
251 |
-
$sortable = $this->get_sortable_columns();
|
252 |
-
|
253 |
-
// combined array with all kinds of columns
|
254 |
-
$this->_column_headers = array($columns, $hidden, $sortable);
|
255 |
-
|
256 |
-
// process bulk actions
|
257 |
-
$this->process_bulk_action();
|
258 |
-
|
259 |
-
// prepare items
|
260 |
-
$search = !empty($_REQUEST['s']) ? trim(wp_unslash($_REQUEST['s'])) : '';
|
261 |
-
|
262 |
-
$args = array(
|
263 |
-
'taxonomy' => $this->taxonomy,
|
264 |
-
'search' => $search,
|
265 |
-
'page' => $this->get_pagenum(),
|
266 |
-
'number' => $per_page,
|
267 |
-
'hide_empty' => 0,
|
268 |
-
'orderby' => 'id'
|
269 |
-
);
|
270 |
-
|
271 |
-
if (!empty($_REQUEST['orderby']))
|
272 |
-
$args['orderby'] = trim(wp_unslash($_REQUEST['orderby']));
|
273 |
-
|
274 |
-
if (!empty($_REQUEST['order']))
|
275 |
-
$args['order'] = trim(wp_unslash($_REQUEST['order']));
|
276 |
-
|
277 |
-
$this->callback_args = $args;
|
278 |
-
|
279 |
-
// get items
|
280 |
-
$this->items = get_categories($args);
|
281 |
-
|
282 |
-
$total_items = count($this->items);
|
283 |
-
$this->set_pagination_args(array(
|
284 |
-
'total_items' => $total_items,
|
285 |
-
'per_page' => $per_page,
|
286 |
-
'total_pages' => ceil($total_items / $per_page)
|
287 |
-
));
|
288 |
-
}
|
289 |
-
|
290 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/includes/class-list-table.php
DELETED
@@ -1,969 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Base class for displaying a list of items in an ajaxified HTML table.
|
4 |
-
*
|
5 |
-
* Derrived from WP_List_Table WordPress 3.9
|
6 |
-
* @link http://codex.wordpress.org/Class_Reference/WP_List_Table
|
7 |
-
*
|
8 |
-
* @package WordPress
|
9 |
-
* @subpackage List_Table
|
10 |
-
* @since 3.1.0
|
11 |
-
*/
|
12 |
-
|
13 |
-
class AdvAds_List_Table {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* The current list of items
|
17 |
-
*
|
18 |
-
* @since 3.1.0
|
19 |
-
* @var array
|
20 |
-
* @access protected
|
21 |
-
*/
|
22 |
-
var $items;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Various information about the current table
|
26 |
-
*
|
27 |
-
* @since 3.1.0
|
28 |
-
* @var array
|
29 |
-
* @access private
|
30 |
-
*/
|
31 |
-
var $_args;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Various information needed for displaying the pagination
|
35 |
-
*
|
36 |
-
* @since 3.1.0
|
37 |
-
* @var array
|
38 |
-
* @access private
|
39 |
-
*/
|
40 |
-
var $_pagination_args = array();
|
41 |
-
|
42 |
-
/**
|
43 |
-
* The current screen
|
44 |
-
*
|
45 |
-
* @since 3.1.0
|
46 |
-
* @var object
|
47 |
-
* @access protected
|
48 |
-
*/
|
49 |
-
var $screen;
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Cached bulk actions
|
53 |
-
*
|
54 |
-
* @since 3.1.0
|
55 |
-
* @var array
|
56 |
-
* @access private
|
57 |
-
*/
|
58 |
-
var $_actions;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Cached pagination output
|
62 |
-
*
|
63 |
-
* @since 3.1.0
|
64 |
-
* @var string
|
65 |
-
* @access private
|
66 |
-
*/
|
67 |
-
var $_pagination;
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Constructor. The child class should call this constructor from its own constructor
|
71 |
-
*
|
72 |
-
* @param array $args An associative array with information about the current table
|
73 |
-
* @access protected
|
74 |
-
*/
|
75 |
-
function __construct( $args = array() ) {
|
76 |
-
$args = wp_parse_args( $args, array(
|
77 |
-
'plural' => '',
|
78 |
-
'singular' => '',
|
79 |
-
'ajax' => false,
|
80 |
-
'screen' => null,
|
81 |
-
) );
|
82 |
-
|
83 |
-
$this->screen = convert_to_screen( $args['screen'] );
|
84 |
-
|
85 |
-
add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 );
|
86 |
-
|
87 |
-
if ( !$args['plural'] )
|
88 |
-
$args['plural'] = $this->screen->base;
|
89 |
-
|
90 |
-
$args['plural'] = sanitize_key( $args['plural'] );
|
91 |
-
$args['singular'] = sanitize_key( $args['singular'] );
|
92 |
-
|
93 |
-
$this->_args = $args;
|
94 |
-
|
95 |
-
if ( $args['ajax'] ) {
|
96 |
-
// wp_enqueue_script( 'list-table' );
|
97 |
-
add_action( 'admin_footer', array( $this, '_js_vars' ) );
|
98 |
-
}
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Checks the current user's permissions
|
103 |
-
* @uses wp_die()
|
104 |
-
*
|
105 |
-
* @since 3.1.0
|
106 |
-
* @access public
|
107 |
-
* @abstract
|
108 |
-
*/
|
109 |
-
function ajax_user_can() {
|
110 |
-
die( 'function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.' );
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Prepares the list of items for displaying.
|
115 |
-
* @uses WP_List_Table::set_pagination_args()
|
116 |
-
*
|
117 |
-
* @since 3.1.0
|
118 |
-
* @access public
|
119 |
-
* @abstract
|
120 |
-
*/
|
121 |
-
function prepare_items() {
|
122 |
-
die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' );
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* An internal method that sets all the necessary pagination arguments
|
127 |
-
*
|
128 |
-
* @param array $args An associative array with information about the pagination
|
129 |
-
* @access protected
|
130 |
-
*/
|
131 |
-
function set_pagination_args( $args ) {
|
132 |
-
$args = wp_parse_args( $args, array(
|
133 |
-
'total_items' => 0,
|
134 |
-
'total_pages' => 0,
|
135 |
-
'per_page' => 0,
|
136 |
-
) );
|
137 |
-
|
138 |
-
if ( !$args['total_pages'] && $args['per_page'] > 0 )
|
139 |
-
$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
|
140 |
-
|
141 |
-
// redirect if page number is invalid and headers are not already sent
|
142 |
-
if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
|
143 |
-
wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
|
144 |
-
exit;
|
145 |
-
}
|
146 |
-
|
147 |
-
$this->_pagination_args = $args;
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Access the pagination args
|
152 |
-
*
|
153 |
-
* @since 3.1.0
|
154 |
-
* @access public
|
155 |
-
*
|
156 |
-
* @param string $key
|
157 |
-
* @return array
|
158 |
-
*/
|
159 |
-
function get_pagination_arg( $key ) {
|
160 |
-
if ( 'page' == $key )
|
161 |
-
return $this->get_pagenum();
|
162 |
-
|
163 |
-
if ( isset( $this->_pagination_args[$key] ) )
|
164 |
-
return $this->_pagination_args[$key];
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Whether the table has items to display or not
|
169 |
-
*
|
170 |
-
* @since 3.1.0
|
171 |
-
* @access public
|
172 |
-
*
|
173 |
-
* @return bool
|
174 |
-
*/
|
175 |
-
function has_items() {
|
176 |
-
return !empty( $this->items );
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Message to be displayed when there are no items
|
181 |
-
*
|
182 |
-
* @since 3.1.0
|
183 |
-
* @access public
|
184 |
-
*/
|
185 |
-
function no_items() {
|
186 |
-
_e( 'No items found.' );
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Display the search box.
|
191 |
-
*
|
192 |
-
* @since 3.1.0
|
193 |
-
* @access public
|
194 |
-
*
|
195 |
-
* @param string $text The search button text
|
196 |
-
* @param string $input_id The search input id
|
197 |
-
*/
|
198 |
-
function search_box( $text, $input_id ) {
|
199 |
-
if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
|
200 |
-
return;
|
201 |
-
|
202 |
-
$input_id = $input_id . '-search-input';
|
203 |
-
|
204 |
-
if ( ! empty( $_REQUEST['orderby'] ) )
|
205 |
-
echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
|
206 |
-
if ( ! empty( $_REQUEST['order'] ) )
|
207 |
-
echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
|
208 |
-
if ( ! empty( $_REQUEST['post_mime_type'] ) )
|
209 |
-
echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
|
210 |
-
if ( ! empty( $_REQUEST['detached'] ) )
|
211 |
-
echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
|
212 |
-
?>
|
213 |
-
<p class="search-box">
|
214 |
-
<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
|
215 |
-
<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
|
216 |
-
<?php submit_button( $text, 'button', false, false, array('id' => 'search-submit') ); ?>
|
217 |
-
</p>
|
218 |
-
<?php
|
219 |
-
}
|
220 |
-
|
221 |
-
/**
|
222 |
-
* Get an associative array ( id => link ) with the list
|
223 |
-
* of views available on this table.
|
224 |
-
*
|
225 |
-
* @since 3.1.0
|
226 |
-
* @access protected
|
227 |
-
*
|
228 |
-
* @return array
|
229 |
-
*/
|
230 |
-
function get_views() {
|
231 |
-
return array();
|
232 |
-
}
|
233 |
-
|
234 |
-
/**
|
235 |
-
* Display the list of views available on this table.
|
236 |
-
*
|
237 |
-
* @since 3.1.0
|
238 |
-
* @access public
|
239 |
-
*/
|
240 |
-
function views() {
|
241 |
-
$views = $this->get_views();
|
242 |
-
/**
|
243 |
-
* Filter the list of available list table views.
|
244 |
-
*
|
245 |
-
* The dynamic portion of the hook name, $this->screen->id, refers
|
246 |
-
* to the ID of the current screen, usually a string.
|
247 |
-
*
|
248 |
-
* @since 3.5.0
|
249 |
-
*
|
250 |
-
* @param array $views An array of available list table views.
|
251 |
-
*/
|
252 |
-
$views = apply_filters( "views_{$this->screen->id}", $views );
|
253 |
-
|
254 |
-
if ( empty( $views ) )
|
255 |
-
return;
|
256 |
-
|
257 |
-
echo "<ul class='subsubsub'>\n";
|
258 |
-
foreach ( $views as $class => $view ) {
|
259 |
-
$views[ $class ] = "\t<li class='$class'>$view";
|
260 |
-
}
|
261 |
-
echo implode( " |</li>\n", $views ) . "</li>\n";
|
262 |
-
echo "</ul>";
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Get an associative array ( option_name => option_title ) with the list
|
267 |
-
* of bulk actions available on this table.
|
268 |
-
*
|
269 |
-
* @since 3.1.0
|
270 |
-
* @access protected
|
271 |
-
*
|
272 |
-
* @return array
|
273 |
-
*/
|
274 |
-
function get_bulk_actions() {
|
275 |
-
return array();
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Display the bulk actions dropdown.
|
280 |
-
*
|
281 |
-
* @since 3.1.0
|
282 |
-
* @access public
|
283 |
-
*/
|
284 |
-
function bulk_actions() {
|
285 |
-
if ( is_null( $this->_actions ) ) {
|
286 |
-
$no_new_actions = $this->_actions = $this->get_bulk_actions();
|
287 |
-
/**
|
288 |
-
* Filter the list table Bulk Actions drop-down.
|
289 |
-
*
|
290 |
-
* The dynamic portion of the hook name, $this->screen->id, refers
|
291 |
-
* to the ID of the current screen, usually a string.
|
292 |
-
*
|
293 |
-
* This filter can currently only be used to remove bulk actions.
|
294 |
-
*
|
295 |
-
* @since 3.5.0
|
296 |
-
*
|
297 |
-
* @param array $actions An array of the available bulk actions.
|
298 |
-
*/
|
299 |
-
$this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
|
300 |
-
$this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
|
301 |
-
$two = '';
|
302 |
-
} else {
|
303 |
-
$two = '2';
|
304 |
-
}
|
305 |
-
|
306 |
-
if ( empty( $this->_actions ) )
|
307 |
-
return;
|
308 |
-
|
309 |
-
echo "<select name='action$two'>\n";
|
310 |
-
echo "<option value='-1' selected='selected'>" . __( 'Bulk Actions' ) . "</option>\n";
|
311 |
-
|
312 |
-
foreach ( $this->_actions as $name => $title ) {
|
313 |
-
$class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
|
314 |
-
|
315 |
-
echo "\t<option value='$name'$class>$title</option>\n";
|
316 |
-
}
|
317 |
-
|
318 |
-
echo "</select>\n";
|
319 |
-
|
320 |
-
submit_button( __( 'Apply' ), 'action', false, false, array( 'id' => "doaction$two" ) );
|
321 |
-
echo "\n";
|
322 |
-
}
|
323 |
-
|
324 |
-
/**
|
325 |
-
* Get the current action selected from the bulk actions dropdown.
|
326 |
-
*
|
327 |
-
* @since 3.1.0
|
328 |
-
* @access public
|
329 |
-
*
|
330 |
-
* @return string|bool The action name or False if no action was selected
|
331 |
-
*/
|
332 |
-
function current_action() {
|
333 |
-
if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
|
334 |
-
return $_REQUEST['action'];
|
335 |
-
|
336 |
-
if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
|
337 |
-
return $_REQUEST['action2'];
|
338 |
-
|
339 |
-
return false;
|
340 |
-
}
|
341 |
-
|
342 |
-
/**
|
343 |
-
* Generate row actions div
|
344 |
-
*
|
345 |
-
* @since 3.1.0
|
346 |
-
* @access protected
|
347 |
-
*
|
348 |
-
* @param array $actions The list of actions
|
349 |
-
* @param bool $always_visible Whether the actions should be always visible
|
350 |
-
* @return string
|
351 |
-
*/
|
352 |
-
function row_actions( $actions, $always_visible = false ) {
|
353 |
-
$action_count = count( $actions );
|
354 |
-
$i = 0;
|
355 |
-
|
356 |
-
if ( !$action_count )
|
357 |
-
return '';
|
358 |
-
|
359 |
-
$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
|
360 |
-
foreach ( $actions as $action => $link ) {
|
361 |
-
++$i;
|
362 |
-
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
363 |
-
$out .= "<span class='$action'>$link$sep</span>";
|
364 |
-
}
|
365 |
-
$out .= '</div>';
|
366 |
-
|
367 |
-
return $out;
|
368 |
-
}
|
369 |
-
|
370 |
-
/**
|
371 |
-
* Display a monthly dropdown for filtering items
|
372 |
-
*
|
373 |
-
* @since 3.1.0
|
374 |
-
* @access protected
|
375 |
-
*/
|
376 |
-
function months_dropdown( $post_type ) {
|
377 |
-
global $wpdb, $wp_locale;
|
378 |
-
|
379 |
-
$months = $wpdb->get_results( $wpdb->prepare( "
|
380 |
-
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
381 |
-
FROM $wpdb->posts
|
382 |
-
WHERE post_type = %s
|
383 |
-
ORDER BY post_date DESC
|
384 |
-
", $post_type ) );
|
385 |
-
|
386 |
-
/**
|
387 |
-
* Filter the 'Months' drop-down results.
|
388 |
-
*
|
389 |
-
* @since 3.7.0
|
390 |
-
*
|
391 |
-
* @param object $months The months drop-down query results.
|
392 |
-
* @param string $post_type The post type.
|
393 |
-
*/
|
394 |
-
$months = apply_filters( 'months_dropdown_results', $months, $post_type );
|
395 |
-
|
396 |
-
$month_count = count( $months );
|
397 |
-
|
398 |
-
if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
|
399 |
-
return;
|
400 |
-
|
401 |
-
$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
|
402 |
-
?>
|
403 |
-
<select name='m'>
|
404 |
-
<option<?php selected( $m, 0 ); ?> value='0'><?php _e( 'Show all dates' ); ?></option>
|
405 |
-
<?php
|
406 |
-
foreach ( $months as $arc_row ) {
|
407 |
-
if ( 0 == $arc_row->year )
|
408 |
-
continue;
|
409 |
-
|
410 |
-
$month = zeroise( $arc_row->month, 2 );
|
411 |
-
$year = $arc_row->year;
|
412 |
-
|
413 |
-
printf( "<option %s value='%s'>%s</option>\n",
|
414 |
-
selected( $m, $year . $month, false ),
|
415 |
-
esc_attr( $arc_row->year . $month ),
|
416 |
-
/* translators: 1: month name, 2: 4-digit year */
|
417 |
-
sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
|
418 |
-
);
|
419 |
-
}
|
420 |
-
?>
|
421 |
-
</select>
|
422 |
-
<?php
|
423 |
-
}
|
424 |
-
|
425 |
-
/**
|
426 |
-
* Display a view switcher
|
427 |
-
*
|
428 |
-
* @since 3.1.0
|
429 |
-
* @access protected
|
430 |
-
*/
|
431 |
-
function view_switcher( $current_mode ) {
|
432 |
-
$modes = array(
|
433 |
-
'list' => __( 'List View' ),
|
434 |
-
'excerpt' => __( 'Excerpt View' )
|
435 |
-
);
|
436 |
-
|
437 |
-
?>
|
438 |
-
<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
|
439 |
-
<div class="view-switch">
|
440 |
-
<?php
|
441 |
-
foreach ( $modes as $mode => $title ) {
|
442 |
-
$class = ( $current_mode == $mode ) ? 'class="current"' : '';
|
443 |
-
echo "<a href='" . esc_url( add_query_arg( 'mode', $mode, $_SERVER['REQUEST_URI'] ) ) . "' $class><img id='view-switch-$mode' src='" . esc_url( includes_url( 'images/blank.gif' ) ) . "' width='20' height='20' title='$title' alt='$title' /></a>\n";
|
444 |
-
}
|
445 |
-
?>
|
446 |
-
</div>
|
447 |
-
<?php
|
448 |
-
}
|
449 |
-
|
450 |
-
/**
|
451 |
-
* Display a comment count bubble
|
452 |
-
*
|
453 |
-
* @since 3.1.0
|
454 |
-
* @access protected
|
455 |
-
*
|
456 |
-
* @param int $post_id
|
457 |
-
* @param int $pending_comments
|
458 |
-
*/
|
459 |
-
function comments_bubble( $post_id, $pending_comments ) {
|
460 |
-
$pending_phrase = sprintf( __( '%s pending' ), number_format( $pending_comments ) );
|
461 |
-
|
462 |
-
if ( $pending_comments )
|
463 |
-
echo '<strong>';
|
464 |
-
|
465 |
-
echo "<a href='" . esc_url( add_query_arg( 'p', $post_id, admin_url( 'edit-comments.php' ) ) ) . "' title='" . esc_attr( $pending_phrase ) . "' class='post-com-count'><span class='comment-count'>" . number_format_i18n( get_comments_number() ) . "</span></a>";
|
466 |
-
|
467 |
-
if ( $pending_comments )
|
468 |
-
echo '</strong>';
|
469 |
-
}
|
470 |
-
|
471 |
-
/**
|
472 |
-
* Get the current page number
|
473 |
-
*
|
474 |
-
* @since 3.1.0
|
475 |
-
* @access protected
|
476 |
-
*
|
477 |
-
* @return int
|
478 |
-
*/
|
479 |
-
function get_pagenum() {
|
480 |
-
$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
|
481 |
-
|
482 |
-
if( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
|
483 |
-
$pagenum = $this->_pagination_args['total_pages'];
|
484 |
-
|
485 |
-
return max( 1, $pagenum );
|
486 |
-
}
|
487 |
-
|
488 |
-
/**
|
489 |
-
* Get number of items to display on a single page
|
490 |
-
*
|
491 |
-
* @since 3.1.0
|
492 |
-
* @access protected
|
493 |
-
*
|
494 |
-
* @return int
|
495 |
-
*/
|
496 |
-
function get_items_per_page( $option, $default = 20 ) {
|
497 |
-
$per_page = (int) get_user_option( $option );
|
498 |
-
if ( empty( $per_page ) || $per_page < 1 )
|
499 |
-
$per_page = $default;
|
500 |
-
|
501 |
-
/**
|
502 |
-
* Filter the number of items to be displayed on each page of the list table.
|
503 |
-
*
|
504 |
-
* The dynamic hook name, $option, refers to the per page option depending
|
505 |
-
* on the type of list table in use. Possible values may include:
|
506 |
-
* 'edit_comments_per_page', 'sites_network_per_page', 'site_themes_network_per_page',
|
507 |
-
* 'themes_netework_per_page', 'users_network_per_page', 'edit_{$post_type}', etc.
|
508 |
-
*
|
509 |
-
* @since 2.9.0
|
510 |
-
*
|
511 |
-
* @param int $per_page Number of items to be displayed. Default 20.
|
512 |
-
*/
|
513 |
-
return (int) apply_filters( $option, $per_page );
|
514 |
-
}
|
515 |
-
|
516 |
-
/**
|
517 |
-
* Display the pagination.
|
518 |
-
*
|
519 |
-
* @since 3.1.0
|
520 |
-
* @access protected
|
521 |
-
*/
|
522 |
-
function pagination( $which ) {
|
523 |
-
if ( empty( $this->_pagination_args ) )
|
524 |
-
return;
|
525 |
-
|
526 |
-
extract( $this->_pagination_args, EXTR_SKIP );
|
527 |
-
|
528 |
-
$output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
|
529 |
-
|
530 |
-
$current = $this->get_pagenum();
|
531 |
-
|
532 |
-
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
|
533 |
-
|
534 |
-
$current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
|
535 |
-
|
536 |
-
$page_links = array();
|
537 |
-
|
538 |
-
$disable_first = $disable_last = '';
|
539 |
-
if ( $current == 1 )
|
540 |
-
$disable_first = ' disabled';
|
541 |
-
if ( $current == $total_pages )
|
542 |
-
$disable_last = ' disabled';
|
543 |
-
|
544 |
-
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
545 |
-
'first-page' . $disable_first,
|
546 |
-
esc_attr__( 'Go to the first page' ),
|
547 |
-
esc_url( remove_query_arg( 'paged', $current_url ) ),
|
548 |
-
'«'
|
549 |
-
);
|
550 |
-
|
551 |
-
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
552 |
-
'prev-page' . $disable_first,
|
553 |
-
esc_attr__( 'Go to the previous page' ),
|
554 |
-
esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
|
555 |
-
'‹'
|
556 |
-
);
|
557 |
-
|
558 |
-
if ( 'bottom' == $which )
|
559 |
-
$html_current_page = $current;
|
560 |
-
else
|
561 |
-
$html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />",
|
562 |
-
esc_attr__( 'Current page' ),
|
563 |
-
$current,
|
564 |
-
strlen( $total_pages )
|
565 |
-
);
|
566 |
-
|
567 |
-
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
|
568 |
-
$page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';
|
569 |
-
|
570 |
-
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
571 |
-
'next-page' . $disable_last,
|
572 |
-
esc_attr__( 'Go to the next page' ),
|
573 |
-
esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
|
574 |
-
'›'
|
575 |
-
);
|
576 |
-
|
577 |
-
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
578 |
-
'last-page' . $disable_last,
|
579 |
-
esc_attr__( 'Go to the last page' ),
|
580 |
-
esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
|
581 |
-
'»'
|
582 |
-
);
|
583 |
-
|
584 |
-
$pagination_links_class = 'pagination-links';
|
585 |
-
if ( ! empty( $infinite_scroll ) )
|
586 |
-
$pagination_links_class = ' hide-if-js';
|
587 |
-
$output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
|
588 |
-
|
589 |
-
if ( $total_pages )
|
590 |
-
$page_class = $total_pages < 2 ? ' one-page' : '';
|
591 |
-
else
|
592 |
-
$page_class = ' no-pages';
|
593 |
-
|
594 |
-
$this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
|
595 |
-
|
596 |
-
echo $this->_pagination;
|
597 |
-
}
|
598 |
-
|
599 |
-
/**
|
600 |
-
* Get a list of columns. The format is:
|
601 |
-
* 'internal-name' => 'Title'
|
602 |
-
*
|
603 |
-
* @since 3.1.0
|
604 |
-
* @access protected
|
605 |
-
* @abstract
|
606 |
-
*
|
607 |
-
* @return array
|
608 |
-
*/
|
609 |
-
function get_columns() {
|
610 |
-
die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' );
|
611 |
-
}
|
612 |
-
|
613 |
-
/**
|
614 |
-
* Get a list of sortable columns. The format is:
|
615 |
-
* 'internal-name' => 'orderby'
|
616 |
-
* or
|
617 |
-
* 'internal-name' => array( 'orderby', true )
|
618 |
-
*
|
619 |
-
* The second format will make the initial sorting order be descending
|
620 |
-
*
|
621 |
-
* @since 3.1.0
|
622 |
-
* @access protected
|
623 |
-
*
|
624 |
-
* @return array
|
625 |
-
*/
|
626 |
-
function get_sortable_columns() {
|
627 |
-
return array();
|
628 |
-
}
|
629 |
-
|
630 |
-
/**
|
631 |
-
* Get a list of all, hidden and sortable columns, with filter applied
|
632 |
-
*
|
633 |
-
* @since 3.1.0
|
634 |
-
* @access protected
|
635 |
-
*
|
636 |
-
* @return array
|
637 |
-
*/
|
638 |
-
function get_column_info() {
|
639 |
-
if ( isset( $this->_column_headers ) )
|
640 |
-
return $this->_column_headers;
|
641 |
-
|
642 |
-
$columns = get_column_headers( $this->screen );
|
643 |
-
$hidden = get_hidden_columns( $this->screen );
|
644 |
-
|
645 |
-
$sortable_columns = $this->get_sortable_columns();
|
646 |
-
/**
|
647 |
-
* Filter the list table sortable columns for a specific screen.
|
648 |
-
*
|
649 |
-
* The dynamic portion of the hook name, $this->screen->id, refers
|
650 |
-
* to the ID of the current screen, usually a string.
|
651 |
-
*
|
652 |
-
* @since 3.5.0
|
653 |
-
*
|
654 |
-
* @param array $sortable_columns An array of sortable columns.
|
655 |
-
*/
|
656 |
-
$_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
|
657 |
-
|
658 |
-
$sortable = array();
|
659 |
-
foreach ( $_sortable as $id => $data ) {
|
660 |
-
if ( empty( $data ) )
|
661 |
-
continue;
|
662 |
-
|
663 |
-
$data = (array) $data;
|
664 |
-
if ( !isset( $data[1] ) )
|
665 |
-
$data[1] = false;
|
666 |
-
|
667 |
-
$sortable[$id] = $data;
|
668 |
-
}
|
669 |
-
|
670 |
-
$this->_column_headers = array( $columns, $hidden, $sortable );
|
671 |
-
|
672 |
-
return $this->_column_headers;
|
673 |
-
}
|
674 |
-
|
675 |
-
/**
|
676 |
-
* Return number of visible columns
|
677 |
-
*
|
678 |
-
* @since 3.1.0
|
679 |
-
* @access public
|
680 |
-
*
|
681 |
-
* @return int
|
682 |
-
*/
|
683 |
-
function get_column_count() {
|
684 |
-
list ( $columns, $hidden ) = $this->get_column_info();
|
685 |
-
$hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
|
686 |
-
return count( $columns ) - count( $hidden );
|
687 |
-
}
|
688 |
-
|
689 |
-
/**
|
690 |
-
* Print column headers, accounting for hidden and sortable columns.
|
691 |
-
*
|
692 |
-
* @since 3.1.0
|
693 |
-
* @access protected
|
694 |
-
*
|
695 |
-
* @param bool $with_id Whether to set the id attribute or not
|
696 |
-
*/
|
697 |
-
function print_column_headers( $with_id = true ) {
|
698 |
-
list( $columns, $hidden, $sortable ) = $this->get_column_info();
|
699 |
-
|
700 |
-
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
|
701 |
-
$current_url = remove_query_arg( 'paged', $current_url );
|
702 |
-
|
703 |
-
if ( isset( $_GET['orderby'] ) )
|
704 |
-
$current_orderby = $_GET['orderby'];
|
705 |
-
else
|
706 |
-
$current_orderby = '';
|
707 |
-
|
708 |
-
if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] )
|
709 |
-
$current_order = 'desc';
|
710 |
-
else
|
711 |
-
$current_order = 'asc';
|
712 |
-
|
713 |
-
if ( ! empty( $columns['cb'] ) ) {
|
714 |
-
static $cb_counter = 1;
|
715 |
-
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
|
716 |
-
. '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
|
717 |
-
$cb_counter++;
|
718 |
-
}
|
719 |
-
|
720 |
-
foreach ( $columns as $column_key => $column_display_name ) {
|
721 |
-
$class = array( 'manage-column', "column-$column_key" );
|
722 |
-
|
723 |
-
$style = '';
|
724 |
-
if ( in_array( $column_key, $hidden ) )
|
725 |
-
$style = 'display:none;';
|
726 |
-
|
727 |
-
$style = ' style="' . $style . '"';
|
728 |
-
|
729 |
-
if ( 'cb' == $column_key )
|
730 |
-
$class[] = 'check-column';
|
731 |
-
elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) )
|
732 |
-
$class[] = 'num';
|
733 |
-
|
734 |
-
if ( isset( $sortable[$column_key] ) ) {
|
735 |
-
list( $orderby, $desc_first ) = $sortable[$column_key];
|
736 |
-
|
737 |
-
if ( $current_orderby == $orderby ) {
|
738 |
-
$order = 'asc' == $current_order ? 'desc' : 'asc';
|
739 |
-
$class[] = 'sorted';
|
740 |
-
$class[] = $current_order;
|
741 |
-
} else {
|
742 |
-
$order = $desc_first ? 'desc' : 'asc';
|
743 |
-
$class[] = 'sortable';
|
744 |
-
$class[] = $desc_first ? 'asc' : 'desc';
|
745 |
-
}
|
746 |
-
|
747 |
-
$column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
|
748 |
-
}
|
749 |
-
|
750 |
-
$id = $with_id ? "id='$column_key'" : '';
|
751 |
-
|
752 |
-
if ( !empty( $class ) )
|
753 |
-
$class = "class='" . join( ' ', $class ) . "'";
|
754 |
-
|
755 |
-
echo "<th scope='col' $id $class $style>$column_display_name</th>";
|
756 |
-
}
|
757 |
-
}
|
758 |
-
|
759 |
-
/**
|
760 |
-
* Display the table
|
761 |
-
*
|
762 |
-
* @since 3.1.0
|
763 |
-
* @access public
|
764 |
-
*/
|
765 |
-
function display() {
|
766 |
-
extract( $this->_args );
|
767 |
-
|
768 |
-
$this->display_tablenav( 'top' );
|
769 |
-
|
770 |
-
?>
|
771 |
-
<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
|
772 |
-
<thead>
|
773 |
-
<tr>
|
774 |
-
<?php $this->print_column_headers(); ?>
|
775 |
-
</tr>
|
776 |
-
</thead>
|
777 |
-
|
778 |
-
<tfoot>
|
779 |
-
<tr>
|
780 |
-
<?php $this->print_column_headers( false ); ?>
|
781 |
-
</tr>
|
782 |
-
</tfoot>
|
783 |
-
|
784 |
-
<tbody id="the-list"<?php if ( $singular ) echo " data-wp-lists='list:$singular'"; ?>>
|
785 |
-
<?php $this->display_rows_or_placeholder(); ?>
|
786 |
-
</tbody>
|
787 |
-
</table>
|
788 |
-
<?php
|
789 |
-
$this->display_tablenav( 'bottom' );
|
790 |
-
}
|
791 |
-
|
792 |
-
/**
|
793 |
-
* Get a list of CSS classes for the <table> tag
|
794 |
-
*
|
795 |
-
* @since 3.1.0
|
796 |
-
* @access protected
|
797 |
-
*
|
798 |
-
* @return array
|
799 |
-
*/
|
800 |
-
function get_table_classes() {
|
801 |
-
return array( 'widefat', 'fixed', $this->_args['plural'] );
|
802 |
-
}
|
803 |
-
|
804 |
-
/**
|
805 |
-
* Generate the table navigation above or below the table
|
806 |
-
*
|
807 |
-
* @since 3.1.0
|
808 |
-
* @access protected
|
809 |
-
*/
|
810 |
-
function display_tablenav( $which ) {
|
811 |
-
if ( 'top' == $which )
|
812 |
-
wp_nonce_field( 'bulk-' . $this->_args['plural'] );
|
813 |
-
?>
|
814 |
-
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
815 |
-
|
816 |
-
<div class="alignleft actions bulkactions">
|
817 |
-
<?php $this->bulk_actions(); ?>
|
818 |
-
</div>
|
819 |
-
<?php
|
820 |
-
$this->extra_tablenav( $which );
|
821 |
-
$this->pagination( $which );
|
822 |
-
?>
|
823 |
-
|
824 |
-
<br class="clear" />
|
825 |
-
</div>
|
826 |
-
<?php
|
827 |
-
}
|
828 |
-
|
829 |
-
/**
|
830 |
-
* Extra controls to be displayed between bulk actions and pagination
|
831 |
-
*
|
832 |
-
* @since 3.1.0
|
833 |
-
* @access protected
|
834 |
-
*/
|
835 |
-
function extra_tablenav( $which ) {}
|
836 |
-
|
837 |
-
/**
|
838 |
-
* Generate the <tbody> part of the table
|
839 |
-
*
|
840 |
-
* @since 3.1.0
|
841 |
-
* @access protected
|
842 |
-
*/
|
843 |
-
function display_rows_or_placeholder() {
|
844 |
-
if ( $this->has_items() ) {
|
845 |
-
$this->display_rows();
|
846 |
-
} else {
|
847 |
-
list( $columns, $hidden ) = $this->get_column_info();
|
848 |
-
echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
|
849 |
-
$this->no_items();
|
850 |
-
echo '</td></tr>';
|
851 |
-
}
|
852 |
-
}
|
853 |
-
|
854 |
-
/**
|
855 |
-
* Generate the table rows
|
856 |
-
*
|
857 |
-
* @since 3.1.0
|
858 |
-
* @access protected
|
859 |
-
*/
|
860 |
-
function display_rows() {
|
861 |
-
foreach ( $this->items as $item )
|
862 |
-
$this->single_row( $item );
|
863 |
-
}
|
864 |
-
|
865 |
-
/**
|
866 |
-
* Generates content for a single row of the table
|
867 |
-
*
|
868 |
-
* @since 3.1.0
|
869 |
-
* @access protected
|
870 |
-
*
|
871 |
-
* @param object $item The current item
|
872 |
-
*/
|
873 |
-
function single_row( $item ) {
|
874 |
-
static $row_class = '';
|
875 |
-
$row_class = ( $row_class == '' ? ' class="alternate"' : '' );
|
876 |
-
|
877 |
-
echo '<tr' . $row_class . '>';
|
878 |
-
$this->single_row_columns( $item );
|
879 |
-
echo '</tr>';
|
880 |
-
}
|
881 |
-
|
882 |
-
/**
|
883 |
-
* Generates the columns for a single row of the table
|
884 |
-
*
|
885 |
-
* @since 3.1.0
|
886 |
-
* @access protected
|
887 |
-
*
|
888 |
-
* @param object $item The current item
|
889 |
-
*/
|
890 |
-
function single_row_columns( $item ) {
|
891 |
-
list( $columns, $hidden ) = $this->get_column_info();
|
892 |
-
|
893 |
-
foreach ( $columns as $column_name => $column_display_name ) {
|
894 |
-
$class = "class='$column_name column-$column_name'";
|
895 |
-
|
896 |
-
$style = '';
|
897 |
-
if ( in_array( $column_name, $hidden ) )
|
898 |
-
$style = ' style="display:none;"';
|
899 |
-
|
900 |
-
$attributes = "$class$style";
|
901 |
-
|
902 |
-
if ( 'cb' == $column_name ) {
|
903 |
-
echo '<th scope="row" class="check-column">';
|
904 |
-
echo $this->column_cb( $item );
|
905 |
-
echo '</th>';
|
906 |
-
}
|
907 |
-
elseif ( method_exists( $this, 'column_' . $column_name ) ) {
|
908 |
-
echo "<td $attributes>";
|
909 |
-
echo call_user_func( array( $this, 'column_' . $column_name ), $item );
|
910 |
-
echo "</td>";
|
911 |
-
}
|
912 |
-
else {
|
913 |
-
echo "<td $attributes>";
|
914 |
-
echo $this->column_default( $item, $column_name );
|
915 |
-
echo "</td>";
|
916 |
-
}
|
917 |
-
}
|
918 |
-
}
|
919 |
-
|
920 |
-
/**
|
921 |
-
* Handle an incoming ajax request (called from admin-ajax.php)
|
922 |
-
*
|
923 |
-
* @since 3.1.0
|
924 |
-
* @access public
|
925 |
-
*/
|
926 |
-
function ajax_response() {
|
927 |
-
$this->prepare_items();
|
928 |
-
|
929 |
-
extract( $this->_args );
|
930 |
-
extract( $this->_pagination_args, EXTR_SKIP );
|
931 |
-
|
932 |
-
ob_start();
|
933 |
-
if ( ! empty( $_REQUEST['no_placeholder'] ) )
|
934 |
-
$this->display_rows();
|
935 |
-
else
|
936 |
-
$this->display_rows_or_placeholder();
|
937 |
-
|
938 |
-
$rows = ob_get_clean();
|
939 |
-
|
940 |
-
$response = array( 'rows' => $rows );
|
941 |
-
|
942 |
-
if ( isset( $total_items ) )
|
943 |
-
$response['total_items_i18n'] = sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) );
|
944 |
-
|
945 |
-
if ( isset( $total_pages ) ) {
|
946 |
-
$response['total_pages'] = $total_pages;
|
947 |
-
$response['total_pages_i18n'] = number_format_i18n( $total_pages );
|
948 |
-
}
|
949 |
-
|
950 |
-
die( json_encode( $response ) );
|
951 |
-
}
|
952 |
-
|
953 |
-
/**
|
954 |
-
* Send required variables to JavaScript land
|
955 |
-
*
|
956 |
-
* @access private
|
957 |
-
*/
|
958 |
-
function _js_vars() {
|
959 |
-
$args = array(
|
960 |
-
'class' => get_class( $this ),
|
961 |
-
'screen' => array(
|
962 |
-
'id' => $this->screen->id,
|
963 |
-
'base' => $this->screen->base,
|
964 |
-
)
|
965 |
-
);
|
966 |
-
|
967 |
-
printf( "<script type='text/javascript'>list_args = %s;</script>\n", json_encode( $args ) );
|
968 |
-
}
|
969 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/includes/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
trunk/admin/views/ad-display-metabox.php
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
<?php $types = Advanced_Ads::get_instance()->ad_types; ?>
|
2 |
-
<h4><?php _e('Display conditions', $this->plugin_slug); ?></h4>
|
3 |
-
<p class="description"><?php _e('Display conditions that are based on the content type.', ADVADS_SLUG); ?></p>
|
4 |
-
<p class="advads-toggle-link" onclick="advads_toggle('#advads-how-it-works')">>>><?php _e('Click to see Help', $this->plugin_slug); ?><<<</p>
|
5 |
-
<ul id="advads-how-it-works" style="display: none;">
|
6 |
-
<li><?php _e('If you want to display the ad everywhere, don’t do anything here. ', $this->plugin_slug); ?></li>
|
7 |
-
<li><?php _e('The fewer conditions you enter, the better the performance will be.', $this->plugin_slug); ?></li>
|
8 |
-
<li><?php _e('Filling more than one item into the ’show here’ text field means at least one of them needs to be true. (OR)', $this->plugin_slug); ?></li>
|
9 |
-
<li><?php _e('Filling more than one item into the ’don’t show’ text field means all must match (AND).', $this->plugin_slug); ?></li>
|
10 |
-
<li><?php _e('When using one of the two choices on checkbox conditions, the rule is binding. E.g. "Front Page: show here" will result on the ad being only visible on the front page.', $this->plugin_slug); ?></li>
|
11 |
-
<li><?php _e('If there is nothing in the row, there won’t be any check. Meaning, if you leave everything empty, the ad will be displayed everywhere.', $this->plugin_slug); ?></li>
|
12 |
-
</ul>
|
13 |
-
<table id="advanced-ad-conditions">
|
14 |
-
<thead>
|
15 |
-
<tr>
|
16 |
-
<th></th>
|
17 |
-
<th><?php _e('show here', $this->plugin_slug); ?></th>
|
18 |
-
<th><?php _e('DON’T show', $this->plugin_slug); ?></th>
|
19 |
-
<th></th>
|
20 |
-
</tr>
|
21 |
-
<?php global $advanced_ads_ad_conditions;
|
22 |
-
if (is_array($advanced_ads_ad_conditions))
|
23 |
-
foreach ($advanced_ads_ad_conditions as $_key => $_condition) :
|
24 |
-
?><tr>
|
25 |
-
<th><?php echo $_condition['label']; ?>
|
26 |
-
<?php if (!empty($_condition['description'])) : ?>
|
27 |
-
<span class="description" title="<?php echo $_condition['description']; ?>">(?)</span>
|
28 |
-
<?php endif; ?>
|
29 |
-
</th>
|
30 |
-
<?php if (empty($_condition['type'])) : continue; ?>
|
31 |
-
<?php elseif ($_condition['type'] == 'idfield' || $_condition['type'] == 'textvalues') : ?>
|
32 |
-
<td><input type="text" name="advanced_ad[conditions][<?php echo $_key; ?>][include]" value="<?php if(isset($ad->conditions[$_key]['include'])) echo $ad->conditions[$_key]['include']; ?>"/></td>
|
33 |
-
<td><input type="text" name="advanced_ad[conditions][<?php echo $_key; ?>][exclude]" value="<?php if(isset($ad->conditions[$_key]['exclude'])) echo $ad->conditions[$_key]['exclude']; ?>"/></td>
|
34 |
-
<?php elseif ($_condition['type'] == 'radio') : ?>
|
35 |
-
<td><input type="radio" name="advanced_ad[conditions][<?php echo $_key; ?>]" value="1" <?php if(isset($ad->conditions[$_key])) checked($ad->conditions[$_key], 1) ?>/></td>
|
36 |
-
<td><input type="radio" name="advanced_ad[conditions][<?php echo $_key; ?>]" value="0" <?php if(isset($ad->conditions[$_key])) checked($ad->conditions[$_key], 0) ?>/></td>
|
37 |
-
<?php endif; ?>
|
38 |
-
<td><button type="button" class="clear-radio"><?php _e('clear', $this->plugin_slug); ?></button></td>
|
39 |
-
</tr>
|
40 |
-
<?php endforeach; ?>
|
41 |
-
</thead>
|
42 |
-
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/views/ad-group-ads-inline-form.php
DELETED
@@ -1,34 +0,0 @@
|
|
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) : ?>
|
6 |
-
<tr>
|
7 |
-
<td><?php echo $_ad->post_title; ?></td>
|
8 |
-
<td class="ad-group-ads-weight">
|
9 |
-
<label>
|
10 |
-
<span class="title"><?php _ex('weight', 'ad group ads form', Advanced_Ads::TD); ?></span>
|
11 |
-
<select name="weight[<?php echo $_ad->ID; ?>]">
|
12 |
-
<?php $ad_weight = (isset($weights[$_ad->ID])) ? $weights[$_ad->ID] : Advads_Ad_Group::MAX_AD_GROUP_WEIGHT; ?>
|
13 |
-
<?php for($i = 0; $i <= Advads_Ad_Group::MAX_AD_GROUP_WEIGHT; $i++) : ?>
|
14 |
-
<option <?php selected($ad_weight, $i); ?>><?php echo $i; ?></option>
|
15 |
-
<?php endfor; ?>
|
16 |
-
</select>
|
17 |
-
</label>
|
18 |
-
</td>
|
19 |
-
</tr>
|
20 |
-
<?php endforeach; ?>
|
21 |
-
</tbody>
|
22 |
-
</table>
|
23 |
-
<p class="inline-edit-save submit">
|
24 |
-
<a href="#inline-edit" class="cancel button-secondary alignleft"><?php _e('Cancel', Advanced_Ads::TD); ?></a>
|
25 |
-
<a href="#inline-edit" class="save button-primary alignright"><?php _e('Update', Advanced_Ads::TD); ?></a>
|
26 |
-
<span class="spinner"></span>
|
27 |
-
<?php wp_nonce_field('ad-groups-inline-edit-nonce', 'advads-ad-groups-inline-form-nonce', false); ?>
|
28 |
-
<input type="hidden" name="taxonomy" value="<?php echo $group->id; ?>" />
|
29 |
-
<br class="clear" />
|
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; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/views/ad-group-edit.php
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Create and edit ad group form
|
4 |
-
*
|
5 |
-
* @package WordPress
|
6 |
-
* @subpackage Administration
|
7 |
-
*/
|
8 |
-
// don't load directly
|
9 |
-
if (!defined('ABSPATH'))
|
10 |
-
die('-1');
|
11 |
-
|
12 |
-
if (!is_int($group_id)) {
|
13 |
-
?>
|
14 |
-
<div id="message" class="updated"><p><strong><?php _e('You did not select an item for editing.'); ?></strong></p></div>
|
15 |
-
<?php
|
16 |
-
return;
|
17 |
-
}
|
18 |
-
|
19 |
-
do_action("{$taxonomy}_pre_edit_form", $tag, $taxonomy);
|
20 |
-
?>
|
21 |
-
|
22 |
-
<div class="wrap">
|
23 |
-
<h2><?php echo $tax->labels->edit_item; ?></h2>
|
24 |
-
<div id="ajax-response"></div>
|
25 |
-
<form name="editgroup" id="editgroup" method="post" action="<?php echo Advanced_Ads_Admin::group_page_url(); ?>" class="validate"<?php do_action($taxonomy . '_term_edit_form_tag'); ?>>
|
26 |
-
<input type="hidden" name="action" value="editedgroup" />
|
27 |
-
<input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
|
28 |
-
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy) ?>" />
|
29 |
-
<?php wp_original_referer_field(true, 'previous');
|
30 |
-
wp_nonce_field('update-group_' . $group_id); ?>
|
31 |
-
<table class="form-table">
|
32 |
-
<tr class="form-field form-required">
|
33 |
-
<th scope="row" valign="top"><label for="name"><?php _ex('Name', 'Taxonomy Name'); ?></label></th>
|
34 |
-
<td><input name="name" id="name" type="text" value="<?php if (isset($tag->name)) echo esc_attr($tag->name); ?>" size="40" aria-required="true" /></td>
|
35 |
-
</tr>
|
36 |
-
<?php if (!global_terms_enabled()) { ?>
|
37 |
-
<tr class="form-field">
|
38 |
-
<th scope="row" valign="top"><label for="slug"><?php _ex('Slug', 'Taxonomy Slug'); ?></label></th>
|
39 |
-
<td><input name="slug" id="slug" type="text" value="<?php if (isset($tag->slug)) echo esc_attr(apply_filters('editable_slug', $tag->slug)); ?>" size="40" />
|
40 |
-
<p class="description"><?php _e('An id-like string with only letters in lower case, numbers, and hyphens. Can be used to query a group.', $this->plugin_slug); ?></p></td>
|
41 |
-
</tr>
|
42 |
-
<?php } ?>
|
43 |
-
<?php if (is_taxonomy_hierarchical($taxonomy)) : ?>
|
44 |
-
<tr class="form-field">
|
45 |
-
<th scope="row" valign="top"><label for="parent"><?php _ex('Parent', 'Taxonomy Parent'); ?></label></th>
|
46 |
-
<td>
|
47 |
-
<?php if($group_id == 0){
|
48 |
-
wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'name' => 'parent', 'orderby' => 'name', 'taxonomy' => $taxonomy, 'hierarchical' => true, 'show_option_none' => __('None')));
|
49 |
-
} else {
|
50 |
-
wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'name' => 'parent', 'orderby' => 'name', 'taxonomy' => $taxonomy, 'selected' => $tag->parent, 'exclude_tree' => $tag->term_id, 'hierarchical' => true, 'show_option_none' => __('None')));
|
51 |
-
}; ?></td>
|
52 |
-
</tr>
|
53 |
-
<?php endif; // is_taxonomy_hierarchical()
|
54 |
-
$text = (isset($tag->description)) ? $tag->description : ''; ?>
|
55 |
-
<tr class="form-field">
|
56 |
-
<th scope="row" valign="top"><label for="description"><?php _ex('Description', 'Taxonomy Description'); ?></label></th>
|
57 |
-
<td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $text; // textarea_escaped ?></textarea></td>
|
58 |
-
</tr>
|
59 |
-
<?php
|
60 |
-
|
61 |
-
do_action($taxonomy . '_edit_form_fields', $tag, $taxonomy);
|
62 |
-
?>
|
63 |
-
</table>
|
64 |
-
<?php
|
65 |
-
do_action($taxonomy . '_edit_form', $tag, $taxonomy);
|
66 |
-
|
67 |
-
if($group_id == 0){
|
68 |
-
submit_button(__('Create new Ad Group', $this->plugin_slug));
|
69 |
-
} else {
|
70 |
-
submit_button(__('Update', $this->plugin_slug));
|
71 |
-
}
|
72 |
-
?>
|
73 |
-
</form>
|
74 |
-
</div>
|
75 |
-
<script type="text/javascript">
|
76 |
-
try {
|
77 |
-
document.forms.edittag.name.focus();
|
78 |
-
} catch (e) {
|
79 |
-
}
|
80 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/views/ad-group.php
DELETED
@@ -1,101 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* page lists ad groups
|
4 |
-
*
|
5 |
-
* @since 1.0.0
|
6 |
-
* @see /wp-admin/edit-tags.php (for a good example in WP core)
|
7 |
-
*/
|
8 |
-
$ad_group_table = new AdvAds_Groups_List_Table(array('screen' => get_current_screen()));
|
9 |
-
$ad_group_table->textdomain = $this->plugin_slug;
|
10 |
-
$pagenum = $ad_group_table->get_pagenum();
|
11 |
-
|
12 |
-
$ad_group_table->prepare_items();
|
13 |
-
$total_pages = $ad_group_table->get_pagination_arg('total_pages');
|
14 |
-
|
15 |
-
if ($pagenum > $total_pages && $total_pages > 0) {
|
16 |
-
wp_redirect(add_query_arg('paged', $total_pages));
|
17 |
-
exit;
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* @TODO those 2 scripts needed? or even extend it with our own?
|
22 |
-
*/
|
23 |
-
// wp_enqueue_script('admin-tags');
|
24 |
-
|
25 |
-
if (current_user_can($tax->cap->edit_terms)) {
|
26 |
-
wp_enqueue_script('inline-edit-group-ads');
|
27 |
-
}
|
28 |
-
|
29 |
-
// require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
30 |
-
|
31 |
-
$messages[$taxonomy] = array(
|
32 |
-
0 => '', // Unused. Messages start at index 1.
|
33 |
-
1 => __('Ad Group added.', $this->plugin_slug),
|
34 |
-
2 => __('Ad Group deleted.', $this->plugin_slug),
|
35 |
-
3 => __('Ad Group updated.', $this->plugin_slug),
|
36 |
-
4 => __('Ad Group not added.', $this->plugin_slug),
|
37 |
-
5 => __('Ad Group not updated.', $this->plugin_slug),
|
38 |
-
6 => __('Ad Group deleted.', $this->plugin_slug)
|
39 |
-
);
|
40 |
-
|
41 |
-
$message = false;
|
42 |
-
if (isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) || isset($forced_message)) {
|
43 |
-
if (isset($msg) && isset($messages[$taxonomy][$msg])){
|
44 |
-
$message = $messages[$taxonomy][$msg];
|
45 |
-
} elseif(isset($messages[$taxonomy][$forced_message])) {
|
46 |
-
$message = $messages[$taxonomy][$forced_message];
|
47 |
-
}
|
48 |
-
}
|
49 |
-
?>
|
50 |
-
|
51 |
-
<div class="wrap nosubsub">
|
52 |
-
<h2><?php
|
53 |
-
echo esc_html($title);
|
54 |
-
if (!empty($_REQUEST['s'])) {
|
55 |
-
printf('<span class="subtitle">' . __('Search results for “%s”', $this->plugin_slug) . '</span>', esc_html(wp_unslash($_REQUEST['s'])));
|
56 |
-
} else {
|
57 |
-
echo ' <a href="' . Advanced_Ads_Admin::group_page_url(array('action' => 'edit')) . '" class="add-new-h2">' . $tax->labels->add_new_item . '</a>';
|
58 |
-
}
|
59 |
-
?>
|
60 |
-
</h2>
|
61 |
-
|
62 |
-
<?php if ($message) : ?>
|
63 |
-
<div id="message" class="updated"><p><?php echo $message; ?></p></div>
|
64 |
-
<?php
|
65 |
-
$_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
|
66 |
-
endif;
|
67 |
-
?>
|
68 |
-
<div id="ajax-response"></div>
|
69 |
-
|
70 |
-
<div id="col-container">
|
71 |
-
<div class="col-wrap">
|
72 |
-
<form class="search-form" action="" method="get">
|
73 |
-
<!--input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /-->
|
74 |
-
<input type="hidden" name="page" value="advanced-ads-groups" />
|
75 |
-
<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
|
76 |
-
<?php $ad_group_table->search_box($tax->labels->search_items, 'tag'); ?>
|
77 |
-
|
78 |
-
</form>
|
79 |
-
<br class="clear" />
|
80 |
-
<form id="posts-filter" action="" method="post">
|
81 |
-
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
|
82 |
-
<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
|
83 |
-
|
84 |
-
<?php $ad_group_table->display(); ?>
|
85 |
-
|
86 |
-
<br class="clear" />
|
87 |
-
</form><?php
|
88 |
-
/**
|
89 |
-
* Fires after the ad grouptable.
|
90 |
-
*
|
91 |
-
* The dynamic portion of the hook name, $taxonomy, refers to the taxonomy slug.
|
92 |
-
*
|
93 |
-
* @since 1.0.0
|
94 |
-
* @param string $taxonomy The taxonomy name.
|
95 |
-
*/
|
96 |
-
do_action("after-{$taxonomy}-table", $taxonomy);
|
97 |
-
?>
|
98 |
-
|
99 |
-
</div>
|
100 |
-
</div><!-- /col-container -->
|
101 |
-
</div><!-- /wrap -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/views/ad-inject-metabox.php
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
<h4><?php _e('Auto Injection', ADVADS_SLUG); ?></h4>
|
2 |
-
<p class="description"><?php _e('Include ads on specific places automatically without shortcodes or functions.', ADVADS_SLUG); ?></p>
|
3 |
-
<?php $options = $ad->options('injection'); ?>
|
4 |
-
<ul id="advanced-ad-injection">
|
5 |
-
<li>
|
6 |
-
<input type="checkbox" name="advanced_ad[injection][header]"
|
7 |
-
id="advanced-ad-injection-header" value="1"
|
8 |
-
<?php checked(!empty($options['header']), 1); ?>/>
|
9 |
-
<label for="advanced-ad-injection-header"><?php _e('Include in Header (before closing </head> Tag, probably not visible)', ADVADS_SLUG); ?></label>
|
10 |
-
</li>
|
11 |
-
<li>
|
12 |
-
<input type="checkbox" name="advanced_ad[injection][footer]"
|
13 |
-
id="advanced-ad-injection-footer" value="1"
|
14 |
-
<?php checked(!empty($options['footer']), 1); ?>/>
|
15 |
-
<label for="advanced-ad-injection-footer"><?php _e('Include in Footer (before closing </body> Tag)', ADVADS_SLUG); ?></label>
|
16 |
-
</li>
|
17 |
-
<li>
|
18 |
-
<input type="checkbox" name="advanced_ad[injection][post_start]"
|
19 |
-
id="advanced-ad-injection-post_start" value="1"
|
20 |
-
<?php checked(!empty($options['post_start']), 1); ?>/>
|
21 |
-
<label for="advanced-ad-injection-post_start"><?php _e('Include before the post content', ADVADS_SLUG); ?></label>
|
22 |
-
</li>
|
23 |
-
<li>
|
24 |
-
<input type="checkbox" name="advanced_ad[injection][post_end]"
|
25 |
-
id="advanced-ad-injection-post_end" value="1"
|
26 |
-
<?php checked(!empty($options['post_end']), 1); ?>/>
|
27 |
-
<label for="advanced-ad-injection-post_end"><?php _e('Include after the post content', ADVADS_SLUG); ?></label>
|
28 |
-
</li>
|
29 |
-
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/views/ad-main-metabox.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php $types = Advanced_Ads::get_instance()->ad_types; ?>
|
2 |
-
<?php if (empty($types)) : ?>
|
3 |
-
<p><?php _e('No ad types defined', $this->plugin_slug); ?></p>
|
4 |
-
<?php else : ?>
|
5 |
-
<h4><?php _e('Ad Type and Content', $this->plugin_slug); ?></h4>
|
6 |
-
<ul id="advanced-ad-type">
|
7 |
-
<?php
|
8 |
-
// choose first type if none set
|
9 |
-
$type = (isset($ad->type)) ? $ad->type : current($types)->ID;
|
10 |
-
foreach ($types as $_type) : ?>
|
11 |
-
<li>
|
12 |
-
<input type="radio" name="advanced_ad[type]"
|
13 |
-
id="advanced-ad-type-<?php echo $_type->ID ?>"
|
14 |
-
value="<?php echo $_type->ID; ?>"
|
15 |
-
<?php checked($type, $_type->ID); ?>/>
|
16 |
-
<label for="advanced-ad-type-<?php echo $_type->ID ?>"><?php echo (empty($_type->title)) ? $_type->ID : $_type->title; ?></label>
|
17 |
-
<?php if (!empty($_type->description)) : ?><span class="description"><?php echo $_type->description; ?></span><?php endif; ?>
|
18 |
-
</li>
|
19 |
-
<?php endforeach; ?>
|
20 |
-
</ul>
|
21 |
-
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/views/ad-parameters-metabox.php
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
<?php $types = Advanced_Ads::get_instance()->ad_types; ?>
|
2 |
-
<h4><?php _e('Ad Parameters', Advanced_Ads::TD); ?></h4>
|
3 |
-
<?php
|
4 |
-
/**
|
5 |
-
* when changing ad type ad parameter content is loaded via ajax
|
6 |
-
* @filesource admin/assets/js/admin.js
|
7 |
-
* @filesource includes/class-ajax-callbacks.php ::load_ad_parameters_metabox
|
8 |
-
* @filesource classes/ad-type-content.php :: renter_parameters()
|
9 |
-
*/
|
10 |
-
?>
|
11 |
-
<div id="advanced-ads-ad-parameters">
|
12 |
-
<?php $type = (isset($types[$ad->type])) ? $types[$ad->type] : current($types);
|
13 |
-
$type->render_parameters($ad); ?>
|
14 |
-
</div>
|
15 |
-
<?php do_action('advanced-ads-ad-params-after', $ad, $types);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/views/ad-visitor-metabox.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<h4><?php _e('Visitor conditions', ADVADS_SLUG); ?></h4>
|
2 |
-
<p class="description"><?php _e('Display conditions that are based on the user. Use with caution on cached websites.', ADVADS_SLUG); ?></p>
|
3 |
-
<?php $options = $ad->options('visitor'); ?>
|
4 |
-
<ul id="advanced-ad-visitor-mobile">
|
5 |
-
<li>
|
6 |
-
<input type="radio" name="advanced_ad[visitor][mobile]"
|
7 |
-
id="advanced-ad-visitor-mobile-all" value=""
|
8 |
-
<?php checked(empty($options['mobile']), 1); ?>/>
|
9 |
-
<label for="advanced-ad-visitor-mobile-all"><?php _e('Display on all devices', ADVADS_SLUG); ?></label>
|
10 |
-
<input type="radio" name="advanced_ad[visitor][mobile]"
|
11 |
-
id="advanced-ad-visitor-mobile-only" value="only"
|
12 |
-
<?php checked($options['mobile'], 'only'); ?>/>
|
13 |
-
<label for="advanced-ad-visitor-mobile-only"><?php _e('only on mobile devices', ADVADS_SLUG); ?></label>
|
14 |
-
<input type="radio" name="advanced_ad[visitor][mobile]"
|
15 |
-
id="advanced-ad-visitor-mobile-no" value="no"
|
16 |
-
<?php checked($options['mobile'], 'no'); ?>/>
|
17 |
-
<label for="advanced-ad-visitor-mobile-no"><?php _e('not on mobile devices', ADVADS_SLUG); ?></label>
|
18 |
-
</li>
|
19 |
-
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/views/admin.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Represents the view for the administration dashboard.
|
4 |
-
*
|
5 |
-
* This includes the header, options, and other information that should provide
|
6 |
-
* The User Interface to the end user.
|
7 |
-
*
|
8 |
-
* @package Advanced_Ads_Admin
|
9 |
-
* @author Thomas Maier <thomas.maier@webgilde.com>
|
10 |
-
* @license GPL-2.0+
|
11 |
-
* @link http://webgilde.com
|
12 |
-
* @copyright 2013 Thomas Maier, webgilde GmbH
|
13 |
-
*/
|
14 |
-
?>
|
15 |
-
|
16 |
-
<div class="wrap">
|
17 |
-
<h2 style="color:red;"><?php _e('Work in progress', $this->plugin_slug); ?></h2>
|
18 |
-
<p><?php _e('This screen is work in progress. You can use the information if you understand them, but there is nothing to do here yet.', $this->plugin_slug); ?></p>
|
19 |
-
<?php screen_icon(); ?>
|
20 |
-
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
|
21 |
-
|
22 |
-
<h2><?php _e('Ad Condition Overview', $this->plugin_slug); ?></h2>
|
23 |
-
<pre><?php print_r($ads_by_conditions); ?></pre>
|
24 |
-
|
25 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/views/debug.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* the view for the debug page
|
4 |
-
*/
|
5 |
-
?>
|
6 |
-
|
7 |
-
<div class="wrap">
|
8 |
-
<h2 style="color:red;"><?php _e('Work in progress', $this->plugin_slug); ?></h2>
|
9 |
-
<p><?php _e('This screen is work in progress. You can use the information if you understand them, but there is nothing to do here yet.', $this->plugin_slug); ?></p>
|
10 |
-
<?php screen_icon(); ?>
|
11 |
-
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
|
12 |
-
|
13 |
-
<h2><?php _e('Ad Condition Overview', $this->plugin_slug); ?></h2>
|
14 |
-
<pre><?php print_r($ads_by_conditions); ?></pre>
|
15 |
-
|
16 |
-
<h2><?php _e('Ad Injections', $this->plugin_slug); ?></h2>
|
17 |
-
<pre><?php print_r($ad_injections); ?></pre>
|
18 |
-
|
19 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/views/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
trunk/admin/views/placements.php
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* the view for the placements page
|
4 |
-
*/
|
5 |
-
?>
|
6 |
-
|
7 |
-
<div class="wrap">
|
8 |
-
<?php if ($error) : ?>
|
9 |
-
<div id="message" class="error"><p><?php echo $error; ?></p></div>
|
10 |
-
<?php endif; ?>
|
11 |
-
<?php screen_icon(); ?>
|
12 |
-
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
|
13 |
-
<p class="description"><?php _e('Placements are physically places in your theme and posts. You can use them if you plan to change ads and ad groups on the same place without the need to change your templates.', ADVADS_SLUG); ?></p>
|
14 |
-
<h2><?php _e('Create a new placement', ADVADS_SLUG); ?></h2>
|
15 |
-
<form method="POST" action="" class="advads-placements-new-form">
|
16 |
-
<label for="advads-placement-name"><?php _e('Name', ADVADS_SLUG); ?></label>
|
17 |
-
<input id="advads-plcement-name" name="advads[placement][name]" type="text" value=""/><br/>
|
18 |
-
<label for="advads-placement-slug"><?php _e('ID', ADVADS_SLUG); ?></label>
|
19 |
-
<input id="advads-plcement-slug" name="advads[placement][slug]" type="text" value=""/>
|
20 |
-
<p class="description"><?php _e('Individual identifier. Allowed are alphanumeric signs (lower case) and hyphen.', ADVADS_SLUG); ?></p>
|
21 |
-
<p class=""><?php _e('You can assign Ads and Groups after you created the placement.', ADVADS_SLUG); ?></p>
|
22 |
-
<input type="submit" class="button button-primary" value="<?php _e('Save New Placement', ADVADS_SLUG); ?>"/>
|
23 |
-
</form>
|
24 |
-
<?php if(isset($placements) && is_array($placements)) : ?>
|
25 |
-
<h2><?php _e('Placements', ADVADS_SLUG); ?></h2>
|
26 |
-
<form method="POST" action="">
|
27 |
-
<table class="advads-placements-table">
|
28 |
-
<thead>
|
29 |
-
<tr>
|
30 |
-
<th><?php _e('Slug', ADVADS_SLUG); ?></th>
|
31 |
-
<th><?php _e('Name', ADVADS_SLUG); ?></th>
|
32 |
-
<th><?php _e('Item', ADVADS_SLUG); ?></th>
|
33 |
-
<th><?php _e('Options', ADVADS_SLUG); ?></th>
|
34 |
-
</tr>
|
35 |
-
</thead>
|
36 |
-
<tbody>
|
37 |
-
<?php foreach($placements as $_placement_slug => $_placement) : ?>
|
38 |
-
<tr>
|
39 |
-
<th><?php echo $_placement_slug; ?></th>
|
40 |
-
<td><?php echo $_placement['name']; ?></td>
|
41 |
-
<td>
|
42 |
-
<?php $items = Advads_Ad_Placements::items_for_select(); ?>
|
43 |
-
<select name="advads[placements][<?php echo $_placement_slug; ?>][item]">
|
44 |
-
<option value=""><?php _e('--empty--', ADVADS_SLUG); ?></option>
|
45 |
-
<?php if(isset($items['ads'])) : ?>
|
46 |
-
<optgroup label="<?php _e('Ads', ADVADS_SLUG); ?>">
|
47 |
-
<?php foreach($items['ads'] as $_item_id => $_item_title) : ?>
|
48 |
-
<option value="<?php echo $_item_id; ?>" <?php if(isset($_placement['item'])) selected($_item_id, $_placement['item']); ?>><?php echo $_item_title; ?></option>
|
49 |
-
<?php endforeach; ?>
|
50 |
-
</optgroup>
|
51 |
-
<?php endif; ?>
|
52 |
-
<?php if(isset($items['groups'])) : ?>
|
53 |
-
<optgroup label="<?php _e('Ad Groups', ADVADS_SLUG); ?>">
|
54 |
-
<?php foreach($items['groups'] as $_item_id => $_item_title) : ?>
|
55 |
-
<option value="<?php echo $_item_id; ?>" <?php if(isset($_placement['item'])) selected($_item_id, $_placement['item']); ?>><?php echo $_item_title; ?></option>
|
56 |
-
<?php endforeach; ?>
|
57 |
-
</optgroup>
|
58 |
-
<?php endif; ?>
|
59 |
-
</select>
|
60 |
-
</td>
|
61 |
-
<td>
|
62 |
-
<input type="checkbox" id="adsads-placements-item-delete" name="advads[placements][<?php echo $_placement_slug; ?>][delete]" value="1"/>
|
63 |
-
<label for="adsads-placements-item-delete"><?php _e('remove placement', ADVADS_SLUG); ?></label>
|
64 |
-
</td>
|
65 |
-
</tr>
|
66 |
-
<?php endforeach; ?>
|
67 |
-
</tbody>
|
68 |
-
</table>
|
69 |
-
<input type="submit" class="button button-primary" value="<?php _e('Save Placements', ADVADS_SLUG); ?>"/>
|
70 |
-
</form>
|
71 |
-
<?php endif; ?>
|
72 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/admin/views/settings.php
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* the view for the settings page
|
4 |
-
*/
|
5 |
-
?>
|
6 |
-
|
7 |
-
<div class="wrap">
|
8 |
-
<?php screen_icon(); ?>
|
9 |
-
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
|
10 |
-
<form method="POST" action="options.php">
|
11 |
-
<?php
|
12 |
-
/**
|
13 |
-
* only display setting field if any registered
|
14 |
-
* @TODO remove when base plugin has its own settings
|
15 |
-
*/
|
16 |
-
global $wp_settings_fields;
|
17 |
-
|
18 |
-
if(isset($wp_settings_fields['advanced_ads_page_advanced-ads-settings'])){
|
19 |
-
settings_fields($this->plugin_screen_hook_suffix);
|
20 |
-
do_settings_sections( $this->plugin_screen_hook_suffix);
|
21 |
-
|
22 |
-
do_action('advanced-ads-settings-form');
|
23 |
-
submit_button();
|
24 |
-
} else {
|
25 |
-
echo '<p>'.__('No settings available yet', $this->plugin_slug).'</p>';
|
26 |
-
}
|
27 |
-
|
28 |
-
?>
|
29 |
-
</form>
|
30 |
-
<hr/>
|
31 |
-
<ul>
|
32 |
-
<li><a href="/wp-admin/edit.php?post_type=advanced_ads&page=advanced-ads-debug"><?php _e('Debug Page', $this->plugin_slug); ?></a></li>
|
33 |
-
<li><a href="http://wordpress.org/plugins/advanced-ads/" title="<?php _e('Advanced Ads on WordPress.org', $this->plugin_slug); ?>"><?php _e('Advanced Ads on wp.org', $this->plugin_slug); ?></a></li>
|
34 |
-
<li><a href="http://webgilde.com" title="<?php _e('the company behind Advanced Ads', $this->plugin_slug); ?>"><?php _e('webgilde GmbH', $this->plugin_slug); ?></a></li>
|
35 |
-
</ul>
|
36 |
-
|
37 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/advanced-ads.php
DELETED
@@ -1,78 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Advanced Ads.
|
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-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.1.0
|
16 |
-
* Author: Thomas Maier
|
17 |
-
* Author URI: http://webgilde.com
|
18 |
-
* Text Domain: advanced-ads
|
19 |
-
* License: GPL-2.0+
|
20 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
21 |
-
* Domain Path: /languages
|
22 |
-
*/
|
23 |
-
|
24 |
-
// If this file is called directly, abort.
|
25 |
-
if ( ! defined( 'WPINC' ) ) {
|
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, textdomain
|
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.
|
55 |
-
*
|
56 |
-
*/
|
57 |
-
register_activation_hook( __FILE__, array( 'Advanced_Ads', 'activate' ) );
|
58 |
-
register_deactivation_hook( __FILE__, array( 'Advanced_Ads', 'deactivate' ) );
|
59 |
-
|
60 |
-
add_action( 'plugins_loaded', array( 'Advanced_Ads', 'get_instance' ) );
|
61 |
-
|
62 |
-
/*----------------------------------------------------------------------------*
|
63 |
-
* Dashboard and Administrative Functionality
|
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' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/assets/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
trunk/assets/screenshot-1.png
DELETED
Binary file
|
trunk/assets/screenshot-2.png
DELETED
Binary file
|
trunk/classes/ad.php
DELETED
@@ -1,626 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Advanced Ads.
|
5 |
-
*
|
6 |
-
* @package Advads_Ad
|
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 |
-
* an ad object
|
15 |
-
*
|
16 |
-
* @package Advads_Ad
|
17 |
-
* @author Thomas Maier <thomas.maier@webgilde.com>
|
18 |
-
*/
|
19 |
-
class Advads_Ad {
|
20 |
-
|
21 |
-
/**
|
22 |
-
* id of the post type for this ad
|
23 |
-
*/
|
24 |
-
protected $id = 0;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* true, if this is an Advanced Ads Ad post type
|
28 |
-
*/
|
29 |
-
protected $is_ad = false;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* ad type
|
33 |
-
*/
|
34 |
-
public $type = 'content';
|
35 |
-
|
36 |
-
/**
|
37 |
-
* object of current ad type
|
38 |
-
*/
|
39 |
-
protected $type_obj;
|
40 |
-
|
41 |
-
/**
|
42 |
-
* content of the ad
|
43 |
-
*
|
44 |
-
* only needed for ad types using the post content field
|
45 |
-
*/
|
46 |
-
public $content = '';
|
47 |
-
|
48 |
-
/**
|
49 |
-
* conditions of the ad display
|
50 |
-
*/
|
51 |
-
public $conditions = array();
|
52 |
-
|
53 |
-
/**
|
54 |
-
* status of the ad (e.g. publish, pending)
|
55 |
-
*/
|
56 |
-
public $status = array();
|
57 |
-
|
58 |
-
/**
|
59 |
-
* array with meta field options aka parameters
|
60 |
-
*/
|
61 |
-
protected $options = array();
|
62 |
-
|
63 |
-
/**
|
64 |
-
* name of the meta field to save options to
|
65 |
-
*/
|
66 |
-
static $options_meta_field = 'advanced_ads_ad_options';
|
67 |
-
|
68 |
-
/**
|
69 |
-
* init ad object
|
70 |
-
*
|
71 |
-
* @param int $id id of the ad (= post id)
|
72 |
-
*/
|
73 |
-
public function __construct($id) {
|
74 |
-
global $advanced_ads_ad_conditions;
|
75 |
-
$id = absint($id);
|
76 |
-
$this->id = $id;
|
77 |
-
|
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 |
-
}
|
85 |
-
$_types = array_unique($_types);
|
86 |
-
foreach($_types as $_type) {
|
87 |
-
$method_name = 'sanitize_condition_'. $_type;
|
88 |
-
if(method_exists($this, $method_name)) {
|
89 |
-
add_filter('advanced-ads-sanitize-condition-' . $_type, array($this, $method_name), 10, 1);
|
90 |
-
} elseif(function_exists('advads_sanitize_condition_' . $_type)) {
|
91 |
-
// check for public function to sanitize this
|
92 |
-
add_filter('advanced-ads-sanitize-condition-' . $_type, 'advads_sanitize_condition_' . $_type, 10, 1);
|
93 |
-
|
94 |
-
}
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* load an ad object by id based on its ad type
|
100 |
-
*
|
101 |
-
* @since 1.0.0
|
102 |
-
*/
|
103 |
-
private function load($id = 0){
|
104 |
-
|
105 |
-
$_data = get_post($id);
|
106 |
-
if($_data == null) return false;
|
107 |
-
|
108 |
-
// return, if not an ad
|
109 |
-
if($_data->post_type != Advanced_Ads::POST_TYPE_SLUG) {
|
110 |
-
return false;
|
111 |
-
} else {
|
112 |
-
$this->is_ad = true;
|
113 |
-
}
|
114 |
-
|
115 |
-
$this->type = $this->options('type');
|
116 |
-
/* load ad type object */
|
117 |
-
$types = Advanced_Ads::get_instance()->ad_types;
|
118 |
-
if(isset($types[$this->type])){
|
119 |
-
$this->type_obj = $types[$this->type];
|
120 |
-
} else {
|
121 |
-
$this->type_obj = new Advads_Ad_Type_Abstract;
|
122 |
-
}
|
123 |
-
|
124 |
-
$this->conditions = $this->options('conditions');
|
125 |
-
$this->status = $_data->post_status;
|
126 |
-
|
127 |
-
// load content based on ad type
|
128 |
-
$this->content = $this->type_obj->load_content($_data);
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* get options from meta field and return specific field
|
133 |
-
*
|
134 |
-
* @param string $field post meta key to be returned
|
135 |
-
* @return mixed meta field content
|
136 |
-
* @since 1.0.0
|
137 |
-
* @todo check against default values
|
138 |
-
*/
|
139 |
-
public function options($field = ''){
|
140 |
-
// retrieve options, if not given yet
|
141 |
-
if($this->options == array()) {
|
142 |
-
$this->options = get_post_meta($this->id, self::$options_meta_field, true);
|
143 |
-
}
|
144 |
-
|
145 |
-
// return specific option
|
146 |
-
if($field != '') {
|
147 |
-
if(!empty($this->options[$field]))
|
148 |
-
return $this->options[$field];
|
149 |
-
} else { // return all options
|
150 |
-
if(!empty($this->options))
|
151 |
-
return $this->options;
|
152 |
-
}
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* set an option of the ad
|
157 |
-
*
|
158 |
-
* @since 1.1.0
|
159 |
-
* @param string $option name of the option
|
160 |
-
* @param mixed $value value of the option
|
161 |
-
*/
|
162 |
-
public function set_option($option = '', $value = ''){
|
163 |
-
if($option == '') return;
|
164 |
-
|
165 |
-
// get current options
|
166 |
-
$options = $this->options();
|
167 |
-
|
168 |
-
// set options
|
169 |
-
$options[$option] = $value;
|
170 |
-
|
171 |
-
// save options
|
172 |
-
$this->options = $options;
|
173 |
-
|
174 |
-
}
|
175 |
-
|
176 |
-
|
177 |
-
/**
|
178 |
-
* return ad content for frontend output
|
179 |
-
*/
|
180 |
-
public function output(){
|
181 |
-
if(!$this->is_ad) return '';
|
182 |
-
|
183 |
-
$output = $this->prepare_frontend_output();
|
184 |
-
return $output;
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* check if the ad can be displayed in frontend due to its conditions
|
189 |
-
*
|
190 |
-
* @return bool $can_display true if can be displayed in frontend
|
191 |
-
*/
|
192 |
-
public function can_display(){
|
193 |
-
|
194 |
-
if($this->can_display_by_conditions()
|
195 |
-
&& $this->can_display_by_visitor())
|
196 |
-
return true;
|
197 |
-
else return false;
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* check display conditions
|
202 |
-
*
|
203 |
-
* @since 1.1.0 moved here from can_display()
|
204 |
-
* @return bool $can_display true if can be displayed in frontend
|
205 |
-
*/
|
206 |
-
public function can_display_by_conditions(){
|
207 |
-
global $post;
|
208 |
-
|
209 |
-
if(empty($this->options['conditions']) ||
|
210 |
-
!is_array($this->options['conditions'])) return true;
|
211 |
-
|
212 |
-
$conditions = $this->options['conditions'];
|
213 |
-
foreach($conditions as $_cond_key => $_cond_value) {
|
214 |
-
switch($_cond_key){
|
215 |
-
// check for post ids
|
216 |
-
case 'postids' :
|
217 |
-
// included posts
|
218 |
-
if(!empty($_cond_value['include'])){
|
219 |
-
$post_ids = explode(',', $_cond_value['include']);
|
220 |
-
if(is_array($post_ids)
|
221 |
-
&& isset($post->ID)
|
222 |
-
&& !in_array($post->ID, $post_ids))
|
223 |
-
return false;
|
224 |
-
}
|
225 |
-
// excluded posts
|
226 |
-
if(!empty($_cond_value['exclude'])){
|
227 |
-
$post_ids = explode(',', $_cond_value['exclude']);
|
228 |
-
if(is_array($post_ids)
|
229 |
-
&& isset($post->ID)
|
230 |
-
&& in_array($post->ID, $post_ids))
|
231 |
-
return false;
|
232 |
-
}
|
233 |
-
break;
|
234 |
-
// check for category ids
|
235 |
-
case 'categoryids' :
|
236 |
-
// included
|
237 |
-
if(!empty($_cond_value['include'])){
|
238 |
-
$category_ids = explode(',', $_cond_value['include']);
|
239 |
-
// check if currently in a post (not post page, but also posts in loops)
|
240 |
-
if(is_array($category_ids) && isset($post->ID)
|
241 |
-
&& !in_category($category_ids, $post)) {
|
242 |
-
return false;
|
243 |
-
}
|
244 |
-
}
|
245 |
-
// check for excluded category ids
|
246 |
-
if(!empty($_cond_value['exclude'])){
|
247 |
-
$category_ids = explode(',', $_cond_value['exclude']);
|
248 |
-
// check if currently in a post (not post page, but also posts in loops)
|
249 |
-
if(is_array($category_ids) && isset($post->ID)
|
250 |
-
&& in_category($category_ids, $post) ) {
|
251 |
-
// being only in one excluded category is enough to not display the ad
|
252 |
-
return false;
|
253 |
-
}
|
254 |
-
}
|
255 |
-
break;
|
256 |
-
// check for included category archive ids
|
257 |
-
// @link http://codex.wordpress.org/Conditional_Tags#A_Category_Page
|
258 |
-
case 'categoryarchiveids' :
|
259 |
-
if(!empty($_cond_value['include'])){
|
260 |
-
$category_ids = explode(',', $_cond_value['include']);
|
261 |
-
if(is_array($category_ids) && !is_category($category_ids))
|
262 |
-
return false;
|
263 |
-
}
|
264 |
-
// check for excluded category archive ids
|
265 |
-
if(!empty($_cond_value['exclude'])){
|
266 |
-
$category_ids = explode(',', $_cond_value['exclude']);
|
267 |
-
if(is_array($category_ids) && is_category($category_ids))
|
268 |
-
return false;
|
269 |
-
}
|
270 |
-
break;
|
271 |
-
// check for included post types
|
272 |
-
case 'posttypes' :
|
273 |
-
if(!empty($_cond_value['include'])){
|
274 |
-
$post_types = explode(',', $_cond_value['include']);
|
275 |
-
// check if currently in a post (not post page, but also posts in loops)
|
276 |
-
if(is_array($post_types) && !in_array(get_post_type(), $post_types)) {
|
277 |
-
return false;
|
278 |
-
}
|
279 |
-
}
|
280 |
-
// check for excluded post types
|
281 |
-
if(!empty($_cond_value['include'])){
|
282 |
-
$post_types = explode(',', $_cond_value['exclude']);
|
283 |
-
// check if currently in a post (not post page, but also posts in loops)
|
284 |
-
if(is_array($post_types) && in_array(get_post_type(), $post_types)) {
|
285 |
-
return false;
|
286 |
-
}
|
287 |
-
}
|
288 |
-
break;
|
289 |
-
// check is_front_page
|
290 |
-
// @link https://codex.wordpress.org/Conditional_Tags#The_Front_Page
|
291 |
-
case 'is_front_page' :
|
292 |
-
if(($_cond_value == 1 && !is_front_page())
|
293 |
-
|| ($_cond_value == 0 && is_front_page()))
|
294 |
-
return false;
|
295 |
-
break;
|
296 |
-
// check is_singular
|
297 |
-
// @link https://codex.wordpress.org/Conditional_Tags#A_Post_Type
|
298 |
-
case 'is_singular' :
|
299 |
-
if(($_cond_value == 1 && !is_singular())
|
300 |
-
|| ($_cond_value == 0 && is_singular()))
|
301 |
-
return false;
|
302 |
-
break;
|
303 |
-
// check is_archive
|
304 |
-
// @link https://codex.wordpress.org/Conditional_Tags#Any_Archive_Page
|
305 |
-
case 'is_archive' :
|
306 |
-
if(($_cond_value == 1 && !is_archive())
|
307 |
-
|| ($_cond_value == 0 && is_archive()))
|
308 |
-
return false;
|
309 |
-
break;
|
310 |
-
// check is_search
|
311 |
-
// @link https://codex.wordpress.org/Conditional_Tags#A_Search_Result_Page
|
312 |
-
case 'is_search' :
|
313 |
-
if(($_cond_value == 1 && !is_search())
|
314 |
-
|| ($_cond_value == 0 && is_search()))
|
315 |
-
return false;
|
316 |
-
break;
|
317 |
-
// check is_404
|
318 |
-
// @link https://codex.wordpress.org/Conditional_Tags#A_404_Not_Found_Page
|
319 |
-
case 'is_404' :
|
320 |
-
if(($_cond_value == 1 && !is_404())
|
321 |
-
|| ($_cond_value == 0 && is_404()))
|
322 |
-
return false;
|
323 |
-
break;
|
324 |
-
// check is_attachment
|
325 |
-
// @link https://codex.wordpress.org/Conditional_Tags#An_Attachment
|
326 |
-
case 'is_attachment' :
|
327 |
-
if(($_cond_value == 1 && !is_attachment())
|
328 |
-
|| ($_cond_value == 0 && is_attachment()))
|
329 |
-
return false;
|
330 |
-
break;
|
331 |
-
}
|
332 |
-
}
|
333 |
-
|
334 |
-
return true;
|
335 |
-
}
|
336 |
-
|
337 |
-
/**
|
338 |
-
* check visitor conditions
|
339 |
-
*
|
340 |
-
* @since 1.1.0
|
341 |
-
* @return bool $can_display true if can be displayed in frontend based on visitor settings
|
342 |
-
*/
|
343 |
-
public function can_display_by_visitor(){
|
344 |
-
|
345 |
-
if(empty($this->options['visitor']) ||
|
346 |
-
!is_array($this->options['visitor'])) return true;
|
347 |
-
|
348 |
-
$visitor_conditions = $this->options('visitor');
|
349 |
-
|
350 |
-
// check mobile condition
|
351 |
-
if(!empty($visitor_conditions['mobile'])){
|
352 |
-
switch($visitor_conditions['mobile']){
|
353 |
-
case 'only' :
|
354 |
-
if(!wp_is_mobile()) return false;
|
355 |
-
break;
|
356 |
-
case 'no' :
|
357 |
-
if(wp_is_mobile()) return false;
|
358 |
-
break;
|
359 |
-
}
|
360 |
-
}
|
361 |
-
|
362 |
-
return true;
|
363 |
-
}
|
364 |
-
|
365 |
-
/**
|
366 |
-
* save an ad to the database
|
367 |
-
* takes values from the current state
|
368 |
-
*/
|
369 |
-
public function save(){
|
370 |
-
global $wpdb;
|
371 |
-
|
372 |
-
// remove slashes from content
|
373 |
-
$content = $this->prepare_content_to_save();
|
374 |
-
|
375 |
-
$where = array('ID' => $this->id);
|
376 |
-
$wpdb->update( $wpdb->posts, array( 'post_content' => $content ), $where );
|
377 |
-
|
378 |
-
// sanitize conditions
|
379 |
-
// see sanitize_conditions function for example on using this filter
|
380 |
-
$conditions = self::sanitize_conditions_on_save($this->conditions);
|
381 |
-
|
382 |
-
// save other options to post meta field
|
383 |
-
$options = $this->options();
|
384 |
-
|
385 |
-
$options['type'] = $this->type;
|
386 |
-
$options['conditions'] = $conditions;
|
387 |
-
|
388 |
-
// filter to manipulate options or add more to be saved
|
389 |
-
$options = apply_filters('advanced-ads-save-options', $options, $this);
|
390 |
-
|
391 |
-
// update global settings
|
392 |
-
$this->update_general_ad_conditions($conditions);
|
393 |
-
|
394 |
-
update_post_meta($this->id, self::$options_meta_field, $options);
|
395 |
-
|
396 |
-
}
|
397 |
-
|
398 |
-
/**
|
399 |
-
* native filter for content field before being saved
|
400 |
-
*
|
401 |
-
* @return string $content ad content
|
402 |
-
* @since 1.0.0
|
403 |
-
*/
|
404 |
-
public function prepare_content_to_save() {
|
405 |
-
|
406 |
-
$content = $this->content;
|
407 |
-
|
408 |
-
// load ad type specific parameter filter
|
409 |
-
$content = $this->type_obj->sanitize_content($content);
|
410 |
-
// apply a custom filter by ad type
|
411 |
-
$content = apply_filters('advanced-ads-pre-ad-save-' . $this->type, $content);
|
412 |
-
|
413 |
-
return $content;
|
414 |
-
}
|
415 |
-
|
416 |
-
/**
|
417 |
-
* native filter for ad parameters before being saved
|
418 |
-
*
|
419 |
-
* @return arr $parameters sanitized parameters
|
420 |
-
*/
|
421 |
-
public function prepare_parameters_to_save() {
|
422 |
-
|
423 |
-
$parameters = $this->parameters;
|
424 |
-
// load ad type specific parameter filter
|
425 |
-
$parameters = $this->type_obj->sanitize_parameters($parameters);
|
426 |
-
|
427 |
-
// apply native WP filter for content fields
|
428 |
-
return $parameters;
|
429 |
-
}
|
430 |
-
|
431 |
-
/**
|
432 |
-
* prepare ads output
|
433 |
-
*
|
434 |
-
* @param string $content ad content
|
435 |
-
* @param obj $ad ad object
|
436 |
-
*/
|
437 |
-
public function prepare_frontend_output(){
|
438 |
-
|
439 |
-
// load ad type specific content filter
|
440 |
-
$output = $this->type_obj->prepare_output($this);
|
441 |
-
|
442 |
-
// apply a custom filter by ad type
|
443 |
-
$output = apply_filters('advanced-ads-ad-output', $output, $this);
|
444 |
-
|
445 |
-
return $output;
|
446 |
-
}
|
447 |
-
|
448 |
-
/**
|
449 |
-
* sanitize ad display conditions when saving the ad
|
450 |
-
*
|
451 |
-
* @param array $conditions conditions array send via the dashboard form for an ad
|
452 |
-
* @return array with sanitized conditions
|
453 |
-
* @since 1.0.0
|
454 |
-
*/
|
455 |
-
public function sanitize_conditions_on_save($conditions = array()){
|
456 |
-
|
457 |
-
global $advanced_ads_ad_conditions;
|
458 |
-
|
459 |
-
if(!is_array($conditions) || $conditions == array()) return array();
|
460 |
-
|
461 |
-
foreach($conditions as $_key => $_condition){
|
462 |
-
if(!is_array($_condition))
|
463 |
-
$_condition = trim($_condition);
|
464 |
-
if($_condition == '') {
|
465 |
-
$conditions[$_key] = $_condition;
|
466 |
-
continue;
|
467 |
-
}
|
468 |
-
$type = $advanced_ads_ad_conditions[$_key]['type'];
|
469 |
-
if(empty($type)) continue;
|
470 |
-
|
471 |
-
// dynamically apply filters for each condition used
|
472 |
-
$conditions[$_key] = apply_filters('advanced-ads-sanitize-condition-' . $type, $_condition);
|
473 |
-
}
|
474 |
-
|
475 |
-
return $conditions;
|
476 |
-
}
|
477 |
-
|
478 |
-
/**
|
479 |
-
* sanitize id input field(s) for pattern /1,2,3,4/
|
480 |
-
*
|
481 |
-
* @pararm array/string $cond input string/array
|
482 |
-
* @return array/string $cond sanitized string/array
|
483 |
-
*/
|
484 |
-
public static function sanitize_condition_idfield($cond = ''){
|
485 |
-
// strip anything that is not comma or number
|
486 |
-
if(is_array($cond)){
|
487 |
-
foreach($cond as $_key => $_cond){
|
488 |
-
$cond[$_key] = preg_replace('#[^0-9,]#', '', $_cond);
|
489 |
-
}
|
490 |
-
} else {
|
491 |
-
$cond = preg_replace('#[^0-9,]#', '', $cond);
|
492 |
-
}
|
493 |
-
return $cond;
|
494 |
-
}
|
495 |
-
|
496 |
-
/**
|
497 |
-
* sanitize radio input field
|
498 |
-
*
|
499 |
-
* @pararm string $string input string
|
500 |
-
* @return string $string sanitized string
|
501 |
-
*/
|
502 |
-
public static function sanitize_condition_radio($string = ''){
|
503 |
-
// only allow 0, 1 and empty
|
504 |
-
return $string = preg_replace('#[^01]#', '', $string);
|
505 |
-
}
|
506 |
-
|
507 |
-
/**
|
508 |
-
* sanitize comma seperated text input field
|
509 |
-
*
|
510 |
-
* @pararm array/string $cond input string/array
|
511 |
-
* @return array/string $cond sanitized string/array
|
512 |
-
*/
|
513 |
-
public static function sanitize_condition_textvalues($cond = ''){
|
514 |
-
// strip anything that is not comma, alphanumeric, minus and underscore
|
515 |
-
if(is_array($cond)){
|
516 |
-
foreach($cond as $_key => $_cond){
|
517 |
-
$cond[$_key] = preg_replace('#[^0-9,A-Za-z-_]#', '', $_cond);
|
518 |
-
}
|
519 |
-
} else {
|
520 |
-
$cond = preg_replace('#[^0-9,A-Za-z-_]#', '', $cond);
|
521 |
-
}
|
522 |
-
return $cond;
|
523 |
-
}
|
524 |
-
|
525 |
-
/**
|
526 |
-
* update general ad conditions with conditions for the current ad
|
527 |
-
*
|
528 |
-
* @param array $conditions ad display conditions from ad form
|
529 |
-
* @since 1.0.0
|
530 |
-
* @todo make those condition checks extendible
|
531 |
-
*/
|
532 |
-
public function update_general_ad_conditions($conditions){
|
533 |
-
global $advanced_ads_ad_conditions;
|
534 |
-
|
535 |
-
$plugin = Advanced_Ads::get_instance();
|
536 |
-
$ads_by_conditions = $plugin->get_ads_by_conditions_array();
|
537 |
-
$plugin_slug = $plugin->get_plugin_slug();
|
538 |
-
|
539 |
-
// remove current ad from general ad condition array
|
540 |
-
$ads_by_conditions = $this->remove_ad_from_general_ad_conditions($this->id, $ads_by_conditions);
|
541 |
-
|
542 |
-
// only run conditions if ad is publically visible
|
543 |
-
if($this->status == 'publish')
|
544 |
-
// iterate through the ads display condition
|
545 |
-
foreach($conditions as $_condition_key => $_condition){
|
546 |
-
if(!isset($advanced_ads_ad_conditions[$_condition_key]['type'])) {
|
547 |
-
$plugin->log(sprintf(__('A "%s" display condition does not exist', $plugin_slug), $_condition_key));
|
548 |
-
return;
|
549 |
-
}
|
550 |
-
// add conditions based on type
|
551 |
-
switch($advanced_ads_ad_conditions[$_condition_key]['type']){
|
552 |
-
case 'idfield' :
|
553 |
-
if(isset($_condition['include']) && $_condition['include'] != ''){
|
554 |
-
$_ids = explode(',', $_condition['include']);
|
555 |
-
if(is_array($_ids)) foreach($_ids as $_id){
|
556 |
-
$ads_by_conditions[$_condition_key][$_id]['include'][] = $this->id;
|
557 |
-
}
|
558 |
-
}
|
559 |
-
if(isset($_condition['exclude']) && $_condition['exclude'] != ''){
|
560 |
-
$_ids = explode(',', $_condition['exclude']);
|
561 |
-
if(is_array($_ids)) foreach($_ids as $_id){
|
562 |
-
$ads_by_conditions[$_condition_key][$_id]['exclude'][] = $this->id;
|
563 |
-
}
|
564 |
-
}
|
565 |
-
break;
|
566 |
-
case 'textvalues' :
|
567 |
-
if(isset($_condition['include']) && $_condition['include'] != ''){
|
568 |
-
$_ids = explode(',', $_condition['include']);
|
569 |
-
if(is_array($_ids)) foreach($_ids as $_id){
|
570 |
-
$ads_by_conditions[$_condition_key][$_id]['include'][] = $this->id;
|
571 |
-
}
|
572 |
-
}
|
573 |
-
if(isset($_condition['exclude']) && $_condition['exclude'] != ''){
|
574 |
-
$_ids = explode(',', $_condition['exclude']);
|
575 |
-
if(is_array($_ids)) foreach($_ids as $_id){
|
576 |
-
$ads_by_conditions[$_condition_key][$_id]['exclude'][] = $this->id;
|
577 |
-
}
|
578 |
-
}
|
579 |
-
break;
|
580 |
-
case 'radio' :
|
581 |
-
if($_condition == 1)
|
582 |
-
$ads_by_conditions[$_condition_key]['include'][] = $this->id;
|
583 |
-
elseif($_condition == 0)
|
584 |
-
$ads_by_conditions[$_condition_key]['exclude'][] = $this->id;
|
585 |
-
break;
|
586 |
-
} // switch
|
587 |
-
} // forearch
|
588 |
-
|
589 |
-
update_option('advads-ads-by-conditions', $ads_by_conditions);
|
590 |
-
}
|
591 |
-
|
592 |
-
/**
|
593 |
-
* remove ad id from ad conditions array
|
594 |
-
*
|
595 |
-
* @param int $ad_id id of the ad (=post id)
|
596 |
-
* @param arr $conditions array with the general, global ad conditions
|
597 |
-
* @since 1.0.0
|
598 |
-
*/
|
599 |
-
static function remove_ad_from_general_ad_conditions($ad_id = 0, $conditions = array()){
|
600 |
-
$ad_id = absint($ad_id);
|
601 |
-
if(empty($ad_id) || !is_array($conditions) || $conditions == array()) return;
|
602 |
-
|
603 |
-
foreach($conditions as $_key => $_cond){
|
604 |
-
// remove single elements
|
605 |
-
if(!is_array($_cond) && $_cond == $ad_id){
|
606 |
-
unset($conditions[$_key]);
|
607 |
-
} elseif(empty($_cond)){
|
608 |
-
unset($conditions[$_key]);
|
609 |
-
}
|
610 |
-
// check recursively
|
611 |
-
elseif(is_array($_cond)){
|
612 |
-
$new_cond = self::remove_ad_from_general_ad_conditions($ad_id, $_cond);
|
613 |
-
|
614 |
-
if($new_cond == array() || $new_cond == ''){
|
615 |
-
// remove empty arrays
|
616 |
-
unset($conditions[$_key]);
|
617 |
-
} else {
|
618 |
-
$conditions[$_key] = $new_cond;
|
619 |
-
}
|
620 |
-
}
|
621 |
-
}
|
622 |
-
|
623 |
-
return $conditions;
|
624 |
-
}
|
625 |
-
|
626 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/classes/ad_ajax_callbacks.php
DELETED
@@ -1,97 +0,0 @@
|
|
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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/classes/ad_group.php
DELETED
@@ -1,347 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Advanced Ads
|
5 |
-
*
|
6 |
-
* @package Advads_Ad_Group
|
7 |
-
* @author Thomas Maier <thomas.maier@webgilde.com>
|
8 |
-
* @license GPL-2.0+
|
9 |
-
* @link http://webgilde.com
|
10 |
-
* @copyright 2014 Thomas Maier, webgilde GmbH
|
11 |
-
*/
|
12 |
-
|
13 |
-
/**
|
14 |
-
* an ad group object
|
15 |
-
*
|
16 |
-
* @package Advads_Ad_Group
|
17 |
-
* @author Thomas Maier <thomas.maier@webgilde.com>
|
18 |
-
*/
|
19 |
-
class Advads_Ad_Group {
|
20 |
-
|
21 |
-
/**
|
22 |
-
* default ad group weight
|
23 |
-
*/
|
24 |
-
const MAX_AD_GROUP_WEIGHT = 10;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* id of the taxonomy of this ad group
|
28 |
-
*/
|
29 |
-
public $id = 0;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* name of the taxonomy
|
33 |
-
*/
|
34 |
-
protected $taxonomy = '';
|
35 |
-
|
36 |
-
/**
|
37 |
-
* post type of the ads
|
38 |
-
*/
|
39 |
-
protected $post_type = '';
|
40 |
-
|
41 |
-
/**
|
42 |
-
* the current loaded ad
|
43 |
-
*/
|
44 |
-
protected $current_ad = '';
|
45 |
-
|
46 |
-
/**
|
47 |
-
* the name of the term
|
48 |
-
*/
|
49 |
-
public $name = '';
|
50 |
-
|
51 |
-
/**
|
52 |
-
* the slug of the term
|
53 |
-
*/
|
54 |
-
public $slug = '';
|
55 |
-
|
56 |
-
/**
|
57 |
-
* the description of the term
|
58 |
-
*/
|
59 |
-
public $description = '';
|
60 |
-
|
61 |
-
/**
|
62 |
-
* containing ad weights
|
63 |
-
*/
|
64 |
-
private $ad_weights = 0;
|
65 |
-
|
66 |
-
/**
|
67 |
-
* array with post type objects (ads)
|
68 |
-
*/
|
69 |
-
private $ads = array();
|
70 |
-
|
71 |
-
/**
|
72 |
-
* init ad group object
|
73 |
-
*
|
74 |
-
* @since 1.0.0
|
75 |
-
* @param int $id id of the ad group (= taxonomy id)
|
76 |
-
*/
|
77 |
-
public function __construct($id) {
|
78 |
-
$id = absint($id);
|
79 |
-
|
80 |
-
if (empty($id))
|
81 |
-
return;
|
82 |
-
|
83 |
-
$this->id = $id;
|
84 |
-
$this->taxonomy = Advanced_Ads::AD_GROUP_TAXONOMY;
|
85 |
-
$this->post_type = Advanced_Ads::POST_TYPE_SLUG;
|
86 |
-
|
87 |
-
$this->load($id);
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* load an ad group object by id
|
92 |
-
*
|
93 |
-
* @since 1.0.0
|
94 |
-
*/
|
95 |
-
private function load($id = 0) {
|
96 |
-
$_group = get_term($id, $this->taxonomy);
|
97 |
-
if ($_group == null)
|
98 |
-
return;
|
99 |
-
|
100 |
-
$this->name = $_group->name;
|
101 |
-
$this->slug = $_group->slug;
|
102 |
-
$this->description = $_group->description;
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* return random ad content for frontend output
|
107 |
-
*
|
108 |
-
* @since 1.0.0
|
109 |
-
* @return string ad content
|
110 |
-
*/
|
111 |
-
public function output_random_ad() {
|
112 |
-
// see prepare_frontend_output for example for this filter
|
113 |
-
$ad = $this->get_random_ad();
|
114 |
-
|
115 |
-
if (!is_object($ad))
|
116 |
-
return '';
|
117 |
-
|
118 |
-
// makes sure the ad filters can also run here
|
119 |
-
$adcontent = $ad->output();
|
120 |
-
|
121 |
-
// filter again, in case a developer wants to filter group output individually
|
122 |
-
$output = apply_filters('advanced-ads-group-output', $adcontent, $this);
|
123 |
-
|
124 |
-
return $output;
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* get a random ad from this group
|
129 |
-
*
|
130 |
-
* @since 1.0.0
|
131 |
-
* @return
|
132 |
-
*/
|
133 |
-
private function get_random_ad() {
|
134 |
-
|
135 |
-
// load all ads
|
136 |
-
$ads = $this->load_all_ads();
|
137 |
-
|
138 |
-
// return, if no ads given
|
139 |
-
if ($ads === array())
|
140 |
-
return;
|
141 |
-
|
142 |
-
// shuffle ads based on ad weight
|
143 |
-
$ads = $this->shuffle_ads($ads);
|
144 |
-
|
145 |
-
// check ads one by one for being able to be displayed on this spot
|
146 |
-
foreach ($ads as $_ad) {
|
147 |
-
// load the ad object
|
148 |
-
$ad = new Advads_Ad($_ad->ID);
|
149 |
-
if ($ad->can_display()) {
|
150 |
-
return $ad;
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
-
return '';
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* return all ads from this group
|
159 |
-
*
|
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();
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
* load all public ads for this group
|
171 |
-
*
|
172 |
-
* @since 1.0.0
|
173 |
-
* @update 1.1.0 load only public ads
|
174 |
-
* @return arr $ads array with ad (post) objects
|
175 |
-
*/
|
176 |
-
private function load_all_ads() {
|
177 |
-
|
178 |
-
$args = array(
|
179 |
-
'post_type' => $this->post_type,
|
180 |
-
'post_status' => 'publish',
|
181 |
-
$this->taxonomy => $this->slug,
|
182 |
-
'orderby' => 'id'
|
183 |
-
);
|
184 |
-
$ads = new WP_Query($args);
|
185 |
-
// not sure if reset of postdata is needed here
|
186 |
-
wp_reset_postdata();
|
187 |
-
|
188 |
-
if ($ads->have_posts()) {
|
189 |
-
return $this->ads = $this->add_post_ids($ads->posts);
|
190 |
-
} else {
|
191 |
-
return $this->ads = array();
|
192 |
-
}
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* use post ids as keys for ad array
|
197 |
-
*
|
198 |
-
* @since 1.0.0
|
199 |
-
* @param arr $ads array with post objects
|
200 |
-
* @return arr $ads array with post objects with post id as their key
|
201 |
-
* @todo check, if there isn’t a WP function for this already
|
202 |
-
*/
|
203 |
-
private function add_post_ids(array $ads){
|
204 |
-
|
205 |
-
$ads_with_id = array();
|
206 |
-
foreach($ads as $_ad){
|
207 |
-
$ads_with_id[$_ad->ID] = $_ad;
|
208 |
-
}
|
209 |
-
|
210 |
-
return $ads_with_id;
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* shuffle ads based on ad weight
|
215 |
-
*
|
216 |
-
* @since 1.0.0
|
217 |
-
* @param arr $ads array with ad objects
|
218 |
-
* @return arr $shuffled_ads shuffled array with ad objects
|
219 |
-
*/
|
220 |
-
private function shuffle_ads($ads = array()) {
|
221 |
-
|
222 |
-
// get saved ad weights
|
223 |
-
$weights = $this->get_ad_weights();
|
224 |
-
|
225 |
-
// if ads and weights don’t have the same keys, update weights array
|
226 |
-
if(count($weights) != count($ads) || array_diff_key($weights, $ads) != array()
|
227 |
-
|| array_diff_key($ads, $weights) != array()) {
|
228 |
-
$this->update_ad_weights();
|
229 |
-
}
|
230 |
-
|
231 |
-
// get a random ad for every ad there is
|
232 |
-
$shuffled_ads = array();
|
233 |
-
$ad_count = count($ads);
|
234 |
-
for($i = 1; $i <= $ad_count; $i++){
|
235 |
-
$random_ad_id = $this->get_random_ad_by_weight($weights);
|
236 |
-
// remove chosen ad from weights array
|
237 |
-
unset($weights[$random_ad_id]);
|
238 |
-
// put random ad into shuffled array
|
239 |
-
if(isset($ads[$random_ad_id])) { $shuffled_ads[] = $ads[$random_ad_id]; }
|
240 |
-
}
|
241 |
-
|
242 |
-
return $shuffled_ads;
|
243 |
-
}
|
244 |
-
|
245 |
-
/**
|
246 |
-
* get random ad by ad weight
|
247 |
-
*
|
248 |
-
* @since 1.0.0
|
249 |
-
* @param array $ad_weights e.g. array(A => 2, B => 3, C => 5)
|
250 |
-
* @source applied with fix for order http://stackoverflow.com/a/11872928/904614
|
251 |
-
*/
|
252 |
-
private function get_random_ad_by_weight(array $ad_weights) {
|
253 |
-
|
254 |
-
// order array by ad weight; lowest first
|
255 |
-
asort($ad_weights);
|
256 |
-
|
257 |
-
// use maximum ad weight for ads without this
|
258 |
-
$max = (int) array_sum($ad_weights);
|
259 |
-
$rand = mt_rand(1, $max);
|
260 |
-
|
261 |
-
foreach ($ad_weights as $key => $value) {
|
262 |
-
$rand -= $value;
|
263 |
-
if ($rand <= 0) {
|
264 |
-
return $key;
|
265 |
-
}
|
266 |
-
}
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* get weights of ads in this group
|
271 |
-
*
|
272 |
-
* @since 1.0.0
|
273 |
-
*/
|
274 |
-
public function get_ad_weights() {
|
275 |
-
if ($this->ad_weights == 0) {
|
276 |
-
$weights = get_option('advads-ad-weights', array());
|
277 |
-
} else {
|
278 |
-
return $this->ad_weights;
|
279 |
-
}
|
280 |
-
if (isset($weights[$this->id])) {
|
281 |
-
return $this->ad_weights = $weights[$this->id];
|
282 |
-
}
|
283 |
-
}
|
284 |
-
|
285 |
-
/**
|
286 |
-
* save ad group weight (into global ad weight array)
|
287 |
-
*
|
288 |
-
* @since 1.0.0
|
289 |
-
* @param arr|str $weights array with ad weights (key: ad id; value: weight)
|
290 |
-
*/
|
291 |
-
public function save_ad_weights($weights = '') {
|
292 |
-
|
293 |
-
// allow only arrays and empty string
|
294 |
-
if (!is_array($weights) && $weights = '')
|
295 |
-
return;
|
296 |
-
|
297 |
-
$global_weights = get_option('advads-ad-weights', array());
|
298 |
-
|
299 |
-
$global_weights[$this->id] = $this->sanitize_ad_weights($weights);
|
300 |
-
|
301 |
-
update_option('advads-ad-weights', $global_weights);
|
302 |
-
}
|
303 |
-
/**
|
304 |
-
* update ad weight based on current ads for the group and ad weight
|
305 |
-
*
|
306 |
-
* @since 1.0.0
|
307 |
-
*/
|
308 |
-
private function update_ad_weights(){
|
309 |
-
$ads = $this->get_all_ads();
|
310 |
-
$weights = $this->get_ad_weights();
|
311 |
-
|
312 |
-
$new_weights = array();
|
313 |
-
// use only ads assigned to the group
|
314 |
-
foreach($ads as $_ad){
|
315 |
-
if(isset($weights[$_ad->ID])){
|
316 |
-
$new_weights[$_ad->ID] = $weights[$_ad->ID];
|
317 |
-
} else {
|
318 |
-
// if no weight is given, use maximum default value
|
319 |
-
$new_weights[$_ad->ID] = self::MAX_AD_GROUP_WEIGHT;
|
320 |
-
}
|
321 |
-
}
|
322 |
-
|
323 |
-
$this->save_ad_weights($new_weights);
|
324 |
-
}
|
325 |
-
|
326 |
-
/**
|
327 |
-
* sanitize ad weights
|
328 |
-
*
|
329 |
-
* @since 1.0.0
|
330 |
-
* @param arr $weights ad weights array with (key: ad id; value: weight)
|
331 |
-
*/
|
332 |
-
private function sanitize_ad_weights($weights = array()) {
|
333 |
-
|
334 |
-
if (!is_array($weights))
|
335 |
-
return '';
|
336 |
-
|
337 |
-
$sanitized_weights = array();
|
338 |
-
foreach ($weights as $_ad_id => $_weight) {
|
339 |
-
$_ad_id = absint($_ad_id);
|
340 |
-
$_weight = absint($_weight);
|
341 |
-
$sanitized_weights[$_ad_id] = $_weight;
|
342 |
-
}
|
343 |
-
|
344 |
-
return $sanitized_weights;
|
345 |
-
}
|
346 |
-
|
347 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/classes/ad_type_abstract.php
DELETED
@@ -1,124 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Advanced Ads Abstract Ad Type
|
4 |
-
*
|
5 |
-
* @package Advanced_Ads
|
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 |
-
* Class containing information that are defaults for all the other ad types
|
12 |
-
*
|
13 |
-
* see ad_type_content.php for an example on ad type
|
14 |
-
*
|
15 |
-
*/
|
16 |
-
class Advads_Ad_Type_Abstract {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* ID - internal type of the ad type
|
20 |
-
*
|
21 |
-
* must be static so set your own ad type ID here
|
22 |
-
* use slug like format, only lower case, underscores and hyphens
|
23 |
-
*
|
24 |
-
* @since 1.0.0
|
25 |
-
*/
|
26 |
-
public $ID = '';
|
27 |
-
|
28 |
-
/**
|
29 |
-
* public title
|
30 |
-
*
|
31 |
-
* will be set within __construct so one can localize it
|
32 |
-
*
|
33 |
-
* @since 1.0.0
|
34 |
-
*/
|
35 |
-
public $title = '';
|
36 |
-
|
37 |
-
/**
|
38 |
-
* description of the ad type
|
39 |
-
*
|
40 |
-
* will be set within __construct so one can localize it
|
41 |
-
*
|
42 |
-
* @since 1.0.0
|
43 |
-
*/
|
44 |
-
public $description = '';
|
45 |
-
|
46 |
-
/**
|
47 |
-
* parameters of the ad
|
48 |
-
*
|
49 |
-
* defaults are set in construct
|
50 |
-
*/
|
51 |
-
public $parameters = array();
|
52 |
-
|
53 |
-
/**
|
54 |
-
* set basic attributes
|
55 |
-
*
|
56 |
-
* @since 1.0.0
|
57 |
-
*/
|
58 |
-
public function __construct() {
|
59 |
-
// initiall
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* output for the ad parameters metabox
|
64 |
-
*
|
65 |
-
* @param obj $ad ad object
|
66 |
-
* @since 1.0.0
|
67 |
-
*/
|
68 |
-
public function render_parameters($ad){
|
69 |
-
/**
|
70 |
-
* this will be loaded by default or using ajax when changing the ad type radio buttons
|
71 |
-
* echo the output right away here
|
72 |
-
* name parameters must be in the "advanced_ads" array
|
73 |
-
*/
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* sanitize ad parameters on save
|
78 |
-
*
|
79 |
-
* @param arr $parameters array with ad parameters
|
80 |
-
* @return arr $parameters sanitized ad parameters
|
81 |
-
* @since 1.0.0
|
82 |
-
*/
|
83 |
-
public function sanitize_parameters($parameters = array()){
|
84 |
-
// no specific filter for content ad parameters, because there are no
|
85 |
-
return $parameters;
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* sanitize content field on save
|
90 |
-
*
|
91 |
-
* @param str $content ad content
|
92 |
-
* @return str $content sanitized ad content
|
93 |
-
* @since 1.0.0
|
94 |
-
*/
|
95 |
-
public function sanitize_content($content = ''){
|
96 |
-
|
97 |
-
// remove slashes from content
|
98 |
-
return $content = wp_unslash($content);
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* load content field for the ad
|
103 |
-
*
|
104 |
-
* @param obj $post WP post object
|
105 |
-
* @return str $content ad content
|
106 |
-
* @since 1.0.0
|
107 |
-
*/
|
108 |
-
public function load_content($post){
|
109 |
-
|
110 |
-
return $post->post_content;
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* prepare the ads frontend output
|
115 |
-
*
|
116 |
-
* @param obj $ad ad object
|
117 |
-
* @return str $content ad content prepared for frontend output
|
118 |
-
* @since 1.0.0
|
119 |
-
*/
|
120 |
-
public function prepare_output($ad){
|
121 |
-
return $ad->content;
|
122 |
-
}
|
123 |
-
|
124 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/classes/ad_type_content.php
DELETED
@@ -1,83 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Advanced Ads Content Ad Type
|
4 |
-
*
|
5 |
-
* @package Advanced_Ads
|
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 |
-
* Class containing information about the content ad type
|
12 |
-
* this should also work as an example for other ad types
|
13 |
-
*
|
14 |
-
* see also includes/ad-type-abstract.php for basic object
|
15 |
-
*
|
16 |
-
*/
|
17 |
-
class Advads_Ad_Type_Content extends Advads_Ad_Type_Abstract{
|
18 |
-
|
19 |
-
/**
|
20 |
-
* ID - internal type of the ad type
|
21 |
-
*
|
22 |
-
* must be static so set your own ad type ID here
|
23 |
-
* use slug like format, only lower case, underscores and hyphens
|
24 |
-
*
|
25 |
-
* @since 1.0.0
|
26 |
-
*/
|
27 |
-
public $ID = 'content';
|
28 |
-
|
29 |
-
/**
|
30 |
-
* set basic attributes
|
31 |
-
*
|
32 |
-
* @since 1.0.0
|
33 |
-
*/
|
34 |
-
public function __construct() {
|
35 |
-
$this->title = __('Rich Content', Advanced_Ads::TD);
|
36 |
-
$this->description = __('The full content editor from WordPress with all features like image upload or styling, but also simple text/html mode for scripts and code.', Advanced_Ads::TD);
|
37 |
-
$this->parameters = array(
|
38 |
-
'content' => ''
|
39 |
-
);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* output for the ad parameters metabox
|
44 |
-
*
|
45 |
-
* this will be loaded using ajax when changing the ad type radio buttons
|
46 |
-
* echo the output right away here
|
47 |
-
* name parameters must be in the "advanced_ads" array
|
48 |
-
*
|
49 |
-
* @param obj $ad ad object
|
50 |
-
* @since 1.0.0
|
51 |
-
*/
|
52 |
-
public function render_parameters($ad){
|
53 |
-
// load tinymc content exitor
|
54 |
-
$content = (isset($ad->content)) ? $ad->content : '';
|
55 |
-
/**
|
56 |
-
* build the tinymc editor
|
57 |
-
* @link http://codex.wordpress.org/Function_Reference/wp_editor
|
58 |
-
*/
|
59 |
-
$args = array(
|
60 |
-
'textarea_name' => 'advanced_ad[content]',
|
61 |
-
'textarea_rows' => 10,
|
62 |
-
'drag_drop_upload' => true
|
63 |
-
);
|
64 |
-
wp_editor($content, 'advanced-ad-parameters-content', $args);
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* sanitize content field on save
|
69 |
-
*
|
70 |
-
* @param str $content ad content
|
71 |
-
* @return str $content sanitized ad content
|
72 |
-
* @since 1.0.0
|
73 |
-
*/
|
74 |
-
public function sanitize_content($content = ''){
|
75 |
-
|
76 |
-
// remove slashes from content
|
77 |
-
$content = wp_unslash($content);
|
78 |
-
|
79 |
-
// use WordPress core content filter
|
80 |
-
return $content = apply_filters('content_save_pre', $content);
|
81 |
-
}
|
82 |
-
|
83 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/classes/ad_type_plain.php
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Advanced Ads Plain Ad Type
|
4 |
-
*
|
5 |
-
* @package Advanced_Ads
|
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 |
-
* Class containing information about the plain text/code ad type
|
12 |
-
*
|
13 |
-
* see ad-type-content.php for a better sample on ad type
|
14 |
-
*
|
15 |
-
*/
|
16 |
-
class Advads_Ad_Type_Plain extends Advads_Ad_Type_Abstract{
|
17 |
-
|
18 |
-
/**
|
19 |
-
* ID - internal type of the ad type
|
20 |
-
* *
|
21 |
-
* @since 1.0.0
|
22 |
-
*/
|
23 |
-
public $ID = 'plain';
|
24 |
-
|
25 |
-
/**
|
26 |
-
* set basic attributes
|
27 |
-
*
|
28 |
-
* @since 1.0.0
|
29 |
-
*/
|
30 |
-
public function __construct() {
|
31 |
-
$this->title = __('Plain Text and Code', Advanced_Ads::TD);
|
32 |
-
$this->description = __('Simple text editor without any filters. You might use it to display unfiltered content, php code or javascript. Shortcodes and other WordPress content field magic does not work here.', Advanced_Ads::TD);
|
33 |
-
$this->parameters = array(
|
34 |
-
'content' => ''
|
35 |
-
);
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* output for the ad parameters metabox
|
40 |
-
*
|
41 |
-
* this will be loaded using ajax when changing the ad type radio buttons
|
42 |
-
* echo the output right away here
|
43 |
-
* name parameters must be in the "advanced_ads" array
|
44 |
-
*
|
45 |
-
* @param obj $ad ad object
|
46 |
-
* @since 1.0.0
|
47 |
-
*/
|
48 |
-
public function render_parameters($ad){
|
49 |
-
// load tinymc content exitor
|
50 |
-
$content = (isset($ad->content)) ? $ad->content : '';
|
51 |
-
/**
|
52 |
-
* build the tinymc editor
|
53 |
-
* @link http://codex.wordpress.org/Function_Reference/wp_editor
|
54 |
-
*/
|
55 |
-
?><p class="description"><?php _e('Insert plain text or code into this field.', Advanced_Ads::TD); ?></p>
|
56 |
-
<textarea id="advads-ad-content-plain" cols="40" rows="10" name="advanced_ad[content]"><?php echo $content; ?></textarea>
|
57 |
-
<?php
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* prepare the ads frontend output
|
62 |
-
*
|
63 |
-
* @param obj $ad ad object
|
64 |
-
* @return str $content ad content prepared for frontend output
|
65 |
-
* @since 1.0.0
|
66 |
-
*/
|
67 |
-
public function prepare_output($ad){
|
68 |
-
// evaluate the code as php
|
69 |
-
ob_start();
|
70 |
-
eval('?>'.$ad->content);
|
71 |
-
$content = ob_get_clean();
|
72 |
-
return $content;
|
73 |
-
}
|
74 |
-
|
75 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/composer.json
DELETED
@@ -1,25 +0,0 @@
|
|
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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/includes/array_ad_conditions.php
DELETED
@@ -1,77 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* conditions under which to (not) show an ad
|
5 |
-
* I don’t like huge arrays like this to clutter my classes
|
6 |
-
* and anyway, this might be needed on multiple places
|
7 |
-
*
|
8 |
-
* at the bottom, you find a filter to be able to extend / remove your own elements
|
9 |
-
*
|
10 |
-
* elements
|
11 |
-
* key - internal id of the condition; needs to be unique, obviously
|
12 |
-
* label - title in the dashboard
|
13 |
-
* description - (optional) description displayed in the dashboard
|
14 |
-
* type - information / markup type
|
15 |
-
* idfield - input field for comma separated lists of ids
|
16 |
-
* radio - radio button
|
17 |
-
*
|
18 |
-
* note: ’idfield’ always has a {field}_not version that is created automatically and being its own condition
|
19 |
-
*
|
20 |
-
*/
|
21 |
-
|
22 |
-
$advanced_ads_slug = Advanced_Ads::get_instance()->get_plugin_slug();
|
23 |
-
|
24 |
-
$advanced_ads_ad_conditions = array(
|
25 |
-
'postids' => array(
|
26 |
-
'label' => __('Single Pages/Posts', $advanced_ads_slug),
|
27 |
-
'description' => __('comma seperated IDs of post, page or custom post type', $advanced_ads_slug),
|
28 |
-
'type' => 'idfield',
|
29 |
-
),
|
30 |
-
'categoryids' => array(
|
31 |
-
'label' => __('Categories', $advanced_ads_slug),
|
32 |
-
'description' => __('comma seperated IDs of categories for posts or category archives', $advanced_ads_slug),
|
33 |
-
'type' => 'idfield',
|
34 |
-
),
|
35 |
-
'categoryarchiveids' => array(
|
36 |
-
'label' => __('Category Archives', $advanced_ads_slug),
|
37 |
-
'description' => __('comma seperated IDs of category archives', $advanced_ads_slug),
|
38 |
-
'type' => 'idfield',
|
39 |
-
),
|
40 |
-
'posttypes' => array(
|
41 |
-
'label' => __('Post Types', $advanced_ads_slug),
|
42 |
-
'description' => __('comma seperated list of post types', $advanced_ads_slug),
|
43 |
-
'type' => 'textvalues',
|
44 |
-
),
|
45 |
-
'is_front_page' => array(
|
46 |
-
'label' => __('Home Page', $advanced_ads_slug),
|
47 |
-
'description' => __('(don’t) show on Home page', $advanced_ads_slug),
|
48 |
-
'type' => 'radio',
|
49 |
-
),
|
50 |
-
'is_singular' => array(
|
51 |
-
'label' => __('Singular Pages', $advanced_ads_slug),
|
52 |
-
'description' => __('(don’t) show on singular pages/posts', $advanced_ads_slug),
|
53 |
-
'type' => 'radio',
|
54 |
-
),
|
55 |
-
'is_archive' => array(
|
56 |
-
'label' => __('Archive Pages', $advanced_ads_slug),
|
57 |
-
'description' => __('(don’t) show on any type of archive page (category, tag, author and date)', $advanced_ads_slug),
|
58 |
-
'type' => 'radio',
|
59 |
-
),
|
60 |
-
'is_search' => array(
|
61 |
-
'label' => __('Search Results', $advanced_ads_slug),
|
62 |
-
'description' => __('(don’t) show on search result pages', $advanced_ads_slug),
|
63 |
-
'type' => 'radio',
|
64 |
-
),
|
65 |
-
'is_404' => array(
|
66 |
-
'label' => __('404 Page', $advanced_ads_slug),
|
67 |
-
'description' => __('(don’t) show on 404 error page', $advanced_ads_slug),
|
68 |
-
'type' => 'radio',
|
69 |
-
),
|
70 |
-
'is_attachment' => array(
|
71 |
-
'label' => __('Attachment Pages', $advanced_ads_slug),
|
72 |
-
'description' => __('(don’t) show on attachment pages', $advanced_ads_slug),
|
73 |
-
'type' => 'radio',
|
74 |
-
)
|
75 |
-
);
|
76 |
-
|
77 |
-
$advanced_ads_ad_conditions = apply_filters('advanced-ads-conditions', $advanced_ads_ad_conditions);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/includes/autoloader.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* autoloader
|
5 |
-
*
|
6 |
-
* currently all classes of real objects (e.g. ads) can be found in /classes on the plugins root directory
|
7 |
-
* all classes have the "Advads_" prefix to prevent any conflicts with other plugins
|
8 |
-
* but filenames don’t use "advads" and are written in lower case
|
9 |
-
* e.g. Advads_Ad is in file classes/ad.php
|
10 |
-
*
|
11 |
-
* to be able to change this structure later, I use an autoloader here
|
12 |
-
*/
|
13 |
-
class Advads_Autoloader {
|
14 |
-
|
15 |
-
public static function load($classname) {
|
16 |
-
// to lower case
|
17 |
-
$classname = strtolower($classname);
|
18 |
-
|
19 |
-
// strip "advads_" prefix
|
20 |
-
$classname = str_replace('advads_', '', $classname);
|
21 |
-
|
22 |
-
$filepath = ADVADS_BASE_PATH . 'classes' . DIRECTORY_SEPARATOR . $classname . '.php';
|
23 |
-
|
24 |
-
if (file_exists($filepath)) {
|
25 |
-
require_once $filepath;
|
26 |
-
} else {
|
27 |
-
return false;
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/includes/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
trunk/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
trunk/languages/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
trunk/languages/plugin-name.pot
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
# Copyright (C) 2013 Thomas Maier, webgilde.com
|
2 |
-
# This file is distributed under the same license as the Advanced_Ads package.
|
3 |
-
msgid ""
|
4 |
-
msgstr ""
|
5 |
-
"Project-Id-Version: TODO 1.0.0\n"
|
6 |
-
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/plugin-name\n"
|
7 |
-
"POT-Creation-Date: 2013-05-10 11:23:19+00:00\n"
|
8 |
-
"PO-Revision-Date: 2013-05-10 10:37-0500\n"
|
9 |
-
"Last-Translator: FULL NAME <email@example.com>\n"
|
10 |
-
"Language-Team: LANGUAGE <translations@example.com >\n"
|
11 |
-
"MIME-Version: 1.0\n"
|
12 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
13 |
-
"Content-Transfer-Encoding: 8bit\n"
|
14 |
-
"X-Generator: Poedit 1.5.7\n"
|
15 |
-
"X-Poedit-KeywordsList: __;_e;_n;_x;esc_html_e;esc_html__;esc_attr_e;"
|
16 |
-
"esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_x:1,2c;_n:1,2\n"
|
17 |
-
"X-Poedit-Basepath: ../\n"
|
18 |
-
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
19 |
-
"X-Poedit-SearchPath-0: .\n"
|
20 |
-
|
21 |
-
#: class-plugin-name-admin.php:170
|
22 |
-
msgid "Page Title"
|
23 |
-
msgstr ""
|
24 |
-
|
25 |
-
#: class-plugin-name-admin.php:171
|
26 |
-
msgid "Menu Text"
|
27 |
-
msgstr ""
|
28 |
-
|
29 |
-
#: class-plugin-name-admin.php:197
|
30 |
-
msgid "Settings"
|
31 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/public/assets/css/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
trunk/public/assets/css/public.css
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
/* This stylesheet is used to style the public-facing components of the plugin. */
|
|
trunk/public/assets/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
trunk/public/assets/js/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
trunk/public/assets/js/public.js
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
(function ( $ ) {
|
2 |
-
"use strict";
|
3 |
-
|
4 |
-
$(function () {
|
5 |
-
|
6 |
-
// Place your public-facing JavaScript here
|
7 |
-
|
8 |
-
});
|
9 |
-
|
10 |
-
}(jQuery));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/public/class-advanced-ads.php
DELETED
@@ -1,706 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Advanced Ads.
|
5 |
-
*
|
6 |
-
* @package Advanced_Ads_Admin
|
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 |
-
* Plugin class. This class should ideally be used to work with the
|
15 |
-
* public-facing side of the WordPress site.
|
16 |
-
*
|
17 |
-
* @package Advanced_Ads
|
18 |
-
* @author Thomas Maier <thomas.maier@webgilde.com>
|
19 |
-
*/
|
20 |
-
class Advanced_Ads {
|
21 |
-
/**
|
22 |
-
* Plugin version, used for cache-busting of style and script file references.
|
23 |
-
*
|
24 |
-
* @since 1.0.0
|
25 |
-
* @var string
|
26 |
-
*/
|
27 |
-
|
28 |
-
const VERSION = '1.0.0';
|
29 |
-
|
30 |
-
/**
|
31 |
-
* post type slug
|
32 |
-
*
|
33 |
-
* @since 1.0.0
|
34 |
-
* @var string
|
35 |
-
*/
|
36 |
-
const POST_TYPE_SLUG = 'advanced_ads';
|
37 |
-
|
38 |
-
/**
|
39 |
-
* text domain
|
40 |
-
*
|
41 |
-
* @since 1.0.0
|
42 |
-
* @var string
|
43 |
-
*/
|
44 |
-
const TD = 'advanced-ads';
|
45 |
-
|
46 |
-
/**
|
47 |
-
* ad group slug
|
48 |
-
*
|
49 |
-
* @since 1.0.0
|
50 |
-
* @var string
|
51 |
-
*/
|
52 |
-
const AD_GROUP_TAXONOMY = 'advanced_ads_groups';
|
53 |
-
|
54 |
-
/**
|
55 |
-
* general plugin slug
|
56 |
-
*
|
57 |
-
* DEPRECATED: The variable name is used as the text domain when internationalizing strings
|
58 |
-
* of text. Its value should match the Text Domain file header in the main
|
59 |
-
* plugin file.
|
60 |
-
*
|
61 |
-
* @since 1.0.0
|
62 |
-
* @var string
|
63 |
-
*/
|
64 |
-
protected $plugin_slug = 'advanced-ads';
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Instance of this class.
|
68 |
-
*
|
69 |
-
* @since 1.0.0
|
70 |
-
* @var object
|
71 |
-
*/
|
72 |
-
protected static $instance = null;
|
73 |
-
|
74 |
-
/**
|
75 |
-
* ad types
|
76 |
-
*/
|
77 |
-
public $ad_types = array();
|
78 |
-
|
79 |
-
/**
|
80 |
-
* plugin options
|
81 |
-
*
|
82 |
-
* @since 1.0.1
|
83 |
-
* @var array (if loaded)
|
84 |
-
*/
|
85 |
-
protected $options = false;
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Initialize the plugin by setting localization and loading public scripts
|
89 |
-
* and styles.
|
90 |
-
*
|
91 |
-
* @since 1.0.0
|
92 |
-
*/
|
93 |
-
private function __construct() {
|
94 |
-
|
95 |
-
// Load plugin text domain
|
96 |
-
add_action('init', array($this, 'load_plugin_textdomain'));
|
97 |
-
|
98 |
-
// activate plugin when new blog is added on multisites
|
99 |
-
add_action('wpmu_new_blog', array($this, 'activate_new_site'));
|
100 |
-
|
101 |
-
// Load public-facing style sheet and JavaScript.
|
102 |
-
add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
|
103 |
-
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
|
104 |
-
|
105 |
-
// initialize plugin specific functions
|
106 |
-
add_action( 'init', array( $this, 'init' ) );
|
107 |
-
register_activation_hook(__FILE__, array($this,'post_types_rewrite_flush'));
|
108 |
-
|
109 |
-
// add short codes
|
110 |
-
add_shortcode('the_ad', array($this, 'shortcode_display_ad'));
|
111 |
-
add_shortcode('the_ad_group', array($this, 'shortcode_display_ad_group'));
|
112 |
-
add_shortcode('the_ad_placement', array($this, 'shortcode_display_ad_placement'));
|
113 |
-
// remove default ad group menu item
|
114 |
-
add_action('admin_menu', array($this, 'remove_taxonomy_menu_item'));
|
115 |
-
|
116 |
-
// setup default ad types
|
117 |
-
add_filter('advanced-ads-ad-types', array($this, 'setup_default_ad_types'));
|
118 |
-
|
119 |
-
// register hooks and filters for auto ad injection
|
120 |
-
add_action('wp_head', array($this, 'inject_header'), 20);
|
121 |
-
add_action('wp_footer', array($this, 'inject_footer'), 20);
|
122 |
-
add_filter('the_content', array($this, 'inject_content'), 20);
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* init / load plugin specific functions and settings
|
127 |
-
*
|
128 |
-
* @since 1.0.0
|
129 |
-
*/
|
130 |
-
public function init(){
|
131 |
-
// load ad post types
|
132 |
-
$this->create_post_types();
|
133 |
-
// set ad types array
|
134 |
-
$this->set_ad_types();
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Return the plugin slug.
|
139 |
-
*
|
140 |
-
* @since 1.0.0
|
141 |
-
* @return Plugin slug variable.
|
142 |
-
*/
|
143 |
-
public function get_plugin_slug() {
|
144 |
-
return $this->plugin_slug;
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Return an instance of this class.
|
149 |
-
*
|
150 |
-
* @since 1.0.0
|
151 |
-
* @return object A single instance of this class.
|
152 |
-
*/
|
153 |
-
public static function get_instance() {
|
154 |
-
|
155 |
-
// If the single instance hasn't been set, set it now.
|
156 |
-
if (null == self::$instance) {
|
157 |
-
self::$instance = new self;
|
158 |
-
}
|
159 |
-
|
160 |
-
return self::$instance;
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Fired when the plugin is activated.
|
165 |
-
*
|
166 |
-
* @since 1.0.0
|
167 |
-
* @param boolean $network_wide True if WPMU superadmin uses
|
168 |
-
* "Network Activate" action, false if
|
169 |
-
* WPMU is disabled or plugin is
|
170 |
-
* activated on an individual blog.
|
171 |
-
*/
|
172 |
-
public static function activate($network_wide) {
|
173 |
-
|
174 |
-
if (function_exists('is_multisite') && is_multisite()) {
|
175 |
-
|
176 |
-
if ($network_wide) {
|
177 |
-
|
178 |
-
// Get all blog ids
|
179 |
-
$blog_ids = self::get_blog_ids();
|
180 |
-
|
181 |
-
foreach ($blog_ids as $blog_id) {
|
182 |
-
|
183 |
-
switch_to_blog($blog_id);
|
184 |
-
self::single_activate();
|
185 |
-
}
|
186 |
-
|
187 |
-
restore_current_blog();
|
188 |
-
} else {
|
189 |
-
self::single_activate();
|
190 |
-
}
|
191 |
-
} else {
|
192 |
-
self::single_activate();
|
193 |
-
}
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Fired when the plugin is deactivated.
|
198 |
-
*
|
199 |
-
* @since 1.0.0
|
200 |
-
* @param boolean $network_wide
|
201 |
-
*
|
202 |
-
* True if WPMU superadmin uses
|
203 |
-
* "Network Deactivate" action, false if
|
204 |
-
* WPMU is disabled or plugin is
|
205 |
-
* deactivated on an individual blog.
|
206 |
-
*/
|
207 |
-
public static function deactivate($network_wide) {
|
208 |
-
|
209 |
-
if (function_exists('is_multisite') && is_multisite()) {
|
210 |
-
|
211 |
-
if ($network_wide) {
|
212 |
-
|
213 |
-
// Get all blog ids
|
214 |
-
$blog_ids = self::get_blog_ids();
|
215 |
-
|
216 |
-
foreach ($blog_ids as $blog_id) {
|
217 |
-
|
218 |
-
switch_to_blog($blog_id);
|
219 |
-
self::single_deactivate();
|
220 |
-
}
|
221 |
-
|
222 |
-
restore_current_blog();
|
223 |
-
} else {
|
224 |
-
self::single_deactivate();
|
225 |
-
}
|
226 |
-
} else {
|
227 |
-
self::single_deactivate();
|
228 |
-
}
|
229 |
-
}
|
230 |
-
|
231 |
-
/**
|
232 |
-
* Fired when a new site is activated with a WPMU environment.
|
233 |
-
*
|
234 |
-
* @since 1.0.0
|
235 |
-
* @param int $blog_id ID of the new blog.
|
236 |
-
*/
|
237 |
-
public function activate_new_site($blog_id) {
|
238 |
-
|
239 |
-
if (1 !== did_action('wpmu_new_blog')) {
|
240 |
-
return;
|
241 |
-
}
|
242 |
-
|
243 |
-
switch_to_blog($blog_id);
|
244 |
-
self::single_activate();
|
245 |
-
restore_current_blog();
|
246 |
-
}
|
247 |
-
|
248 |
-
/**
|
249 |
-
* Get all blog ids of blogs in the current network that are:
|
250 |
-
* - not archived
|
251 |
-
* - not spam
|
252 |
-
* - not deleted
|
253 |
-
*
|
254 |
-
* @since 1.0.0
|
255 |
-
* @return array|false The blog ids, false if no matches.
|
256 |
-
*/
|
257 |
-
private static function get_blog_ids() {
|
258 |
-
|
259 |
-
global $wpdb;
|
260 |
-
|
261 |
-
// get an array of blog ids
|
262 |
-
$sql = "SELECT blog_id FROM $wpdb->blogs
|
263 |
-
WHERE archived = '0' AND spam = '0'
|
264 |
-
AND deleted = '0'";
|
265 |
-
|
266 |
-
return $wpdb->get_col($sql);
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* Fired for each blog when the plugin is activated.
|
271 |
-
*
|
272 |
-
* @since 1.0.0
|
273 |
-
*/
|
274 |
-
private static function single_activate() {
|
275 |
-
// @TODO: Define activation functionality here
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Fired for each blog when the plugin is deactivated.
|
280 |
-
*
|
281 |
-
* @since 1.0.0
|
282 |
-
*/
|
283 |
-
private static function single_deactivate() {
|
284 |
-
// @TODO: Define deactivation functionality here
|
285 |
-
}
|
286 |
-
|
287 |
-
/**
|
288 |
-
* Load the plugin text domain for translation.
|
289 |
-
*
|
290 |
-
* @since 1.0.0
|
291 |
-
*/
|
292 |
-
public function load_plugin_textdomain() {
|
293 |
-
|
294 |
-
$domain = self::TD;
|
295 |
-
$locale = apply_filters('advanced-ads-plugin-locale', get_locale(), $domain);
|
296 |
-
|
297 |
-
load_textdomain($domain, trailingslashit(WP_LANG_DIR) . $domain . '/' . $domain . '-' . $locale . '.mo');
|
298 |
-
}
|
299 |
-
|
300 |
-
/**
|
301 |
-
* Register and enqueue public-facing style sheet.
|
302 |
-
*
|
303 |
-
* @since 1.0.0
|
304 |
-
*/
|
305 |
-
public function enqueue_styles() {
|
306 |
-
wp_enqueue_style($this->plugin_slug . '-plugin-styles', plugins_url('assets/css/public.css', __FILE__), array(), self::VERSION);
|
307 |
-
}
|
308 |
-
|
309 |
-
/**
|
310 |
-
* Register and enqueues public-facing JavaScript files.
|
311 |
-
*
|
312 |
-
* @since 1.0.0
|
313 |
-
*/
|
314 |
-
public function enqueue_scripts() {
|
315 |
-
wp_enqueue_script($this->plugin_slug . '-plugin-script', plugins_url('assets/js/public.js', __FILE__), array('jquery'), self::VERSION);
|
316 |
-
}
|
317 |
-
|
318 |
-
/**
|
319 |
-
* define ad types with their options
|
320 |
-
*
|
321 |
-
* name => publically readable name
|
322 |
-
* description => publically readable description
|
323 |
-
* editor => kind of editor: text (normal text field), content (WP content field), none (no content field)
|
324 |
-
* will display text field, if left empty
|
325 |
-
*
|
326 |
-
* @since 1.0.0
|
327 |
-
*/
|
328 |
-
public function set_ad_types() {
|
329 |
-
|
330 |
-
/**
|
331 |
-
* load default ad type files
|
332 |
-
* custom ad types can also be loaded in your own plugin or functions.php
|
333 |
-
*/
|
334 |
-
$types = array();
|
335 |
-
|
336 |
-
/**
|
337 |
-
* developers can add new ad types using this filter
|
338 |
-
* see classes/ad-type-content.php for an example for an ad type and usage of this filter
|
339 |
-
*/
|
340 |
-
$this->ad_types = apply_filters('advanced-ads-ad-types', $types);
|
341 |
-
}
|
342 |
-
|
343 |
-
/**
|
344 |
-
* add plain and content ad types to the default ads of the plugin using a filter
|
345 |
-
*
|
346 |
-
* @since 1.0.0
|
347 |
-
*
|
348 |
-
*/
|
349 |
-
function setup_default_ad_types($types){
|
350 |
-
$types['plain'] = new Advads_Ad_Type_Plain(); /* plain text and php code */
|
351 |
-
// $types['content'] = new Advads_Ad_Type_Content(); /* rich content editor */
|
352 |
-
return $types;
|
353 |
-
}
|
354 |
-
|
355 |
-
/**
|
356 |
-
* get an array with all ads by conditions
|
357 |
-
* = list possible ads for each condition
|
358 |
-
*
|
359 |
-
* @since 1.0.0
|
360 |
-
* @return arr $ads_by_conditions
|
361 |
-
* @todo make static
|
362 |
-
*/
|
363 |
-
public function get_ads_by_conditions_array(){
|
364 |
-
|
365 |
-
$ads_by_conditions = get_option('advads-ads-by-conditions', array());
|
366 |
-
// load default array if no conditions saved yet
|
367 |
-
if(!is_array($ads_by_conditions)){
|
368 |
-
$ads_by_conditions = array();
|
369 |
-
}
|
370 |
-
|
371 |
-
return $ads_by_conditions;
|
372 |
-
}
|
373 |
-
|
374 |
-
/**
|
375 |
-
* get the array with global ad injections
|
376 |
-
*
|
377 |
-
* @since 1.1.0
|
378 |
-
* @return arr $ad_injections
|
379 |
-
* @todo make static
|
380 |
-
*/
|
381 |
-
public function get_ad_injections_array(){
|
382 |
-
|
383 |
-
$ad_injections = get_option('advads-ads-injections', array());
|
384 |
-
// load default array if not saved yet
|
385 |
-
if(!is_array($ad_injections)){
|
386 |
-
$ad_injections = array();
|
387 |
-
}
|
388 |
-
|
389 |
-
return $ad_injections;
|
390 |
-
}
|
391 |
-
|
392 |
-
/**
|
393 |
-
* get the array with ad placements
|
394 |
-
*
|
395 |
-
* @since 1.1.0
|
396 |
-
* @return arr $ad_placements
|
397 |
-
*/
|
398 |
-
static public function get_ad_placements_array(){
|
399 |
-
|
400 |
-
$ad_placements = get_option('advads-ads-placements', array());
|
401 |
-
// load default array if not saved yet
|
402 |
-
if(!is_array($ad_placements)){
|
403 |
-
$ad_placements = array();
|
404 |
-
}
|
405 |
-
|
406 |
-
return $ad_placements;
|
407 |
-
}
|
408 |
-
|
409 |
-
/**
|
410 |
-
* shortcode to include ad in frontend
|
411 |
-
*
|
412 |
-
* @since 1.0.0
|
413 |
-
* @param arr $atts
|
414 |
-
*/
|
415 |
-
public function shortcode_display_ad($atts){
|
416 |
-
extract( shortcode_atts( array(
|
417 |
-
'id' => 0,
|
418 |
-
), $atts ) );
|
419 |
-
|
420 |
-
// use the public available function here
|
421 |
-
return get_ad($id);
|
422 |
-
}
|
423 |
-
|
424 |
-
/**
|
425 |
-
* shortcode to include ad from an ad group in frontend
|
426 |
-
*
|
427 |
-
* @since 1.0.0
|
428 |
-
* @param arr $atts
|
429 |
-
*/
|
430 |
-
public function shortcode_display_ad_group($atts){
|
431 |
-
extract( shortcode_atts( array(
|
432 |
-
'id' => 0,
|
433 |
-
), $atts ) );
|
434 |
-
|
435 |
-
// use the public available function here
|
436 |
-
return get_ad_group($id);
|
437 |
-
}
|
438 |
-
|
439 |
-
/**
|
440 |
-
* shortcode to display content of an ad placement in frontend
|
441 |
-
*
|
442 |
-
* @since 1.1.0
|
443 |
-
* @param arr $atts
|
444 |
-
*/
|
445 |
-
public function shortcode_display_ad_placement($atts){
|
446 |
-
extract( shortcode_atts( array(
|
447 |
-
'id' => '',
|
448 |
-
), $atts ) );
|
449 |
-
|
450 |
-
// use the public available function here
|
451 |
-
return get_ad_placement($id);
|
452 |
-
}
|
453 |
-
|
454 |
-
/**
|
455 |
-
* Registers ad post type and group taxonomies
|
456 |
-
*
|
457 |
-
* @since 1.0.0
|
458 |
-
*/
|
459 |
-
public function create_post_types() {
|
460 |
-
if (did_action('init') !== 1) {
|
461 |
-
return;
|
462 |
-
}
|
463 |
-
|
464 |
-
// register ad group taxonomy
|
465 |
-
if(!taxonomy_exists(self::AD_GROUP_TAXONOMY)){
|
466 |
-
$post_type_params = $this->get_group_taxonomy_params();
|
467 |
-
register_taxonomy(self::AD_GROUP_TAXONOMY, array(self::POST_TYPE_SLUG), $post_type_params);
|
468 |
-
}
|
469 |
-
|
470 |
-
// register ad post type
|
471 |
-
if (!post_type_exists(self::POST_TYPE_SLUG)) {
|
472 |
-
$post_type_params = $this->get_post_type_params();
|
473 |
-
register_post_type(self::POST_TYPE_SLUG, $post_type_params);
|
474 |
-
}
|
475 |
-
}
|
476 |
-
|
477 |
-
/**
|
478 |
-
* Defines the parameters for the ad post type taxonomy
|
479 |
-
*
|
480 |
-
* @since 1.0.0
|
481 |
-
* @return array
|
482 |
-
*/
|
483 |
-
protected function get_group_taxonomy_params(){
|
484 |
-
$labels = array(
|
485 |
-
'name' => _x('Ad Groups', 'ad group general name', $this->plugin_slug),
|
486 |
-
'singular_name' => _x('Ad Group', 'ad group singular name', $this->plugin_slug),
|
487 |
-
'search_items' => __('Search Ad Groups', $this->plugin_slug),
|
488 |
-
'all_items' => __('All Ad Groups', $this->plugin_slug),
|
489 |
-
'parent_item' => __('Parent Ad Groups', $this->plugin_slug),
|
490 |
-
'parent_item_colon' => __('Parent Ad Groups:', $this->plugin_slug),
|
491 |
-
'edit_item' => __('Edit Ad Group', $this->plugin_slug),
|
492 |
-
'update_item' => __('Update Ad Group', $this->plugin_slug),
|
493 |
-
'add_new_item' => __('Add New Ad Group', $this->plugin_slug),
|
494 |
-
'new_item_name' => __('New Ad Groups Name', $this->plugin_slug),
|
495 |
-
'menu_name' => __('Ad Groups', $this->plugin_slug),
|
496 |
-
'not_found' => __('No Ad Group found', $this->plugin_slug),
|
497 |
-
);
|
498 |
-
|
499 |
-
$args = array(
|
500 |
-
'hierarchical' => true,
|
501 |
-
'labels' => $labels,
|
502 |
-
'show_ui' => true,
|
503 |
-
'show_in_nav_menus' => false,
|
504 |
-
'show_tagcloud' => false,
|
505 |
-
'show_admin_column' => false,
|
506 |
-
'query_var' => true,
|
507 |
-
'rewrite' => false,
|
508 |
-
);
|
509 |
-
|
510 |
-
return $args;
|
511 |
-
}
|
512 |
-
|
513 |
-
/**
|
514 |
-
* Defines the parameters for the custom post type
|
515 |
-
*
|
516 |
-
* @since 1.0.0
|
517 |
-
* @return array
|
518 |
-
*/
|
519 |
-
protected function get_post_type_params() {
|
520 |
-
$labels = array(
|
521 |
-
'name' => __('Ads', $this->plugin_slug),
|
522 |
-
'singular_name' => __('Ad', $this->plugin_slug),
|
523 |
-
'add_new' => 'Add New',
|
524 |
-
'add_new_item' => __('Add New Ad', $this->plugin_slug),
|
525 |
-
'edit' => __('Edit', $this->plugin_slug),
|
526 |
-
'edit_item' => __('Edit Ad', $this->plugin_slug),
|
527 |
-
'new_item' => __('New Ad', $this->plugin_slug),
|
528 |
-
'view' => __('View', $this->plugin_slug),
|
529 |
-
'view_item' => __('View the Ad', $this->plugin_slug),
|
530 |
-
'search_items' => __('Search Ads', $this->plugin_slug),
|
531 |
-
'not_found' => __('No Ads found', $this->plugin_slug),
|
532 |
-
'not_found_in_trash' => __('No Ads found in Trash', $this->plugin_slug),
|
533 |
-
'parent' => __('Parent Ad', $this->plugin_slug),
|
534 |
-
);
|
535 |
-
|
536 |
-
$post_type_params = array(
|
537 |
-
'labels' => $labels,
|
538 |
-
'singular_label' => __('Ad', $this->plugin_slug),
|
539 |
-
'public' => false,
|
540 |
-
'show_ui' => true,
|
541 |
-
'menu_position' => 50, // above first seperator
|
542 |
-
'hierarchical' => false,
|
543 |
-
'capability_type' => 'page',
|
544 |
-
'has_archive' => false,
|
545 |
-
'rewrite' => array('slug' => $this->plugin_slug),
|
546 |
-
'query_var' => true,
|
547 |
-
'supports' => array('title'),
|
548 |
-
'taxonomies' => array(self::AD_GROUP_TAXONOMY)
|
549 |
-
);
|
550 |
-
|
551 |
-
return apply_filters('advanced-ads-post-type-params', $post_type_params);
|
552 |
-
}
|
553 |
-
|
554 |
-
/**
|
555 |
-
* remove WP tag edit page for the ad group taxonomy
|
556 |
-
* needed, because we can’t remove it with `show_ui` without also removing the meta box
|
557 |
-
*
|
558 |
-
* @since 1.0.0
|
559 |
-
*/
|
560 |
-
public function remove_taxonomy_menu_item() {
|
561 |
-
remove_submenu_page( 'edit.php?post_type=advanced_ads', 'edit-tags.php?taxonomy=advanced_ads_groups&post_type=advanced_ads' );
|
562 |
-
}
|
563 |
-
|
564 |
-
/**
|
565 |
-
* flush rewrites on plugin activation so permalinks for them work from the beginning on
|
566 |
-
*
|
567 |
-
* @since 1.0.0
|
568 |
-
* @link http://codex.wordpress.org/Function_Reference/register_post_type#Flushing_Rewrite_on_Activation
|
569 |
-
*/
|
570 |
-
public function post_types_rewrite_flush(){
|
571 |
-
// load custom post type
|
572 |
-
$this->create_post_types();
|
573 |
-
// flush rewrite rules
|
574 |
-
flush_rewrite_rules();
|
575 |
-
}
|
576 |
-
|
577 |
-
/**
|
578 |
-
* log error messages when debug is enabled
|
579 |
-
*
|
580 |
-
* @since 1.0.0
|
581 |
-
* @link http://www.smashingmagazine.com/2011/03/08/ten-things-every-wordpress-plugin-developer-should-know/
|
582 |
-
*/
|
583 |
-
public function log($message) {
|
584 |
-
if (WP_DEBUG === true) {
|
585 |
-
if (is_array($message) || is_object($message)) {
|
586 |
-
error_log('Advanced Ads Error following:', $this->plugin_slug);
|
587 |
-
error_log(print_r($message, true));
|
588 |
-
} else {
|
589 |
-
$message = sprintf(__('Advanced Ads Error: %s', $this->plugin_slug), $message);
|
590 |
-
error_log($message);
|
591 |
-
}
|
592 |
-
}
|
593 |
-
}
|
594 |
-
|
595 |
-
/**
|
596 |
-
* return plugin options
|
597 |
-
*
|
598 |
-
* @since 1.0.1
|
599 |
-
* @return arr $options
|
600 |
-
* @todo parse default options
|
601 |
-
*/
|
602 |
-
public function options(){
|
603 |
-
if($this->options === false){
|
604 |
-
$this->options = get_option(ADVADS_SLUG, array());
|
605 |
-
}
|
606 |
-
|
607 |
-
return $this->options;
|
608 |
-
}
|
609 |
-
|
610 |
-
/**
|
611 |
-
* injected ad into header
|
612 |
-
*
|
613 |
-
* @since 1.1.0
|
614 |
-
*/
|
615 |
-
public function inject_header(){
|
616 |
-
// get information about injected ads
|
617 |
-
$injections = get_option('advads-ads-injections', array());
|
618 |
-
if(isset($injections['header']) && is_array($injections['header'])){
|
619 |
-
$ads = $injections['header'];
|
620 |
-
// randomize ads
|
621 |
-
shuffle($ads);
|
622 |
-
// check ads one by one for being able to be displayed on this spot
|
623 |
-
foreach ($ads as $_ad_id) {
|
624 |
-
// load the ad object
|
625 |
-
$ad = new Advads_Ad($_ad_id);
|
626 |
-
if ($ad->can_display()) {
|
627 |
-
// display the ad
|
628 |
-
echo $ad->output();
|
629 |
-
}
|
630 |
-
}
|
631 |
-
}
|
632 |
-
}
|
633 |
-
|
634 |
-
/**
|
635 |
-
* injected ads into footer
|
636 |
-
*
|
637 |
-
* @since 1.1.0
|
638 |
-
*/
|
639 |
-
public function inject_footer(){
|
640 |
-
// get information about injected ads
|
641 |
-
$injections = get_option('advads-ads-injections', array());
|
642 |
-
if(isset($injections['footer']) && is_array($injections['footer'])){
|
643 |
-
$ads = $injections['footer'];
|
644 |
-
// randomize ads
|
645 |
-
shuffle($ads);
|
646 |
-
// check ads one by one for being able to be displayed on this spot
|
647 |
-
foreach ($ads as $_ad_id) {
|
648 |
-
// load the ad object
|
649 |
-
$ad = new Advads_Ad($_ad_id);
|
650 |
-
if ($ad->can_display()) {
|
651 |
-
// display the ad
|
652 |
-
echo $ad->output();
|
653 |
-
}
|
654 |
-
}
|
655 |
-
}
|
656 |
-
}
|
657 |
-
|
658 |
-
/**
|
659 |
-
* injected ad into content (before and after)
|
660 |
-
* displays ALL ads
|
661 |
-
*
|
662 |
-
* @since 1.1.0
|
663 |
-
* @param str $content post content
|
664 |
-
*/
|
665 |
-
public function inject_content($content = ''){
|
666 |
-
// run only on single pages
|
667 |
-
if(!is_single()) return;
|
668 |
-
|
669 |
-
// get information about injected ads
|
670 |
-
$injections = get_option('advads-ads-injections', array());
|
671 |
-
|
672 |
-
// display ad before the content
|
673 |
-
if(isset($injections['post_start']) && is_array($injections['post_start'])){
|
674 |
-
$ads = $injections['post_start'];
|
675 |
-
// randomize ads
|
676 |
-
shuffle($ads);
|
677 |
-
// check ads one by one for being able to be displayed on this spot
|
678 |
-
foreach ($ads as $_ad_id) {
|
679 |
-
// load the ad object
|
680 |
-
$ad = new Advads_Ad($_ad_id);
|
681 |
-
if ($ad->can_display()) {
|
682 |
-
// display the ad
|
683 |
-
$content = $ad->output() . $content;
|
684 |
-
}
|
685 |
-
}
|
686 |
-
}
|
687 |
-
|
688 |
-
// display ad after the content
|
689 |
-
if(isset($injections['post_end']) && is_array($injections['post_end'])){
|
690 |
-
$ads = $injections['post_end'];
|
691 |
-
// randomize ads
|
692 |
-
shuffle($ads);
|
693 |
-
// check ads one by one for being able to be displayed on this spot
|
694 |
-
foreach ($ads as $_ad_id) {
|
695 |
-
// load the ad object
|
696 |
-
$ad = new Advads_Ad($_ad_id);
|
697 |
-
if ($ad->can_display()) {
|
698 |
-
// display the ad
|
699 |
-
$content .= $ad->output();
|
700 |
-
}
|
701 |
-
}
|
702 |
-
}
|
703 |
-
|
704 |
-
return $content;
|
705 |
-
}
|
706 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/public/functions.php
DELETED
@@ -1,91 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* functions that are directly available in WordPress themes (and plugins)
|
5 |
-
*/
|
6 |
-
|
7 |
-
/**
|
8 |
-
* return ad content
|
9 |
-
*
|
10 |
-
* @since 1.0.0
|
11 |
-
* @param int $id id of the ad (post)
|
12 |
-
*
|
13 |
-
*/
|
14 |
-
function get_ad($id = 0){
|
15 |
-
$id = absint($id);
|
16 |
-
if(empty($id)) return;
|
17 |
-
|
18 |
-
// get ad
|
19 |
-
$ad = new Advads_Ad($id);
|
20 |
-
|
21 |
-
// check conditions
|
22 |
-
if($ad->can_display())
|
23 |
-
return $ad->output();
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* echo an ad
|
28 |
-
*
|
29 |
-
* @since 1.0.0
|
30 |
-
* @param int $id id of the ad (post)
|
31 |
-
*/
|
32 |
-
function the_ad($id = 0){
|
33 |
-
|
34 |
-
echo get_ad($id);
|
35 |
-
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* return an ad from an ad group based on ad weight
|
40 |
-
*
|
41 |
-
* @since 1.0.0
|
42 |
-
* @param int $id id of the ad group (taxonomy)
|
43 |
-
*
|
44 |
-
*/
|
45 |
-
function get_ad_group($id = 0){
|
46 |
-
$id = absint($id);
|
47 |
-
if(empty($id)) return;
|
48 |
-
|
49 |
-
// get ad
|
50 |
-
$adgroup = new Advads_Ad_Group($id);
|
51 |
-
return $adgroup->output_random_ad();
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* echo an ad from an ad group
|
56 |
-
*
|
57 |
-
* @since 1.0.0
|
58 |
-
* @param int $id id of the ad (post)
|
59 |
-
*/
|
60 |
-
function the_ad_group($id = 0){
|
61 |
-
|
62 |
-
echo get_ad_group($id);
|
63 |
-
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* return content of an ad placement
|
68 |
-
*
|
69 |
-
* @since 1.1.0
|
70 |
-
* @param string $id slug of the ad placement
|
71 |
-
*
|
72 |
-
*/
|
73 |
-
function get_ad_placement($id = ''){
|
74 |
-
if($id == '') return;
|
75 |
-
|
76 |
-
// get placement content
|
77 |
-
$output = Advads_Ad_Placements::output($id);
|
78 |
-
return $output;
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* return content of an ad placement
|
83 |
-
*
|
84 |
-
* @since 1.1.0
|
85 |
-
* @param string $id slug of the ad placement
|
86 |
-
*/
|
87 |
-
function the_ad_placement($id = ''){
|
88 |
-
|
89 |
-
echo get_ad_placement($id);
|
90 |
-
|
91 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/public/includes/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
trunk/public/views/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
trunk/public/views/public.php
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Represents the view for the public-facing component of the plugin.
|
4 |
-
*
|
5 |
-
* This typically includes any information, if any, that is rendered to the
|
6 |
-
* frontend of the theme when the plugin is activated.
|
7 |
-
*
|
8 |
-
* @package Plugin_Name
|
9 |
-
* @author Your Name <email@example.com>
|
10 |
-
* @license GPL-2.0+
|
11 |
-
* @link http://example.com
|
12 |
-
* @copyright 2013 Your Name or Company Name
|
13 |
-
*/
|
14 |
-
?>
|
15 |
-
|
16 |
-
<!-- This file is used to markup the public facing aspect of the plugin. -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/readme.txt
DELETED
@@ -1,144 +0,0 @@
|
|
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.0
|
7 |
-
License: GPLv2 or later
|
8 |
-
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
-
|
10 |
-
Manage and optimize your ads in WordPress as easy as creating posts.
|
11 |
-
|
12 |
-
== Description ==
|
13 |
-
|
14 |
-
Advanced Ads is made by publishers for publishers. Based on my experience delivering millions of ads per month I build this plugin as a powerful, but light weight solution to not only manage and serve ads in WordPress, but to test and optimize them as well.
|
15 |
-
|
16 |
-
Learn more on the [plugin homepage](http://wpadvancedads.com).
|
17 |
-
|
18 |
-
= create and manage ads =
|
19 |
-
|
20 |
-
* create ads as easy as creating posts
|
21 |
-
* group ads
|
22 |
-
|
23 |
-
= display ads =
|
24 |
-
|
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 |
-
|
31 |
-
= display conditions =
|
32 |
-
|
33 |
-
deliver ads based on conditions like
|
34 |
-
* post type
|
35 |
-
* post id
|
36 |
-
* category
|
37 |
-
* single, category and archive pages
|
38 |
-
* special page types like 404, attachment and front page
|
39 |
-
|
40 |
-
= visitor conditions =
|
41 |
-
|
42 |
-
display ads by conditions based on the visitor
|
43 |
-
* all devices, mobile only or exclude mobile users
|
44 |
-
|
45 |
-
= based on WordPress standards =
|
46 |
-
|
47 |
-
* integrated into WordPress using standards like custom post types, taxonomies and hooks
|
48 |
-
* easily customizable by any WordPress plugin developer
|
49 |
-
|
50 |
-
Learn more on the [plugin homepage](http://wpadvancedads.com).
|
51 |
-
|
52 |
-
= AddOns =
|
53 |
-
|
54 |
-
* increase click rates with fixed, sticky and anchor ads with Sticky Ads - [Demo](http://wpadvancedads.com/sticky-ads/demo/)
|
55 |
-
|
56 |
-
== Installation ==
|
57 |
-
|
58 |
-
This section describes how to install the plugin and get it working.
|
59 |
-
|
60 |
-
e.g.
|
61 |
-
|
62 |
-
= Using The WordPress Dashboard =
|
63 |
-
|
64 |
-
1. Navigate to the 'Add New' in the plugins dashboard
|
65 |
-
2. Search for 'plugin-name'
|
66 |
-
3. Click 'Install Now'
|
67 |
-
4. Activate the plugin on the Plugin dashboard
|
68 |
-
|
69 |
-
= Uploading in WordPress Dashboard =
|
70 |
-
|
71 |
-
1. Navigate to the 'Add New' in the plugins dashboard
|
72 |
-
2. Navigate to the 'Upload' area
|
73 |
-
3. Select `plugin-name.zip` from your computer
|
74 |
-
4. Click 'Install Now'
|
75 |
-
5. Activate the plugin in the Plugin dashboard
|
76 |
-
|
77 |
-
= Using FTP =
|
78 |
-
|
79 |
-
1. Download `plugin-name.zip`
|
80 |
-
2. Extract the `plugin-name` directory to your computer
|
81 |
-
3. Upload the `plugin-name` directory to the `/wp-content/plugins/` directory
|
82 |
-
4. Activate the plugin in the Plugin dashboard
|
83 |
-
|
84 |
-
== Displaying Ads ==
|
85 |
-
|
86 |
-
You can use functions and shortcodes to display ads and ad groups.
|
87 |
-
|
88 |
-
The integers in this example are the IDs of the elements.
|
89 |
-
|
90 |
-
Use these shortcode to insert an ad or ad group into your post/page.
|
91 |
-
|
92 |
-
`[the_ad id="24"]`
|
93 |
-
`[the_ad_group id="5"]`
|
94 |
-
|
95 |
-
Use these functions to insert an ad or ad group into your template file.
|
96 |
-
|
97 |
-
`<?php the_ad(24); ?>`
|
98 |
-
`<?php the_ad_group(5); ?>`
|
99 |
-
|
100 |
-
In addition to directly displaying ads and groups you can define ad placements and assign either an ad or group to them.
|
101 |
-
|
102 |
-
`[the_ad_placement id="header-left"]`
|
103 |
-
`<?php the_ad_placement('header-left'); ?>`
|
104 |
-
|
105 |
-
== Frequently Asked Questions ==
|
106 |
-
|
107 |
-
= Is there a revenue share? =
|
108 |
-
|
109 |
-
There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way that you earn less than you would directly including the ad code in your template.
|
110 |
-
|
111 |
-
== Screenshots ==
|
112 |
-
|
113 |
-
1. Create an ad almost like you would create an article or page.
|
114 |
-
2. Choose from various conditions where and where not to display your ad.
|
115 |
-
|
116 |
-
== Changelog ==
|
117 |
-
|
118 |
-
= 1.1.0 =
|
119 |
-
|
120 |
-
* allow displaying ads on mobile devices only or exclude from mobile devices
|
121 |
-
* auto inject ad into header, footer and post content
|
122 |
-
* display Ad id on Ad edit page
|
123 |
-
* hide Ad for groups if the Ad is not made public
|
124 |
-
* use Ad Placements to be more flexible when displaying ads or ad group in template files
|
125 |
-
* bugfixes
|
126 |
-
|
127 |
-
= 1.0.3 =
|
128 |
-
|
129 |
-
* bugfix added missing file to repository
|
130 |
-
|
131 |
-
= 1.0.2 =
|
132 |
-
|
133 |
-
* bugfix for editing ad weights in ad groups
|
134 |
-
* bugfix for autoloader
|
135 |
-
|
136 |
-
= 1.0.1 =
|
137 |
-
|
138 |
-
* several new hooks
|
139 |
-
* seperated settings and debug page
|
140 |
-
* few internal optimizations
|
141 |
-
* few bugfixes for php < 5.3
|
142 |
-
|
143 |
-
= 1.0 =
|
144 |
-
* first release
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/uninstall.php
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<?php
|
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
|
13 |
-
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
14 |
-
exit;
|
15 |
-
}
|
16 |
-
|
17 |
-
// @TODO: Define uninstall functionality here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|