forked from cedaro/wprestcop
-
Notifications
You must be signed in to change notification settings - Fork 2
/
wprestcop.php
80 lines (73 loc) · 1.89 KB
/
wprestcop.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
<?php
/**
* WP REST Cop
*
* @package Cedaro\WPRESTCop
* @copyright Copyright (c) 2015 Cedaro, LLC
* @license GPL-2.0+
*
* @wordpress-plugin
* Plugin Name: WP REST Cop
* Plugin URI: https://github.com/cedaro/wprestcop
* Description: Manage access to the WP REST API.
* Version: 1.0.0
* Author: Cedaro
* Author URI: http://www.cedaro.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wprestcop
* Domain Path: /languages
*/
use Cedaro\WPRESTCop\IPRules;
use Cedaro\WPRESTCop\Plugin;
include( __DIR__ . '/php/AbstractPlugin.php' );
include( __DIR__ . '/php/Plugin.php' );
include( __DIR__ . '/php/IPRulesInterface.php' );
include( __DIR__ . '/php/IPRules.php' );
include( __DIR__ . '/php/Meter.php' );
include( __DIR__ . '/php/MeterMaid.php' );
/**
* Retrieve the main plugin instance.
*
* @since 1.0.0
*
* @return \Cedaro\WPRESTCop\Plugin
*/
function wprestcop() {
static $instance;
if ( null === $instance ) {
$instance = new Plugin( new IPRules() );
}
return $instance;
}
$wprestcop = wprestcop()
->set_basename( plugin_basename( __FILE__ ) )
->set_directory( plugin_dir_path( __FILE__ ) )
->set_file( __FILE__ )
->set_slug( 'wprestcop' )
->set_url( plugin_dir_url( __FILE__ ) );
/**
* Register WP CLI commands.
*/
if ( defined( 'WP_CLI' ) && WP_CLI ) {
include( __DIR__ . '/php/CLI.php' );
$wprestcop->initialize_ip_rules();
WP_CLI::add_command( 'restcop', '\Cedaro\WPRESTCop\CLI' );
}
/**
* Localize the plugin.
*
* @since 1.0.0
*/
add_action( 'plugins_loaded', function() use ( $wprestcop ) {
$plugin_rel_path = dirname( $wprestcop->get_basename() ) . '/languages';
load_plugin_textdomain( $wprestcop->get_slug(), false, $plugin_rel_path );
} );
/**
* Load the plugin when the REST API is initialized.
*
* @since 1.0.0
*/
add_action( 'rest_api_init', function() use ( $wprestcop ) {
$wprestcop->load();
}, 5 );