-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaqinfo.php
executable file
·174 lines (135 loc) · 4.58 KB
/
aqinfo.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
<?php
/**
*
* @package AQInfo Widget Plugin
* @version 1.0.1
*/
namespace D\DUFFION;
/*
* Plugin Name: Duffion - AQI Widget Plugin
* Plugin URI: https://duffion.com
* Description: This is a custom AQI tool that integrates both Wunderground and Purple air data into displayable widgets for the frontend
* Version: 1.0.1
* Author: Chris "Duffs" Crevling
* Text Domain: d-aqinfo-plugin
* 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_AQI')) :
// Load in global vars //
$d_plugin_dirs = [];
$d_modules = [];
class D_AQI
{
var $version = '1.0.1';
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-aqi/',
'target_branch' => 'production'
];
$this->updater = \Puc_v4_Factory::buildUpdateChecker(
$config['git'],
__FILE__,
'd-plugin-aqi'
);
//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 //
}
}
/**
* Global Functionset - D_FULCRUM() - only run once []
*
*/
function D_AQI()
{
global $d_aqi;
if (!isset($d_aqi)) {
$d_aqi = new d_aqi();
$d_aqi->init();
}
return $d_aqi;
}
// Instantiate
D_AQI();
endif;