Skip to content

Commit a25ec39

Browse files
Merge pull request #401 from ahmedkaludi/1.9.26
1.9.26
2 parents 3b102d0 + 55f4ce2 commit a25ec39

File tree

13 files changed

+543
-567
lines changed

13 files changed

+543
-567
lines changed

admin/analytics-settings.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class adsforwp_admin_analytics_settings{
44
public function __construct() {
55

66
add_action( 'admin_enqueue_scripts', array($this, 'adsforwp_chart_register_scripts') );
7-
add_action( 'admin_menu', array($this, 'adsforwp_add_analytics_menu_links'),20);
7+
add_action( 'admin_menu', array($this, 'adsforwp_add_analytics_menu_links'),10);
88
add_filter( 'adsforwp_localize_filter',array($this,'adsforwp_add_localize_analytics_data'),10,2);
99

1010
}
@@ -35,8 +35,17 @@ public function adsforwp_add_analytics_menu_links() {
3535
'adsforwp-analytics',
3636
array($this , 'adsforwp_admin_analytics_render')
3737
);
38-
}
38+
if(!defined('ADSFORWP_PRO_VERSION') && current_user_can('manage_options')){
3939

40+
add_submenu_page( 'edit.php?post_type=adsforwp', 'AdsForWP', '<span class="adsforwp-upgrade-to-pro">'. esc_html__('Upgrade To Premium', 'ads-for-wp').'</span>', 'manage_options', 'adsforwp_data_premium', array($this, 'adsforwp_premium_interface_render') );
41+
}
42+
}
43+
public function adsforwp_premium_interface_render(){
44+
45+
wp_redirect( 'https://structured-data-for-wp.com/pricing/' );
46+
exit;
47+
48+
}
4049

4150
public function adsforwp_admin_analytics_interface_render(){
4251

admin/common-functions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function adsforwp_export_all_settings(){
8686

8787
header('Content-type: application/json');
8888
header('Content-disposition: attachment; filename=adsforwpbackup.json');
89-
echo json_encode($export_data_all);
89+
echo wp_json_encode($export_data_all);
9090

9191
wp_die();
9292
}
@@ -1602,7 +1602,7 @@ public function adsforwp_fetch_all_ads(){
16021602
)
16031603
);
16041604

1605-
set_transient( 'transient_all_afw_ads_data', json_encode($all_ads), 60 );
1605+
set_transient( 'transient_all_afw_ads_data', wp_json_encode($all_ads), 60 );
16061606

16071607
}
16081608
return $all_ads;
@@ -1644,7 +1644,7 @@ public function adsforwp_fetch_all_groups(){
16441644
)
16451645
);
16461646

1647-
set_transient( 'transient_all_groups_data', json_encode($all_groups), 60 );
1647+
set_transient( 'transient_all_groups_data', wp_json_encode($all_groups), 60 );
16481648
}
16491649

16501650
return $all_groups;

admin/control-center.php

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ function adsforwp_display_ads_txt() {
1414
$link = "https";
1515
} else{
1616
$link = "http";
17-
}
17+
}
18+
19+
$host = '';
20+
if (isset($_SERVER['HTTP_HOST']) && !empty($_SERVER['HTTP_HOST'])) {
21+
$host = $_SERVER['HTTP_HOST'];
22+
}
1823

1924
$link .= "://";
20-
$link .= $_SERVER['HTTP_HOST'];
25+
$link .= $host;
2126
$link .= esc_url_raw($_SERVER['REQUEST_URI']);
2227

