diff --git a/adrotate-statistics.php b/adrotate-statistics.php index b23b3e8..267b608 100644 --- a/adrotate-statistics.php +++ b/adrotate-statistics.php @@ -13,10 +13,10 @@ Name: adrotate_get_stats Purpose: Quick check for the latest number of clicks and impressions -------------------------------------------------------------*/ -function adrotate_get_stats($ad, $when = 0, $until = 0) { +function adrotate_get_stats($ad_id, $when = 0, $until = 0) { global $wpdb; - $stats = $wpdb->get_row("SELECT SUM(`clicks`) as `clicks`, SUM(`impressions`) as `impressions` FROM `{$wpdb->prefix}adrotate_stats` WHERE `ad` = {$ad} AND `thetime` >= {$when} AND `thetime` <= {$until} GROUP BY `ad` ORDER BY `ad` ASC;", ARRAY_A); + $stats = $wpdb->get_row("SELECT SUM(`clicks`) as `clicks`, SUM(`impressions`) as `impressions` FROM `{$wpdb->prefix}adrotate_stats` WHERE `ad` = {$ad_id} AND `thetime` >= {$when} AND `thetime` <= {$until} GROUP BY `ad` ORDER BY `ad` ASC;", ARRAY_A); if(empty($stats['clicks'])) $stats['clicks'] = '0'; if(empty($stats['impressions'])) $stats['impressions'] = '0'; @@ -62,7 +62,7 @@ function adrotate_date_start($what) { Name: adrotate_count_impression Purpose: Count Impressions where needed -------------------------------------------------------------*/ -function adrotate_count_impression($ad, $group = 0, $blog_id = 0) { +function adrotate_count_impression($ad_id, $group_id = 0, $blog_id = 0) { global $wpdb, $adrotate_config; $now = current_time('timestamp'); @@ -77,16 +77,16 @@ function adrotate_count_impression($ad, $group = 0, $blog_id = 0) { $impression_timer = $now - $adrotate_config['impression_timer']; if($remote_ip != 'unknown' AND !empty($remote_ip)) { - $saved_timer = $wpdb->get_var($wpdb->prepare("SELECT `timer` FROM `{$wpdb->prefix}adrotate_tracker` WHERE `ipaddress` = '%s' AND `stat` = 'i' AND `bannerid` = %d ORDER BY `timer` DESC LIMIT 1;", $remote_ip, $ad)); + $saved_timer = $wpdb->get_var($wpdb->prepare("SELECT `timer` FROM `{$wpdb->prefix}adrotate_tracker` WHERE `ipaddress` = '%s' AND `stat` = 'i' AND `bannerid` = %d ORDER BY `timer` DESC LIMIT 1;", $remote_ip, $ad_id)); if($saved_timer < $impression_timer AND adrotate_is_human()) { - $stats = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `{$wpdb->prefix}adrotate_stats` WHERE `ad` = %d AND `group` = %d AND `thetime` = {$today};", $ad, $group)); + $stats = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `{$wpdb->prefix}adrotate_stats` WHERE `ad` = %d AND `group` = %d AND `thetime` = {$today};", $ad_id, $group_id)); if($stats > 0) { $wpdb->query("UPDATE `{$wpdb->prefix}adrotate_stats` SET `impressions` = `impressions` + 1 WHERE `id` = {$stats};"); } else { - $wpdb->insert($wpdb->prefix.'adrotate_stats', array('ad' => $ad, 'group' => $group, 'thetime' => $today, 'clicks' => 0, 'impressions' => 1)); + $wpdb->insert($wpdb->prefix.'adrotate_stats', array('ad' => $ad_id, 'group' => $group_id, 'thetime' => $today, 'clicks' => 0, 'impressions' => 1)); } - $wpdb->insert($wpdb->prefix."adrotate_tracker", array('ipaddress' => $remote_ip, 'timer' => $now, 'bannerid' => $ad, 'stat' => 'i')); + $wpdb->insert($wpdb->prefix."adrotate_tracker", array('ipaddress' => $remote_ip, 'timer' => $now, 'bannerid' => $ad_id, 'stat' => 'i')); } } @@ -109,9 +109,9 @@ function adrotate_impression_callback() { $meta = esc_attr($meta); // Don't use $impression_timer - It's for impressions used in javascript - list($ad, $group, $blog_id, $impression_timer) = explode(",", $meta, 4); - if(is_numeric($ad) AND is_numeric($group) AND is_numeric($blog_id)) { - adrotate_count_impression($ad, $group, $blog_id); + list($ad_id, $group_id, $blog_id, $impression_timer) = explode(",", $meta, 4); + if(is_numeric($ad_id) AND is_numeric($group_id) AND is_numeric($blog_id)) { + adrotate_count_impression($ad_id, $group_id, $blog_id); } die(); @@ -133,9 +133,9 @@ function adrotate_click_callback() { $meta = esc_attr($meta); // Don't use $impression_timer - It's for impressions used in javascript - list($ad, $group, $blog_id, $impression_timer) = explode(",", $meta, 4); + list($ad_id, $group_id, $blog_id, $impression_timer) = explode(",", $meta, 4); - if(is_numeric($ad) AND is_numeric($group) AND is_numeric($blog_id)) { + if(is_numeric($ad_id) AND is_numeric($group_id) AND is_numeric($blog_id)) { if($blog_id > 0 AND adrotate_is_networked()) { $current_blog = $wpdb->blogid; switch_to_blog($blog_id); @@ -148,29 +148,29 @@ function adrotate_click_callback() { $today = adrotate_date_start('day'); $click_timer = $now - $adrotate_config['click_timer']; - $saved_timer = $wpdb->get_var($wpdb->prepare("SELECT `timer` FROM `{$wpdb->prefix}adrotate_tracker` WHERE `ipaddress` = '%s' AND `stat` = 'c' AND `bannerid` = %d ORDER BY `timer` DESC LIMIT 1;", $remote_ip, $ad)); + $saved_timer = $wpdb->get_var($wpdb->prepare("SELECT `timer` FROM `{$wpdb->prefix}adrotate_tracker` WHERE `ipaddress` = '%s' AND `stat` = 'c' AND `bannerid` = %d ORDER BY `timer` DESC LIMIT 1;", $remote_ip, $ad_id)); if($saved_timer < $click_timer) { - $stats = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `{$wpdb->prefix}adrotate_stats` WHERE `ad` = %d AND `group` = %d AND `thetime` = {$today};", $ad, $group)); + $stats = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `{$wpdb->prefix}adrotate_stats` WHERE `ad` = %d AND `group` = %d AND `thetime` = {$today};", $ad_id, $group_id)); if($stats > 0) { $wpdb->query("UPDATE `{$wpdb->prefix}adrotate_stats` SET `clicks` = `clicks` + 1 WHERE `id` = {$stats};"); } else { - $wpdb->insert($wpdb->prefix.'adrotate_stats', array('ad' => $ad, 'group' => $group, 'thetime' => $today, 'clicks' => 1, 'impressions' => 1)); + $wpdb->insert($wpdb->prefix.'adrotate_stats', array('ad' => $ad_id, 'group' => $group_id, 'thetime' => $today, 'clicks' => 1, 'impressions' => 1)); } - $wpdb->insert($wpdb->prefix.'adrotate_tracker', array('ipaddress' => $remote_ip, 'timer' => $now, 'bannerid' => $ad, 'stat' => 'c')); + $wpdb->insert($wpdb->prefix.'adrotate_tracker', array('ipaddress' => $remote_ip, 'timer' => $now, 'bannerid' => $ad_id, 'stat' => 'c')); } // Advertising budget - $wpdb->query("UPDATE `{$wpdb->prefix}adrotate` SET `budget` = `budget` - `crate` WHERE `id` = {$ad} AND `crate` > 0;"); + $wpdb->query("UPDATE `{$wpdb->prefix}adrotate` SET `budget` = `budget` - `crate` WHERE `id` = {$ad_id} AND `crate` > 0;"); } if($blog_id > 0 AND adrotate_is_networked()) { switch_to_blog($current_blog); } - unset($remote_ip, $track, $meta, $ad, $group, $remote, $banner); + unset($remote_ip, $track, $meta, $ad_id, $group_id, $remote, $banner); } die(); } -?> \ No newline at end of file +?> diff --git a/adrotate.php b/adrotate.php index 49a87b7..571b53f 100644 --- a/adrotate.php +++ b/adrotate.php @@ -1,12 +1,12 @@
-@@ -25,7 +25,7 @@ |
: , : , : , : , : . | @@ -52,10 +52,10 @@
".__("Allowed", 'adrotate')."";
} else {
- echo "".__("Your website's current setup does not allow for unfiltered code to be used in adverts.", 'adrotate')." ".__("This is required for javascript adverts to work. To enable this you need to set the DISALLOW_UNFILTERED_HTML definition to 'true' in your wp-config.php file.", 'adrotate')." ".__("More info", 'adrotate').""; + echo "".__("Your website's current setup does not allow for unfiltered code to be used in adverts.", 'adrotate')." ".__("This is required for javascript adverts to work. To enable this you need to set the DISALLOW_UNFILTERED_HTML definition to 'false' in your wp-config.php file.", 'adrotate')." ".__("More info", 'adrotate').""; } ?> |
@@ -79,25 +79,25 @@
-
- ".$adrotate_version['current']."";
- if($adrotate_version['current'] != ADROTATE_VERSION) {
- echo "".__("Should be:", 'adrotate')." ".ADROTATE_VERSION."";
- }
+ if($adrotate_version['current'] != ADROTATE_VERSION) {
+ echo "".__("Should be:", 'adrotate')." ".ADROTATE_VERSION."";
+ }
?>
|
- ".$adrotate_db_version['current']."";
- if($adrotate_db_version['current'] != ADROTATE_DB_VERSION) {
+ if($adrotate_db_version['current'] != ADROTATE_DB_VERSION) {
echo "".__("Should be:", 'adrotate')." ".ADROTATE_DB_VERSION."";
- }
+ }
?>
|
diff --git a/library/dashboard.css b/library/dashboard.css
index 3438791..1456788 100644
--- a/library/dashboard.css
+++ b/library/dashboard.css
@@ -12,6 +12,8 @@
.stats_large { display: block; margin-bottom: 10px; margin-top: 10px; text-align: center; font-weight: bold; }
.number_large { margin: 20px; font-size: 28px; }
+.adrotate_inline_error { margin-left:10px; padding:5px; background-color:#c00; color:#fff; }
+
/* Ad previews */
.preview-wrapper { padding:0; width:50%; height:100px; border:3px solid; border-radius:10px; text-align:center; }
.preview-inner { padding:20px 10px; display:inline-block; text-align:center; }
@@ -97,4 +99,4 @@
.ui-datepicker-unselectable .ui-state-default { background: #f4f4f4; color: #b4b3b3; }
.ui-datepicker-calendar td:first-child .ui-state-active { width: 29px; margin-left: 0; }
.ui-datepicker-calendar td:last-child .ui-state-active { width: 29px; margin-right: 0; }
-.ui-datepicker-calendar tr:last-child .ui-state-active { height: 29px; margin-bottom: 0; }
\ No newline at end of file
+.ui-datepicker-calendar tr:last-child .ui-state-active { height: 29px; margin-bottom: 0; }
diff --git a/library/uploader-hook.js b/library/uploader-hook.js
index 3dcbd68..a2e4994 100644
--- a/library/uploader-hook.js
+++ b/library/uploader-hook.js
@@ -1,8 +1,7 @@
/*
use the Media Uploader from WordPress
-Version: 1.0
-Original code: Arnan de Gans
-Copyright: (c) 2020 Arnan de Gans
+Version: 1.1
+Copyright: (c) 2020-2024 Arnan de Gans
*/
jQuery(document).ready(function(){
var custom_uploader;
@@ -12,11 +11,31 @@ jQuery(document).ready(function(){
custom_uploader.open();
return;
}
- custom_uploader = wp.media.frames.file_frame = wp.media({title: 'Choose Banner',button: {text: 'Choose Banner'},multiple: false});
+ custom_uploader = wp.media.frames.file_frame = wp.media({
+ title: 'Choose Banner',
+ button: {text: 'Choose Banner'},
+ multiple: false,
+ library: { type: 'image/jpg, image/jpeg, image/gif, image/png, image/svg, image/webp, text/html, text/htm' }
+ });
custom_uploader.on('select', function() {
attachment = custom_uploader.state().get('selection').first().toJSON();
+ // Check if selected mediafile is of wrong file type
+ allowedFiles = ['image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/svg', 'image/webp', 'text/html', 'text/htm'];
+ if(!allowedFiles.includes(attachment.mime)) {
+ // Create error element
+ const err_el = document.createElement('span');
+ err_el.classList.add('adrotate_inline_error');
+ err_el.innerHTML = 'File (' + attachment.mime + ') is not supported for ads.';
+ // Check if error message does not exist yet and add it if it doesn't
+ if(!document.querySelector('.adrotate-wrong-filetype')) {
+ jQuery('#adrotate_image_button').after(err_el);
+ jQuery('#adrotate_image').val('');
+ }
+ return;
+ }
+ jQuery('.adrotate-wrong-filetype').remove();
jQuery('#adrotate_image').val(attachment.url);
});
custom_uploader.open();
});
-});
\ No newline at end of file
+});
diff --git a/readme.txt b/readme.txt
index 603d4b1..4d2c88a 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,13 +1,13 @@
=== AdRotate Banner Manager - The only ad manager you'll need ===
Contributors: adegans
-Donate link: https://www.arnan.me/donate.html
-Tags: ads, banner manager, adsense, affiliate, banners
+Stable tag: 5.13.5
Requires at least: 4.9
-Tested up to: 6.6.1
+Tested up to: 6.7
CP requires at least: 1.0
-CP tested up to: 2.1.1
+CP tested up to: 2.2
Requires PHP: 7.4
-Stable tag: 5.13.4
+Donate link: https://ajdg.solutions/product/adrotate-pro-single/
+Tags: ads, banner manager, adsense, affiliate, banners
License: GPLv3
Advertising made easy. Manage all your ads including Google Ads, Amazon banners and many more from your dashboard.
@@ -101,11 +101,15 @@ Installing AdRotate is super easy.
- A new menu called "AdRotate" appears in the WordPress navigation.
- From this menu you'll handle everything related to **AdRotate Banner Manager**.
-For more detailed instructions check out the [installation steps](https://ajdg.solutions/support/adrotate-manuals/installing-adrotate-on-your-website/?mtm_campaign=adrotate&mtm_kwd=readme) on the AdRotate website.
+For more detailed instructions check out the [installation steps](https://ajdg.solutions/support/adrotate-manuals/installing-adrotate-on-your-website/) on the AdRotate website.
== Changelog ==
-For the full changelog check out the [development page](https://ajdg.solutions/support/adrotate-development/?mtm_campaign=adrotate&mtm_kwd=readme).
+For the full changelog check out the [development page](https://ajdg.solutions/support/adrotate-development/).
+
+= AdRotate 5.13.5 =
+* [update] WordPress media uploader only lists and allows relevant files
+* [fix] Text indicating unfiltered html suggesting the wrong setting
= AdRotate 5.13.4 =
* [fix] Image selection not kept when using the advert generator
@@ -195,7 +199,7 @@ For the full changelog check out the [development page](https://ajdg.solutions/s
* [new] Automated trigger after updates to finish the update
* [removed] wp_cache_set() for stats
-Be a Pro and get [AdRotate Professional](https://ajdg.solutions/product-category/adrotate-pro/?mtm_campaign=adrotate&mtm_kwd=readme) to support the plugin and get more features!
+Be a Pro and get [AdRotate Professional](https://ajdg.solutions/product-category/adrotate-pro/) to support the plugin and get more features!
== Upgrade Notice ==
@@ -204,11 +208,11 @@ Enjoy this update with the latest tweaks and improvements for AdRotate Banner Ma
== Frequently Asked Questions ==
= How do I use AdRotate? =
-Take a look at the [user guides](https://ajdg.solutions/support/adrotate-manuals/?mtm_campaign=adrotate&mtm_kwd=readme).
+Take a look at the [user guides](https://ajdg.solutions/support/adrotate-manuals/).
You can also post your questions on the [forum](https://ajdg.solutions/forums/forum/adrotate-for-wordpress/).
= I need help with this plugin =
-The best place to ask your question is on my [support forum](https://ajdg.solutions/forums/forum/adrotate-for-wordpress/?mtm_campaign=adrotate&mtm_kwd=readme).
+The best place to ask your question is on my [support forum](https://ajdg.solutions/forums/forum/adrotate-for-wordpress/).
The forum is checked daily and most questions are answered within hours.
= Does AdRotate offer click tracking? =
@@ -222,11 +226,11 @@ Most ads, from any ad server, work without special tricks or tweaks.
Yes!
= This is cool, do you have more plugins? =
-Yep, check out my website [AJdG Solutions](https://ajdg.solutions/?mtm_campaign=adrotate&mtm_kwd=readme)
+Yep, check out my website [AJdG Solutions](https://ajdg.solutions/)
= Why do some dashboard notifications look so ugly =
If a dashboard notification misses its layout or looks out of shape try clearing your browser cache.
-Some ad blockers block parts of the AdRotate dashboard, check out this page to make an exception for your website in adblockers - [Whitelist your site](https://ajdg.solutions/support/adrotate-manuals/configure-adblockers-for-your-own-website/?mtm_campaign=adrotate&mtm_kwd=readme).
+Some ad blockers block parts of the AdRotate dashboard, check out this page to make an exception for your website in adblockers - [Whitelist your site](https://ajdg.solutions/support/adrotate-manuals/configure-adblockers-for-your-own-website/).
= Is AdRotate compatible with Yoast SEO or other SEO plugins? =
Yes, Yoast SEO, All-in-One SEO pack and all other SEO plugins work fine with AdRotate.