PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.8.1
Shortcodes and extra features for Phlox theme v2.8.1
2.17.22 2.17.21 2.17.20 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / public / class-auxels.php
auxin-elements / public Last commit date
assets 5 years ago includes 5 years ago templates 5 years ago class-auxels.php 6 years ago
class-auxels.php
347 lines
1 <?php
2 /**
3 * Auxin Elements.
4 *
5 * @echo HEADER
6 */
7
8 if ( ! class_exists( 'AUXELS' ) ) :
9
10
11
12 class AUXELS {
13
14 /**
15 * Unique identifier for your plugin.
16 *
17 * The variable name is used as the text domain when internationalizing strings of text.
18 *
19 * @since 1.0.0
20 *
21 * @var string
22 */
23 protected $plugin_slug = 'auxin-elements';
24
25 /**
26 * Instance of this class.
27 *
28 * @since 1.0.0
29 *
30 * @var object
31 */
32 protected static $instance = null;
33
34
35 /**
36 * Instance of Admin class.
37 *
38 * @since 1.0.0
39 *
40 * @var object
41 */
42 public $admin = null;
43
44
45
46 /**
47 * Initialize the plugin
48 *
49 * @since 1.0.0
50 */
51 private function __construct() {
52
53 $this->includes();
54
55 add_action( 'init', array( $this, 'init' ) );
56
57
58 // Activate plugin when new blog is added
59 add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) );
60
61 // Loaded action
62 do_action( 'auxels_loaded' );
63 }
64
65
66 /**
67 *
68 * @return [type] [description]
69 */
70 private function includes() {
71
72 // Auto-load classes on demand
73 if ( function_exists( "__autoload" ) ) {
74 spl_autoload_register( "__autoload" );
75 }
76 spl_autoload_register( array( $this, 'autoload' ) );
77
78 // Load components
79 require( AUXELS_DIR . '/vendor/autoload.php' );
80
81 // load common functionalities
82 include_once( AUXELS_INC_DIR . '/index.php' );
83
84 if ( defined( 'WP_CLI' ) && WP_CLI ) {
85 include( AUXELS_ADMIN_DIR . '/includes/classes/class-auxin-cli-commands.php' );
86 }
87
88 // Dashboard and Administrative Functionality
89 if ( is_admin() ) {
90
91 // Load AJAX spesific codes on demand
92 if ( defined('DOING_AJAX') && DOING_AJAX ){
93 include( AUXELS_ADMIN_DIR . '/includes/admin-ajax.php' );
94 include( AUXELS_ADMIN_DIR . '/includes/admin-the-functions.php' );
95 include( 'includes/frontend-ajax.php' );
96 }
97
98 // Load admin spesific codes
99 else {
100 $this->admin = include( AUXELS_ADMIN_DIR . '/class-auxels-admin.php' );
101 }
102
103 // Load Frontend Functionality
104 } else {
105 include 'includes/index.php';
106 }
107
108 }
109
110
111
112 /**
113 * Auto-load classes on demand to reduce memory consumption
114 *
115 * @param mixed $class
116 * @return void
117 */
118 public function autoload( $class ) {
119 $path = null;
120 $class = strtolower( $class );
121 $file = 'class-' . str_replace( '_', '-', $class ) . '.php';
122
123 // the possible pathes containing classes
124 $possible_pathes = array(
125 AUXELS_INC_DIR . '/classes/',
126 AUXELS_ADMIN_DIR . '/includes/classes/'
127 );
128
129 foreach ( $possible_pathes as $path ) {
130 if( is_readable( $path . $file ) ){
131 include_once( $path . $file );
132 return;
133 }
134
135 }
136
137 }
138
139
140
141 /**
142 * Init the plugin when WordPress Initialises.
143 *
144 * @return void
145 */
146 public function init(){
147 // Load plugin text domain
148 $this->load_plugin_textdomain();
149 }
150
151
152 /**
153 * Return an instance of this class.
154 *
155 * @since 1.0.0
156 *
157 * @return object A single instance of this class.
158 */
159 public static function get_instance() {
160
161 // If the single instance hasn't been set, set it now.
162 if ( null == self::$instance ) {
163 self::$instance = new self;
164 }
165
166 return self::$instance;
167 }
168
169
170 /**
171 * Fired when the plugin is activated.
172 *
173 * @since 1.0.0
174 *
175 * @param boolean $network_wide True if WPMU superadmin uses
176 * "Network Activate" action, false if
177 * WPMU is disabled or plugin is
178 * activated on an individual blog.
179 */
180 public static function activate( $network_wide ) {
181
182 if ( function_exists( 'is_multisite' ) && is_multisite() ) {
183
184 if ( $network_wide ) {
185
186 // Get all blog ids
187 $blog_ids = self::get_blog_ids();
188
189 foreach ( $blog_ids as $blog_id ) {
190
191 switch_to_blog( $blog_id );
192 self::single_activate();
193 }
194
195 restore_current_blog();
196
197 } else {
198 self::single_activate();
199 }
200
201 } else {
202 self::single_activate();
203 }
204
205 }
206
207
208 /**
209 * Fired when the plugin is deactivated.
210 *
211 * @since 1.0.0
212 *
213 * @param boolean $network_wide True if WPMU superadmin uses
214 * "Network Deactivate" action, false if
215 * WPMU is disabled or plugin is
216 * deactivated on an individual blog.
217 */
218 public static function deactivate( $network_wide ) {
219
220 if ( function_exists( 'is_multisite' ) && is_multisite() ) {
221
222 if ( $network_wide ) {
223
224 // Get all blog ids
225 $blog_ids = self::get_blog_ids();
226
227 foreach ( $blog_ids as $blog_id ) {
228
229 switch_to_blog( $blog_id );
230 self::single_deactivate();
231
232 }
233
234 restore_current_blog();
235
236 } else {
237 self::single_deactivate();
238 }
239
240 } else {
241 self::single_deactivate();
242 }
243
244 }
245
246
247 /**
248 * Fired for each blog when the plugin is activated.
249 *
250 * @since 1.0.0
251 */
252 private static function single_activate() {
253 add_action( 'after_setup_theme', array( 'AUXELS', 'flush' ) );
254
255 do_action( 'auxels_activated', get_current_blog_id() );
256 }
257
258
259 /**
260 * Fired for each blog when the plugin is deactivated.
261 *
262 * @since 1.0.0
263 */
264 private static function single_deactivate() {
265 do_action( 'auxels_deactivated' );
266 }
267
268
269 /**
270 * Fired when a new site is activated with a WPMU environment.
271 *
272 * @since 1.0.0
273 *
274 * @param int $blog_id ID of the new blog.
275 */
276 public function activate_new_site( $blog_id ) {
277
278 if ( 1 !== did_action( 'wpmu_new_blog' ) ) {
279 return;
280 }
281
282 switch_to_blog( $blog_id );
283 self::single_activate();
284 restore_current_blog();
285
286 }
287
288 /**
289 * Get all blog ids of blogs in the current network that are:
290 * - not archived
291 * - not spam
292 * - not deleted
293 *
294 * @since 1.0.0
295 *
296 * @return array|false The blog ids, false if no matches.
297 */
298 private static function get_blog_ids() {
299
300 global $wpdb;
301
302 // get an array of blog ids
303 $sql = "SELECT blog_id FROM $wpdb->blogs
304 WHERE archived = '0' AND spam = '0'
305 AND deleted = '0'";
306
307 return $wpdb->get_col( $sql );
308
309 }
310 /**
311 * Get the template path.
312 * @return string
313 */
314 public function template_path() {
315 return apply_filters( 'auxin_elements_template_path', AUXELS_PUB_DIR . '/templates/' );
316 }
317
318 /**
319 * Flush and perform some tasks on theme setup
320 *
321 * @since 1.0.0
322 */
323 public static function flush() {
324 // try to regenerate the asset files on plugin activation
325 auxin_add_custom_js();
326 auxin_add_custom_css();
327 }
328
329 /**
330 * Load the plugin text domain for translation.
331 *
332 * @since 1.0.0
333 */
334 public function load_plugin_textdomain() {
335
336 $locale = apply_filters( 'plugin_locale', get_locale(), 'auxin-elements' );
337 load_textdomain( 'auxin-elements', trailingslashit( WP_LANG_DIR ) . 'auxin-elements' . '/' . 'auxin-elements' . '-' . $locale . '.mo' );
338 load_plugin_textdomain( 'auxin-elements', FALSE, basename( AUXELS_DIR ) . '/languages/' );
339 }
340
341 }
342
343 endif;
344
345 function AUXELS(){ return AUXELS::get_instance(); }
346 AUXELS();
347