-
Notifications
You must be signed in to change notification settings - Fork 0
/
sof-videos.php
206 lines (166 loc) · 4.06 KB
/
sof-videos.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?php
/**
* SOF Videos
*
* Plugin Name: SOF Videos
* Description: Provides a Video post type which can be embedded in a standard post and has its own navigable archives.
* Plugin URI: https://github.com/spiritoffootball/sof-videos
* GitHub Plugin URI: https://github.com/spiritoffootball/sof-videos
* Version: 1.0.0a
* Author: Christian Wach
* Author URI: https://haystack.co.uk
* Text Domain: sof-videos
* Domain Path: /languages
*
* @package Spirit_Of_Football_Videos
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
// Set our version here.
define( 'SOF_VIDEOS_VERSION', '1.0.0a' );
// Store reference to this file.
if ( ! defined( 'SOF_VIDEOS_FILE' ) ) {
define( 'SOF_VIDEOS_FILE', __FILE__ );
}
// Store URL to this plugin's directory.
if ( ! defined( 'SOF_VIDEOS_URL' ) ) {
define( 'SOF_VIDEOS_URL', plugin_dir_url( SOF_VIDEOS_FILE ) );
}
// Store PATH to this plugin's directory.
if ( ! defined( 'SOF_VIDEOS_PATH' ) ) {
define( 'SOF_VIDEOS_PATH', plugin_dir_path( SOF_VIDEOS_FILE ) );
}
/**
* SOF Videos Class.
*
* A class that encapsulates the functionality of this plugin.
*
* @since 0.1
*/
class Spirit_Of_Football_Videos {
/**
* Custom Post Type object.
*
* @since 0.1
* @access public
* @var Spirit_Of_Football_Videos_CPT
*/
public $cpt;
/**
* Metaboxes object.
*
* @since 0.1
* @access public
* @var Spirit_Of_Football_Videos_Metaboxes
*/
public $metaboxes;
/**
* Shortcodes object.
*
* @since 0.1
* @access public
* @var Spirit_Of_Football_Videos_Shortcodes
*/
public $shortcodes;
/**
* Constructor.
*
* @since 0.1
*/
public function __construct() {
// Bootstrap plugin.
$this->include_files();
$this->setup_globals();
$this->register_hooks();
}
/**
* Include files.
*
* @since 0.1
*/
public function include_files() {
// Include class files.
include_once SOF_VIDEOS_PATH . 'includes/sof-videos-cpt.php';
include_once SOF_VIDEOS_PATH . 'includes/sof-videos-metaboxes.php';
include_once SOF_VIDEOS_PATH . 'includes/sof-videos-shortcodes.php';
}
/**
* Set up objects.
*
* @since 0.1
*/
public function setup_globals() {
// Instantiate objects.
$this->cpt = new Spirit_Of_Football_Videos_CPT();
$this->metaboxes = new Spirit_Of_Football_Videos_Metaboxes();
$this->shortcodes = new Spirit_Of_Football_Videos_Shortcodes();
}
/**
* Register WordPress hooks.
*
* @since 0.1
*/
public function register_hooks() {
// Use translation.
add_action( 'plugins_loaded', [ $this, 'translation' ] );
// Hooks that always need to be present.
$this->cpt->register_hooks();
$this->metaboxes->register_hooks();
$this->shortcodes->register_hooks();
}
/**
* Actions to perform on plugin activation.
*
* @since 0.1
*/
public function activate() {
// Pass through.
$this->cpt->activate();
}
/**
* Actions to perform on plugin deactivation NOT deletion.
*
* @since 0.1
*/
public function deactivate() {
// Pass through.
$this->cpt->deactivate();
}
/**
* Loads translations.
*
* @since 0.1
*/
public function translation() {
// Load translations.
// phpcs:ignore WordPress.WP.DeprecatedParameters.Load_plugin_textdomainParam2Found
load_plugin_textdomain(
'sof-videos', // Unique name.
false, // Deprecated argument.
dirname( plugin_basename( SOF_VIDEOS_FILE ) ) . '/languages/' // Relative path to files.
);
}
}
/**
* Utility to get a reference to this plugin.
*
* @since 0.1
*
* @return Spirit_Of_Football_Videos $plugin The plugin reference.
*/
function spirit_of_football_videos() {
// Store instance in static variable.
static $plugin = false;
// Maybe return instance.
if ( false === $plugin ) {
$plugin = new Spirit_Of_Football_Videos();
}
// --<
return $plugin;
}
// Initialise plugin now.
spirit_of_football_videos();
// Activation.
register_activation_hook( __FILE__, [ spirit_of_football_videos(), 'activate' ] );
// Deactivation.
register_deactivation_hook( __FILE__, [ spirit_of_football_videos(), 'deactivate' ] );