-
Notifications
You must be signed in to change notification settings - Fork 3
/
plugin-bootstrap.php
108 lines (95 loc) · 1.96 KB
/
plugin-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
<?php
/**
* Team Bios Plugin
*
* @package KnowTheCode\TeamBios
* @author hellofromTonya
* @license GPL-2.0+
*
* @wordpress-plugin
* Plugin Name: Team Bios Plugin
* Plugin URI: https://knowthecode.io/labs/lets-build-wordpress-starter-plugin
* Description: Team Bios functionality and custom post type for the Custom Post Type Basics Labs
* Version: 1.0.1
* Author: hellofromTonya
* Author URI: https://knowthecode.io
* Text Domain: teambios
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
namespace KnowTheCode\TeamBios;
if ( ! defined( 'ABSPATH' ) ) {
exit( 'Cheatin’ uh?' );
}
/**
* Setup the plugin's constants.
*
* @since 1.0.0
*
* @return void
*/
function init_constants() {
$plugin_url = plugin_dir_url( __FILE__ );
if ( is_ssl() ) {
$plugin_url = str_replace( 'http://', 'https://', $plugin_url );
}
define( 'TEAMBIOS_URL', $plugin_url );
define( 'TEAMBIOS_DIR', plugin_dir_path( __DIR__ ) );
}
/**
* Initialize the plugin hooks
*
* @since 1.0.0
*
* @return void
*/
function init_hooks() {
register_activation_hook( __FILE__, __NAMESPACE__ . '\flush_rewrites' );
register_deactivation_hook( __FILE__, __NAMESPACE__ . '\deactivate_plugin' );
}
/**
* Flush the rewrites.
*
* @since 1.0.0
*
* @return void
*/
function flush_rewrites() {
init_autoloader();
Custom\register_custom_post_type();
flush_rewrite_rules();
}
/**
* The plugin is deactivating. Delete out the rewrite rules option.
*
* @since 1.0.1
*
* @return void
*/
function deactivate_plugin() {
delete_option( 'rewrite_rules' );
}
/**
* Kick off the plugin by initializing the plugin files.
*
* @since 1.0.0
*
* @return void
*/
function init_autoloader() {
require_once( 'src/support/autoloader.php' );
Support\autoload_files( __DIR__ . '/src/' );
}
/**
* Launch the plugin
*
* @since 1.0.0
*
* @return void
*/
function launch() {
init_autoloader();
}
init_constants();
init_hooks();
launch();