@@ -44,15 +44,15 @@ public function get_meta_field( $value, $object_id, $meta_key ) {
44
44
switch ( $ this ->object_type ) {
45
45
46
46
case 'post ' :
47
- if ( is_null ( wpm_get_post_config ( get_post_type ( $ object_id ) ) ) ) {
47
+ if ( null === wpm_get_post_config ( get_post_type ( $ object_id ) ) ) {
48
48
return $ value ;
49
49
}
50
50
51
51
break ;
52
52
53
53
case 'term ' :
54
54
$ term = get_term ( $ object_id );
55
- if ( ! $ term || is_null ( wpm_get_taxonomy_config ( $ term ->taxonomy ) ) ) {
55
+ if ( ! $ term || null === wpm_get_taxonomy_config ( $ term ->taxonomy ) ) {
56
56
return $ value ;
57
57
}
58
58
}
@@ -76,16 +76,15 @@ public function get_meta_field( $value, $object_id, $meta_key ) {
76
76
return $ value ;
77
77
}
78
78
79
- $ meta_config = apply_filters ( "wpm_ {$ meta_key }_meta_config " , $ object_fields_config [ $ meta_key ], $ object_id );
79
+ $ meta_config = apply_filters ( "wpm_ {$ meta_key }_meta_config " , $ object_fields_config [ $ meta_key ], false , $ object_id );
80
80
$ meta_config = apply_filters ( "wpm_ {$ this ->object_type }_meta_ {$ meta_key }_config " , $ meta_config , $ object_id );
81
81
82
- if ( is_null ( $ meta_config ) ) {
82
+ if ( null === $ meta_config ) {
83
83
return $ value ;
84
84
}
85
85
86
- $ column = sanitize_key ( $ this ->object_type . '_id ' );
87
- $ id_column = 'user ' === $ this ->object_type ? 'umeta_id ' : 'meta_id ' ;
88
-
86
+ $ column = sanitize_key ( $ this ->object_type . '_id ' );
87
+ $ id_column = 'user ' === $ this ->object_type ? 'umeta_id ' : 'meta_id ' ;
89
88
$ meta_values = wp_cache_get ( $ object_id , $ this ->object_type . '_ ' . $ meta_key . '_wpm_meta ' );
90
89
$ values = array ();
91
90
@@ -119,7 +118,6 @@ public function get_meta_field( $value, $object_id, $meta_key ) {
119
118
}
120
119
121
120
return null ;
122
-
123
121
}
124
122
125
123
/**
@@ -139,15 +137,15 @@ public function update_meta_field( $check, $object_id, $meta_key, $meta_value, $
139
137
switch ( $ this ->object_type ) {
140
138
141
139
case 'post ' :
142
- if ( is_null ( wpm_get_post_config ( get_post_type ( $ object_id ) ) ) ) {
140
+ if ( null === wpm_get_post_config ( get_post_type ( $ object_id ) ) ) {
143
141
return $ check ;
144
142
}
145
143
146
144
break ;
147
145
148
146
case 'term ' :
149
147
$ term = get_term ( $ object_id );
150
- if ( ! $ term || is_null ( wpm_get_taxonomy_config ( $ term ->taxonomy ) ) ) {
148
+ if ( ! $ term || null === wpm_get_taxonomy_config ( $ term ->taxonomy ) ) {
151
149
return $ check ;
152
150
}
153
151
}
@@ -162,14 +160,13 @@ public function update_meta_field( $check, $object_id, $meta_key, $meta_value, $
162
160
$ meta_config = apply_filters ( "wpm_ {$ meta_key }_meta_config " , $ object_fields_config [ $ meta_key ], $ meta_value , $ object_id );
163
161
$ meta_config = apply_filters ( "wpm_ {$ this ->object_type }_meta_ {$ meta_key }_config " , $ meta_config , $ meta_value , $ object_id );
164
162
165
- if ( is_null ( $ meta_config ) ) {
163
+ if ( null === $ meta_config ) {
166
164
return $ check ;
167
165
}
168
166
169
167
$ table = $ wpdb ->{$ this ->object_table };
170
168
$ column = sanitize_key ( $ this ->object_type . '_id ' );
171
169
$ id_column = 'user ' === $ this ->object_type ? 'umeta_id ' : 'meta_id ' ;
172
-
173
170
$ meta_value = apply_filters ( 'wpm_update_meta_value ' , $ meta_value , $ meta_key );
174
171
$ meta_value = apply_filters ( "wpm_update_ {$ meta_key }_meta_value " , $ meta_value );
175
172
$ meta_value = apply_filters ( "wpm_update_ {$ this ->object_type }_meta_ {$ meta_key }_value " , $ meta_value );
@@ -205,6 +202,7 @@ public function update_meta_field( $check, $object_id, $meta_key, $meta_value, $
205
202
$ old_value = maybe_unserialize ( $ old_value );
206
203
$ old_value = apply_filters ( "wpm_filter_old_ {$ meta_key }_meta_value " , $ old_value , $ meta_value , $ meta_config );
207
204
$ meta_value = wpm_set_new_value ( $ old_value , $ meta_value , $ meta_config );
205
+ $ meta_value = apply_filters ( "wpm_filter_new_ {$ meta_key }_meta_value " , $ meta_value , $ old_value , $ meta_config );
208
206
}
209
207
210
208
$ meta_value = maybe_serialize ( $ meta_value );
@@ -215,7 +213,7 @@ public function update_meta_field( $check, $object_id, $meta_key, $meta_value, $
215
213
216
214
if ( ! wpm_is_ml_value ( $ prev_value ) ) {
217
215
$ like = '% ' . $ wpdb ->esc_like ( esc_sql ( $ prev_value ) ) . '% ' ;
218
- $ prev_value = $ wpdb ->get_var ( $ wpdb ->prepare ( "SELECT meta_value FROM {$ wpdb ->{$ this ->object_table }} WHERE meta_key = %s AND {$ column } = %d AND meta_value LIKE '%s' LIMIT 1 " , $ meta_key , $ object_id , $ like ) );
216
+ $ prev_value = $ wpdb ->get_var ( $ wpdb ->prepare ( "SELECT meta_value FROM {$ wpdb ->{$ this ->object_table }} WHERE meta_key = %s AND {$ column } = %d AND meta_value LIKE %s LIMIT 1 " , $ meta_key , $ object_id , $ like ) );
219
217
}
220
218
221
219
$ prev_value = maybe_serialize ( $ prev_value );
@@ -295,7 +293,17 @@ public function update_meta_field( $check, $object_id, $meta_key, $meta_value, $
295
293
return true ;
296
294
}
297
295
298
-
296
+ /**
297
+ * Add new meta for translation
298
+ *
299
+ * @param $check null|mixed
300
+ * @param $object_id int
301
+ * @param $meta_key
302
+ * @param $meta_value mixed
303
+ * @param $unique bool
304
+ *
305
+ * @return mixed
306
+ */
299
307
public function add_meta_field ( $ check , $ object_id , $ meta_key , $ meta_value , $ unique ) {
300
308
global $ wpdb ;
301
309
@@ -306,14 +314,14 @@ public function add_meta_field( $check, $object_id, $meta_key, $meta_value, $uni
306
314
switch ( $ this ->object_type ) {
307
315
308
316
case 'post ' :
309
- if ( is_null ( wpm_get_post_config ( get_post_type ( $ object_id ) ) ) ) {
317
+ if ( null === wpm_get_post_config ( get_post_type ( $ object_id ) ) ) {
310
318
return $ check ;
311
319
}
312
320
break ;
313
321
314
322
case 'term ' :
315
323
$ term = get_term ( $ object_id );
316
- if ( ! $ term || is_null ( wpm_get_taxonomy_config ( $ term ->taxonomy ) ) ) {
324
+ if ( ! $ term || null === wpm_get_taxonomy_config ( $ term ->taxonomy ) ) {
317
325
return $ check ;
318
326
}
319
327
}
@@ -328,13 +336,12 @@ public function add_meta_field( $check, $object_id, $meta_key, $meta_value, $uni
328
336
$ meta_config = apply_filters ( "wpm_ {$ meta_key }_meta_config " , $ object_fields_config [ $ meta_key ], $ meta_value , $ object_id );
329
337
$ meta_config = apply_filters ( "wpm_ {$ this ->object_type }_meta_ {$ meta_key }_config " , $ meta_config , $ meta_value , $ object_id );
330
338
331
- if ( is_null ( $ meta_config ) ) {
339
+ if ( null === $ meta_config ) {
332
340
return $ check ;
333
341
}
334
342
335
- $ table = $ wpdb ->{$ this ->object_table };
336
- $ column = sanitize_key ( $ this ->object_type . '_id ' );
337
-
343
+ $ table = $ wpdb ->{$ this ->object_table };
344
+ $ column = sanitize_key ( $ this ->object_type . '_id ' );
338
345
$ meta_value = apply_filters ( 'wpm_add_meta_value ' , $ meta_value , $ meta_key );
339
346
$ meta_value = apply_filters ( "wpm_add_ {$ meta_key }_meta_value " , $ meta_value );
340
347
$ meta_value = apply_filters ( "wpm_add_ {$ this ->object_type }_meta_ {$ meta_key }_value " , $ meta_value );
@@ -343,15 +350,13 @@ public function add_meta_field( $check, $object_id, $meta_key, $meta_value, $uni
343
350
$ meta_value = wpm_set_new_value ( array (), $ meta_value , $ meta_config );
344
351
}
345
352
346
-
347
353
if ( $ unique && $ wpdb ->get_var ( $ wpdb ->prepare ( "SELECT COUNT(*) FROM $ table WHERE meta_key = %s AND $ column = %d " , $ meta_key , $ object_id ) )
348
354
) {
349
355
return false ;
350
356
}
351
357
352
358
$ _meta_value = $ meta_value ;
353
-
354
- $ meta_value = maybe_serialize ( $ meta_value );
359
+ $ meta_value = maybe_serialize ( $ meta_value );
355
360
356
361
/**
357
362
* Fires immediately before meta of a specific type is added.
@@ -411,22 +416,22 @@ public function delete_meta_field( $meta_ids, $object_id, $meta_key ) {
411
416
switch ( $ this ->object_type ) {
412
417
413
418
case 'post ' :
414
- if ( is_null ( wpm_get_post_config ( get_post_type ( $ object_id ) ) ) ) {
419
+ if ( null === wpm_get_post_config ( get_post_type ( $ object_id ) ) ) {
415
420
return ;
416
421
}
417
422
break ;
418
423
419
424
case 'term ' :
420
425
$ term = get_term ( $ object_id );
421
- if ( ! $ term || is_null ( wpm_get_taxonomy_config ( $ term ->taxonomy ) ) ) {
426
+ if ( ! $ term || null === wpm_get_taxonomy_config ( $ term ->taxonomy ) ) {
422
427
return ;
423
428
}
424
429
}
425
430
426
431
$ config = wpm_get_config ();
427
432
$ object_fields_config = apply_filters ( "wpm_ {$ this ->object_type }_fields_config " , $ config [ "{$ this ->object_type }_fields " ] );
428
433
429
- if ( ! isset ( $ object_fields_config [ $ meta_key ] ) || is_null ( $ object_fields_config [ $ meta_key ] ) ) {
434
+ if ( ! isset ( $ object_fields_config [ $ meta_key ] ) || null === $ object_fields_config [ $ meta_key ] ) {
430
435
return ;
431
436
}
432
437
0 commit comments