forked from christiespeich/Mooberry-Book-Manager
/
mooberry-book-manager.php
201 lines (166 loc) · 5.48 KB
/
mooberry-book-manager.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
/**
* Plugin Name: Mooberry Book Manager
* Plugin URI: http://www.mooberrydreams.com/products/mooberry-book-manager/
* Description: An easy-to-use system for authors. Add your new book to your site in minutes, including links for purchase or download, sidebar widgets, and more.
* Author: Mooberry Dreams
* Author URI: http://www.mooberrydreams.com/
* Version: 3.0
* Text Domain: mooberry-book-manager
* Domain Path: languages
*
* Copyright 2015 Mooberry Dreams (email : bookmanager@mooberrydreams.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package MBDB
* @author Mooberry Dreams
* @version 3.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
// Plugin version
if ( ! defined( 'MBDB_PLUGIN_VERSION' ) ) {
define( 'MBDB_PLUGIN_VERSION', '3.0' );
}
if ( ! defined( 'MBDB_PLUGIN_VERSION_KEY' ) ) {
define('MBDB_PLUGIN_VERSION_KEY', 'mbdb_version');
}
// Plugin Folder Path
if ( ! defined( 'MBDB_PLUGIN_DIR' ) ) {
define( 'MBDB_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
// Plugin Folder URL
if ( ! defined( 'MBDB_PLUGIN_URL' ) ) {
define( 'MBDB_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
// Plugin Root File
if ( ! defined( 'MBDB_PLUGIN_FILE' ) ) {
define( 'MBDB_PLUGIN_FILE', __FILE__ );
}
// Load in CMB2
if ( file_exists( MBDB_PLUGIN_DIR . 'includes/cmb2/init.php' ) ) {
require_once MBDB_PLUGIN_DIR . 'includes/cmb2/init.php';
} elseif ( file_exists( MBDB_PLUGIN_DIR . 'includes/CMB2/init.php' ) ) {
require_once MBDB_PLUGIN_DIR . 'includes/CMB2/init.php';
}
require_once MBDB_PLUGIN_DIR . 'includes/plugin-functions.php';
require_once MBDB_PLUGIN_DIR . 'includes/mooberry-dreams/moobd-database.php';
require_once MBDB_PLUGIN_DIR . 'includes/class-mbdb-db-cpt.php';
require_once MBDB_PLUGIN_DIR . 'includes/class-mbdb-db-books.php';
require_once MBDB_PLUGIN_DIR . 'includes/class-mbdb-cpt.php';
require_once MBDB_PLUGIN_DIR . 'includes/class-mbdb-book.php';
require_once MBDB_PLUGIN_DIR . 'includes/helper-functions.php';
require_once MBDB_PLUGIN_DIR . 'includes/helper-functions-updates.php';
require_once MBDB_PLUGIN_DIR . 'includes/helper-functions-validation.php';
require_once MBDB_PLUGIN_DIR . 'includes/scripts-and-styles.php';
require_once MBDB_PLUGIN_DIR . 'book.php';
require_once MBDB_PLUGIN_DIR . 'single-book.php';
require_once MBDB_PLUGIN_DIR . 'book-grid.php';
require_once MBDB_PLUGIN_DIR . 'book-widget.php';
require_once MBDB_PLUGIN_DIR . 'admin-settings-page.php';
require_once MBDB_PLUGIN_DIR . 'tax-grid.php';
if ( ! class_exists( 'Mooberry_Book_Manager' ) ) :
/**
* Main Mooberry_Book_Manager Class
*
* @since 3.0
*/
final class Mooberry_Book_Manager {
/** Singleton *************************************************************/
/**
* @var Mooberry_Book_Manager The one true Mooberry_Book_Manager
* @since 3.0
*/
private static $instance;
/**
* MBDB Books Object
*
* @var object
* @since 3.0
*/
public $books;
/**
* Main Mooberry_Book_Manager Instance
*
* Insures that only one instance of Mooberry_Book_Manager exists in memory at any one
* time. Also prevents needing to define globals all over the place.
*
* @since 3.0
* @static
* @staticvar array $instance
* @see MBDB()
* @return The one true Mooberry_Book_Manager
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Mooberry_Book_Manager ) ) {
self::$instance = new Mooberry_Book_Manager;
self::$instance->books = new MBDB_Books();
}
return self::$instance;
}
/**
* Throw error on object clone
*
* The whole idea of the singleton design pattern is that there is a single
* object therefore, we don't want the object to be cloned.
*
* @since 3.0
* @return void
*/
public function __clone() {
// Cloning instances of the class is forbidden
_doing_it_wrong( __FUNCTION__, 'Cheatin’ huh?', '3.0' );
}
/**
* Disable unserializing of the class
*
* @since 3.0
* @return void
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden
_doing_it_wrong( __FUNCTION__, 'Cheatin’ huh?', '3.0' );
}
}
endif; // End if class_exists check
/**
* The main function responsible for returning the one true Mooberry Book Manager
* Instance to functions everywhere.
*
* Use this function like you would a global variable, except without needing
* to declare the global.
*
* Example: <?php $mbdb = MBDB(); ?>
*
* @since 3.0
* @return object The one true Mooberry_Book_Manager Instance
*/
function MBDB() {
return Mooberry_Book_Manager::instance();
}
// Get MBDB Running
MBDB();
/*
add_filter('tc_include_cpt_in_archives' , 'mbdb_tc_archives');
function mbdb_tc_archives($include) {
error_log('inclue cpt in archives');
error_log(get_post_type());
if (get_post_type() == 'mbdb_book' || get_post_type() == 'mbdb_tax_grid') {
return false;
} else {
return $include;
}
}
*/