Changeset 1752896
- Timestamp:
- 10/26/2017 03:55:50 AM (8 years ago)
- Location:
- acf-to-rest-api
- Files:
-
- 227 added
- 2 deleted
- 8 edited
-
assets/banner-1544x500.jpg (modified) (previous)
-
assets/banner-772x250.jpg (modified) (previous)
-
assets/icon-128x128.jpg (modified) (previous)
-
assets/icon-256x256.jpg (modified) (previous)
-
tags/3.0.0-beta (added)
-
tags/3.0.0-beta/class-acf-to-rest-api.php (added)
-
tags/3.0.0-beta/languages (added)
-
tags/3.0.0-beta/languages/pt_BR.mo (added)
-
tags/3.0.0-beta/legacy (added)
-
tags/3.0.0-beta/legacy/v2 (added)
-
tags/3.0.0-beta/legacy/v2/class-acf-to-rest-api-v2.php (added)
-
tags/3.0.0-beta/legacy/v2/lib (added)
-
tags/3.0.0-beta/legacy/v2/lib/endpoints (added)
-
tags/3.0.0-beta/legacy/v2/lib/endpoints/class-acf-to-rest-api-attachment-controller.php (added)
-
tags/3.0.0-beta/legacy/v2/lib/endpoints/class-acf-to-rest-api-controller.php (added)
-
tags/3.0.0-beta/legacy/v2/lib/endpoints/class-acf-to-rest-api-option-controller.php (added)
-
tags/3.0.0-beta/legacy/v2/lib/endpoints/class-acf-to-rest-api-term-controller.php (added)
-
tags/3.0.0-beta/readme.md (added)
-
tags/3.0.0-beta/readme.txt (added)
-
tags/3.0.0-beta/shared (added)
-
tags/3.0.0-beta/shared/includes (added)
-
tags/3.0.0-beta/shared/includes/admin (added)
-
tags/3.0.0-beta/shared/includes/admin/views (added)
-
tags/3.0.0-beta/shared/includes/admin/views/html-notice-missing-acf.php (added)
-
tags/3.0.0-beta/shared/includes/admin/views/html-notice-missing-rest-api.php (added)
-
tags/3.0.0-beta/shared/includes/admin/views/html-settings-field.php (added)
-
tags/3.0.0-beta/shared/includes/admin/views/html-settings-section.php (added)
-
tags/3.0.0-beta/shared/lib (added)
-
tags/3.0.0-beta/shared/lib/class-acf-to-rest-api-settings.php (added)
-
tags/3.0.0-beta/v3 (added)
-
tags/3.0.0-beta/v3/class-acf-to-rest-api-v3.php (added)
-
tags/3.0.0-beta/v3/lib (added)
-
tags/3.0.0-beta/v3/lib/class-acf-to-rest-api-acf-api.php (added)
-
tags/3.0.0-beta/v3/lib/class-acf-to-rest-api-acf-field-settings.php (added)
-
tags/3.0.0-beta/v3/lib/endpoints (added)
-
tags/3.0.0-beta/v3/lib/endpoints/class-acf-to-rest-api-attachments-controller.php (added)
-
tags/3.0.0-beta/v3/lib/endpoints/class-acf-to-rest-api-comments-controller.php (added)
-
tags/3.0.0-beta/v3/lib/endpoints/class-acf-to-rest-api-controller.php (added)
-
tags/3.0.0-beta/v3/lib/endpoints/class-acf-to-rest-api-options-controller.php (added)
-
tags/3.0.0-beta/v3/lib/endpoints/class-acf-to-rest-api-posts-controller.php (added)
-
tags/3.0.0-beta/v3/lib/endpoints/class-acf-to-rest-api-terms-controller.php (added)
-
tags/3.0.0-beta/v3/lib/endpoints/class-acf-to-rest-api-users-controller.php (added)
-
tags/3.0.1-beta (added)
-
tags/3.0.1-beta/class-acf-to-rest-api.php (added)
-
tags/3.0.1-beta/composer.json (added)
-
tags/3.0.1-beta/languages (added)
-
tags/3.0.1-beta/languages/pt_BR.mo (added)
-
tags/3.0.1-beta/legacy (added)
-
tags/3.0.1-beta/legacy/v2 (added)
-
tags/3.0.1-beta/legacy/v2/class-acf-to-rest-api-v2.php (added)
-
tags/3.0.1-beta/legacy/v2/lib (added)
-
tags/3.0.1-beta/legacy/v2/lib/endpoints (added)
-
tags/3.0.1-beta/legacy/v2/lib/endpoints/class-acf-to-rest-api-attachment-controller.php (added)
-
tags/3.0.1-beta/legacy/v2/lib/endpoints/class-acf-to-rest-api-controller.php (added)
-
tags/3.0.1-beta/legacy/v2/lib/endpoints/class-acf-to-rest-api-option-controller.php (added)
-
tags/3.0.1-beta/legacy/v2/lib/endpoints/class-acf-to-rest-api-term-controller.php (added)
-
tags/3.0.1-beta/readme.md (added)
-
tags/3.0.1-beta/readme.txt (added)
-
tags/3.0.1-beta/shared (added)
-
tags/3.0.1-beta/shared/includes (added)
-
tags/3.0.1-beta/shared/includes/admin (added)
-
tags/3.0.1-beta/shared/includes/admin/views (added)
-
tags/3.0.1-beta/shared/includes/admin/views/html-notice-missing-acf.php (added)
-
tags/3.0.1-beta/shared/includes/admin/views/html-notice-missing-rest-api.php (added)
-
tags/3.0.1-beta/shared/includes/admin/views/html-settings-field.php (added)
-
tags/3.0.1-beta/shared/includes/admin/views/html-settings-section.php (added)
-
tags/3.0.1-beta/shared/lib (added)
-
tags/3.0.1-beta/shared/lib/class-acf-to-rest-api-settings.php (added)
-
tags/3.0.1-beta/v3 (added)
-
tags/3.0.1-beta/v3/class-acf-to-rest-api-v3.php (added)
-
tags/3.0.1-beta/v3/lib (added)
-
tags/3.0.1-beta/v3/lib/class-acf-to-rest-api-acf-api.php (added)
-
tags/3.0.1-beta/v3/lib/class-acf-to-rest-api-acf-field-settings.php (added)
-
tags/3.0.1-beta/v3/lib/endpoints (added)
-
tags/3.0.1-beta/v3/lib/endpoints/class-acf-to-rest-api-attachments-controller.php (added)
-
tags/3.0.1-beta/v3/lib/endpoints/class-acf-to-rest-api-comments-controller.php (added)
-
tags/3.0.1-beta/v3/lib/endpoints/class-acf-to-rest-api-controller.php (added)
-
tags/3.0.1-beta/v3/lib/endpoints/class-acf-to-rest-api-options-controller.php (added)
-
tags/3.0.1-beta/v3/lib/endpoints/class-acf-to-rest-api-posts-controller.php (added)
-
tags/3.0.1-beta/v3/lib/endpoints/class-acf-to-rest-api-terms-controller.php (added)
-
tags/3.0.1-beta/v3/lib/endpoints/class-acf-to-rest-api-users-controller.php (added)
-
tags/3.0.2 (added)
-
tags/3.0.2-beta (added)
-
tags/3.0.2-beta/class-acf-to-rest-api.php (added)
-
tags/3.0.2-beta/composer.json (added)
-
tags/3.0.2-beta/languages (added)
-
tags/3.0.2-beta/languages/pt_BR.mo (added)
-
tags/3.0.2-beta/legacy (added)
-
tags/3.0.2-beta/legacy/v2 (added)
-
tags/3.0.2-beta/legacy/v2/class-acf-to-rest-api-v2.php (added)
-
tags/3.0.2-beta/legacy/v2/lib (added)
-
tags/3.0.2-beta/legacy/v2/lib/endpoints (added)
-
tags/3.0.2-beta/legacy/v2/lib/endpoints/class-acf-to-rest-api-attachment-controller.php (added)
-
tags/3.0.2-beta/legacy/v2/lib/endpoints/class-acf-to-rest-api-controller.php (added)
-
tags/3.0.2-beta/legacy/v2/lib/endpoints/class-acf-to-rest-api-option-controller.php (added)
-
tags/3.0.2-beta/legacy/v2/lib/endpoints/class-acf-to-rest-api-term-controller.php (added)
-
tags/3.0.2-beta/readme.md (added)
-
tags/3.0.2-beta/readme.txt (added)
-
tags/3.0.2-beta/shared (added)
-
tags/3.0.2-beta/shared/includes (added)
-
tags/3.0.2-beta/shared/includes/admin (added)
-
tags/3.0.2-beta/shared/includes/admin/views (added)
-
tags/3.0.2-beta/shared/includes/admin/views/html-notice-missing-acf.php (added)
-
tags/3.0.2-beta/shared/includes/admin/views/html-notice-missing-rest-api.php (added)
-
tags/3.0.2-beta/shared/includes/admin/views/html-settings-field.php (added)
-
tags/3.0.2-beta/shared/includes/admin/views/html-settings-section.php (added)
-
tags/3.0.2-beta/shared/lib (added)
-
tags/3.0.2-beta/shared/lib/class-acf-to-rest-api-settings.php (added)
-
tags/3.0.2-beta/v3 (added)
-
tags/3.0.2-beta/v3/class-acf-to-rest-api-v3.php (added)
-
tags/3.0.2-beta/v3/lib (added)
-
tags/3.0.2-beta/v3/lib/class-acf-to-rest-api-acf-api.php (added)
-
tags/3.0.2-beta/v3/lib/class-acf-to-rest-api-acf-field-settings.php (added)
-
tags/3.0.2-beta/v3/lib/endpoints (added)
-
tags/3.0.2-beta/v3/lib/endpoints/class-acf-to-rest-api-attachments-controller.php (added)
-
tags/3.0.2-beta/v3/lib/endpoints/class-acf-to-rest-api-comments-controller.php (added)
-
tags/3.0.2-beta/v3/lib/endpoints/class-acf-to-rest-api-controller.php (added)
-
tags/3.0.2-beta/v3/lib/endpoints/class-acf-to-rest-api-options-controller.php (added)
-
tags/3.0.2-beta/v3/lib/endpoints/class-acf-to-rest-api-posts-controller.php (added)
-
tags/3.0.2-beta/v3/lib/endpoints/class-acf-to-rest-api-terms-controller.php (added)
-
tags/3.0.2-beta/v3/lib/endpoints/class-acf-to-rest-api-users-controller.php (added)
-
tags/3.0.2/class-acf-to-rest-api.php (added)
-
tags/3.0.2/composer.json (added)
-
tags/3.0.2/languages (added)
-
tags/3.0.2/languages/pt_BR.mo (added)
-
tags/3.0.2/legacy (added)
-
tags/3.0.2/legacy/v2 (added)
-
tags/3.0.2/legacy/v2/class-acf-to-rest-api-v2.php (added)
-
tags/3.0.2/legacy/v2/lib (added)
-
tags/3.0.2/legacy/v2/lib/endpoints (added)
-
tags/3.0.2/legacy/v2/lib/endpoints/class-acf-to-rest-api-attachment-controller.php (added)
-
tags/3.0.2/legacy/v2/lib/endpoints/class-acf-to-rest-api-controller.php (added)
-
tags/3.0.2/legacy/v2/lib/endpoints/class-acf-to-rest-api-option-controller.php (added)
-
tags/3.0.2/legacy/v2/lib/endpoints/class-acf-to-rest-api-term-controller.php (added)
-
tags/3.0.2/readme.md (added)
-
tags/3.0.2/readme.txt (added)
-
tags/3.0.2/shared (added)
-
tags/3.0.2/shared/includes (added)
-
tags/3.0.2/shared/includes/admin (added)
-
tags/3.0.2/shared/includes/admin/views (added)
-
tags/3.0.2/shared/includes/admin/views/html-notice-missing-acf.php (added)
-
tags/3.0.2/shared/includes/admin/views/html-notice-missing-rest-api.php (added)
-
tags/3.0.2/shared/includes/admin/views/html-settings-field.php (added)
-
tags/3.0.2/shared/includes/admin/views/html-settings-section.php (added)
-
tags/3.0.2/shared/lib (added)
-
tags/3.0.2/shared/lib/class-acf-to-rest-api-settings.php (added)
-
tags/3.0.2/v3 (added)
-
tags/3.0.2/v3/class-acf-to-rest-api-v3.php (added)
-
tags/3.0.2/v3/lib (added)
-
tags/3.0.2/v3/lib/class-acf-to-rest-api-acf-api.php (added)
-
tags/3.0.2/v3/lib/class-acf-to-rest-api-acf-field-settings.php (added)
-
tags/3.0.2/v3/lib/endpoints (added)
-
tags/3.0.2/v3/lib/endpoints/class-acf-to-rest-api-attachments-controller.php (added)
-
tags/3.0.2/v3/lib/endpoints/class-acf-to-rest-api-comments-controller.php (added)
-
tags/3.0.2/v3/lib/endpoints/class-acf-to-rest-api-controller.php (added)
-
tags/3.0.2/v3/lib/endpoints/class-acf-to-rest-api-options-controller.php (added)
-
tags/3.0.2/v3/lib/endpoints/class-acf-to-rest-api-posts-controller.php (added)
-
tags/3.0.2/v3/lib/endpoints/class-acf-to-rest-api-terms-controller.php (added)
-
tags/3.0.2/v3/lib/endpoints/class-acf-to-rest-api-users-controller.php (added)
-
tags/3.1.0 (added)
-
tags/3.1.0/class-acf-to-rest-api.php (added)
-
tags/3.1.0/composer.json (added)
-
tags/3.1.0/languages (added)
-
tags/3.1.0/languages/pt_BR.mo (added)
-
tags/3.1.0/legacy (added)
-
tags/3.1.0/legacy/v2 (added)
-
tags/3.1.0/legacy/v2/class-acf-to-rest-api-v2.php (added)
-
tags/3.1.0/legacy/v2/lib (added)
-
tags/3.1.0/legacy/v2/lib/endpoints (added)
-
tags/3.1.0/legacy/v2/lib/endpoints/class-acf-to-rest-api-attachment-controller.php (added)
-
tags/3.1.0/legacy/v2/lib/endpoints/class-acf-to-rest-api-controller.php (added)
-
tags/3.1.0/legacy/v2/lib/endpoints/class-acf-to-rest-api-option-controller.php (added)
-
tags/3.1.0/legacy/v2/lib/endpoints/class-acf-to-rest-api-term-controller.php (added)
-
tags/3.1.0/readme.md (added)
-
tags/3.1.0/readme.txt (added)
-
tags/3.1.0/shared (added)
-
tags/3.1.0/shared/includes (added)
-
tags/3.1.0/shared/includes/admin (added)
-
tags/3.1.0/shared/includes/admin/views (added)
-
tags/3.1.0/shared/includes/admin/views/html-notice-missing-acf.php (added)
-
tags/3.1.0/shared/includes/admin/views/html-notice-missing-rest-api.php (added)
-
tags/3.1.0/shared/includes/admin/views/html-settings-field.php (added)
-
tags/3.1.0/shared/includes/admin/views/html-settings-section.php (added)
-
tags/3.1.0/shared/lib (added)
-
tags/3.1.0/shared/lib/class-acf-to-rest-api-settings.php (added)
-
tags/3.1.0/v3 (added)
-
tags/3.1.0/v3/class-acf-to-rest-api-v3.php (added)
-
tags/3.1.0/v3/lib (added)
-
tags/3.1.0/v3/lib/class-acf-to-rest-api-acf-api.php (added)
-
tags/3.1.0/v3/lib/class-acf-to-rest-api-acf-field-settings.php (added)
-
tags/3.1.0/v3/lib/endpoints (added)
-
tags/3.1.0/v3/lib/endpoints/class-acf-to-rest-api-attachments-controller.php (added)
-
tags/3.1.0/v3/lib/endpoints/class-acf-to-rest-api-comments-controller.php (added)
-
tags/3.1.0/v3/lib/endpoints/class-acf-to-rest-api-controller.php (added)
-
tags/3.1.0/v3/lib/endpoints/class-acf-to-rest-api-options-controller.php (added)
-
tags/3.1.0/v3/lib/endpoints/class-acf-to-rest-api-posts-controller.php (added)
-
tags/3.1.0/v3/lib/endpoints/class-acf-to-rest-api-terms-controller.php (added)
-
tags/3.1.0/v3/lib/endpoints/class-acf-to-rest-api-users-controller.php (added)
-
trunk/class-acf-to-rest-api.php (modified) (7 diffs)
-
trunk/composer.json (added)
-
trunk/includes (deleted)
-
trunk/languages/pt_BR.mo (modified) (previous)
-
trunk/legacy (added)
-
trunk/legacy/v2 (added)
-
trunk/legacy/v2/class-acf-to-rest-api-v2.php (added)
-
trunk/legacy/v2/lib (added)
-
trunk/legacy/v2/lib/endpoints (added)
-
trunk/legacy/v2/lib/endpoints/class-acf-to-rest-api-attachment-controller.php (added)
-
trunk/legacy/v2/lib/endpoints/class-acf-to-rest-api-controller.php (added)
-
trunk/legacy/v2/lib/endpoints/class-acf-to-rest-api-option-controller.php (added)
-
trunk/legacy/v2/lib/endpoints/class-acf-to-rest-api-term-controller.php (added)
-
trunk/lib (deleted)
-
trunk/readme.md (modified) (8 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/shared (added)
-
trunk/shared/includes (added)
-
trunk/shared/includes/admin (added)
-
trunk/shared/includes/admin/views (added)
-
trunk/shared/includes/admin/views/html-notice-missing-acf.php (added)
-
trunk/shared/includes/admin/views/html-notice-missing-rest-api.php (added)
-
trunk/shared/includes/admin/views/html-settings-field.php (added)
-
trunk/shared/includes/admin/views/html-settings-section.php (added)
-
trunk/shared/lib (added)
-
trunk/shared/lib/class-acf-to-rest-api-settings.php (added)
-
trunk/v3 (added)
-
trunk/v3/class-acf-to-rest-api-v3.php (added)
-
trunk/v3/lib (added)
-
trunk/v3/lib/class-acf-to-rest-api-acf-api.php (added)
-
trunk/v3/lib/class-acf-to-rest-api-acf-field-settings.php (added)
-
trunk/v3/lib/endpoints (added)
-
trunk/v3/lib/endpoints/class-acf-to-rest-api-attachments-controller.php (added)
-
trunk/v3/lib/endpoints/class-acf-to-rest-api-comments-controller.php (added)
-
trunk/v3/lib/endpoints/class-acf-to-rest-api-controller.php (added)
-
trunk/v3/lib/endpoints/class-acf-to-rest-api-options-controller.php (added)
-
trunk/v3/lib/endpoints/class-acf-to-rest-api-posts-controller.php (added)
-
trunk/v3/lib/endpoints/class-acf-to-rest-api-terms-controller.php (added)
-
trunk/v3/lib/endpoints/class-acf-to-rest-api-users-controller.php (added)
Legend:
- Unmodified
- Added
- Removed
-
acf-to-rest-api/trunk/class-acf-to-rest-api.php
r1461787 r1752896 2 2 /** 3 3 * Plugin Name: ACF to REST API 4 * Description: Exposes Advanced Custom Fields Endpoints in the W P REST API v24 * Description: Exposes Advanced Custom Fields Endpoints in the WordPress REST API 5 5 * Author: Aires Gonçalves 6 6 * Author URI: http://github.com/airesvsg 7 * Version: 2.2.17 * Version: 3.1.0 8 8 * Plugin URI: http://github.com/airesvsg/acf-to-rest-api 9 9 */ … … 17 17 class ACF_To_REST_API { 18 18 19 const VERSION = '2.2.1'; 19 const VERSION = '3.1.0'; 20 21 private static $old_request_version = 2; 22 private static $default_request_version = 3; 23 private static $request_version; 24 25 private static $instance = null; 20 26 21 27 public static function init() { … … 24 30 } 25 31 32 protected static function instance() { 33 if ( is_null( self::$instance ) ) { 34 $class = 'ACF_To_REST_API_V' . self::handle_request_version(); 35 if ( class_exists( $class ) ) { 36 self::$instance = new $class; 37 } 38 } 39 return self::$instance; 40 } 41 26 42 private static function includes() { 43 if ( self::$old_request_version == self::handle_request_version() ) { 44 require_once dirname( __FILE__ ) . '/legacy/v2/class-acf-to-rest-api-v2.php'; 45 } else { 46 require_once dirname( __FILE__ ) . '/v3/class-acf-to-rest-api-v3.php'; 47 } 48 27 49 if ( self::is_plugin_active( 'all' ) ) { 28 require_once dirname( __FILE__ ) . '/lib/endpoints/class-acf-to-rest-api-controller.php';29 require_once dirname( __FILE__ ) . '/lib/endpoints/class-acf-to-rest-api-option-controller.php';30 require_once dirname( __FILE__ ) . '/lib/endpoints/class-acf-to-rest-api-term-controller.php';31 require_once dirname( __FILE__ ) . '/lib/endpoints/class-acf-to-rest-api-attachment-controller.php';50 if ( is_admin() ) { 51 require_once dirname( __FILE__ ) . '/shared/lib/class-acf-to-rest-api-settings.php'; 52 } 53 self::instance()->includes(); 32 54 } 55 } 56 57 public static function handle_request_version() { 58 if ( is_null( self::$request_version ) ) { 59 if ( defined( 'ACF_TO_REST_API_REQUEST_VERSION' ) ) { 60 self::$request_version = (int) ACF_TO_REST_API_REQUEST_VERSION; 61 } else { 62 self::$request_version = (int) get_option( 'acf_to_rest_api_request_version', self::$default_request_version ); 63 } 64 } 65 return self::$request_version; 33 66 } 34 67 35 68 private static function hooks() { 36 69 add_action( 'init', array( __CLASS__, 'load_plugin_textdomain' ) ); 70 37 71 if ( self::is_plugin_active( 'all' ) ) { 38 72 add_action( 'rest_api_init', array( __CLASS__, 'create_rest_routes' ), 10 ); 73 if ( self::$default_request_version == self::handle_request_version() ) { 74 ACF_To_REST_API_ACF_Field_Settings::hooks(); 75 } 39 76 } else { 40 77 add_action( 'admin_notices', array( __CLASS__, 'missing_notice' ) ); 41 78 } 79 42 80 } 43 81 … … 48 86 49 87 public static function create_rest_routes() { 50 $default = array( 'user', 'comment', 'term', 'option' ); 51 $types = get_post_types( array( 'show_in_rest' => true ) ); 52 53 if ( $types && isset( $types['attachment'] ) ) { 54 unset( $types['attachment'] ); 55 $default[] = 'media'; 56 } 57 58 $types = apply_filters( 'acf/rest_api/types', array_merge( $types, array_combine( $default, $default ) ) ); 59 60 if ( is_array( $types ) && count( $types ) > 0 ) { 61 foreach( $types as $type ) { 62 if ( 'term' == $type ) { 63 $controller = new ACF_To_REST_API_Term_Controller( $type ); 64 } elseif ( 'media' == $type ) { 65 $controller = new ACF_To_REST_API_Attachment_Controller( $type ); 66 } elseif ( 'option' == $type ) { 67 $controller = new ACF_To_REST_API_Option_Controller( $type ); 68 } else { 69 $controller = new ACF_To_REST_API_Controller( $type ); 70 } 71 72 $controller->register_routes(); 73 $controller->register_hooks(); 74 } 75 } 88 self::instance()->create_rest_routes(); 76 89 } 77 90 … … 90 103 public static function is_plugin_installed( $plugin ) { 91 104 if ( ! function_exists( 'get_plugins' ) ) { 92 include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 105 include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 93 106 } 94 107 … … 104 117 if ( is_array( $plugins ) && count( $plugins ) > 0 ) { 105 118 foreach ( $paths as $path ) { 106 if ( isset( $plugins[ $path] ) && ! empty( $plugins[$path] ) ) {119 if ( isset( $plugins[ $path ] ) && ! empty( $plugins[ $path ] ) ) { 107 120 return $path; 108 121 } 109 } 122 } 110 123 } 111 124 } … … 115 128 116 129 public static function missing_notice() { 117 if ( ! self::is_plugin_active( 'rest-api' ) ) { 118 include dirname( __FILE__ ) . '/includes/admin/views/html-notice-missing-rest-api.php'; 119 } 120 121 if ( ! self::is_plugin_active( 'acf' ) ) { 122 include dirname( __FILE__ ) . '/includes/admin/views/html-notice-missing-acf.php'; 123 } 130 self::instance()->missing_notice(); 124 131 } 125 132 } -
acf-to-rest-api/trunk/readme.md
r1461787 r1752896 1 1 ACF to REST API 2 2 ==== 3 Exposes [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-fields/) Endpoints in the [W P REST API v2](https://wordpress.org/plugins/rest-api/)3 Exposes [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-fields/) Endpoints in the [WordPress REST API](https://developer.wordpress.org/rest-api/) 4 4 5 5 https://wordpress.org/plugins/acf-to-rest-api/ … … 8 8 - [Endpoints](#endpoints) 9 9 - [Filters](#filters) 10 - [Editing the fields](#editing-the-fields) 11 - [Example](#example) 10 - [Deprecated Filters ](#deprecated-filters) 11 - [Request API Version ](#request-api-version) 12 - [Field Settings ](#field-settings) 13 - [Editing the Fields](#editing-the-fields) 14 - [Examples](#examples) 12 15 - [Cache](#cache) 13 16 … … 22 25 | Endpoint | READABLE | EDITABLE | 23 26 |----------|:--------:|:--------:| 24 | /wp-json/acf/v2/post/**{id}** |  |  | 25 | /wp-json/acf/v2/post/**{id}**/**{field-name}** |  |  | 26 | /wp-json/acf/v2/page/**{id}** |  |  | 27 | /wp-json/acf/v2/page/**{id}**/**{field-name}** |  |  | 28 | /wp-json/acf/v2/user/**{id}** |  |  | 29 | /wp-json/acf/v2/user/**{id}**/**{field-name}** |  |  | 30 | /wp-json/acf/v2/term/**{taxonomy}**/**{id}** |  |  | 31 | /wp-json/acf/v2/term/**{taxonomy}**/**{id}**/**{field-name}** |  |  | 32 | /wp-json/acf/v2/comment/**{id}** |  |  | 33 | /wp-json/acf/v2/comment/**{id}**/**{field-name}** |  |  | 34 | /wp-json/acf/v2/media/**{id}** |  |  | 35 | /wp-json/acf/v2/media/**{id}**/**{field-name}** |  |  | 36 | /wp-json/acf/v2/**{post-type}**/**{id}** |  |  | 37 | /wp-json/acf/v2/**{post-type}**/**{id}**/**{field-name}** |  |  | 38 | /wp-json/acf/v2/options |  |  | 39 | /wp-json/acf/v2/options/**{field-name}** |  |  | 27 | /wp-json/acf/v3/posts  |  |  | 28 | /wp-json/acf/v3/posts/**{id}** |  |  | 29 | /wp-json/acf/v3/posts/**{id}**/**{field-name}** |  |  | 30 | /wp-json/acf/v3/pages  |  |  | 31 | /wp-json/acf/v3/pages/**{id}** |  |  | 32 | /wp-json/acf/v3/pages/**{id}**/**{field-name}** |  |  | 33 | /wp-json/acf/v3/users  |  |  | 34 | /wp-json/acf/v3/users/**{id}** |  |  | 35 | /wp-json/acf/v3/users/**{id}**/**{field-name}** |  |  | 36 | /wp-json/acf/v3/**{taxonomy}**  |  |  | 37 | /wp-json/acf/v3/**{taxonomy}**/**{id}**  |  |  | 38 | /wp-json/acf/v3/**{taxonomy}**/**{id}**/**{field-name}**  |  |  | 39 | /wp-json/acf/v3/comments  |  |  | 40 | /wp-json/acf/v3/comments/**{id}** |  |  | 41 | /wp-json/acf/v3/comments/**{id}**/**{field-name}** |  |  | 42 | /wp-json/acf/v3/media  |  |  | 43 | /wp-json/acf/v3/media/**{id}** |  |  | 44 | /wp-json/acf/v3/media/**{id}**/**{field-name}** |  |  | 45 | /wp-json/acf/v3/**{post-type}**  |  |  | 46 | /wp-json/acf/v3/**{post-type}**/**{id}**  |  |  | 47 | /wp-json/acf/v3/**{post-type}**/**{id}**/**{field-name}**  |  |  | 48 | /wp-json/acf/v3/options/**{id}**  |  |  | 49 | /wp-json/acf/v3/options/**{id}**/**{field-name}**  |  |  | 40 50 41 51 Filters … … 43 53 | Filter | Argument(s) | 44 54 |-----------|-----------| 45 | acf/rest_api/types | array **$types** | 46 | acf/rest_api/type | string **$type** | 47 | acf/rest_api/id | mixed ( string, integer, boolean ) **$id** | 55 | acf/rest_api/id | mixed ( string, integer, boolean ) **$id**<br>string **$type** <br>string **$controller**  | 48 56 | acf/rest_api/key | string **$key**<br>WP_REST_Request **$request**<br>string **$type** | 49 57 | acf/rest_api/item_permissions/get | boolean **$permission**<br>WP_REST_Request **$request**<br>string **$type** | 50 58 | acf/rest_api/item_permissions/update | boolean **$permission**<br>WP_REST_Request **$request**<br>string **$type** | 59 | acf/rest_api/**{type}**/prepare_item | mixed ( array, boolean ) **$item**<br>WP_REST_Request **$request** | 60 | acf/rest_api/**{type}**/get_fields | mixed ( array, WP_REST_Request ) **$data**<br>mixed ( WP_REST_Request, NULL ) **$request** | 61 | acf/rest_api/field_settings/show_in_rest  | boolean **$show** | 62 | acf/rest_api/field_settings/edit_in_rest  | boolean **$edit** | 63 64 Basic example of how to use the filters, in this case I will set a new permission to get the fields 65 ```PHP 66 add_filter( 'acf/rest_api/item_permissions/get', function( $permission ) { 67 return current_user_can( 'edit_posts' ); 68 } ); 69 ``` 70 71 Deprecated filters 72 ==== 73 | Filter | Argument(s) | 74 |-----------|-----------| 75 | acf/rest_api/type | string **$type** | 76 | acf/rest_api/types | array **$types** | 51 77 | acf/rest_api/default_rest_base | boolean **$default**<br>string **$type** | 52 | acf/rest_api/**{type}**/prepare_item | mixed ( array, boolean ) **$item**<br>WP_REST_Request **$request** |53 | acf/rest_api/**{type}**/get_fields | mixed ( array, WP_REST_Request ) **$data**<br>mixed ( WP_REST_Request, NULL ) **$request**<br>mixed ( WP_REST_Response, NULL ) **$response**<br>mixed ( WP_Post, WP_Term, WP_User, NULL ) **$object** |54 78 55 If you do not want edit/show the fields of posts. So, you must use the filter `acf/rest_api/types` 79 Request API version 80 ==== 81 See below how to select the Request API Version. 82 83 1. Open the plugins page; 84 2. Click the settings link under the pluing name ( `ACF to REST API` ); 85 3. Select your version in the `ACF to REST API` session; 86 4. Click in the button Save changes. 87 88  89 90 The other alternative is to define the constant `ACF_TO_REST_API_REQUEST_VERSION` in your `wp-config.php` 56 91 57 92 ```PHP 58 add_filter( 'acf/rest_api/types', function( $types ) { 59 if ( array_key_exists( 'post', $types ) ) { 60 unset( $types['post'] ); 61 } 93 define( 'ACF_TO_REST_API_REQUEST_VERSION', 2 ); 94 ``` 62 95 63 return $types; 64 } ); 96 Field Settings 97 ==== 98 In this version is possible to configure the field options via admin. 99 100 The options are enabled using the filters below, by default theses options are disabled. 101 102 ```PHP 103 // Enable the option show in rest 104 add_filter( 'acf/rest_api/field_settings/show_in_rest', '__return_true' ); 105 106 // Enable the option edit in rest 107 add_filter( 'acf/rest_api/field_settings/edit_in_rest', '__return_true' ); 65 108 ``` 109 110 After you activate the filters, all your fields should show these options: 111  112 66 113 67 114 Editing the fields … … 69 116 The fields should be sent into the key `fields`. 70 117 71 118  72 119 73 **Action:** http://localhost/wp-json/acf/v 2/post/1120 **Action:** http://localhost/wp-json/acf/v3/posts/1 74 121 75 122 ```HTML 76 <form action="http://localhost/wp-json/acf/v 2/post/1" method="POST">77 <?php78 // http://v2.wp-api.org/guide/authentication 79 wp_nonce_field( 'wp_rest' );80 ?>81 <label>Site: <input type="text" name="fields[site]"></label>82 <button type="submit">Save</button>123 <form action="http://localhost/wp-json/acf/v3/posts/1" method="POST"> 124 <?php 125 // https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/ 126 wp_nonce_field( 'wp_rest' ); 127 ?> 128 <label>Site: <input type="text" name="fields[site]"></label> 129 <button type="submit">Save</button> 83 130 </form> 84 131 ``` … … 88 135 ```HTML 89 136 <form action="http://localhost/wp-json/wp/v2/posts/1" method="POST"> 90 <?php91 // http://v2.wp-api.org/guide/authentication 92 wp_nonce_field( 'wp_rest' );93 ?>94 <label>Title: <input type="text" name="title"></label>95 <h3>ACF</h3>96 <label>Site: <input type="text" name="fields[site]"></label>97 <button type="submit">Save</button>137 <?php 138 // https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/ 139 wp_nonce_field( 'wp_rest' ); 140 ?> 141 <label>Title: <input type="text" name="title"></label> 142 <h3>ACF</h3> 143 <label>Site: <input type="text" name="fields[site]"></label> 144 <button type="submit">Save</button> 98 145 </form> 99 146 ``` … … 103 150 ```PHP 104 151 add_filter( 'acf/rest_api/key', function( $key, $request, $type ) { 105 return 'acf_fields';152 return 'acf_fields'; 106 153 }, 10, 3 ); 107 154 ``` … … 110 157 111 158 ```HTML 112 <form action="http://localhost/wp-json/acf/v 2/post/1" method="POST">113 <?php114 // http://v2.wp-api.org/guide/authentication 115 wp_nonce_field( 'wp_rest' );116 ?>117 <label>Site: <input type="text" name="acf_fields[site]"></label>118 <button type="submit">Save</button>159 <form action="http://localhost/wp-json/acf/v3/posts/1" method="POST"> 160 <?php 161 // https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/ 162 wp_nonce_field( 'wp_rest' ); 163 ?> 164 <label>Site: <input type="text" name="acf_fields[site]"></label> 165 <button type="submit">Save</button> 119 166 </form> 120 167 ``` 121 168 122 Example 169 Examples 123 170 ==== 124 171 Sample theme to edit the ACF Fields. 125 172 126 173 https://github.com/airesvsg/acf-to-rest-api-example 174 175 To-do list  176 177 https://github.com/airesvsg/to-do-list-acf-to-rest-api 127 178 128 179 Cache -
acf-to-rest-api/trunk/readme.txt
r1548410 r1752896 2 2 Contributors: airesvsg 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=airesvsg%40gmail%2ecom&lc=BR&item_name=Aires%20Goncalves&no_note=0¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest 4 Tags: acf, api, rest, wp-api, wp-rest-api, json, wp, wordpress, wp-rest-api 5 Requires at least: 4. 36 Tested up to: 4. 77 Stable tag: 2.2.14 Tags: acf, api, rest, wp-api, wp-rest-api, json, wp, wordpress, wp-rest-api, wordpress-rest-api 5 Requires at least: 4.6 6 Tested up to: 4.8.2 7 Stable tag: 3.1.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 Exposes Advanced Custom Fields Endpoints in the W P REST API v211 Exposes Advanced Custom Fields Endpoints in the WordPress REST API 12 12 13 13 == Description == 14 Exposes [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-fields/) Endpoints in the [W P REST API v2](https://wordpress.org/plugins/rest-api/)14 Exposes [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-fields/) Endpoints in the [WordPress REST API](https://developer.wordpress.org/rest-api/) 15 15 16 16 **See details on GitHub:** http://github.com/airesvsg/acf-to-rest-api … … 21 21 22 22 == Changelog == 23 24 = 3.1.0 = 25 fix indentation 26 removing unnecessary code 27 removing anonymous function 28 29 = 3.0.2 = 30 stable version 31 32 = 3.0.2-beta = 33 adding fallback to get_fields 34 changing default value to acf field setting 35 36 = 3.0.1-beta = 37 fix default params bug 38 39 = 3.0.0-beta = 40 more readable endpoints ( https://github.com/airesvsg/acf-to-rest-api/issues/46 ) - Thanks to Imaginet 41 change return when acf filed key is empty ( https://github.com/airesvsg/acf-to-rest-api/issues/48 ) - Thanks to Joris Verbogt 42 multiple custom options pages ( https://github.com/airesvsg/acf-to-rest-api/issues/85 ) - Thanks to Alex Patton 43 bugfix ACF key in taxonomy ( https://github.com/airesvsg/acf-to-rest-api/issues/43 ) - Thanks to Cesar Denis 44 depreacted filter acf/rest_api/type 45 depreacted filter acf/rest_api/types 46 depreacted filter acf/rest_api/default_rest_base 23 47 24 48 = 2.2.1 =
Note: See TracChangeset
for help on using the changeset viewer.