-
Notifications
You must be signed in to change notification settings - Fork 13
/
pressbooks-textbook.php
118 lines (102 loc) · 3.02 KB
/
pressbooks-textbook.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
<?php
/**
* Plugin Name: Textbooks for Pressbooks
* Description: A plugin that extends Pressbooks for textbook authoring
* Version: 4.3.1
* Author: BCcampus
* Author URI: https://github.com/BCcampus
* Text Domain: pressbooks-textbook
* License: GPL-2.0+
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages
* GitHub Plugin URI: https://github.com/BCcampus/pressbooks-textbook
* Tags: pressbooks, OER, publishing, textbooks
* Pressbooks tested up to: 5.7.0
*/
// If file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
return;
}
/*
|--------------------------------------------------------------------------
| Minimum requirements before either PB or PBT objects are instantiated
|--------------------------------------------------------------------------
|
|
|
|
*/
if ( ! include_once( WP_PLUGIN_DIR . '/pressbooks/compatibility.php' ) ) {
add_action(
'admin_notices', function () {
echo '<div id="message" class="error fade"><p>' . __( 'PBT cannot find a Pressbooks install.', 'pressbooks-textbook' ) . '</p></div>';
}
);
return;
}
if ( function_exists( 'pb_meets_minimum_requirements' ) ) {
if ( ! pb_meets_minimum_requirements() ) { // This PB function checks for both multisite, PHP and WP minimum versions.
add_action(
'admin_notices', function () {
echo '<div id="message" class="error fade"><p>' . __( 'Your PHP or WP version may not be up to date.', 'pressbooks-textbook' ) . '</p></div>';
}
);
return;
}
}
add_filter(
'init', function () {
// the constants below should be available in the init hook
if ( ! version_compare( PB_PLUGIN_VERSION, '5.0.0', '>=' ) ) {
add_action(
'admin_notices', function () {
echo '<div id="message" class="error fade"><p>' . __( 'Textbooks for Pressbooks requires Pressbooks 5.0.0 or greater.', 'pressbooks-textbook' ) . '</p></div>';
}
);
return;
}
update_site_option( 'pbt_pb_version', PB_PLUGIN_VERSION );
}
);
/*
|--------------------------------------------------------------------------
| autoload classes
|--------------------------------------------------------------------------
|
|
|
|
*/
if ( function_exists( '\HM\Autoloader\register_class_path' ) ) {
\HM\Autoloader\register_class_path( 'PBT', __DIR__ . '/inc' );
} else {
require_once( __DIR__ . '/autoloader.php' );
}
$composer = __DIR__ . '/vendor/autoload.php';
if ( file_exists( $composer ) ) {
require_once( $composer );
}
/*
|--------------------------------------------------------------------------
| Other requirements
|--------------------------------------------------------------------------
|
|
|
|
*/
require __DIR__ . '/constants.php';
require __DIR__ . '/inc/settings/namespace.php';
/*
|--------------------------------------------------------------------------
| All Your Base Are Belong To Us
|--------------------------------------------------------------------------
|
|
|
|
*/
\PBT\Textbook::get_instance();
if ( is_admin() ) {
\PBT\Admin\TextbookAdmin::get_instance();
}