{"action":"created","comment":{"url":"https://api.github.com/repos/moxie-lean/wp-acf/pulls/comments/65192902","id":65192902,"diff_hunk":"@@ -0,0 +1,55 @@\n+<?php namespace Lean\\Acf;\n+\n+use Lean\\Acf;\n+\n+/**\n+ * Output ACF fields in the WP Rest API.\n+ */\n+class RestApi {\n+\n+\tconst FIELD_NAME = 'acf';\n+\n+\t/**\n+\t * Initiate the ACF Rest API functionality.\n+\t */\n+\tpublic static function init() {\n+\t\tadd_action( 'rest_api_init', [ __CLASS__, 'register' ] );\n+\t}\n+\n+\t/**\n+\t * Register the field for all post types and users.\n+\t */\n+\tpublic static function register() {\n+\t\tforeach ( [ 'post', 'user' ] as $type ) {\n+\t\t\tregister_rest_field(\n+\t\t\t\t'post' === $type ? get_post_types() : $type ,\n+\t\t\t\tself::FIELD_NAME,\n+\t\t\t\t[ 'get_callback' => [ __CLASS__, 'get_' . $type . '_fields' ] ]\n+\t\t\t);\n+\t\t}\n+\t}\n+\n+\t/**\n+\t * Get all ACF fields for the post.\n+\t *\n+\t * @param array \t\t   $object     The current object.\n+\t * @param string \t\t   $field_name The field name.\n+\t * @param \\WP_REST_Request $request    The request.\n+\t * @return array\n+\t */\n+\tpublic static function get_post_fields( $object, $field_name, $request ) {","path":"src/Acf/RestApi.php","position":40,"original_position":40,"commit_id":"0029976465939be696625b0cc8650a964ff76a59","original_commit_id":"0029976465939be696625b0cc8650a964ff76a59","user":{"login":"adamf321","id":5068959,"avatar_url":"https://avatars.githubusercontent.com/u/5068959?v=3","gravatar_id":"","url":"https://api.github.com/users/adamf321","html_url":"https://github.com/adamf321","followers_url":"https://api.github.com/users/adamf321/followers","following_url":"https://api.github.com/users/adamf321/following{/other_user}","gists_url":"https://api.github.com/users/adamf321/gists{/gist_id}","starred_url":"https://api.github.com/users/adamf321/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamf321/subscriptions","organizations_url":"https://api.github.com/users/adamf321/orgs","repos_url":"https://api.github.com/users/adamf321/repos","events_url":"https://api.github.com/users/adamf321/events{/privacy}","received_events_url":"https://api.github.com/users/adamf321/received_events","type":"User","site_admin":false},"body":"The WP callback always passed in these 3 args. I think it's best to leave them in as it documents the callback fully for future use (I always do the same for wp filters and actions).","created_at":"2016-05-31T14:33:14Z","updated_at":"2016-05-31T14:33:14Z","html_url":"https://github.com/moxie-lean/wp-acf/pull/23#discussion_r65192902","pull_request_url":"https://api.github.com/repos/moxie-lean/wp-acf/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/moxie-lean/wp-acf/pulls/comments/65192902"},"html":{"href":"https://github.com/moxie-lean/wp-acf/pull/23#discussion_r65192902"},"pull_request":{"href":"https://api.github.com/repos/moxie-lean/wp-acf/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/moxie-lean/wp-acf/pulls/23","id":72020542,"html_url":"https://github.com/moxie-lean/wp-acf/pull/23","diff_url":"https://github.com/moxie-lean/wp-acf/pull/23.diff","patch_url":"https://github.com/moxie-lean/wp-acf/pull/23.patch","issue_url":"https://api.github.com/repos/moxie-lean/wp-acf/issues/23","number":23,"state":"open","locked":false,"title":"Rest api","user":{"login":"adamf321","id":5068959,"avatar_url":"https://avatars.githubusercontent.com/u/5068959?v=3","gravatar_id":"","url":"https://api.github.com/users/adamf321","html_url":"https://github.com/adamf321","followers_url":"https://api.github.com/users/adamf321/followers","following_url":"https://api.github.com/users/adamf321/following{/other_user}","gists_url":"https://api.github.com/users/adamf321/gists{/gist_id}","starred_url":"https://api.github.com/users/adamf321/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamf321/subscriptions","organizations_url":"https://api.github.com/users/adamf321/orgs","repos_url":"https://api.github.com/users/adamf321/repos","events_url":"https://api.github.com/users/adamf321/events{/privacy}","received_events_url":"https://api.github.com/users/adamf321/received_events","type":"User","site_admin":false},"body":"* **What kind of change does this PR introduce?** (Bug fix, feature,\r\n  docs update, ...)\r\nFeature\r\n\r\n\r\n* **What is the current behavior?** (You can also link to an open issue\r\n  here)\r\nACF fields pulled into custom posts endpoint\r\n\r\n\r\n* **What is the new behavior (if this is a feature change)?**\r\nACF fields can be added to the standard WP REST API posts endpoint\r\n\r\n\r\n* **Does this PR introduce a breaking change?** (What changes might\r\n  users need to make in their application due to this PR?)\r\nNo\r\n\r\n\r\n* **Other information**:\r\n\r\n","created_at":"2016-05-31T13:59:57Z","updated_at":"2016-05-31T14:33:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"250d70c101e1448cf14609d7b5830684810292b5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/moxie-lean/wp-acf/pulls/23/commits","review_comments_url":"https://api.github.com/repos/moxie-lean/wp-acf/pulls/23/comments","review_comment_url":"https://api.github.com/repos/moxie-lean/wp-acf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/moxie-lean/wp-acf/issues/23/comments","statuses_url":"https://api.github.com/repos/moxie-lean/wp-acf/statuses/0029976465939be696625b0cc8650a964ff76a59","head":{"label":"moxie-lean:rest-api","ref":"rest-api","sha":"0029976465939be696625b0cc8650a964ff76a59","user":{"login":"moxie-lean","id":15912467,"avatar_url":"https://avatars.githubusercontent.com/u/15912467?v=3","gravatar_id":"","url":"https://api.github.com/users/moxie-lean","html_url":"https://github.com/moxie-lean","followers_url":"https://api.github.com/users/moxie-lean/followers","following_url":"https://api.github.com/users/moxie-lean/following{/other_user}","gists_url":"https://api.github.com/users/moxie-lean/gists{/gist_id}","starred_url":"https://api.github.com/users/moxie-lean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moxie-lean/subscriptions","organizations_url":"https://api.github.com/users/moxie-lean/orgs","repos_url":"https://api.github.com/users/moxie-lean/repos","events_url":"https://api.github.com/users/moxie-lean/events{/privacy}","received_events_url":"https://api.github.com/users/moxie-lean/received_events","type":"Organization","site_admin":false},"repo":{"id":51704066,"name":"wp-acf","full_name":"moxie-lean/wp-acf","owner":{"login":"moxie-lean","id":15912467,"avatar_url":"https://avatars.githubusercontent.com/u/15912467?v=3","gravatar_id":"","url":"https://api.github.com/users/moxie-lean","html_url":"https://github.com/moxie-lean","followers_url":"https://api.github.com/users/moxie-lean/followers","following_url":"https://api.github.com/users/moxie-lean/following{/other_user}","gists_url":"https://api.github.com/users/moxie-lean/gists{/gist_id}","starred_url":"https://api.github.com/users/moxie-lean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moxie-lean/subscriptions","organizations_url":"https://api.github.com/users/moxie-lean/orgs","repos_url":"https://api.github.com/users/moxie-lean/repos","events_url":"https://api.github.com/users/moxie-lean/events{/privacy}","received_events_url":"https://api.github.com/users/moxie-lean/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/moxie-lean/wp-acf","description":"","fork":false,"url":"https://api.github.com/repos/moxie-lean/wp-acf","forks_url":"https://api.github.com/repos/moxie-lean/wp-acf/forks","keys_url":"https://api.github.com/repos/moxie-lean/wp-acf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/moxie-lean/wp-acf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/moxie-lean/wp-acf/teams","hooks_url":"https://api.github.com/repos/moxie-lean/wp-acf/hooks","issue_events_url":"https://api.github.com/repos/moxie-lean/wp-acf/issues/events{/number}","events_url":"https://api.github.com/repos/moxie-lean/wp-acf/events","assignees_url":"https://api.github.com/repos/moxie-lean/wp-acf/assignees{/user}","branches_url":"https://api.github.com/repos/moxie-lean/wp-acf/branches{/branch}","tags_url":"https://api.github.com/repos/moxie-lean/wp-acf/tags","blobs_url":"https://api.github.com/repos/moxie-lean/wp-acf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/moxie-lean/wp-acf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/moxie-lean/wp-acf/git/refs{/sha}","trees_url":"https://api.github.com/repos/moxie-lean/wp-acf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/moxie-lean/wp-acf/statuses/{sha}","languages_url":"https://api.github.com/repos/moxie-lean/wp-acf/languages","stargazers_url":"https://api.github.com/repos/moxie-lean/wp-acf/stargazers","contributors_url":"https://api.github.com/repos/moxie-lean/wp-acf/contributors","subscribers_url":"https://api.github.com/repos/moxie-lean/wp-acf/subscribers","subscription_url":"https://api.github.com/repos/moxie-lean/wp-acf/subscription","commits_url":"https://api.github.com/repos/moxie-lean/wp-acf/commits{/sha}","git_commits_url":"https://api.github.com/repos/moxie-lean/wp-acf/git/commits{/sha}","comments_url":"https://api.github.com/repos/moxie-lean/wp-acf/comments{/number}","issue_comment_url":"https://api.github.com/repos/moxie-lean/wp-acf/issues/comments{/number}","contents_url":"https://api.github.com/repos/moxie-lean/wp-acf/contents/{+path}","compare_url":"https://api.github.com/repos/moxie-lean/wp-acf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/moxie-lean/wp-acf/merges","archive_url":"https://api.github.com/repos/moxie-lean/wp-acf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/moxie-lean/wp-acf/downloads","issues_url":"https://api.github.com/repos/moxie-lean/wp-acf/issues{/number}","pulls_url":"https://api.github.com/repos/moxie-lean/wp-acf/pulls{/number}","milestones_url":"https://api.github.com/repos/moxie-lean/wp-acf/milestones{/number}","notifications_url":"https://api.github.com/repos/moxie-lean/wp-acf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/moxie-lean/wp-acf/labels{/name}","releases_url":"https://api.github.com/repos/moxie-lean/wp-acf/releases{/id}","deployments_url":"https://api.github.com/repos/moxie-lean/wp-acf/deployments","created_at":"2016-02-14T17:10:56Z","updated_at":"2016-03-09T00:09:53Z","pushed_at":"2016-05-31T14:02:38Z","git_url":"git://github.com/moxie-lean/wp-acf.git","ssh_url":"git@github.com:moxie-lean/wp-acf.git","clone_url":"https://github.com/moxie-lean/wp-acf.git","svn_url":"https://github.com/moxie-lean/wp-acf","homepage":null,"size":35,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"moxie-lean:master","ref":"master","sha":"3197562ba95ddafa49b4cdbf56264968bc3ad5cc","user":{"login":"moxie-lean","id":15912467,"avatar_url":"https://avatars.githubusercontent.com/u/15912467?v=3","gravatar_id":"","url":"https://api.github.com/users/moxie-lean","html_url":"https://github.com/moxie-lean","followers_url":"https://api.github.com/users/moxie-lean/followers","following_url":"https://api.github.com/users/moxie-lean/following{/other_user}","gists_url":"https://api.github.com/users/moxie-lean/gists{/gist_id}","starred_url":"https://api.github.com/users/moxie-lean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moxie-lean/subscriptions","organizations_url":"https://api.github.com/users/moxie-lean/orgs","repos_url":"https://api.github.com/users/moxie-lean/repos","events_url":"https://api.github.com/users/moxie-lean/events{/privacy}","received_events_url":"https://api.github.com/users/moxie-lean/received_events","type":"Organization","site_admin":false},"repo":{"id":51704066,"name":"wp-acf","full_name":"moxie-lean/wp-acf","owner":{"login":"moxie-lean","id":15912467,"avatar_url":"https://avatars.githubusercontent.com/u/15912467?v=3","gravatar_id":"","url":"https://api.github.com/users/moxie-lean","html_url":"https://github.com/moxie-lean","followers_url":"https://api.github.com/users/moxie-lean/followers","following_url":"https://api.github.com/users/moxie-lean/following{/other_user}","gists_url":"https://api.github.com/users/moxie-lean/gists{/gist_id}","starred_url":"https://api.github.com/users/moxie-lean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moxie-lean/subscriptions","organizations_url":"https://api.github.com/users/moxie-lean/orgs","repos_url":"https://api.github.com/users/moxie-lean/repos","events_url":"https://api.github.com/users/moxie-lean/events{/privacy}","received_events_url":"https://api.github.com/users/moxie-lean/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/moxie-lean/wp-acf","description":"","fork":false,"url":"https://api.github.com/repos/moxie-lean/wp-acf","forks_url":"https://api.github.com/repos/moxie-lean/wp-acf/forks","keys_url":"https://api.github.com/repos/moxie-lean/wp-acf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/moxie-lean/wp-acf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/moxie-lean/wp-acf/teams","hooks_url":"https://api.github.com/repos/moxie-lean/wp-acf/hooks","issue_events_url":"https://api.github.com/repos/moxie-lean/wp-acf/issues/events{/number}","events_url":"https://api.github.com/repos/moxie-lean/wp-acf/events","assignees_url":"https://api.github.com/repos/moxie-lean/wp-acf/assignees{/user}","branches_url":"https://api.github.com/repos/moxie-lean/wp-acf/branches{/branch}","tags_url":"https://api.github.com/repos/moxie-lean/wp-acf/tags","blobs_url":"https://api.github.com/repos/moxie-lean/wp-acf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/moxie-lean/wp-acf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/moxie-lean/wp-acf/git/refs{/sha}","trees_url":"https://api.github.com/repos/moxie-lean/wp-acf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/moxie-lean/wp-acf/statuses/{sha}","languages_url":"https://api.github.com/repos/moxie-lean/wp-acf/languages","stargazers_url":"https://api.github.com/repos/moxie-lean/wp-acf/stargazers","contributors_url":"https://api.github.com/repos/moxie-lean/wp-acf/contributors","subscribers_url":"https://api.github.com/repos/moxie-lean/wp-acf/subscribers","subscription_url":"https://api.github.com/repos/moxie-lean/wp-acf/subscription","commits_url":"https://api.github.com/repos/moxie-lean/wp-acf/commits{/sha}","git_commits_url":"https://api.github.com/repos/moxie-lean/wp-acf/git/commits{/sha}","comments_url":"https://api.github.com/repos/moxie-lean/wp-acf/comments{/number}","issue_comment_url":"https://api.github.com/repos/moxie-lean/wp-acf/issues/comments{/number}","contents_url":"https://api.github.com/repos/moxie-lean/wp-acf/contents/{+path}","compare_url":"https://api.github.com/repos/moxie-lean/wp-acf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/moxie-lean/wp-acf/merges","archive_url":"https://api.github.com/repos/moxie-lean/wp-acf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/moxie-lean/wp-acf/downloads","issues_url":"https://api.github.com/repos/moxie-lean/wp-acf/issues{/number}","pulls_url":"https://api.github.com/repos/moxie-lean/wp-acf/pulls{/number}","milestones_url":"https://api.github.com/repos/moxie-lean/wp-acf/milestones{/number}","notifications_url":"https://api.github.com/repos/moxie-lean/wp-acf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/moxie-lean/wp-acf/labels{/name}","releases_url":"https://api.github.com/repos/moxie-lean/wp-acf/releases{/id}","deployments_url":"https://api.github.com/repos/moxie-lean/wp-acf/deployments","created_at":"2016-02-14T17:10:56Z","updated_at":"2016-03-09T00:09:53Z","pushed_at":"2016-05-31T14:02:38Z","git_url":"git://github.com/moxie-lean/wp-acf.git","ssh_url":"git@github.com:moxie-lean/wp-acf.git","clone_url":"https://github.com/moxie-lean/wp-acf.git","svn_url":"https://github.com/moxie-lean/wp-acf","homepage":null,"size":35,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/moxie-lean/wp-acf/pulls/23"},"html":{"href":"https://github.com/moxie-lean/wp-acf/pull/23"},"issue":{"href":"https://api.github.com/repos/moxie-lean/wp-acf/issues/23"},"comments":{"href":"https://api.github.com/repos/moxie-lean/wp-acf/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/moxie-lean/wp-acf/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/moxie-lean/wp-acf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/moxie-lean/wp-acf/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/moxie-lean/wp-acf/statuses/0029976465939be696625b0cc8650a964ff76a59"}}}}
{"actor":{"display_login":"adamf321"}}