forked from chrisblakley/Nebula
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnebula.php
More file actions
120 lines (102 loc) · 4.47 KB
/
nebula.php
File metadata and controls
120 lines (102 loc) · 4.47 KB
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
<?php
if ( !defined('ABSPATH') ){ exit; } //Exit if accessed directly
if ( !class_exists('Nebula') ){
require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once ABSPATH . 'wp-admin/includes/file.php';
//Require Nebula libraries
require_once get_template_directory() . '/libs/Assets.php';
require_once get_template_directory() . '/libs/Options/Options.php';
require_once get_template_directory() . '/libs/Utilities/Utilities.php';
require_once get_template_directory() . '/libs/Options/Customizer.php';
require_once get_template_directory() . '/libs/Security.php';
require_once get_template_directory() . '/libs/Optimization.php';
require_once get_template_directory() . '/libs/Functions.php';
require_once get_template_directory() . '/libs/Comments.php';
require_once get_template_directory() . '/libs/Shortcodes.php';
require_once get_template_directory() . '/libs/Gutenberg/Gutenberg.php';
require_once get_template_directory() . '/libs/Widgets.php';
require_once get_template_directory() . '/libs/Admin/Admin.php';
require_once get_template_directory() . '/libs/Ecommerce.php';
require_once get_template_directory() . '/libs/Aliases.php';
require_once get_template_directory() . '/libs/Legacy/Legacy.php'; //Backwards compatibility
//Main Nebula class
class Nebula {
use Assets { Assets::hooks as AssetsHooks; }
use Options { Options::hooks as OptionsHooks; }
use Utilities { Utilities::hooks as UtilitiesHooks; }
use Customizer { Customizer::hooks as CustomizerHooks; }
use Security { Security::hooks as SecurityHooks; }
use Optimization { Optimization::hooks as OptimizationHooks; }
use Functions { Functions::hooks as FunctionsHooks; }
use Comments { Comments::hooks as CommentsHooks; }
use Shortcodes { Shortcodes::hooks as ShortcodesHooks; }
use Gutenberg { Gutenberg::hooks as GutenbergHooks; }
use Widgets { Widgets::hooks as WidgetsHooks; }
use Admin { Admin::hooks as AdminHooks; }
use Ecommerce { Ecommerce::hooks as EcommerceHooks; }
use Legacy { Legacy::hooks as LegacyHooks; }
private static $instance;
public $plugins = array();
//Get active instance
public static function instance(){
if ( !self::$instance ){
self::$instance = new Nebula();
self::$instance->constants();
self::$instance->variables();
self::$instance->hooks();
}
return self::$instance;
}
//Setup plugin constants
private function constants(){
define('NEBULA_VER', $this->version('raw')); //Nebula version
define('NEBULA_DIR', get_template_directory()); //Nebula path
define('NEBULA_URL', get_template_directory_uri()); //Nebula URL
}
//Set variables
private function variables(){
$this->time_before_nebula = microtime(true); //Prep the time before Nebula begins
global $content_width;
//$content_width is a global variable used by WordPress for max image upload sizes and media embeds (in pixels).
//If the content area is 960px wide, set $content_width = 940; so images and videos will not overflow.
if ( !isset($content_width) ){
$content_width = 710;
}
}
//Run action and filter hooks
private function hooks(){
//Adjust the content width when the full width page template is being used
add_action('template_redirect', array($this, 'set_content_width'));
$this->AssetsHooks(); //Register Assets hooks
$this->OptionsHooks(); //Register Options hooks
$this->UtilitiesHooks(); //Register Utilities hooks
$this->SecurityHooks(); //Register Security hooks
$this->OptimizationHooks(); //Register Optimization hooks
$this->CustomizerHooks(); //Register Customizer hooks
$this->FunctionsHooks(); //Register Functions hooks
$this->CommentsHooks(); //Register Comments hooks
$this->ShortcodesHooks(); //Register Shortcodes hooks
$this->GutenbergHooks(); //Register Gutenberg hooks
$this->WidgetsHooks(); //Register Widgets hooks
if ( $this->is_admin_page() || is_admin_bar_showing() || $this->is_login_page() ){
$this->AdminHooks(); //Register Admin hooks
}
if ( is_plugin_active('woocommerce/woocommerce.php') ){
$this->EcommerceHooks(); //Register Ecommerce hooks
}
}
public function set_content_width(){
$override = apply_filters('pre_nebula_set_content_width', false);
if ( $override !== false ){return $override;}
global $content_width;
if ( is_page_template('fullwidth.php') ){
$content_width = 1040;
}
}
}
}
//The main function responsible for returning Nebula instance
add_action('init', 'nebula', 1);
function nebula(){
return Nebula::instance();
}