forked from airesvsg/acf-to-wp-rest-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acf-to-wp-rest-api.php
47 lines (35 loc) · 1.23 KB
/
acf-to-wp-rest-api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* Plugin Name: ACF to WP REST API
* Description: Get all ACF fields in WP REST API responses.
* Author: Aires Gonçalves
* Author URI: http://github.com/airesvsg
* Version: 1.3
* Plugin URI: http://github.com/airesvsg/acf-to-wp-rest-api
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'ACF_To_WP_REST_API' ) ) {
class ACF_To_WP_REST_API {
private static $CLASSES = array( 'base', 'post', 'page', 'user', 'term', 'comment', 'attachment', 'options', 'custom-post-type' );
public function __construct() {
add_action( 'init', array( $this, 'includes' ), 90 );
}
public function includes() {
if ( ! class_exists( 'ACF_to_REST_API' ) ) {
add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
}
foreach ( self::$CLASSES as $class ) {
require_once "includes/classes/class-acf-to-wp-rest-api-{$class}.php";
}
}
public static function admin_notices() {
include_once 'includes/admin/views/html-notice-upgrade.php';
}
}
}
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if ( is_plugin_active( 'advanced-custom-fields/acf.php' ) || is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) || is_plugin_active( 'acf-pro/acf.php' ) ) {
new ACF_To_WP_REST_API();
}