-
Notifications
You must be signed in to change notification settings - Fork 0
/
xkcd_embedder.php
68 lines (54 loc) · 1.97 KB
/
xkcd_embedder.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
<?php
/*
Plugin Name: XKCD Embedder
Plugin URI: https://profiles.wordpress.org/jsulz
Description: A plugin to add your favorite comics from XKCD
Author: Jared Sulzdorf
Version: 1.0.0
Author URI: https://profiles.wordpress.org/jsulz
*/
// Peace out if you're trying to access this up front
if( ! defined( 'ABSPATH' ) ) exit;
//If this class don't exist, make it so
if( ! class_exists( 'XKCD_Embedder' ) ) {
class XKCD_Embedder {
private static $instance;
//the magic
public static function instance() {
if( ! self::$instance ) {
self::$instance = new XKCD_Embedder();
self::$instance->plugin_constants();
self::$instance->plugin_requires();
self::$instance->xkcd_embedder_load_plugin_textdomain();
}
return self::$instance;
}
//the constants (folders and such)
public function plugin_constants() {
define('XKCD_EMBEDDER_FOLDER', plugin_dir_path( __FILE__ ));
define('XKCD_EMBEDDER_INC', trailingslashit(XKCD_EMBEDDER_FOLDER . 'inc'));
define('XKCD_EMBEDDER_CSS', XKCD_EMBEDDER_FOLDER . 'css');
define('XKCD_EMBEDDER_SHORTCODES', XKCD_EMBEDDER_INC . 'shortcodes.php');
define('XKCD_EMBEDDER_SCRIPTS', XKCD_EMBEDDER_INC . 'scripts.php');
define('XKCD_EMBEDDER_WIDGET', XKCD_EMBEDDER_INC . 'widget.php');
define('XKCD_EMBEDDER_CLIENT', XKCD_EMBEDDER_INC . 'client.php');
}
//the files
public function plugin_requires() {
require(XKCD_EMBEDDER_SHORTCODES);
require(XKCD_EMBEDDER_SCRIPTS);
require(XKCD_EMBEDDER_WIDGET);
require(XKCD_EMBEDDER_CLIENT);
}
//in case someone wants to translate stuff
public function xkcd_embedder_load_plugin_textdomain() {
load_plugin_textdomain( 'xkcd_embedder', FALSE, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
}
}
//get this show on the road
function xkcd_embedder() {
return XKCD_Embedder::instance();
}
add_action( 'plugins_loaded', 'xkcd_embedder' );
?>