-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.php
111 lines (95 loc) · 2.14 KB
/
plugin.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
<?php
/**
* Plugin Name: WP Projects
* Plugin URI: https://github.com/anisur2805/wp-projects
* Description: WP Projects is for showcase custom post type
* Version: 1.0.0
* Author: Anisur Rahman
* Author URI: https://github.com/anisur2805
* Text Domain: wp-projects
* Domain Path: /languages/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*
*/
use WP\Projects\Ajax;
use WP\Projects\Installer;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
require_once __DIR__ . '/vendor/autoload.php';
final class WP_Projects {
/**
* plugin version
*/
const VERSION = '1.0';
/**
* class constructor
*/
private function __construct() {
$this->define_constants();
register_activation_hook( __FILE__, array( $this, 'activate' ) );
add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
}
/**
* Initialize a singleton instance
*
* @return \WP_Projects
*/
public static function init() {
static $instance = false;
if ( ! $instance ) {
$instance = new self();
}
return $instance;
}
/**
* define plugin require constants
*
* @return void
*/
public function define_constants() {
// @codingStandardsIgnoreStart
define( 'WP_Projects_VERSION', self::VERSION );
define( 'WP_Projects_FILE', __FILE__ );
define( 'WP_Projects_PATH', __DIR__ );
define( 'WP_Projects_URL', plugins_url( '', WP_Projects_FILE ) );
define( 'WP_Projects_ASSETS', WP_Projects_URL . '/assets' );
define( 'WP_Projects_INCLUDES', WP_Projects_URL . '/includes' );
// @codingStandardsIgnoreEnd
}
/**
* Do staff upon plugin activation
*
* @return void
*/
public function activate() {
$installer = new Installer();
$installer->run();
}
public function init_plugin() {
/**
* Load Assets
*/
new WP\Projects\Assets();
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
new Ajax();
}
/**
* Load Admin Class
*/
if ( is_admin() ) {
new \WP\Projects\Admin();
} else {
new \WP\Projects\Frontend();
}
}
}
/**
* Initialize the main plugin
*
* @return \WP_Projects
*/
function wp_projects() {
return WP_Projects::init();
}
wp_projects();