@@ -10,6 +10,14 @@ public function __construct(){
1010 }
1111
1212 public function resolve ($ data ){
13+
14+ if ( !check_ajax_referer ( 'mf_nonce_ajax ' , 'security ' , false ) ) {
15+ mf_ajax_call::remove_upload_file ();
16+ $ resp = array ('success ' => false , 'msg ' => __ ('Sorry, your nonce did not verify.. ' ,$ mf_domain ) );
17+ echo json_encode ($ resp );
18+ die;
19+ }
20+
1321 $ type = $ data ['type ' ];
1422 if (method_exists ($ this , $ type )){
1523 $ this ->$ type ($ data );
@@ -24,10 +32,14 @@ public function mf_sort_field($data){
2432 array_walk ( $ order , create_function ( '&$v,$k ' , '$v = str_replace("order_","",$v); ' ));
2533
2634 if ( $ thing = mf_custom_fields::save_order_field ( $ data ['group_id ' ], $ order ) ) {
27- print "1 " ;
35+ $ resp = array ('success ' => true );
36+ echo json_encode ($ resp );
2837 die;
2938 }
30- print "0 " ; //error!
39+
40+ $ resp = array ('success ' => false , 'msg ' => __ ('Ups, something went wrong ' ,$ mf_domain ) );
41+ echo json_encode ($ resp );
42+ die;
3143 }
3244 }
3345
@@ -39,9 +51,9 @@ public function check_name_post_type($data){
3951 $ check = mf_posttype::check_post_type ($ type ,$ id );
4052 if ($ check ){
4153 // exist type(name) in the system
42- $ resp = array ('success ' => 0 , 'msg ' => __ ('The Type(name) of Post type exist,Please choose a different type(name). ' ,$ mf_domain ) );
54+ $ resp = array ('success ' => false , 'msg ' => __ ('The Type(name) of Post type exist,Please choose a different type(name). ' ,$ mf_domain ) );
4355 }else {
44- $ resp = array ('success ' => 1 );
56+ $ resp = array ('success ' => true );
4557 }
4658 echo json_encode ($ resp );
4759 }
@@ -52,11 +64,11 @@ public function check_name_custom_group($data){
5264 $ name = $ data ['group_name ' ];
5365 $ post_type = $ data ['post_type ' ];
5466 $ id = $ data ['group_id ' ];
55- $ resp = array ('success ' => 1 );
67+ $ resp = array ('success ' => true );
5668
5769 $ check = mf_custom_group::check_group ($ name ,$ post_type ,$ id );
5870 if ($ check ){
59- $ resp = array ('success ' => 0 , 'msg ' => __ ('The name of Group exist in this post type, Please choose a different name. ' ,$ mf_domain ) );
71+ $ resp = array ('success ' => false , 'msg ' => __ ('The name of Group exist in this post type, Please choose a different name. ' ,$ mf_domain ) );
6072 }
6173
6274 echo json_encode ($ resp );
@@ -68,11 +80,11 @@ public function check_name_custom_field($data){
6880 $ name = $ data ['field_name ' ];
6981 $ post_type = $ data ['post_type ' ];
7082 $ id = $ data ['field_id ' ];
71- $ resp = array ('success ' => 1 );
83+ $ resp = array ('success ' => true );
7284
7385 $ check = mf_custom_fields::check_group ($ name ,$ post_type ,$ id );
7486 if ($ check ){
75- $ resp = array ('success ' => 0 , 'msg ' => __ ('The name of Field exist in this post type, Please choose a different name. ' ,$ mf_domain ) );
87+ $ resp = array ('success ' => false , 'msg ' => __ ('The name of Field exist in this post type, Please choose a different name. ' ,$ mf_domain ) );
7688 }
7789 echo json_encode ($ resp );
7890 }
@@ -151,10 +163,8 @@ public function set_default_categories($data){
151163 );
152164 }
153165 $ wpdb ->query ($ sql );
154- $ resp = array ('success ' => 1 );
155-
166+ $ resp = array ('success ' => true );
156167 //update_post_meta(-2, $post_type, $cats);
157-
158168 echo json_encode ($ resp );
159169 }
160170
@@ -172,13 +182,6 @@ public static function remove_upload_file() {
172182 public function upload_ajax ($ data ){
173183 global $ mf_domain ;
174184
175- if ( !check_ajax_referer ( 'mf_nonce_ajax ' , 'security ' , false ) ) {
176- mf_ajax_call::remove_upload_file ();
177- $ resp = array ('success ' => false , 'msg ' => __ ('Sorry, your nonce did not verify.. ' ,$ mf_domain ) );
178- echo json_encode ($ resp );
179- die;
180- }
181-
182185 if ( !current_user_can ('upload_files ' ) ){
183186 mf_ajax_call::remove_upload_file ();
184187 $ resp = array ('success ' => false , 'msg ' => __ ('You do not have sufficient permissions to upload images. ' ,$ mf_domain ) );
0 commit comments