File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use WP_Error ;
6
6
use WP \OAuth2 \Client ;
7
+ use WP_Query ;
7
8
use WP_User ;
8
9
9
10
class Access_Token extends Token {
@@ -21,14 +22,15 @@ protected static function get_meta_prefix() {
21
22
* @return static|null Token if ID is found, null otherwise.
22
23
*/
23
24
public static function get_by_id ( $ id ) {
25
+ $ key = static ::META_PREFIX . $ id ;
24
26
$ args = array (
25
27
'post_type ' => Client::POST_TYPE ,
26
28
'post_status ' => 'publish ' ,
27
29
'posts_per_page ' => 1 ,
28
30
'no_found_rows ' => true ,
29
31
'meta_query ' => array (
30
32
array (
31
- 'key ' => static :: META_PREFIX . $ id ,
33
+ 'key ' => $ key ,
32
34
'compare ' => 'EXISTS ' ,
33
35
),
34
36
),
@@ -38,7 +40,12 @@ public static function get_by_id( $id ) {
38
40
return null ;
39
41
}
40
42
41
- return new static ( $ query ->posts [0 ] );
43
+ $ value = get_post_meta ( $ query ->posts [0 ]->ID , wp_slash ( $ key ), false );
44
+ if ( empty ( $ value ) ) {
45
+ return null ;
46
+ }
47
+
48
+ return new static ( $ key , $ value [0 ] );
42
49
}
43
50
44
51
public static function create ( Client $ client , WP_User $ user ) {
You can’t perform that action at this time.
0 commit comments