-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathacf-api-fields.php
More file actions
109 lines (83 loc) · 2.24 KB
/
Copy pathacf-api-fields.php
File metadata and controls
109 lines (83 loc) · 2.24 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/*
Plugin Name: Advanced Custom Fields: API Fields
Plugin URI: https://github.com/lucasstark/acf-api-fields
Description: WP Rest API Object and Relationship Fields
Version: 0.0.2
Author: Lucas Stark
Author URI: http://www.github.com/lucasstark/
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
load_plugin_textdomain( 'acf-wp-rest-api-fields', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
class ACF_API_Fields_Main {
private static $instance;
public static function register() {
if ( self::$instance == null ) {
self::$instance = new ACF_API_Fields_Main();
}
}
/**
*
* @return ACF_API_Fields_Main
*/
public static function instance() {
self::register();
return self::$instance;
}
/**
* Version string for JS and CSS.
* @var string
*/
private $_assets_version = '1.0.0';
/**
*
* @var ACF_API_Fields_API
*/
public $api;
private function __construct() {
add_action('plugins_loaded', array($this, 'on_plugins_loaded'));
add_action( 'acf/include_field_types', array($this, 'include_field_types') );
}
public function on_plugins_loaded() {
//I know these names are really long, I'll refactor later.
require_once 'inc/models/class-acf-api-fields-model-post.php';
require_once 'inc/class-acf-api-fields-api.php';
$this->api = new ACF_API_Fields_API();
}
public function include_field_types( $version ) {
//require_once('inc/acf-wp-rest-api-fields-object.php');
require_once('inc/fields/class-acf-api-fields-field-relationship.php');
}
/**
* Gets the static asset version or a random string if SCRIPT_DEBUG is enabled.
* @return string
*/
public function assets_version() {
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
//return time();
return $this->_assets_version;
} else {
return $this->_assets_version;
}
}
public function plugin_url() {
return plugin_dir_url( __FILE__ );
}
/**
* Get the plugin path.
* @access public
* @return string
*/
public function plugin_dir() {
return untrailingslashit( plugin_dir_path( __FILE__ ) );
}
}
ACF_API_Fields_Main::register();
/**
*
* @return ACF_API_Fields_Main
*/
function ACF_API_Fields() {
return ACF_API_Fields_Main::instance();
}