-
Notifications
You must be signed in to change notification settings - Fork 25
/
simple-jwt-authentication.php
executable file
·129 lines (102 loc) · 2.73 KB
/
simple-jwt-authentication.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
121
122
123
124
125
126
127
128
129
<?php
/**
* Plugin Name: Simple JWT Authentication
* Plugin URI: http://github.com/jonathan-dejong/simple-jwt-authentication
* Description: Extends the WP REST API using JSON Web Tokens Authentication as an authentication method.
* Version: 1.4.0
* Author: Jonathan de Jong
* Author URI: http://github.com/jonathan-dejong
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
* Text Domain: simple-jwt-authentication
* Domain Path: /languages
*
* @since 1.0
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
class Simple_Jwt_Authentication {
protected $plugin_name;
protected $plugin_version;
/**
* Initialize the class and set its properties.
*
* @since 1.0
*/
public function __construct() {
$this->plugin_name = 'simple-jwt-authentication';
$this->plugin_version = '1.4.0';
// Load all dependency files.
$this->load_dependencies();
// Activation hook
register_activation_hook( __FILE__, array( $this, 'activate' ) );
// Deactivation hook
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
// Localization
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
}
/**
* Loads all dependencies in our plugin.
*
* @since 1.0
*/
public function load_dependencies() {
// Load all Composer dependencies
$this->include_file( 'vendor/autoload.php' );
$this->include_file( 'class-simple-jwt-authentication-api.php' );
// Admin specific includes
if ( is_admin() ) {
$this->include_file( 'admin/class-simple-jwt-authentication-settings.php' );
$this->include_file( 'admin/class-simple-jwt-authentication-profile.php' );
}
$this->include_file( 'class-simple-jwt-authentication-rest.php' );
}
/**
* Includes a single file located inside /includes.
*
* @param string $path relative path to /includes
* @since 1.0
*/
private function include_file( $path ) {
$plugin_name = $this->plugin_name;
$plugin_version = $this->plugin_version;
$includes_dir = trailingslashit( plugin_dir_path( __FILE__ ) . 'includes' );
if ( file_exists( $includes_dir . $path ) ) {
include_once $includes_dir . $path;
}
}
/**
* The code that runs during plugin activation.
*
* @since 1.0
*/
public function activate() {
}
/**
* The code that runs during plugin deactivation.
*
* @since 1.0
*/
public function deactivate() {
}
/**
* Load the plugin text domain for translation.
*
* @since 1.0
*/
public function load_textdomain() {
load_plugin_textdomain(
'simple-jwt-authentication',
false,
basename( dirname( __FILE__ ) ) . '/languages/'
);
}
}
/**
* Begins execution of the plugin.
*
* @since 1.0
*/
new Simple_Jwt_Authentication();