-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchargify.php
More file actions
executable file
·163 lines (128 loc) · 4.45 KB
/
chargify.php
File metadata and controls
executable file
·163 lines (128 loc) · 4.45 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
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
<?php
namespace D\CHARGIFY;
/*
* Plugin Name: Chargify API Helper Tool
* Plugin URI: https://duffion.com
* Description: This is a custom built tool that allows for easy integration with the Chargify API
* Version: 1.0.3
* Author: Christopher "Duffs" Crevling & John Underwood
* Text Domain: chargify-api-helper
* 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_CHARGIFY')) :
// Load in global vars //
$d_plugin_dirs = [];
$d_modules = [];
class D_CHARGIFY
{
var $version = '1.0.3';
public $settings = [];
public $modules = [];
public $dirs = [
'partials' => 'templates/partials',
'modules' => 'inc/modules',
'inc' => 'inc',
'traits' => 'inc/traits',
'assets' => 'assets',
'scripts' => 'assets/js',
'styles' => 'assets/css',
'fe_styles' => 'assets/css/fe',
'templates' => 'templates',
'modules' => 'inc/modules',
'templates-modules' => 'templates/modules',
'vendors' => 'inc/vendors'
];
// [ '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-checker/plugin-update-checker.php';
$config = [
'git' => 'https://github.com/Duffion/d-plugin-netcito/',
'target_branch' => 'production'
];
$this->updater = \Puc_v4_Factory::buildUpdateChecker(
$config['git'],
__FILE__,
'd-plugin-netcito'
);
//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);
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'] . '/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_CHARGIFY() - only run once []
*
*/
function D_CHARGIFY()
{
global $d_chargify;
if (!isset($d_chargify)) {
$d_chargify = new d_chargify();
$d_chargify->init();
}
return $d_chargify;
}
// Instantiate
D_CHARGIFY();
endif;