@@ -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 */
451456function 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
473489474490 $ 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 }
0 commit comments