Skip to content

Commit eea48d4

Browse files
authored
Merge pull request #386 from ahmedkaludi/1.9.24
1.9.24
2 parents 744374c + dd20c87 commit eea48d4

File tree

10 files changed

+136
-53
lines changed

10 files changed

+136
-53
lines changed

admin/analytics.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ public function adsforwp_insert_ad_impression(){
259259

260260
$ad_ids = array_map('sanitize_text_field', $_POST['ad_ids']);
261261

262-
$device_name = sanitize_text_field($_POST['device_name']);
262+
$device_name = sanitize_text_field($_POST['device_name']);
263263

264-
if($ad_ids){
264+
if($ad_ids && !$this->is_admin_user()){
265265

266266
foreach ($ad_ids as $ad_id){
267267

@@ -274,6 +274,16 @@ public function adsforwp_insert_ad_impression(){
274274
}
275275
wp_die();
276276
}
277+
278+
public function is_admin_user() {
279+
$status = false;
280+
if( is_user_logged_in() ) {
281+
if(current_user_can('administrator' )){
282+
$status = true;
283+
}
284+
}
285+
return $status;
286+
}
277287

278288
/**
279289
* Ajax handler to get ad clicks in NON AMP
@@ -289,12 +299,9 @@ public function adsforwp_insert_ad_clicks(){
289299
}
290300

291301
$device_name = sanitize_text_field($_POST['device_name']);
292-
$ad_id = sanitize_text_field($_POST['ad_id']);
293-
294-
if($ad_id){
295-
296-
$this->adsforwp_insert_clicks($ad_id, $device_name);
297-
302+
$ad_id = sanitize_text_field($_POST['ad_id']);
303+
if($ad_id && !$this->is_admin_user()){
304+
$this->adsforwp_insert_clicks($ad_id, $device_name);
298305
}
299306
wp_die();
300307
}

admin/control-center.php

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,16 @@ function adsforwp_send_query_message(){
461461

462462
require_once ABSPATH . "wp-includes/pluggable.php";
463463
$message = sanitize_textarea_field($_POST['message']);
464+
$email = sanitize_email($_POST['email']);
464465
$user = wp_get_current_user();
465466
$user_data = $user->data;
466-
$user_email = $user_data->user_email;
467+
$user_email = $user_data->user_email;
468+
469+
if($email){
470+
$user_email = $email;
471+
}
467472
//php mailer variables
468-
$to = 'team@magazine3.com';
473+
$to = 'team@magazine3.in';
469474
$subject = "Ads For WP Customer Query";
470475
$headers = 'From: '. esc_attr($user_email) . "\r\n" .
471476
'Reply-To: ' . esc_attr($user_email) . "\r\n";
@@ -806,13 +811,20 @@ function adsforwp_setup_post_type() {
806811
'menu_position' => 100
807812
);
808813
register_post_type( 'adsforwp', $args );
809-
814+
$common_function_obj = new adsforwp_admin_common_functions();
815+
$all_ads = $common_function_obj->adsforwp_fetch_all_ads();
816+
817+
$not_found_button_group = '<div><p style="float:left;margin-right:5px;">'.esc_html__('Welcome to groups for WP. It looks like you don\'t have any ads.', 'ads-for-wp').'</p> <a href="'.esc_url( admin_url( 'post-new.php?post_type=adsforwp' ) ).'" class="button button-primary">'.esc_html__('Let\'s create a new Ad', 'ads-for-wp').'</a></div>';
818+
if ($all_ads) {
819+
$not_found_button_group = '<div><p style="float:left;margin-right:5px;">'.esc_html__('Welcome to groups for WP. It looks like you don\'t have any group.', 'ads-for-wp').'</p> <a href="'.esc_url( admin_url( 'post-new.php?post_type=adsforwp-groups' ) ).'" class="button button-primary">'.esc_html__('Let\'s create a new Group', 'ads-for-wp').'</a></div>';
820+
}
810821
$group_post_type = array(
811822
'labels' => array(
812823
'name' => esc_html__( 'Groups', 'ads-for-wp' ),
813824
'add_new' => esc_html__( 'Add New Groups', 'ads-for-wp' ),
814825
'add_new_item' => esc_html__( 'Edit Groups', 'ads-for-wp' ),
815826
'edit_item' => esc_html__('Edit AD','ads-for-wp'),
827+
'not_found' => $not_found_button_group,
816828
),
817829
'public' => true,
818830
'has_archive' => false,
@@ -1060,36 +1072,48 @@ function adsforwp_removing_wysiwig() {
10601072
* REGISTER ALL NON-ADMIN SCRIPTS
10611073
*/
10621074
function adsforwp_frontend_enqueue(){
1063-
10641075
$settings = adsforwp_defaultSettings();
1065-
1066-
if( ADSFORWP_ENVIRONMENT == 'DEV'){
1067-
wp_register_script('adsforwp-ads-frontend-js', ADSFORWP_PLUGIN_DIR_URI . 'public/assets/js/ads-frontend.js', array( 'jquery' ), ADSFORWP_VERSION, true);
1068-
wp_register_script('adsforwp-ads-front-js', ADSFORWP_PLUGIN_DIR_URI . 'public/assets/js/ads-front.js', array( 'jquery' ), ADSFORWP_VERSION, true);
1069-
}else{
1070-
wp_register_script('adsforwp-ads-frontend-js', ADSFORWP_PLUGIN_DIR_URI . 'public/assets/js/ads-frontend.min.js', array( 'jquery' ), ADSFORWP_VERSION, true);
1071-
wp_register_script('adsforwp-ads-front-js', ADSFORWP_PLUGIN_DIR_URI . 'public/assets/js/ads-front.min.js', array( 'jquery' ), ADSFORWP_VERSION, true);
1072-
}
1073-
$browserdata = array();
1074-
$object_name = array(
1075-
'ajax_url' => admin_url( 'admin-ajax.php' ),
1076-
'adsforwp_front_nonce' => wp_create_nonce('adsforwp_ajax_check_front_nonce')
1077-
);
1078-
1079-
$object_browser = apply_filters('adsforwp_localize_browser_filter',$browserdata,'adsforwp_localize_data');
1076+
$all_ads_post = adsforwp_get_ad_ids();
1077+
if($all_ads_post){
1078+
$need_to_display = false;
1079+
foreach ($all_ads_post as $post_ad_id) {
1080+
$service = new adsforwp_output_service();
1081+
$ad_status = $service->adsforwp_is_condition($post_ad_id);
1082+
if ($ad_status) {
1083+
$need_to_display = true;
1084+
break;
1085+
}
1086+
}
1087+
if ($need_to_display) {
1088+
if( ADSFORWP_ENVIRONMENT == 'DEV'){
1089+
wp_register_script('adsforwp-ads-frontend-js', ADSFORWP_PLUGIN_DIR_URI . 'public/assets/js/ads-frontend.js', array( 'jquery' ), ADSFORWP_VERSION, true);
1090+
wp_register_script('adsforwp-ads-front-js', ADSFORWP_PLUGIN_DIR_URI . 'public/assets/js/ads-front.js', array( 'jquery' ), ADSFORWP_VERSION, true);
1091+
}else{
1092+
wp_register_script('adsforwp-ads-frontend-js', ADSFORWP_PLUGIN_DIR_URI . 'public/assets/js/ads-frontend.min.js', array( 'jquery' ), ADSFORWP_VERSION, true);
1093+
wp_register_script('adsforwp-ads-front-js', ADSFORWP_PLUGIN_DIR_URI . 'public/assets/js/ads-front.min.js', array( 'jquery' ), ADSFORWP_VERSION, true);
1094+
}
1095+
$browserdata = array();
1096+
$object_name = array(
1097+
'ajax_url' => admin_url( 'admin-ajax.php' ),
1098+
'adsforwp_front_nonce' => wp_create_nonce('adsforwp_ajax_check_front_nonce')
1099+
);
1100+
1101+
$object_browser = apply_filters('adsforwp_localize_browser_filter',$browserdata,'adsforwp_localize_data');
10801102

1081-
if(isset($settings['ad_performance_tracker'])){
1082-
$object_name['ad_performance_tracker'] = $settings['ad_performance_tracker'];
1083-
}
1103+
if(isset($settings['ad_performance_tracker'])){
1104+
$object_name['ad_performance_tracker'] = $settings['ad_performance_tracker'];
1105+
}
10841106

1085-
wp_localize_script('adsforwp-ads-front-js', 'adsforwp_obj', $object_name);
1086-
wp_localize_script('adsforwp-ads-frontend-js', 'adsforwp_browser_obj', $object_browser);
1087-
wp_enqueue_script('adsforwp-ads-front-js');
1088-
wp_enqueue_script('adsforwp-ads-frontend-js');
1089-
if( ADSFORWP_ENVIRONMENT == 'DEV'){
1090-
wp_enqueue_style( 'ads-for-wp-front-css', ADSFORWP_PLUGIN_DIR_URI . 'public/assets/css/adsforwp-front.css', false , ADSFORWP_VERSION );
1091-
}else{
1092-
wp_enqueue_style( 'ads-for-wp-front-css', ADSFORWP_PLUGIN_DIR_URI . 'public/assets/css/adsforwp-front.min.css', false , ADSFORWP_VERSION );
1107+
wp_localize_script('adsforwp-ads-front-js', 'adsforwp_obj', $object_name);
1108+
wp_localize_script('adsforwp-ads-frontend-js', 'adsforwp_browser_obj', $object_browser);
1109+
wp_enqueue_script('adsforwp-ads-front-js');
1110+
wp_enqueue_script('adsforwp-ads-frontend-js');
1111+
if( ADSFORWP_ENVIRONMENT == 'DEV'){
1112+
wp_enqueue_style( 'ads-for-wp-front-css', ADSFORWP_PLUGIN_DIR_URI . 'public/assets/css/adsforwp-front.css', false , ADSFORWP_VERSION );
1113+
}else{
1114+
wp_enqueue_style( 'ads-for-wp-front-css', ADSFORWP_PLUGIN_DIR_URI . 'public/assets/css/adsforwp-front.min.css', false , ADSFORWP_VERSION );
1115+
}
1116+
}
10931117
}
10941118

10951119
}

admin/inc/Google/Service/Analytics.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class Adsforwp_Google_Service_Analytics extends Adsforwp_Google_Service
6464
public $management_webpropertyUserLinks;
6565
public $metadata_columns;
6666
public $provisioning;
67+
public $serviceName;
6768

6869

6970
/**

admin/inc/analytics-settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class Adsforwp_analyticsSettings{
88
public $redirect = 'http://www.adsforwp.com/analtyics/index.php';
99

1010
public $settings;
11+
protected $client;
12+
protected $service;
1113
protected $state_data;
1214
protected $transient_timeout;
1315
protected $load_settings;

admin/settings.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -846,18 +846,23 @@ public function adsforwp_ad_label_options_callback(){
846846
public function adsforwp_contact_us_form_callback(){
847847
?>
848848
<div class="afw_contact_us_div">
849-
<strong><?php echo esc_html__('If you have any query, please write the query in below box or email us at', 'ads-for-wp') ?> <a href="mailto:[email protected]">[email protected]</a>. <?php echo esc_html__('We will reply to your email address shortly', 'ads-for-wp') ?></strong>
850-
849+
<strong><?php echo esc_html__('If you have any query, please write the query in below box or email us at', 'ads-for-wp') ?> <a href="mailto:[email protected]">[email protected]</a>. <?php echo esc_html__('We will reply to your email address shortly', 'ads-for-wp') ?></strong>
851850
<ul>
851+
<li>
852+
<label class="support-label"><?= esc_html_e( 'Email', 'ads-for-wp' ) ?><span class="afw-query-error">*</span></label>
853+
<div class="support-input">
854+
<input type="text" id="adsforwp_query_email" name="adsforwp_query_email"
855+
placeholder="<?= esc_html_e( 'Enter your Email', 'ads-for-wp' ) ?>" />
856+
</div>
857+
</li>
852858
<li>
853859
<textarea rows="5" cols="60" id="adsforwp_query_message" name="adsforwp_query_message"> </textarea>
854860
<br>
855861
<span class="afw-query-success afw_hide"><?php echo esc_html__('Message sent successfully, Please wait we will get back to you shortly', 'ads-for-wp'); ?></span>
856862
<span class="afw-query-error afw_hide"><?php echo esc_html__('Message not sent. please check your network connection', 'ads-for-wp'); ?></span>
857863
</li>
858864
<li><button class="button afw-send-query"><?php echo esc_html__('Send Message', 'ads-for-wp'); ?></button></li>
859-
</ul>
860-
865+
</ul>
861866
</div>
862867
<?php
863868
}

ads-for-wp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Google Adsense & Banner Ads by AdsforWP
44
Plugin URI: https://wordpress.org/plugins/ads-for-wp/
55
Description: AdsforWP is an Google Ads & Banner ads plugin built for WordPress & AMP. Easy to Use, Unlimited Incontent Ads, Adsense, Premium Features and more
6-
Version: 1.9.23
6+
Version: 1.9.24
77
Author: Magazine3
88
Author URI: http://adsforwp.com/
99
Donate link: https://www.paypal.me/Kaludi/25usd
@@ -20,7 +20,7 @@
2020
define('ADSFORWP_PLUGIN_BASENAME', plugin_basename(__FILE__));
2121
define( 'ADSFORWP_LIB_PATH', dirname( __FILE__ ) . '/admin/inc/' );
2222
if ( ! defined( 'ADSFORWP_VERSION' ) ) {
23-
define( 'ADSFORWP_VERSION', '1.9.23' );
23+
define( 'ADSFORWP_VERSION', '1.9.24' );
2424
}
2525

2626
//define( 'ADSFORWP_ENVIRONMENT', 'DEV' );

output/functions.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,12 +1272,16 @@ public function adsforwp_display_ads($content){
12721272
$contentTempArray = array_filter(explode(" ", $contentTemp));
12731273
$contentTempfirst = array_slice($contentTempArray, 0, $fifty);
12741274
$contentTempsecond = array_slice( $contentTempArray, $fifty );
1275+
$needleOccueance = 0;
12751276
$firstPreText = end( $contentTempfirst );
1276-
$needleOccueance = substr_count( implode(" ", $contentTempfirst), $firstPreText);
1277+
if(!empty($contentTempfirst)){
1278+
$needleOccueance = substr_count( implode(" ", $contentTempfirst), $firstPreText);
1279+
}
12771280
$actualContent = '';
12781281
$i=1;
12791282
$lastPos = 0;
1280-
while (($lastPos = strpos($content, $firstPreText, $lastPos+1))!== false) {
1283+
1284+
while (($lastPos = (($lastPos+1) <= strlen($content) ? strpos($content, $firstPreText, $lastPos+1) :false))!== false) {
12811285
if($i==$needleOccueance){
12821286
$part1 = substr( $content, 0, $lastPos);
12831287
$part2 = substr( $content, $lastPos, strlen($content));
@@ -3335,6 +3339,18 @@ public function adsforwp_adblocker_detector(){
33353339
}else{
33363340
$scriptUrl = site_url()."?adsforwp_front_js=1";
33373341
}
3342+
$all_ads_post = adsforwp_get_ad_ids();
3343+
if($all_ads_post){
3344+
$need_to_display = false;
3345+
foreach ($all_ads_post as $post_ad_id) {
3346+
$service = new adsforwp_output_service();
3347+
$ad_status = $service->adsforwp_is_condition($post_ad_id);
3348+
if ($ad_status) {
3349+
$need_to_display = true;
3350+
break;
3351+
}
3352+
}
3353+
if ($need_to_display) {
33383354
?>
33393355
<script type="text/javascript">
33403356
jQuery(document).ready( function($) {
@@ -3344,6 +3360,8 @@ public function adsforwp_adblocker_detector(){
33443360
});
33453361
</script>
33463362
<?php
3363+
}
3364+
}
33473365
}
33483366
}
33493367
if (class_exists('adsforwp_output_functions')) {

public/assets/js/adsforwp.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,19 +1294,23 @@ jQuery( document ).ready(function($) {
12941294
}
12951295
});
12961296
//query form send starts here
1297-
1297+
function isValidEmail(email) {
1298+
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
1299+
return regex.test(email);
1300+
}
12981301
$(".afw-send-query").on("click", function(e){
12991302

13001303
e.preventDefault();
1304+
var email = $("#adsforwp_query_email").val();
13011305
var message = $("#adsforwp_query_message").val();
13021306

1303-
if($.trim(message) !=''){
1307+
if($.trim(message) !='' && $.trim(email) !='' && isValidEmail(email) == true){
13041308

13051309
$.ajax({
13061310
type: "POST",
13071311
url:adsforwp_localize_data.ajax_url,
13081312
dataType: "json",
1309-
data:{action:"adsforwp_send_query_message", message:message, adsforwp_security_nonce:adsforwp_localize_data.adsforwp_security_nonce},
1313+
data:{action:"adsforwp_send_query_message", message:message, email: email,adsforwp_security_nonce:adsforwp_localize_data.adsforwp_security_nonce},
13101314
success:function(response){
13111315
if(response['status'] =='t'){
13121316
$(".afw-query-success").show();
@@ -1322,7 +1326,20 @@ jQuery( document ).ready(function($) {
13221326
});
13231327

13241328
} else{
1325-
alert('Please type message');
1329+
if ($.trim(message) == '' && $.trim(email) == '') {
1330+
alert('Please enter the email, message');
1331+
} else {
1332+
if ($.trim(email) == '') {
1333+
alert('Please enter the email');
1334+
}
1335+
if ($.trim(message) == '') {
1336+
alert('Please enter the message');
1337+
}
1338+
if (isValidEmail(email) == false) {
1339+
alert('Please enter a valid email');
1340+
}
1341+
1342+
}
13261343
}
13271344

13281345
});

public/assets/js/adsforwp.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Contributors: magazine3
33
Tags: Ads, Google Adsense, Media Net, DFP, Custom Code, Infolinks, AMP, Adsense, SEO, Advertisement
44
Requires at least: 3.6
5-
Tested up to: 6.1
6-
Stable tag: 1.9.23
5+
Tested up to: 6.2
6+
Stable tag: 1.9.24
77
Donate link: https://www.paypal.me/Kaludi/25usd
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -65,6 +65,15 @@ Google Api Php Client library used https://github.com/googleapis/google-api-php-
6565

6666
== Changelog ==
6767

68+
= 1.9.24 (13 April 2023) =
69+
* Improvement: Change email id and put email text field in contact us support tab #386
70+
* Bug Fixed: Deprecated: Creation of dynamic property in php 8.2.0 #381
71+
* Improvement: Give notice in group ads list if there are no ads #384
72+
* Bug Fixed: The ads for wp scripts are loading on homepage without any ads on the homepage #339
73+
* Bug Fixed: Need to exclude impression count of the admin on local ads #346
74+
* Bug Fixed: invalid form control with name='adsforwp_query_email' is not focusable. in browser console #385
75+
* Bug Fixed: Warnings in adsforwp #335
76+
6877
= 1.9.23 (17 November 2022) =
6978
* Bug Fixed: Doesn't save as "show globally". #372
7079
* Improvement: Removed deprecated warning in PHP 8.1.10. #373

0 commit comments

Comments
 (0)