2328
if ( trailingslashit(get_site_url()).'ads.txt' === esc_url_raw($link) ) {
@@ -146,9 +151,9 @@ function adsforwp_reset_all_settings(){
146151
}
147152

148153
if($result){
149-
echo json_encode(array('status'=>'t'));
154+
echo wp_json_encode(array('status'=>'t'));
150155
}else{
151-
echo json_encode(array('status'=>'f'));
156+
echo wp_json_encode(array('status'=>'f'));
152157
}
153158
wp_die();
154159
}
@@ -318,11 +323,11 @@ function adsforwp_review_notice_remindme(){
318323

319324
if($result){
320325

321-
echo json_encode(array('status'=>'t'));
326+
echo wp_json_encode(array('status'=>'t'));
322327

323328
}else{
324329

325-
echo json_encode(array('status'=>'f'));
330+
echo wp_json_encode(array('status'=>'f'));
326331

327332
}
328333
wp_die();
@@ -344,11 +349,11 @@ function adsforwp_review_notice_close(){
344349

345350
if($result){
346351

347-
echo json_encode(array('status'=>'t'));
352+
echo wp_json_encode(array('status'=>'t'));
348353

349354
}else{
350355

351-
echo json_encode(array('status'=>'f'));
356+
echo wp_json_encode(array('status'=>'f'));
352357

353358
}
354359
wp_die();
@@ -421,11 +426,11 @@ function adsforwp_import_plugin_data(){
421426

422427
if($result){
423428

424-
echo json_encode(array('status'=>'t', 'message'=>esc_html__('Data has been imported succeessfully','ads-for-wp')));
429+
echo wp_json_encode(array('status'=>'t', 'message'=>esc_html__('Data has been imported succeessfully','ads-for-wp')));
425430

426431
}else{
427432

428-
echo json_encode(array('status'=>'f', 'message'=>esc_html__('Plugin data is not available or it is not activated','ads-for-wp')));
433+
echo wp_json_encode(array('status'=>'f', 'message'=>esc_html__('Plugin data is not available or it is not activated','ads-for-wp')));
429434

430435
}
431436
wp_die();
@@ -449,6 +454,9 @@ function adsforwp_disable_new_posts() {
449454
* @return type json string
450455
*/
451456
function adsforwp_send_query_message(){
457+
if ( ! current_user_can( 'manage_options' ) ) {
458+
return;
459+
}
452460

453461
if ( ! isset( $_POST['adsforwp_security_nonce'] ) ){
454462
return;
@@ -459,29 +467,36 @@ function adsforwp_send_query_message(){
459467

460468
if ( is_user_logged_in() ) {
461469

462-
require_once ABSPATH . "wp-includes/pluggable.php";
470+
require_once ABSPATH . "wp-includes/pluggable.php";
471+
$customer_type = 'Are you a premium customer ? No';
463472
$message = sanitize_textarea_field($_POST['message']);
464-
$email = sanitize_email($_POST['email']);
473+
$premium_cus = isset($_POST['premium_cus'])? sanitize_textarea_field($_POST['premium_cus']):'';
465474
$user = wp_get_current_user();
466475
$user_data = $user->data;
467476
$user_email = $user_data->user_email;
468-
477+
478+
if($premium_cus == 'yes'){
479+
$customer_type = 'Are you a premium customer ? Yes';
480+
}
481+
482+
$message = '<p>'.$message.'</p><br><br>'
483+
. $customer_type
484+
. '<br><br>'.'Query from plugin support tab';
469485
if($email){
470486
$user_email = $email;
471487
}
472488
//php mailer variables
473489
474490
$subject = "Ads For WP Customer Query";
475491
$headers = 'From: '. esc_attr($user_email) . "\r\n" .
476-
'Reply-To: ' . esc_attr($user_email) . "\r\n";
477-
492+
'Reply-To: ' . esc_attr($user_email) . "\r\n";
478493
// Load WP components, no themes.
479494
$sent = wp_mail($to, $subject, strip_tags($message), $headers);
480495

481496
if($sent){
482-
echo json_encode(array('status'=>'t'));
497+
echo wp_wp_json_encode(array('status'=>'t', 'msg'=> esc_html__('Request Submitted succeessfully..', 'ads-for-wp' )));
483498
}else{
484-
echo json_encode(array('status'=>'f'));
499+
echo wp_wp_json_encode(array('status'=>'f', 'msg'=> esc_html__('Something wrong with this request.', 'ads-for-wp' )));
485500
}
486501

487502
}
@@ -626,9 +641,9 @@ function adsforwp_ajax_check_post_availability(){
626641
$ad_sense_type = get_post_meta($auto_adsense_post[0]->ID,$key='adsense_type',true);
627642
}
628643
if($ad_sense_type){
629-
echo json_encode(array('status'=> 't','post_id'=> $auto_adsense_post[0]->ID, 'adsense_type'=> $ad_sense_type));
644+
echo wp_json_encode(array('status'=> 't','post_id'=> $auto_adsense_post[0]->ID, 'adsense_type'=> $ad_sense_type));
630645
}else{
631-
echo json_encode(array('status'=> 'f','post_id'=> esc_html__('not available', 'ads-for-wp')));
646+
echo wp_json_encode(array('status'=> 'f','post_id'=> esc_html__('not available', 'ads-for-wp')));
632647
}
633648

634649
wp_die();
@@ -1280,7 +1295,7 @@ function adsforwp_published(){
12801295
}
12811296

12821297
if($ads_post_ids){
1283-
$ads_post_ids_json = json_encode($ads_post_ids);
1298+
$ads_post_ids_json = wp_json_encode($ads_post_ids);
12841299
set_transient('adsforwp_transient_ads_ids', $ads_post_ids_json);
12851300
}
12861301

@@ -1354,7 +1369,7 @@ function adsforwp_groups_published(){
13541369

13551370
if($group_post_ids){
13561371

1357-
$group_post_ids_json = json_encode($group_post_ids);
1372+
$group_post_ids_json = wp_json_encode($group_post_ids);
13581373
set_transient('adsforwp_groups_transient_ids', $group_post_ids_json);
13591374

13601375
}

admin/inc/analytics-settings.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,7 @@ public function adsforwp_google_authentication(){
238238
if ( $this->pa_connect() ) { wp_redirect( esc_url(admin_url( 'edit.php?post_type=adsforwp&page=adsforwp-analytics' ))); }
239239
} catch (Exception $e) {
240240
echo $e->getMessage();
241-
}
242-
wp_redirect( esc_url(admin_url( 'edit.php?post_type=adsforwp&page=adsforwp-analytics' )));
243-
exit;
241+
}
244242
}
245243
}
246244

0 commit comments

Comments
 (0)