├── .gitignore ├── LICENSE ├── README.md └── plugin.php /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .htaccess 3 | sitemap.xml 4 | sitemap.xml.gz 5 | wp-config.php 6 | wp-content/advanced-cache.php 7 | wp-content/backup-db/ 8 | wp-content/backups/ 9 | wp-content/blogs.dir/ 10 | wp-content/cache/ 11 | wp-content/upgrade/ 12 | wp-content/uploads/ 13 | wp-content/wp-cache-config.php 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WP-JSON-API-ACF 2 | =============== 3 | 4 | By default the Wordpress JSON API: [WP-API](http://wp-api.org/) doesn't include Advanced Custom Fields. 5 | This plugin fixes that. 6 | 7 | Grown from https://gist.github.com/rileypaulsen/9b4505cdd0ac88d5ef51 8 | but a plugin is nicer: I didn't want to modify the other plugin 9 | 10 | Not actively in development, as I'm no longer involved with the project this was developed for. If you want to take over, let me know! 11 | PanMan 12 | -------------------------------------------------------------------------------- /plugin.php: -------------------------------------------------------------------------------- 1 | taxonomy."_". $post->term_id ); 19 | $data['meta'] = array_merge($data['meta'], $customMeta ); 20 | return $data; 21 | } 22 | 23 | function wp_api_encode_acf_user($data,$post){ 24 | $customMeta = (array) get_fields("user_". $data['ID']); 25 | $data['meta'] = array_merge($data['meta'], $customMeta ); 26 | return $data; 27 | } 28 | 29 | add_filter('json_prepare_post', 'wp_api_encode_acf', 10, 3); 30 | add_filter('json_prepare_page', 'wp_api_encode_acf', 10, 3); 31 | add_filter('json_prepare_attachment', 'wp_api_encode_acf', 10, 3); 32 | add_filter('json_prepare_term', 'wp_api_encode_acf_taxonomy', 10, 2); 33 | add_filter('json_prepare_user', 'wp_api_encode_acf_user', 10, 2); 34 | --------------------------------------------------------------------------------