-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelper-wp.php
58 lines (54 loc) · 1.23 KB
/
helper-wp.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
<?php
/**
* Plugin Name: Helper WP
* Plugin URI:
* Description: Set of classes to assist in the development of plugins
* Author: leobaiano
* Author URI: https://github.com/leobaiano
* Version: 1.0.0
* License: GPLv2 or later
* Text Domain: helper-wp
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Helper WP
*
* @author Leo Baiano <[email protected]>
*/
class Helper_WP {
/**
* Instance of this class.
*
* @var object
*/
protected static $instance = null;
private function __construct(){
// Load Helpers
add_action( 'init', array( $this, 'load_helper' ) );
}
/**
* Return an instance of this class.
*
* @return object A single instance of this class.
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Load auxiliary and third classes are in the class directory
*
*/
public function load_helper() {
$class_dir = plugin_dir_path( __FILE__ ) . "/helper/";
foreach ( glob( $class_dir . "*.php" ) as $filename ){
include $filename;
}
}
}
add_action( 'plugins_loaded', array( 'Helper_WP', 'get_instance' ), 0 );