-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli-tools-for-sof.php
executable file
·101 lines (81 loc) · 2.05 KB
/
cli-tools-for-sof.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
<?php
/**
* Plugin Name: Command Line Tools for Spirit of Football
* Plugin URI: https://github.com/spiritoffootball/cli-tools-for-sof
* GitHub Plugin URI: https://github.com/spiritoffootball/cli-tools-for-sof
* Description: Manage aspects of the Spirit of Football website through the command line.
* Author: Christian Wach
* Version: 1.0.0
* Author URI: https://haystack.co.uk
*
* @package Command_Line_Tools_For_SOF
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
// Set our version here.
define( 'COMMAND_LINE_SOF_VERSION', '1.0.0' );
// Store reference to this file.
if ( ! defined( 'COMMAND_LINE_SOF_FILE' ) ) {
define( 'COMMAND_LINE_SOF_FILE', __FILE__ );
}
// Store URL to this plugin's directory.
if ( ! defined( 'COMMAND_LINE_SOF_URL' ) ) {
define( 'COMMAND_LINE_SOF_URL', plugin_dir_url( COMMAND_LINE_SOF_FILE ) );
}
// Store PATH to this plugin's directory.
if ( ! defined( 'COMMAND_LINE_SOF_PATH' ) ) {
define( 'COMMAND_LINE_SOF_PATH', plugin_dir_path( COMMAND_LINE_SOF_FILE ) );
}
/**
* Command Line Tools for SOF Class.
*
* A class that encapsulates plugin functionality.
*
* @since 1.0.0
*/
class Command_Line_Tools_For_SOF {
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct() {
// Load wp-cli tools.
$this->include_files();
}
/**
* Loads the wp-cli tools.
*
* @since 1.0.0
*/
public function include_files() {
// Bail if not wp-cli context.
if ( ! defined( 'WP_CLI' ) ) {
return;
}
// Bail if not PHP 5.6+.
if ( ! version_compare( phpversion(), '5.6.0', '>=' ) ) {
return;
}
// Load our wp-cli tools.
require COMMAND_LINE_SOF_PATH . 'includes/wp-cli-sof.php';
}
}
/**
* Bootstrap plugin if not yet loaded and returns reference.
*
* @since 1.0.0
*
* @return Command_Line_Tools_for_SOF $plugin The plugin reference.
*/
function command_line_sof() {
// Maybe bootstrap plugin.
static $plugin;
if ( ! isset( $plugin ) ) {
$plugin = new Command_Line_Tools_For_SOF();
}
// Return reference.
return $plugin;
}
// Bootstrap immediately.
command_line_sof();