PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 15.3.2
Jetpack – WP Security, Backup, Speed, & Growth v15.3.2
12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 14.4.2 All 500 releases
jetpack / _inc / lib / core-api / load-wpcom-endpoints.php
load-wpcom-endpoints.php
63 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Loader for WP REST API endpoints that are synced with WP.com.
4 *
5 * On WP.com see:
6 * - wp-content/mu-plugins/rest-api.php
7 * - wp-content/rest-api-plugins/jetpack-endpoints/
8 *
9 * @package automattic/jetpack
10 */
11
12 /**
13 * Disable direct access.
14 */
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit( 0 );
17 }
18
19 /**
20 * Loop through endpoint files and load them.
21 *
22 * @param string $file_pattern Path pattern to the endpoints (pattern must be supported by glob()).
23 */
24 function wpcom_rest_api_v2_load_plugin_files( $file_pattern ) {
25 $plugins = glob( __DIR__ . '/' . $file_pattern );
26
27 if ( ! is_array( $plugins ) ) {
28 return;
29 }
30
31 foreach ( array_filter( $plugins, 'is_file' ) as $plugin ) {
32 require_once $plugin;
33 }
34 }
35
36 /**
37 * API v2 plugins: define a class, then call this function.
38 *
39 * @param string $class_name The name of the class to load.
40 */
41 function wpcom_rest_api_v2_load_plugin( $class_name ) {
42 global $wpcom_rest_api_v2_plugins;
43
44 if ( ! isset( $wpcom_rest_api_v2_plugins ) ) {
45 $wpcom_rest_api_v2_plugins = array();
46 }
47
48 if ( ! isset( $wpcom_rest_api_v2_plugins[ $class_name ] ) ) {
49 $wpcom_rest_api_v2_plugins[ $class_name ] = new $class_name();
50 }
51 }
52
53 require __DIR__ . '/class-wpcom-rest-field-controller.php';
54
55 /**
56 * Load the REST API v2 plugin files during the plugins_loaded action.
57 */
58 function load_wpcom_rest_api_v2_plugin_files() {
59 wpcom_rest_api_v2_load_plugin_files( 'wpcom-endpoints/*.php' );
60 wpcom_rest_api_v2_load_plugin_files( 'wpcom-fields/*.php' );
61 }
62 add_action( 'plugins_loaded', 'load_wpcom_rest_api_v2_plugin_files' );
63