-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsf-adminbar-tools.php
104 lines (89 loc) · 2.17 KB
/
sf-adminbar-tools.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
<?php
/**
* Plugin Name: SF Admin Bar Tools
* Plugin URI: https://www.screenfeed.fr/sf-abt/
* Description: Adds some small development tools to the admin bar.
* Version: 4.0
* Requires PHP: 5.6
* Author: Grégory Viguier
* Author URI: https://www.screenfeed.fr/greg/
* License: GPLv3
* License URI: https://www.screenfeed.fr/gpl-v3.txt
* Text Domain: sf-adminbar-tools
* Domain Path: /languages/
* php version 5.2
*
* @package Screenfeed/sf-adminbar-tools
*/
defined( 'ABSPATH' ) || exit; // @phpstan-ignore-line
define( 'SFABT_VERSION', '4.0' );
add_action( 'plugins_loaded', 'sfabt_plugin_init' );
/**
* Initializes the plugin.
*
* @since 4.0.0
*
* @return void
*/
function sfabt_plugin_init() {
// Nothing to do during autosave.
if ( defined( 'DOING_AUTOSAVE' ) ) {
return;
}
$plugin_dir = plugin_dir_path( __FILE__ );
$plugin_name = 'SF Admin Bar Tools';
// Check for WordPress and PHP version.
require_once $plugin_dir . '/src/class-sfabt-requirements-check.php';
$requirement_checks = new SFABT_Requirements_Check(
array(
'plugin_name' => $plugin_name,
'plugin_version' => SFABT_VERSION,
'wp_version' => '4.7',
'php_version' => '5.6',
)
);
if ( ! $requirement_checks->check() ) {
$requirement_checks->add_notice();
return;
}
// Init the plugin.
require_once $plugin_dir . '/src/classes/Plugin.php';
$plugin = call_user_func(
array( 'Screenfeed\AdminbarTools\Plugin', 'construct' ),
array(
'plugin_file' => __FILE__,
'plugin_name' => $plugin_name,
)
);
$plugin->init();
}
/**
* Returns the user capacity required to operate the plugin.
*
* @since 4.0.0
*
* @return string A user capacity or user role.
*/
function sfabt_get_user_capacity() {
static $cap;
if ( isset( $cap ) ) {
return $cap;
}
if ( defined( 'SFABT_CAP' ) && is_string( SFABT_CAP ) && '' !== SFABT_CAP ) {
$cap = SFABT_CAP;
} else {
$cap = 'administrator';
}
return $cap;
}
/**
* Loads the plugin translations.
* Previously named `sfabt_lang_init()`.
*
* @since 4.0.0
*
* @return void
*/
function sfabt_load_translations() {
load_plugin_textdomain( 'sf-adminbar-tools', false, basename( dirname( __FILE__ ) ) . '/languages/' );
}