PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.5.8
Shortcodes and extra features for Phlox theme v2.5.8
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 6 years ago includes 6 years ago templates 6 years ago class-auxels.php 6 years ago
class-auxels.php
344 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
85 // Dashboard and Administrative Functionality
86 if ( is_admin() ) {
87
88 // Load AJAX spesific codes on demand
89 if ( defined('DOING_AJAX') && DOING_AJAX ){
90 include( AUXELS_ADMIN_DIR . '/includes/admin-ajax.php' );
91 include( AUXELS_ADMIN_DIR . '/includes/admin-the-functions.php' );
92 include( 'includes/frontend-ajax.php' );
93 }
94
95 // Load admin spesific codes
96 else {
97 $this->admin = include( AUXELS_ADMIN_DIR . '/class-auxels-admin.php' );
98 }
99
100 // Load Frontend Functionality
101 } else {
102 include 'includes/index.php';
103 }
104
105 }
106
107
108
109 /**
110 * Auto-load classes on demand to reduce memory consumption
111 *
112 * @param mixed $class
113 * @return void
114 */
115 public function autoload( $class ) {
116 $path = null;
117 $class = strtolower( $class );
118 $file = 'class-' . str_replace( '_', '-', $class ) . '.php';
119
120 // the possible pathes containing classes
121 $possible_pathes = array(
122 AUXELS_INC_DIR . '/classes/',
123 AUXELS_ADMIN_DIR . '/includes/classes/'
124 );
125
126 foreach ( $possible_pathes as $path ) {
127 if( is_readable( $path . $file ) ){
128 include_once( $path . $file );
129 return;
130 }
131
132 }
133
134 }
135
136
137
138 /**
139 * Init the plugin when WordPress Initialises.
140 *
141 * @return void
142 */
143 public function init(){
144 // Load plugin text domain
145 $this->load_plugin_textdomain();
146 }
147
148
149 /**
150 * Return an instance of this class.
151 *
152 * @since 1.0.0
153 *
154 * @return object A single instance of this class.
155 */
156 public static function get_instance() {
157
158 // If the single instance hasn't been set, set it now.
159 if ( null == self::$instance ) {
160 self::$instance = new self;
161 }
162
163 return self::$instance;
164 }
165
166
167 /**
168 * Fired when the plugin is activated.
169 *
170 * @since 1.0.0
171 *
172 * @param boolean $network_wide True if WPMU superadmin uses
173 * "Network Activate" action, false if
174 * WPMU is disabled or plugin is
175 * activated on an individual blog.
176 */
177 public static function activate( $network_wide ) {
178
179 if ( function_exists( 'is_multisite' ) && is_multisite() ) {
180
181 if ( $network_wide ) {
182
183 // Get all blog ids
184 $blog_ids = self::get_blog_ids();
185
186 foreach ( $blog_ids as $blog_id ) {
187
188 switch_to_blog( $blog_id );
189 self::single_activate();
190 }
191
192 restore_current_blog();
193
194 } else {
195 self::single_activate();
196 }
197
198 } else {
199 self::single_activate();
200 }
201
202 }
203
204
205 /**
206 * Fired when the plugin is deactivated.
207 *
208 * @since 1.0.0
209 *
210 * @param boolean $network_wide True if WPMU superadmin uses
211 * "Network Deactivate" action, false if
212 * WPMU is disabled or plugin is
213 * deactivated on an individual blog.
214 */
215 public static function deactivate( $network_wide ) {
216
217 if ( function_exists( 'is_multisite' ) && is_multisite() ) {
218
219 if ( $network_wide ) {
220
221 // Get all blog ids
222 $blog_ids = self::get_blog_ids();
223
224 foreach ( $blog_ids as $blog_id ) {
225
226 switch_to_blog( $blog_id );
227 self::single_deactivate();
228
229 }
230
231 restore_current_blog();
232
233 } else {
234 self::single_deactivate();
235 }
236
237 } else {
238 self::single_deactivate();
239 }
240
241 }
242
243
244 /**
245 * Fired for each blog when the plugin is activated.
246 *
247 * @since 1.0.0
248 */
249 private static function single_activate() {
250 add_action( 'after_setup_theme', array( 'AUXELS', 'flush' ) );
251
252 do_action( 'auxels_activated', get_current_blog_id() );
253 }
254
255
256 /**
257 * Fired for each blog when the plugin is deactivated.
258 *
259 * @since 1.0.0
260 */
261 private static function single_deactivate() {
262 do_action( 'auxels_deactivated' );
263 }
264
265
266 /**
267 * Fired when a new site is activated with a WPMU environment.
268 *
269 * @since 1.0.0
270 *
271 * @param int $blog_id ID of the new blog.
272 */
273 public function activate_new_site( $blog_id ) {
274
275 if ( 1 !== did_action( 'wpmu_new_blog' ) ) {
276 return;
277 }
278
279 switch_to_blog( $blog_id );
280 self::single_activate();
281 restore_current_blog();
282
283 }
284
285 /**
286 * Get all blog ids of blogs in the current network that are:
287 * - not archived
288 * - not spam
289 * - not deleted
290 *
291 * @since 1.0.0
292 *
293 * @return array|false The blog ids, false if no matches.
294 */
295 private static function get_blog_ids() {
296
297 global $wpdb;
298
299 // get an array of blog ids
300 $sql = "SELECT blog_id FROM $wpdb->blogs
301 WHERE archived = '0' AND spam = '0'
302 AND deleted = '0'";
303
304 return $wpdb->get_col( $sql );
305
306 }
307 /**
308 * Get the template path.
309 * @return string
310 */
311 public function template_path() {
312 return apply_filters( 'auxin_elements_template_path', AUXELS_PUB_DIR . '/templates/' );
313 }
314
315 /**
316 * Flush and perform some tasks on theme setup
317 *
318 * @since 1.0.0
319 */
320 public static function flush() {
321 // try to regenerate the asset files on plugin activation
322 auxin_add_custom_js();
323 auxin_add_custom_css();
324 }
325
326 /**
327 * Load the plugin text domain for translation.
328 *
329 * @since 1.0.0
330 */
331 public function load_plugin_textdomain() {
332
333 $locale = apply_filters( 'plugin_locale', get_locale(), 'auxin-elements' );
334 load_textdomain( 'auxin-elements', trailingslashit( WP_LANG_DIR ) . 'auxin-elements' . '/' . 'auxin-elements' . '-' . $locale . '.mo' );
335 load_plugin_textdomain( 'auxin-elements', FALSE, basename( AUXELS_DIR ) . '/languages/' );
336 }
337
338 }
339
340 endif;
341
342 function AUXELS(){ return AUXELS::get_instance(); }
343 AUXELS();
344