Skip to content

Commit 0eb93fd

Browse files
authored
Merge pull request #155 from dshanske/registermeta
Add relme to REST API
2 parents ca26a17 + 0958bcf commit 0eb93fd

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

Diff for: .travis.yml

-10
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ matrix:
2727
- php: 5.6
2828
- php: 5.6
2929
env: WP_PULUGIN_DEPLOY=1
30-
- php: 5.5
31-
env: WP_VERSION=4.7 WP_MULTISITE=0
32-
- php: 5.4
33-
env: WP_VERSION=4.7 WP_MULTISITE=0
34-
- php: 5.3
35-
env: WP_VERSION=4.7 WP_MULTISITE=0
36-
dist: precise
37-
- php: 5.2
38-
env: WP_VERSION=4.7 WP_MULTISITE=0
39-
dist: precise
4030
before_script:
4131
- |
4232
# Remove Xdebug for a huge performance increase:

Diff for: includes/class-hcard-user.php

+21
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static function init() {
1919
add_action( 'personal_options_update', array( 'HCard_User', 'save_profile' ), 11 );
2020
add_action( 'edit_user_profile_update', array( 'HCard_User', 'save_profile' ), 11 );
2121
add_filter( 'wp_head', array( 'HCard_User', 'pgp' ), 11 );
22+
add_action( 'rest_api_init', array( 'HCard_User', 'rest_fields' ) );
2223
}
2324

2425
/**
@@ -196,6 +197,26 @@ public static function extended_profile_textarea_field( $user, $key, $title, $de
196197
<?php
197198
}
198199

200+
public static function rest_fields() {
201+
register_rest_field(
202+
'user',
203+
'me',
204+
array(
205+
'get_callback' => function( $user, $attr, $request, $object_type ) {
206+
return array_values( self::get_rel_me( $user['id'] ) );
207+
},
208+
)
209+
);
210+
register_rest_field(
211+
'user',
212+
'first_name',
213+
array(
214+
'get_callback' => function( $user, $attr, $request, $object_type ) {
215+
return get_user_meta( $user['id'], 'first_name' );
216+
},
217+
)
218+
);
219+
}
199220

200221
public static function save_profile( $user_id ) {
201222
if ( ! current_user_can( 'edit_user', $user_id ) ) {

Diff for: phpcs.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<exclude-pattern>*/includes/class-connekt-plugin-installer.php</exclude-pattern>
1010
<exclude-pattern>*/vendor/*</exclude-pattern>
1111
<rule ref="PHPCompatibility"/>
12-
<config name="testVersion" value="5.3-"/>
12+
<config name="testVersion" value="5.6-"/>
1313
<rule ref="WordPress-Core" />
1414
<rule ref="WordPress.Files.FileName">
1515
<properties>

Diff for: readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
**Donate link:** https://indieweb.org/how-to-sponsor
44
**Tags:** indieweb, webmention, POSSE, indieauth
55
**Requires at least:** 4.7
6-
**Requires PHP:** 5.3
6+
**Requires PHP:** 5.6
77
**Tested up to:** 5.3.2
88
**Stable tag:** 3.4.2
99
**License:** MIT

Diff for: readme.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: pfefferle, indieweb, dshanske
33
Donate link: https://indieweb.org/how-to-sponsor
44
Tags: indieweb, webmention, POSSE, indieauth
55
Requires at least: 4.7
6-
Requires PHP: 5.3
6+
Requires PHP: 5.6
77
Tested up to: 5.3.2
88
Stable tag: 3.4.2
99
License: MIT

0 commit comments

Comments
 (0)