This repository was archived by the owner on Apr 12, 2024. It is now read-only.
forked from BCcampus/pressbooks-textbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpressbooks-textbook.php
More file actions
150 lines (131 loc) · 3.79 KB
/
pressbooks-textbook.php
File metadata and controls
150 lines (131 loc) · 3.79 KB
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
141
142
143
144
145
146
147
148
149
150
<?php
/**
* Textbooks for Pressbooks
*
* @package Pressbooks_Textbook
* @author Brad Payne
* @license GPL-2.0+
* @copyright Brad Payne
*
* @wordpress-plugin
* Plugin Name: Textbooks for Pressbooks
* Description: A plugin that extends Pressbooks for textbook authoring
* Version: 4.2.0
* Author: Brad Payne
* Author URI: http://github.com/bdolor
* Text Domain: pressbooks-textbook
* License: GPL-2.0+
* License URI: http://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.4.4
*/
// If file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die();
}
/*
|--------------------------------------------------------------------------
| Constants
|--------------------------------------------------------------------------
|
|
|
|
*/
if ( ! defined( 'PBT_PLUGIN_DIR' ) ) {
define( 'PBT_PLUGIN_DIR', __DIR__ . '/' );
}
if ( ! defined( 'PBT_PLUGIN_URL' ) ) {
define( 'PBT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
// Must have trailing slash!
if ( ! defined( 'PB_PLUGIN_DIR' ) ) {
define( 'PB_PLUGIN_DIR', WP_PLUGIN_DIR . '/pressbooks/' );
}
// Allow override in wp-config.php
if ( ! defined( 'WP_DEFAULT_THEME' ) ) {
define( 'WP_DEFAULT_THEME', 'opentextbook' );
};
// Hide PB cover promotion
define( 'PB_HIDE_COVER_PROMO', true );
/*
|--------------------------------------------------------------------------
| Minimum requirements before either PB or PBT objects are instantiated
|--------------------------------------------------------------------------
|
|
|
|
*/
function pb_compatibility() {
$min_pb_compatibility_version = '5.0.0';
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;
}
}
if ( ! version_compare( PB_PLUGIN_VERSION, $min_pb_compatibility_version, '>=' ) ) {
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;
}
// need version number outside of init hook
update_site_option( 'pbt_pb_version', PB_PLUGIN_VERSION );
}
add_action( 'init', 'pb_compatibility' );
/*
|--------------------------------------------------------------------------
| autoload classes
|--------------------------------------------------------------------------
|
|
|
|
*/
require PBT_PLUGIN_DIR . 'autoloader.php';
// Load Composer Dependencies
$composer = PBT_PLUGIN_DIR . 'vendor/autoload.php';
if ( file_exists( $composer ) ) {
require_once( $composer );
}
/*
|--------------------------------------------------------------------------
| Other requirements
|--------------------------------------------------------------------------
|
|
|
|
*/
require PBT_PLUGIN_DIR . 'inc/pbt-settings.php';
/*
|--------------------------------------------------------------------------
| All Your Base Are Belong To Us
|--------------------------------------------------------------------------
|
|
|
|
*/
\PBT\Textbook::get_instance();
if ( is_admin() ) {
new \PBT\Admin\TextbookAdmin;
}