-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathPluginHeader.php
60 lines (47 loc) · 992 Bytes
/
PluginHeader.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
<?php
namespace AC\Plugin;
class PluginHeader {
const AUTHOR = 'AuthorName';
const DESCRIPTION = 'Description';
const NAME = 'Name';
const PLUGIN_URI = 'PluginURI';
const REQUIRES_PHP = 'RequiresPHP';
const REQUIRES_WP = 'RequiresWP';
const TITLE = 'Title';
const VERSION = 'Version';
/**
* @var string
*/
private $file;
public function __construct( $file ) {
$this->file = (string) $file;
}
/**
* @param string $var
*
* @return string|null
*/
public function get( $var ) {
$data = $this->get_data();
return isset( $data[ $var ] )
? (string) $data[ $var ]
: null;
}
/**
* @return Version
*/
public function get_version() {
return new Version( (string) $this->get( self::VERSION ) );
}
/**
* @return array
*/
private function get_data() {
static $data = null;
require_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( null === $data ) {
$data = get_plugin_data( $this->file, false, false );
}
return $data;
}
}