-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbootstrap.php
116 lines (104 loc) · 2.29 KB
/
bootstrap.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
112
113
114
115
116
<?php
/**
* PHP Namespace Lab Plugin
*
* @package KnowTheCode\InsOutsPHPNamespacing
* @author hellofromTonya
* @license GPL-2.0+
*
* @wordpress-plugin
* Plugin Name: PHP Namespace Lab Plugin
* Plugin URI: https://github.com/KnowTheCode/SandboxPlugin
* Description: Lab coding plugin for the Ins and Out of PHP Namespacing for WordPress.
* Version: 1.0.0
* Author: hellofromTonya
* Author URI: https://KnowTheCode.io
* Text Domain: php-namespacing
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
if ( ! defined( 'ABSPATH' ) ) {
exit( 'Cheatin’ uh?' );
}
/**
* Setup the plugin's constants.
*
* @since 1.0.0
*
* @return void
*/
function phpnamespacing_init_constants() {
$plugin_url = plugin_dir_url( __FILE__ );
if ( is_ssl() ) {
$plugin_url = str_replace( 'http://', 'https://', $plugin_url );
}
define( 'PHPNAMESPACING_URL', $plugin_url );
define( 'PHPNAMESPACING_DIR', plugin_dir_path( __DIR__ ) );
}
/**
* Initialize the plugin hooks
*
* @since 1.0.0
*
* @return void
*/
function phpnamespacing_init_hooks() {
register_activation_hook( __FILE__, 'phpnamespacing_activate_plugin' );
register_deactivation_hook( __FILE__, 'phpnamespacing_deactivate_plugin' );
register_uninstall_hook( __FILE__, 'phpnamespacing_uninstall_plugin' );
}
/**
* Plugin activation handler
*
* @since 1.0.0
*
* @return void
*/
function phpnamespacing_activate_plugin() {
phpnamespacing_init_autoloader();
phpnamespacing_register_custom_post_type();
flush_rewrite_rules();
}
/**
* The plugin is deactivating. Delete out the rewrite rules option.
*
* @since 1.0.1
*
* @return void
*/
function phpnamespacing_deactivate_plugin() {
delete_option( 'rewrite_rules' );
}
/**
* Uninstall plugin handler
*
* @since 1.0.1
*
* @return void
*/
function phpnamespacing_uninstall_plugin() {
delete_option( 'rewrite_rules' );
}
/**
* Kick off the plugin by initializing the plugin files.
*
* @since 1.0.0
*
* @return void
*/
function phpnamespacing_init_autoloader() {
require_once( 'src/custom/post-type.php' );
}
/**
* Launch the plugin
*
* @since 1.0.0
*
* @return void
*/
function phpnamespacing_launch() {
phpnamespacing_init_autoloader();
}
phpnamespacing_init_constants();
phpnamespacing_init_hooks();
phpnamespacing_launch();