-
Notifications
You must be signed in to change notification settings - Fork 1
/
wpup.php
executable file
·265 lines (232 loc) · 6.42 KB
/
wpup.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<?php
/**
* Plugin Name: WP Profile Builder
* Plugin URI: https://github.com/asaquzzaman/wp-user-profile-builder
* Description: With the Profile plugin you can create users profile template layout.
* Version: 0.2
* Author: asaquzzaman
* Author URI: http://mishubd.com
* Requires at least: 4.0
* Tested up to: 4.7.3
* Text Domain: wpupb
* Domain Path: /i18n/languages/
*/
/**
* Copyright (c) 2013 name (email: ). All rights reserved.
*
* Released under the GPL license
* http://www.opensource.org/licenses/gpl-license.php
*
* This is an add-on for WordPress
* http://wordpress.org/
*
* **********************************************************************
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* **********************************************************************
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* UserProfile class
*
* @class UserProfile The class that holds the entire USER PROFILE plugin
*/
final class UserProfile {
/**
* Main UserProfile Instance
*
* @since 0.1
*
* @return UserProfile - Main instance
*/
public static function init() {
static $instance = false;
if ( ! $instance ) {
$instance = new self();
}
return $instance;
}
/**
* Constructor for the UserProfile class
*
* Sets up all the appropriate hooks and actions within this plugin.
*/
public function __construct() {
// Define constants
$this->define_constants();
// Include required files
$this->includes();
// Before active this plugin
register_activation_hook( __FILE__, array( 'WPUP_Install', 'install' ) );
// instantiate classes
$this->instantiate();
// Initialize the action hooks
$this->init_actions();
// load the modules
$this->load_module();
// Loaded action
do_action( 'wpup_loaded' );
}
/**
* Define UserProfile Constants
*
* @since 0.1
*
* @return void
*/
private function define_constants() {
$this->define( 'WPUP_VERSION', '0.2' );
$this->define( 'WPUP_DB_VERSION', '0.1' );
$this->define( 'WPUP_PATH', dirname( __FILE__ ) );
$this->define( 'WPUP_URL', plugins_url( '', __FILE__ ) );
$this->define( 'WPUP_ASSETS', WPUP_URL . '/assets' );
$this->define( 'WPUP_INCLUDES', WPUP_PATH . '/includes' );
$this->define( 'WPUP_IS_ADMIN', is_admin() );
}
/**
* Define constant if not already set
*
* @since 0.1
*
* @param string $name
* @param string|bool $value
*
* @return void
*/
private function define( $name, $value ) {
if ( ! defined( $name ) ) {
define( $name, $value );
}
}
/**
* Doing some action before active this plugin
*
* @since 0.1
*
* @return void
*/
function install() {
update_option( 'wpup_supper_admin', get_current_user_id() );
update_option( 'wpup_version', WPUP_VERSION );
update_option( 'wpup_db_version', WPUP_DB_VERSION );
}
/**
* Include the required files
*
* @since 0.1
*
* @return void
*/
private function includes() {
include_once( 'includes/wpup-functions.php' );
include_once( 'includes/class-wpup-autoloader.php' );
include_once( 'includes/class-wpup-ajax.php' );
include_once( 'includes/class-wpup-post-types.php' ); // Registers post types
include_once( 'includes/class-wpup-install.php' );
include_once( 'includes/class-wpup-scripts-register.php' );
if ( $this->is_request( 'admin' ) ) {
$this->admin_includes();
}
if ( $this->is_request( 'frontend' ) ) {
$this->frontend_includes();
}
}
/**
* Include the required admin file
*
* @since 0.1
*
* @return void
*/
function admin_includes() {
include_once( 'includes/admin/class-wpup-admin.php' );
}
/**
* Include the required front-end file
*
* @since 0.1
*
* @return void
*/
function frontend_includes() {
include_once( 'includes/class-wpup-frontend-scripts.php' ); // Frontend Scripts
include_once( 'includes/class-wpup-shortcodes.php' ); // Shortcodes class
}
/**
* Instantiate classes
*
* @return void
*/
private function instantiate() {
}
/**
* Initialize WordPress action hooks
*
* @return void
*/
private function init_actions() {
add_action( 'init', array( 'WPUP_Shortcodes', 'init' ) );
}
/**
* Load the current ERP module
*
* We don't load every module at once, just load
* what is necessary
*
* @return void
*/
public function load_module() {
}
/**
* What type of request is this?
*
* @param string $type admin, ajax, cron or frontend.
* @return bool
*/
private function is_request( $type ) {
switch ( $type ) {
case 'admin' :
return is_admin();
case 'ajax' :
return defined( 'DOING_AJAX' );
case 'cron' :
return defined( 'DOING_CRON' );
case 'frontend' :
return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
}
}
/**
* Get the template path.
* @return string
*/
public function template_path() {
return apply_filters( 'wpup_template_path', 'wpup/' );
}
}
/**
* Main instance of wpup.
*
* Returns the main instance of wpup to prevent the need to use globals.
*
* @since 0.1
*
* @return UserProfile
*/
function WPUP() {
return UserProfile::init();
}
// Global for backwards compatibility.
$GLOBALS['UserProfile'] = WPUP();