-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmm-matter.php
140 lines (122 loc) · 3.63 KB
/
mm-matter.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
* The MM Matter plugin file
*
* Make matter for ManualMaker—front and back.
*
* @link https://github.com/reubenlillie/manualmaker
*
* @package MM_Matter
* @author Reuben L. Lillie <rlillie@nazarene.org>
* @copyright 2017 Church of the Nazarene
* @license <http://www.gnu.org/licenses/gpl-2.0.txt> GNUv2 or later
*
* @wordpress-plugin
* Plugin Name: MM Matter
* Plugin URI: https://github.com/reubenlillie/mm-matter.git
* Description: Make matter for ManualMaker—front and back.
* Author: Reuben L. Lillie
* Author URI: http://reubenlillie.com/about/
* Version: 0.1.0
* License: GPLv2 or later
* Domain Path: /languages
* Text Domain: mm-matter
*
* MM Matter is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License,
* or any later version.
*
* MM Matter is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with MM Matter. If not, see https://www.gnu.org/licenses/gpl-2.0.html
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Checks whether required plugins are active.
*
* @since 0.1.0
*/
function action_mm_matter_has_required_plugins() {
if (
is_admin()
&& current_user_can( 'activate_plugins' )
&& ( !is_plugin_active( 'manualmaker/manualmaker.php' ) )
) {
/**
* Displays an error message in the admin area.
*
* @since 0.1.0
*
* @see admin_notices()
* @link https://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices
*/
add_action( 'admin_notices', 'action_mm_matter_notice' );
/* This action is documented in 'wp-admin/includes/plugin.php' */
deactivate_plugins( plugin_basename( __FILE__ ) );
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
} // if
}
} // action_mm_matter_has_required_plugins()
add_action( 'admin_init', 'action_mm_matter_has_required_plugins' );
/**
* Runs when any of the required plugins is not active.
*
* @since 0.1.0
*/
function mm_matter_notice() {
if ( !is_plugin_active( 'manualmaker/manualmaker.php' ) ) {
?>
<div class="error">
<p><?php
echo sprintf( __( 'Sorry, but MM Matter requires '
. 'The Church of the Nazarene\'s %sManualMaker%s plugin '
. 'to be installed and active.',
'mm-matter'
),
'<a href="https://github.com/reubenlillie/manualmaker/" target="_blank">',
'</a>'
);
?></p>
</div>
<?php
} // if
} // action_mm_matter_notice()
/**
* Runs when MM Matter is actived.
*/
require_once( plugin_dir_path( __FILE__ ) . 'includes/mm-matter-activate.php' );
/**
* Completes MM Matter activation.
*
* @since 0.1.0
*
* @see register_activation_hook()
* @link https://developer.wordpress.org/reference/functions/register_activation_hook/
*/
register_activation_hook( __FILE__, 'mm_matter_activate' );
/**
* Runs when MM Matter is deactived.
*/
require_once( plugin_dir_path( __FILE__ ) . 'includes/mm-matter-deactivate.php' );
/**
* Completes MM Matter deactivation.
*
* @since 0.1.0
*
* @see register_deactivation_hook()
* @link https://developer.wordpress.org/reference/functions/register_deactivation_hook/
*/
register_deactivation_hook( __FILE__, 'mm_matter_deactivate' );
/**
* Controls MM Matter's core dependencies.
*/
require_once( plugin_dir_path( __FILE__ ) . 'includes/mm-matter-core.php' );