Version Description
adding rest base support adding new filter acf/rest_api/default_rest_base
Download this release
Release Info
Developer | airesvsg |
Plugin | ACF to REST API |
Version | 2.1.0 |
Comparing to | |
See all releases |
Code changes from version 2.0.7 to 2.1.0
- class-acf-to-rest-api.php +2 -2
- includes/admin/views/html-notice-missing-acf.php +27 -27
- includes/admin/views/html-notice-missing-rest-api.php +27 -27
- lib/endpoints/class-acf-to-rest-api-attachment-controller.php +14 -14
- lib/endpoints/class-acf-to-rest-api-controller.php +22 -8
- lib/endpoints/class-acf-to-rest-api-option-controller.php +8 -3
- lib/endpoints/class-acf-to-rest-api-term-controller.php +60 -44
- readme.md +2 -1
- readme.txt +5 -1
class-acf-to-rest-api.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Description: Edit, Get and Puts ACF fields in WordPress REST API.
|
5 |
* Author: Aires Gonçalves
|
6 |
* Author URI: http://github.com/airesvsg
|
7 |
-
* Version: 2.0
|
8 |
* Plugin URI: http://github.com/airesvsg/acf-to-rest-api
|
9 |
*/
|
10 |
|
@@ -16,7 +16,7 @@ if ( ! class_exists( 'ACF_To_REST_API' ) ) {
|
|
16 |
|
17 |
class ACF_To_REST_API {
|
18 |
|
19 |
-
const VERSION = '2.0
|
20 |
|
21 |
public static function init() {
|
22 |
self::includes();
|
4 |
* Description: Edit, Get and Puts ACF fields in WordPress REST API.
|
5 |
* Author: Aires Gonçalves
|
6 |
* Author URI: http://github.com/airesvsg
|
7 |
+
* Version: 2.1.0
|
8 |
* Plugin URI: http://github.com/airesvsg/acf-to-rest-api
|
9 |
*/
|
10 |
|
16 |
|
17 |
class ACF_To_REST_API {
|
18 |
|
19 |
+
const VERSION = '2.1.0';
|
20 |
|
21 |
public static function init() {
|
22 |
self::includes();
|
includes/admin/views/html-notice-missing-acf.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
$is_installed = ACF_To_REST_API::is_plugin_installed( 'acf' );
|
8 |
-
|
9 |
-
$target = false;
|
10 |
-
$action = __( 'Install', 'acf-to-rest-api' );
|
11 |
-
if ( current_user_can( 'install_plugins' ) ) {
|
12 |
-
if ( $is_installed ) {
|
13 |
-
$action = __( 'Active', 'acf-to-rest-api' );
|
14 |
-
$url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . $is_installed . '&plugin_status=active' ), 'activate-plugin_' . $is_installed );
|
15 |
-
} else {
|
16 |
-
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=advanced-custom-fields' ), 'install-plugin_advanced-custom-fields' );
|
17 |
-
}
|
18 |
-
} else {
|
19 |
-
$target = true;
|
20 |
-
$url = 'http://wordpress.org/plugins/advanced-custom-fields/';
|
21 |
-
}
|
22 |
-
|
23 |
-
?>
|
24 |
-
|
25 |
-
<div class="notice error is-dismissible">
|
26 |
-
<p><strong><?php esc_html_e( 'ACF to REST API', 'act-to-rest-api' ); ?></strong> <?php esc_html_e( 'depends on the last version of Advanced Custom Fields to work!', 'acf-to-rest-api' ); ?></p>
|
27 |
-
<p><a href="<?php echo esc_url( $url ); ?>" class="button button-primary"<?php if ( $target ) : ?> target="_blank"<?php endif; ?>><?php esc_html_e( $action . ' Advanced Custom Fields', 'acf-to-rest-api' ); ?></a></p>
|
28 |
</div>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
$is_installed = ACF_To_REST_API::is_plugin_installed( 'acf' );
|
8 |
+
|
9 |
+
$target = false;
|
10 |
+
$action = __( 'Install', 'acf-to-rest-api' );
|
11 |
+
if ( current_user_can( 'install_plugins' ) ) {
|
12 |
+
if ( $is_installed ) {
|
13 |
+
$action = __( 'Active', 'acf-to-rest-api' );
|
14 |
+
$url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . $is_installed . '&plugin_status=active' ), 'activate-plugin_' . $is_installed );
|
15 |
+
} else {
|
16 |
+
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=advanced-custom-fields' ), 'install-plugin_advanced-custom-fields' );
|
17 |
+
}
|
18 |
+
} else {
|
19 |
+
$target = true;
|
20 |
+
$url = 'http://wordpress.org/plugins/advanced-custom-fields/';
|
21 |
+
}
|
22 |
+
|
23 |
+
?>
|
24 |
+
|
25 |
+
<div class="notice error is-dismissible">
|
26 |
+
<p><strong><?php esc_html_e( 'ACF to REST API', 'act-to-rest-api' ); ?></strong> <?php esc_html_e( 'depends on the last version of Advanced Custom Fields to work!', 'acf-to-rest-api' ); ?></p>
|
27 |
+
<p><a href="<?php echo esc_url( $url ); ?>" class="button button-primary"<?php if ( $target ) : ?> target="_blank"<?php endif; ?>><?php esc_html_e( $action . ' Advanced Custom Fields', 'acf-to-rest-api' ); ?></a></p>
|
28 |
</div>
|
includes/admin/views/html-notice-missing-rest-api.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
$is_installed = ACF_To_REST_API::is_plugin_installed( 'rest-api' );
|
8 |
-
|
9 |
-
$target = false;
|
10 |
-
$action = __( 'Install', 'acf-to-rest-api' );
|
11 |
-
if ( current_user_can( 'install_plugins' ) ) {
|
12 |
-
if ( $is_installed ) {
|
13 |
-
$action = __( 'Active', 'acf-to-rest-api' );
|
14 |
-
$url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=rest-api/plugin.php&plugin_status=active' ), 'activate-plugin_rest-api/plugin.php' );
|
15 |
-
} else {
|
16 |
-
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=rest-api' ), 'install-plugin_rest-api' );
|
17 |
-
}
|
18 |
-
} else {
|
19 |
-
$target = true;
|
20 |
-
$url = 'http://wordpress.org/plugins/rest-api/';
|
21 |
-
}
|
22 |
-
|
23 |
-
?>
|
24 |
-
|
25 |
-
<div class="notice error is-dismissible">
|
26 |
-
<p><strong><?php esc_html_e( 'ACF to REST API', 'act-to-rest-api' ); ?></strong> <?php esc_html_e( 'depends on the last version of WordPress REST API to work!', 'acf-to-rest-api' ); ?></p>
|
27 |
-
<p><a href="<?php echo esc_url( $url ); ?>" class="button button-primary"<?php if ( $target ) : ?> target="_blank"<?php endif; ?>><?php esc_html_e( $action . ' WordPress REST API', 'acf-to-rest-api' ); ?></a></p>
|
28 |
</div>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
$is_installed = ACF_To_REST_API::is_plugin_installed( 'rest-api' );
|
8 |
+
|
9 |
+
$target = false;
|
10 |
+
$action = __( 'Install', 'acf-to-rest-api' );
|
11 |
+
if ( current_user_can( 'install_plugins' ) ) {
|
12 |
+
if ( $is_installed ) {
|
13 |
+
$action = __( 'Active', 'acf-to-rest-api' );
|
14 |
+
$url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=rest-api/plugin.php&plugin_status=active' ), 'activate-plugin_rest-api/plugin.php' );
|
15 |
+
} else {
|
16 |
+
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=rest-api' ), 'install-plugin_rest-api' );
|
17 |
+
}
|
18 |
+
} else {
|
19 |
+
$target = true;
|
20 |
+
$url = 'http://wordpress.org/plugins/rest-api/';
|
21 |
+
}
|
22 |
+
|
23 |
+
?>
|
24 |
+
|
25 |
+
<div class="notice error is-dismissible">
|
26 |
+
<p><strong><?php esc_html_e( 'ACF to REST API', 'act-to-rest-api' ); ?></strong> <?php esc_html_e( 'depends on the last version of WordPress REST API to work!', 'acf-to-rest-api' ); ?></p>
|
27 |
+
<p><a href="<?php echo esc_url( $url ); ?>" class="button button-primary"<?php if ( $target ) : ?> target="_blank"<?php endif; ?>><?php esc_html_e( $action . ' WordPress REST API', 'acf-to-rest-api' ); ?></a></p>
|
28 |
</div>
|
lib/endpoints/class-acf-to-rest-api-attachment-controller.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'ACF_To_REST_API_Attachment_Controller' ) ) {
|
8 |
-
class ACF_To_REST_API_Attachment_Controller extends ACF_To_REST_API_Controller {
|
9 |
-
public function register_hooks() {
|
10 |
-
$this->type = 'attachment';
|
11 |
-
parent::register_hooks();
|
12 |
-
}
|
13 |
-
}
|
14 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'ACF_To_REST_API_Attachment_Controller' ) ) {
|
8 |
+
class ACF_To_REST_API_Attachment_Controller extends ACF_To_REST_API_Controller {
|
9 |
+
public function register_hooks() {
|
10 |
+
$this->type = 'attachment';
|
11 |
+
parent::register_hooks();
|
12 |
+
}
|
13 |
+
}
|
14 |
+
}
|
lib/endpoints/class-acf-to-rest-api-controller.php
CHANGED
@@ -13,17 +13,19 @@ if ( ! class_exists( 'ACF_To_REST_API_Controller' ) ) {
|
|
13 |
|
14 |
public function __construct( $type ) {
|
15 |
$this->type = apply_filters( 'acf/rest_api/type', $type );
|
|
|
|
|
16 |
}
|
17 |
|
18 |
public function register_hooks() {
|
19 |
if ( $this->type ) {
|
20 |
-
add_filter(
|
21 |
-
add_action(
|
22 |
}
|
23 |
}
|
24 |
|
25 |
public function register_routes() {
|
26 |
-
register_rest_route( '
|
27 |
array(
|
28 |
'methods' => WP_REST_Server::READABLE,
|
29 |
'callback' => array( $this, 'get_item' ),
|
@@ -37,12 +39,24 @@ if ( ! class_exists( 'ACF_To_REST_API_Controller' ) ) {
|
|
37 |
) );
|
38 |
}
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
public function get_item( $request ) {
|
41 |
return $this->get_fields( $request );
|
42 |
}
|
43 |
|
44 |
public function get_item_permissions_check( $request ) {
|
45 |
-
return apply_filters(
|
46 |
}
|
47 |
|
48 |
public function rest_prepare( $response, $post, $request ) {
|
@@ -50,7 +64,7 @@ if ( ! class_exists( 'ACF_To_REST_API_Controller' ) ) {
|
|
50 |
}
|
51 |
|
52 |
public function update_item_permissions_check( $request ) {
|
53 |
-
return apply_filters(
|
54 |
}
|
55 |
|
56 |
public function update_item( $request ) {
|
@@ -73,7 +87,7 @@ if ( ! class_exists( 'ACF_To_REST_API_Controller' ) ) {
|
|
73 |
return new WP_REST_Response( $this->get_fields( $request ), 200 );
|
74 |
}
|
75 |
|
76 |
-
return new WP_Error( 'cant_update_item', __(
|
77 |
}
|
78 |
|
79 |
public function rest_insert( $object, $request, $creating ) {
|
@@ -109,7 +123,7 @@ if ( ! class_exists( 'ACF_To_REST_API_Controller' ) ) {
|
|
109 |
}
|
110 |
}
|
111 |
|
112 |
-
return apply_filters(
|
113 |
}
|
114 |
|
115 |
protected function get_id( $object ) {
|
@@ -196,7 +210,7 @@ if ( ! class_exists( 'ACF_To_REST_API_Controller' ) ) {
|
|
196 |
$data = $response;
|
197 |
}
|
198 |
|
199 |
-
return apply_filters(
|
200 |
}
|
201 |
|
202 |
protected function get_field_objects( $id ) {
|
13 |
|
14 |
public function __construct( $type ) {
|
15 |
$this->type = apply_filters( 'acf/rest_api/type', $type );
|
16 |
+
$this->namespace = 'acf/v2';
|
17 |
+
$this->rest_base = $this->get_rest_base( $this->type );
|
18 |
}
|
19 |
|
20 |
public function register_hooks() {
|
21 |
if ( $this->type ) {
|
22 |
+
add_filter( 'rest_prepare_' . $this->type, array( $this, 'rest_prepare' ), 10, 3 );
|
23 |
+
add_action( 'rest_insert_' . $this->type, array( $this, 'rest_insert' ), 10, 3 );
|
24 |
}
|
25 |
}
|
26 |
|
27 |
public function register_routes() {
|
28 |
+
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
29 |
array(
|
30 |
'methods' => WP_REST_Server::READABLE,
|
31 |
'callback' => array( $this, 'get_item' ),
|
39 |
) );
|
40 |
}
|
41 |
|
42 |
+
protected function get_rest_base( $type ) {
|
43 |
+
global $wp_post_types;
|
44 |
+
|
45 |
+
$default = apply_filters( 'acf/rest_api/default_rest_base', ! in_array( $type, array( 'post', 'page' ) ), $type );
|
46 |
+
|
47 |
+
if ( $default && isset( $wp_post_types[$type] ) && isset( $wp_post_types[$type]->rest_base ) ) {
|
48 |
+
return $wp_post_types[$type]->rest_base;
|
49 |
+
}
|
50 |
+
|
51 |
+
return $type;
|
52 |
+
}
|
53 |
+
|
54 |
public function get_item( $request ) {
|
55 |
return $this->get_fields( $request );
|
56 |
}
|
57 |
|
58 |
public function get_item_permissions_check( $request ) {
|
59 |
+
return apply_filters( 'acf/rest_api/item_permissions/get', true, $request, $this->type );
|
60 |
}
|
61 |
|
62 |
public function rest_prepare( $response, $post, $request ) {
|
64 |
}
|
65 |
|
66 |
public function update_item_permissions_check( $request ) {
|
67 |
+
return apply_filters( 'acf/rest_api/item_permissions/update', current_user_can( 'edit_posts' ), $request, $this->type );
|
68 |
}
|
69 |
|
70 |
public function update_item( $request ) {
|
87 |
return new WP_REST_Response( $this->get_fields( $request ), 200 );
|
88 |
}
|
89 |
|
90 |
+
return new WP_Error( 'cant_update_item', __( 'Cannot update item', 'acf-to-rest-api' ), array( 'status' => 500 ) );
|
91 |
}
|
92 |
|
93 |
public function rest_insert( $object, $request, $creating ) {
|
123 |
}
|
124 |
}
|
125 |
|
126 |
+
return apply_filters( 'acf/rest_api/' . $this->type . '/prepare_item', $item, $request );
|
127 |
}
|
128 |
|
129 |
protected function get_id( $object ) {
|
210 |
$data = $response;
|
211 |
}
|
212 |
|
213 |
+
return apply_filters( 'acf/rest_api/' . $this->type . '/get_fields', $data, $request, $response, $object );
|
214 |
}
|
215 |
|
216 |
protected function get_field_objects( $id ) {
|
lib/endpoints/class-acf-to-rest-api-option-controller.php
CHANGED
@@ -6,8 +6,13 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
6 |
|
7 |
if ( ! class_exists( 'ACF_To_REST_API_Option_Controller' ) ) {
|
8 |
class ACF_To_REST_API_Option_Controller extends ACF_To_REST_API_Controller {
|
|
|
|
|
|
|
|
|
|
|
9 |
public function register_routes() {
|
10 |
-
register_rest_route( '
|
11 |
array(
|
12 |
'methods' => WP_REST_Server::READABLE,
|
13 |
'callback' => array( $this, 'get_item' ),
|
@@ -20,7 +25,7 @@ if ( ! class_exists( 'ACF_To_REST_API_Option_Controller' ) ) {
|
|
20 |
),
|
21 |
) );
|
22 |
|
23 |
-
register_rest_route( '
|
24 |
array(
|
25 |
'methods' => WP_REST_Server::READABLE,
|
26 |
'callback' => array( $this, 'get_item' ),
|
@@ -53,7 +58,7 @@ if ( ! class_exists( 'ACF_To_REST_API_Option_Controller' ) ) {
|
|
53 |
if ( $name ) {
|
54 |
$value = get_field( $name, $this->type );
|
55 |
$data = array( $name => $value );
|
56 |
-
return apply_filters(
|
57 |
}
|
58 |
}
|
59 |
|
6 |
|
7 |
if ( ! class_exists( 'ACF_To_REST_API_Option_Controller' ) ) {
|
8 |
class ACF_To_REST_API_Option_Controller extends ACF_To_REST_API_Controller {
|
9 |
+
public function __construct( $type ) {
|
10 |
+
parent::__construct( $type );
|
11 |
+
$this->rest_base = 'options';
|
12 |
+
}
|
13 |
+
|
14 |
public function register_routes() {
|
15 |
+
register_rest_route( $this->namespace, '/' . $this->rest_base, array(
|
16 |
array(
|
17 |
'methods' => WP_REST_Server::READABLE,
|
18 |
'callback' => array( $this, 'get_item' ),
|
25 |
),
|
26 |
) );
|
27 |
|
28 |
+
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<name>[\w\-\_]+)', array(
|
29 |
array(
|
30 |
'methods' => WP_REST_Server::READABLE,
|
31 |
'callback' => array( $this, 'get_item' ),
|
58 |
if ( $name ) {
|
59 |
$value = get_field( $name, $this->type );
|
60 |
$data = array( $name => $value );
|
61 |
+
return apply_filters( 'acf/rest_api/' . $this->type . '/get_fields', $data, $request, $response, $object );
|
62 |
}
|
63 |
}
|
64 |
|
lib/endpoints/class-acf-to-rest-api-term-controller.php
CHANGED
@@ -1,44 +1,60 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'ACF_To_REST_API_Term_Controller' ) ) {
|
8 |
-
class ACF_To_REST_API_Term_Controller extends ACF_To_REST_API_Controller {
|
9 |
-
public function register_routes() {
|
10 |
-
register_rest_route( '
|
11 |
-
array(
|
12 |
-
'methods' => WP_REST_Server::READABLE,
|
13 |
-
'callback' => array( $this, 'get_item' ),
|
14 |
-
'permission_callback' => array( $this, 'get_item_permissions_check' ),
|
15 |
-
),
|
16 |
-
array(
|
17 |
-
'methods' => WP_REST_Server::EDITABLE,
|
18 |
-
'callback' => array( $this, 'update_item' ),
|
19 |
-
'permission_callback' => array( $this, 'update_item_permissions_check' ),
|
20 |
-
),
|
21 |
-
) );
|
22 |
-
}
|
23 |
-
|
24 |
-
public function get_item( $request ) {
|
25 |
-
if (
|
26 |
-
return parent::get_item( $request );
|
27 |
-
}
|
28 |
-
|
29 |
-
return new WP_Error( 'rest_no_route', __( 'No route was found matching the URL and request method', 'acf-to-rest-api' ), array( 'status' => 404 ) );
|
30 |
-
}
|
31 |
-
|
32 |
-
protected
|
33 |
-
global $wp_taxonomies;
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'ACF_To_REST_API_Term_Controller' ) ) {
|
8 |
+
class ACF_To_REST_API_Term_Controller extends ACF_To_REST_API_Controller {
|
9 |
+
public function register_routes() {
|
10 |
+
register_rest_route( $this->namespace, '/' . $this->type . '/(?P<taxonomy>[\w\-\_]+)/(?P<id>[\d]+)', array(
|
11 |
+
array(
|
12 |
+
'methods' => WP_REST_Server::READABLE,
|
13 |
+
'callback' => array( $this, 'get_item' ),
|
14 |
+
'permission_callback' => array( $this, 'get_item_permissions_check' ),
|
15 |
+
),
|
16 |
+
array(
|
17 |
+
'methods' => WP_REST_Server::EDITABLE,
|
18 |
+
'callback' => array( $this, 'update_item' ),
|
19 |
+
'permission_callback' => array( $this, 'update_item_permissions_check' ),
|
20 |
+
),
|
21 |
+
) );
|
22 |
+
}
|
23 |
+
|
24 |
+
public function get_item( $request ) {
|
25 |
+
if ( $this->show( $request ) ) {
|
26 |
+
return parent::get_item( $request );
|
27 |
+
}
|
28 |
+
|
29 |
+
return new WP_Error( 'rest_no_route', __( 'No route was found matching the URL and request method', 'acf-to-rest-api' ), array( 'status' => 404 ) );
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function get_rest_base( $request ) {
|
33 |
+
global $wp_taxonomies;
|
34 |
+
|
35 |
+
$taxonomy = false;
|
36 |
+
if ( $request instanceof WP_REST_Request ) {
|
37 |
+
$taxonomy = $request->get_param( 'taxonomy' );
|
38 |
+
}
|
39 |
+
|
40 |
+
if ( $taxonomy && ! array_key_exists( $taxonomy, $wp_taxonomies ) ) {
|
41 |
+
foreach( $wp_taxonomies as $tax_key => $tax_value ) {
|
42 |
+
if ( isset( $tax_value->rest_base ) && $taxonomy == $tax_value->rest_base ) {
|
43 |
+
$request->set_param( 'taxonomy', $tax_key );
|
44 |
+
return $tax_key;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
return $taxonomy;
|
50 |
+
}
|
51 |
+
|
52 |
+
protected function show( $object ) {
|
53 |
+
global $wp_taxonomies;
|
54 |
+
|
55 |
+
$taxonomy = $this->get_rest_base( $request );
|
56 |
+
|
57 |
+
return $taxonomy && isset( $wp_taxonomies[$taxonomy]->show_in_rest ) && $wp_taxonomies[$taxonomy]->show_in_rest;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
readme.md
CHANGED
@@ -38,6 +38,7 @@ Filters
|
|
38 |
| acf/rest_api/key | string **$key**<br>WP_REST_Request **$request**<br>string **$type** |
|
39 |
| acf/rest_api/item_permissions/get | boolean **$permission**<br>WP_REST_Request **$request**<br>string **$type** |
|
40 |
| acf/rest_api/item_permissions/update | boolean **$permission**<br>WP_REST_Request **$request**<br>string **$type** |
|
|
|
41 |
| acf/rest_api/**{type}**/prepare_item | mixed ( array, boolean ) **$item**<br>WP_REST_Request **$request** |
|
42 |
| 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** |
|
43 |
|
@@ -112,4 +113,4 @@ Example
|
|
112 |
====
|
113 |
Sample theme to edit the ACF Fields.
|
114 |
|
115 |
-
https://github.com/airesvsg/acf-to-rest-api-example
|
38 |
| acf/rest_api/key | string **$key**<br>WP_REST_Request **$request**<br>string **$type** |
|
39 |
| acf/rest_api/item_permissions/get | boolean **$permission**<br>WP_REST_Request **$request**<br>string **$type** |
|
40 |
| acf/rest_api/item_permissions/update | boolean **$permission**<br>WP_REST_Request **$request**<br>string **$type** |
|
41 |
+
| acf/rest_api/default_rest_base | boolean **$default**<br>string **$type** |
|
42 |
| acf/rest_api/**{type}**/prepare_item | mixed ( array, boolean ) **$item**<br>WP_REST_Request **$request** |
|
43 |
| 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** |
|
44 |
|
113 |
====
|
114 |
Sample theme to edit the ACF Fields.
|
115 |
|
116 |
+
https://github.com/airesvsg/acf-to-rest-api-example
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: airesvsg
|
|
3 |
Tags: acf, api, rest, wp-api, wp-rest-api, json, wp, wordpress, wp-rest-api
|
4 |
Requires at least: 4.3
|
5 |
Tested up to: 4.4
|
6 |
-
Stable tag: 2.0
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -22,6 +22,10 @@ http://github.com/airesvsg/acf-to-rest-api
|
|
22 |
|
23 |
== Changelog ==
|
24 |
|
|
|
|
|
|
|
|
|
25 |
= 2.0.7 =
|
26 |
bugfix when create a new item
|
27 |
|
3 |
Tags: acf, api, rest, wp-api, wp-rest-api, json, wp, wordpress, wp-rest-api
|
4 |
Requires at least: 4.3
|
5 |
Tested up to: 4.4
|
6 |
+
Stable tag: 2.1.0
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
22 |
|
23 |
== Changelog ==
|
24 |
|
25 |
+
= 2.1.0 =
|
26 |
+
adding rest base support
|
27 |
+
adding new filter acf/rest_api/default_rest_base
|
28 |
+
|
29 |
= 2.0.7 =
|
30 |
bugfix when create a new item
|
31 |
|