-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultitool.php
More file actions
264 lines (230 loc) · 9.74 KB
/
multitool.php
File metadata and controls
264 lines (230 loc) · 9.74 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
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
<?php
/**
* Plugin Name: Multitool
* Plugin URI: https://www.wordpress.org/plugins/multitool
* Github URI: https://github.com/ryanbayne/multitool
* Description: The Swiss-Army-Plugin for WordPress.
* Version: 1.2.1
* Author: Ryan Bayne
* Author URI: https://multitool.wordpress.com/
* Requires at least: 4.4
* Tested up to: 4.8
* License: GPL3
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
* Domain Path: /i18n/languages/
*
* @package Multitool
* @author Ryan Bayne
* @license GNU General Public License, Version 3
* @copyright 2016-2017 Ryan R. Bayne (SqueekyCoder@Gmail.com)
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'WordPressMultitool' ) ) :
/**
* Main Multitool Class.
*
* @class Multitool
* @version 1.0.0
*/
final class WordPressMultitool {
/**
* Multitool version.
*
* @var string
*/
public $version = '1.2.1';
/**
* Minimum WP version.
*
* @var string
*/
public $min_wp_version = '4.4';
/**
* The single instance of the class.
*
* @var Multitool
* @since 2.1
*/
protected static $_instance = null;
/**
* Session instance.
*
* @var Multitool_Session
*/
public $session = null;
/**
* Main Multitool Instance.
*
* Ensures only one instance of Multitool is loaded or can be loaded.
*
* @since 1.0
* @static
* @see WordPressSeed()
* @return Multitool - Main instance.
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Cloning Multitool is forbidden.
* @since 1.0
*/
public function __clone() {
_doing_it_wrong( __FUNCTION__, __( 'Your not allowed to do that!', 'multitool' ), '1.0' );
}
/**
* Unserializing instances of this class is forbidden.
* @since 1.0
*/
public function __wakeup() {
_doing_it_wrong( __FUNCTION__, __( 'Your not allowed to do that!', 'multitool' ), '1.0' );
}
/**
* Auto-load in-accessible properties on demand.
* @param mixed $key
* @return mixed
*/
public function __get( $key ) {
if ( in_array( $key, array( 'mailer' ) ) ) {
return $this->$key();
}
}
/**
* Multitool Constructor.
*/
public function __construct() {
$this->define_constants();
$this->includes();
$this->init_hooks();
do_action( 'multitool_loaded' );
}
/**
* Hook into actions and filters.
* @since 1.0
*/
private function init_hooks() {
register_activation_hook( __FILE__, array( 'Multitool_Install', 'install' ) );
// Do not confuse deactivation of a plugin with deletion of a plugin - two very different requests.
register_deactivation_hook( __FILE__, array( 'Multitool_Install', 'deactivate' ) );
add_action( 'init', array( $this, 'init' ), 0 );
}
/**
* Define Multitool Constants.
*/
private function define_constants() {
$upload_dir = wp_upload_dir();
// Main (package) constants.
if ( ! defined( 'MULTITOOL_PLUGIN_FILE' ) ) { define( 'MULTITOOL_PLUGIN_FILE', __FILE__ ); }
if ( ! defined( 'MULTITOOL_PLUGIN_BASENAME' ) ) { define( 'MULTITOOL_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); }
if ( ! defined( 'MULTITOOL_PLUGIN_DIR_PATH' ) ) { define( 'MULTITOOL_PLUGIN_DIR_PATH', plugin_dir_path( __FILE__ ) ); }
if ( ! defined( 'MULTITOOL_VERSION' ) ) { define( 'MULTITOOL_VERSION', $this->version ); }
if ( ! defined( 'MULTITOOL_MIN_WP_VERSION' ) ) { define( 'MULTITOOL_MIN_WP_VERSION', $this->min_wp_version ); }
if ( ! defined( 'MULTITOOL_LOG_DIR' ) ) { define( 'MULTITOOL_LOG_DIR', $upload_dir['basedir'] . '/multitool-logs/' ); }
if ( ! defined( 'MULTITOOL_SESSION_CACHE_GROUP' ) ) { define( 'MULTITOOL_SESSION_CACHE_GROUP', 'multitool_session_id' ); }
if ( ! defined( 'MULTITOOL_DEV_MODE' ) ) { define( 'MULTITOOL_DEV_MODE', false ); }
if ( ! defined( 'MULTITOOL_WORDPRESSORG_SLUG' ) ) { define( 'MULTITOOL_WORDPRESSORG_SLUG', false ); }
if ( ! defined( 'MULTITOOL_MARKETPLACE' ) ) { define( 'MULTITOOL_MARKETPLACE', false ); }
if ( ! defined( 'MULTITOOL_MARKETPLACE_ID' ) ) { define( 'MULTITOOL_MARKETPLACE_ID', false ); }
// Support (project) constants.
if ( ! defined( 'MULTITOOL_HOME' ) ) { define( 'MULTITOOL_HOME', 'https://multitool.wordpress.com/' ); }
if ( ! defined( 'MULTITOOL_FORUM' ) ) { define( 'MULTITOOL_FORUM', 'https://multitool.slack.com/' ); }
if ( ! defined( 'MULTITOOL_TWITTER' ) ) { define( 'MULTITOOL_TWITTER', false ); }
if ( ! defined( 'MULTITOOL_DONATE' ) ) { define( 'MULTITOOL_DONATE', 'https://www.patreon.com/ryanbayne' ); }
if ( ! defined( 'MULTITOOL_SKYPE' ) ) { define( 'MULTITOOL_SKYPE', 'https://join.skype.com/bVtDaGHd9Nnl' ); }
if ( ! defined( 'MULTITOOL_GITHUB' ) ) { define( 'MULTITOOL_GITHUB', 'https://github.com/RyanBayne/multitool' ); }
if ( ! defined( 'MULTITOOL_DEMOSITE' ) ) { define( 'MULTITOOL_DEMOSITE', false ); };
if ( ! defined( 'MULTITOOL_SLACK' ) ) { define( 'MULTITOOL_SLACK', 'https://ryanbayne.slack.com/messages/C5FSX5WHG/details/' ); }
if ( ! defined( 'MULTITOOL_DOCS' ) ) { define( 'MULTITOOL_DOCS', 'https://github.com/RyanBayne/multitool/wiki' ); }
if ( ! defined( 'MULTITOOL_FACEBOOK' ) ) { define( 'MULTITOOL_FACEBOOK', 'https://www.facebook.com/WordPress-Plugin-Seed-704154249757165/' ); }
// Author (social) constants - can act as default when support constants are false.
if ( ! defined( 'MULTITOOL_AUTHOR_HOME' ) ) { define( 'MULTITOOL_AUTHOR_HOME', 'https://www.linkedin.com/in/ryanrbayne/' ); }
if ( ! defined( 'MULTITOOL_AUTHOR_FORUM' ) ) { define( 'MULTITOOL_AUTHOR_FORUM', false ); }
if ( ! defined( 'MULTITOOL_AUTHOR_TWITTER' ) ) { define( 'MULTITOOL_AUTHOR_TWITTER', 'http://www.twitter.com/Ryan_R_Bayne' ); }
if ( ! defined( 'MULTITOOL_AUTHOR_FACEBOOK' ) ) { define( 'MULTITOOL_AUTHOR_FACEBOOK', 'https://www.facebook.com/ryanrbayne' ); }
if ( ! defined( 'MULTITOOL_AUTHOR_DONATE' ) ) { define( 'MULTITOOL_AUTHOR_DONATE', 'https://www.patreon.com/ryanbayne' ); }
if ( ! defined( 'MULTITOOL_AUTHOR_SKYPE' ) ) { define( 'MULTITOOL_AUTHOR_SKYPE', 'https://join.skype.com/gNuxSa4wnQTV' ); }
if ( ! defined( 'MULTITOOL_AUTHOR_GITHUB' ) ) { define( 'MULTITOOL_AUTHOR_GITHUB', 'https://github.com/RyanBayne' ); }
if ( ! defined( 'MULTITOOL_AUTHOR_LINKEDIN' ) ) { define( 'MULTITOOL_AUTHOR_LINKEDIN', 'https://www.linkedin.com/in/ryanrbayne/' ); }
if ( ! defined( 'MULTITOOL_AUTHOR_DISCORD' ) ) { define( 'MULTITOOL_AUTHOR_DISCORD', 'https://discord.gg/PcqNqNh' ); }
if ( ! defined( 'MULTITOOL_AUTHOR_SLACK' ) ) { define( 'MULTITOOL_AUTHOR_SLACK', 'https://ryanbayne.slack.com/threads/team/' ); }
}
/**
* Include required core files used in admin and on the frontend.
*/
public function includes() {
include_once( 'includes/functions.multitool-core.php' );
include_once( 'includes/class.multitool-debug.php' );
include_once( 'includes/class.multitool-autoloader.php' );
include_once( 'includes/functions.multitool-validate.php' );
include_once( 'includes/class.multitool-install.php' );
include_once( 'includes/class.multitool-ajax.php' );
include_once( 'includes/class.multitool-configurationtools.php' );
if ( multitool_is_request( 'admin' ) ) {
include_once( 'includes/admin/class.multitool-admin.php' );
}
if ( multitool_is_request( 'frontend' ) ) {
$this->frontend_includes();
}
// Create listener objects if switches are set to 'yes'.
if( get_option( 'multitool_main_listener_switch' ) == 'yes' ) {
include_once( 'includes/class.multitool-listener.php' );
}
}
/**
* Include required frontend files.
*/
public function frontend_includes() {
include_once( 'includes/class.multitool-frontend-scripts.php' );
}
/**
* Initialise WordPress Plugin Seed when WordPress Initialises.
*/
public function init() {
// Before init action.
do_action( 'before_multitool_init' );
// Init action.
do_action( 'multitool_init' );
}
/**
* Get the plugin url.
* @return string
*/
public function plugin_url() {
return untrailingslashit( plugins_url( '/', __FILE__ ) );
}
/**
* Get the plugin path.
* @return string
*/
public function plugin_path() {
return untrailingslashit( plugin_dir_path( __FILE__ ) );
}
/**
* Get Ajax URL (this is the URL to WordPress core ajax file).
* @return string
*/
public function ajax_url() {
return admin_url( 'admin-ajax.php', 'relative' );
}
}
endif;
if( !function_exists( 'GlobalMultitool' ) ) {
/**
* Main instance of WordPress Plugin Seed.
*
* Returns the main instance of Multitool to prevent the need to use globals.
*
* @since 1.0
* @return Multitool
*/
function GlobalMultitool() {
return WordPressMultitool::instance();
}
// Global for backwards compatibility.
$GLOBALS['multitool'] = GlobalMultitool();
}