This repository has been archived by the owner on Mar 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pods-rest-api.php
120 lines (96 loc) · 3.44 KB
/
pods-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
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
110
111
112
113
114
115
116
117
118
119
120
<?php
/*
Plugin Name: Pods REST API
Plugin URI: http://pods.io/
Description: Extends the WordPress REST API for Pods
Version: 0.0.1
Author: Pods Framework Team
Author URI: http://pods.io/about/
Text Domain: pods-rest-api
Domain Path: /languages/
GitHub Plugin URI: https://github.com/pods-rest-api/pods
GitHub Branch: master
Copyright 2015 Pods Foundation, Inc (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* The current version of this plugin.
*
* @since 0.0.1
*/
define( 'PODS_REST_API_VERSION', '0.0.1' );
/**
* The minimum supported version of Pods
*
* @todo Make this 2.5.2 or later
*
* @since 0.0.1
*/
define( 'PODS_REST_API_MIN_PODS_VERSION', '2.5.1.2' );
if ( ! defined( 'PODS_REST_API_ENABLE_DEFAULT_ROUTES' ) ) {
/**
* Enable default routes
*
* Set as false in wp-config or anywhere before plugins_loaded to disable default routes.
*
* @since 0.0.1
*/
define( 'PODS_REST_API_ENABLE_DEFAULT_ROUTES', true );
}
if ( ! defined( 'PODS_REST_API_BASE_URL' ) ) {
/**
* Sets the base URL for API.
*
* This is the first segment(s) after the base prefix for WP REST API. Default is "Pods", can be overridden in wp-config.php or anytime before plugins_loaded
*
* @since 0.0.1
*/
define( 'PODS_REST_API_BASE_URL', 'pods' );
}
/**
* Load the plugin if dependencies are met.
*/
add_action( 'plugins_loaded', 'pods_rest_api_maybe_load' );
function pods_rest_api_maybe_load() {
$fail = false;
if ( ! defined( 'PODS_VERSION' ) ) {
$fail[] = __( 'Pods REST API requires Pods.', 'pods-rest-api' );
}
if ( ! class_exists( 'WP_JSON_Posts_Controller' ) ) {
$fail[] = __( 'Pods REST API requires the core WordPress REST API be active.', 'pods-rest-api' );
}
if ( ! is_array( $fail ) ) {
if ( ! version_compare( PODS_VERSION, PODS_REST_API_MIN_PODS_VERSION, '>=' ) ) {
$fail[] = __( sprintf( 'Pods REST API requires Pods version %1s or later. Current version is %2s.', PODS_REST_API_MIN_PODS_VERSION, PODS_VERSION ), 'pods-rest-api' );
}
if ( ! version_compare( PHP_VERSION, '5.3.0', '>=' ) ) {
$fail[] = __( sprintf( 'Pods REST API requires PHP version %1s or later. Current version is %2s.', '5.3.0', PHP_VERSION ), 'pods-rest-api' );
}
}
if ( is_array( $fail ) ) {
if ( is_admin() ) {
foreach ( $fail as $message ) {
echo sprintf( '<div id="message" class="error"><p>%s</p></div>',
$message
);
}
}
return false;
}
include_once( dirname( __FILE__ ) . '/classes/class-pods-rest-api.php' );
include_once( dirname( __FILE__ ) . '/classes/class-pods-rest-api-controller.php' );
include_once( dirname( __FILE__ ) . '/classes/class-pods-rest-api-response-controller.php' );
include_once( dirname( __FILE__ ) . '/classes/class-pods-api-request-params.php' );
include_once( dirname( __FILE__ ) . '/includes/functions.php' );
new Pods_REST_API();
}