-
Notifications
You must be signed in to change notification settings - Fork 0
/
fulcrum.php
executable file
·208 lines (164 loc) · 5.53 KB
/
fulcrum.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
207
208
<?php
/**
*
* @package Fulcrum
* @version 1.0
*/
namespace D\FULCRUM;
/*
* Plugin Name: Fulcrum - Helper Tool
* Plugin URI: https://duffion.com
* Description: This is the custom built tool that allows for modular helper tools for Fulcrum Synced sites
* Version: 1.0
* Author: Chris "Duffs" Crevling
* Text Domain: fulcrum-pos
* Author URI: https://duffion.com
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('ABSPATH')) exit; // Exit if accessed directly
if (!class_exists('D_FULCRUM')) :
// Load in global vars //
$d_plugin_dirs = [];
$d_modules = [];
class D_FULCRUM
{
var $version = '1.0';
public $settings = [];
public $modules = [];
private $updater = [];
public $dirs = [
'partials' => 'templates/partials',
'modules' => 'inc/modules',
'inc' => 'inc',
'traits' => 'inc/traits',
'vendors' => 'inc/vendors',
'assets' => 'assets',
'scripts' => 'assets/js',
'styles' => 'assets/css',
'templates' => 'templates',
'modules' => 'inc/modules',
'templates-modules' => 'templates/modules',
];
// [ 'filename without php' => 'name of dir from above config' ] //
private $_loading = [
'core' => 'inc',
'enqueue' => 'inc'
];
private $instance = [];
/**
* __construct - []
*
*/
function __construct()
{
$this->_define();
}
function _git_updater()
{
require $this->dirs['plugin'] . '/' . $this->dirs['vendors'] . '/plugin-update-checkers/plugin-update-checker.php';
$config = [
'git' => 'https://github.com/Duffion/d-plugin-fulcrum/',
'target_branch' => 'production'
];
$this->updater = \Puc_v4_Factory::buildUpdateChecker(
$config['git'],
__FILE__,
'fulcrum'
);
//Set the branch that contains the stable release.
$this->updater->setBranch($config['target_branch']);
}
/**
* _load - []
* We need to load in all the required core files / traits
*/
function _load()
{
global $d_instance, $d_loaded;
// Lets create a global instance to make sure we only load items not already loaded //
$d_loaded = [];
$d_instance = (!isset($d_instance) ? [] : $d_instance);
$this->_define();
require_once $this->dirs['plugin'] . '/' . $this->dirs['inc'] . '/util.php';
require_once $this->dirs['plugin'] . '/' . $this->dirs['traits'] . '/d-primary.php';
require_once $this->dirs['plugin'] . '/' . $this->dirs['traits'] . '/d-templates.php';
require_once $this->dirs['plugin'] . '/' . $this->dirs['inc'] . '/d-crons.php';
require_once $this->dirs['plugin'] . '/' . $this->dirs['inc'] . '/vendors.php';
$this->_git_updater();
// Lets now load in our other flies with the util loader //
if ($this->_loading && count($this->_loading) > 0) {
foreach ($this->_loading as $file => $dir_name) {
$file_loc = (isset($this->dirs[$dir_name]) ? $this->dirs['plugin'] . '/' . $this->dirs[$dir_name] . '/' . $file . '.php' : false);
if ($file_loc) d_req($file_loc);
$this->instance['loaded'] = $d_loaded;
}
}
}
/**
* _define - []
*
*/
function _define($r = false)
{
global $d_plugin_dirs;
$this->dirs['plugin'] = rtrim(plugin_dir_path(__FILE__), '/');
$d_plugin_dirs = $this->dirs;
}
/**
* init - []
*
*/
function init()
{
// Load in any needed configs or passable globals here so loaded items can use properly //
// Lets manually load in our starting files //
$this->_load();
// Do anything extra after we have loaded in the core //
$this->register_plugin_hooks();
}
function register_plugin_hooks()
{
// on activate //
register_activation_hook(__FILE__, 'activate_plugin');
// on deactivate //
register_deactivation_hook(__FILE__, 'deactivate_plugin');
}
function deactivate_plugin()
{
// we need to remove all cron jobs this plugin has registered //
global $d__crons;
$d__crons->unschedule_hooks();
// remove all plugin option data //
$options = [
'fulcrum_adp_categories',
'fulcrum_adp_published',
'fulcrum_ic_logs',
'fulcrum_ic_reset',
'fulcrum__pcs_jobs',
'fulcrum_cron_actions'
];
foreach ($options as $option) {
delete_option($option);
}
}
function activate_plugin()
{
}
}
/**
* Global Functionset - D_FULCRUM() - only run once []
*
*/
function D_FULCRUM()
{
global $d_fulcrum;
if (!isset($d_fulcrum)) {
$d_fulcrum = new d_fulcrum();
$d_fulcrum->init();
}
return $d_fulcrum;
}
// Instantiate
D_FULCRUM();
endif;