PluginProbe
Novelist / 1.1.9
Novelist v1.1.9
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.10 1.1.11 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.0-beta1 All 26 releases
novelist / novelist.php

novelist.php in Novelist 1.1.9, at novelist.php

239 lines 7.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Novelist
4 * Plugin URI: https://novelistplugin.com
5 * Description: Easily organize and display your portfolio of books
6 * Version: 1.1.9
7 * Author: Nose Graze
8 * Author URI: https://www.nosegraze.com
9 * License: GPL2
10 * Text Domain: novelist
11 * Domain Path: languages
12 *
13 * Novelist is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 2 of the License, or
16 * any later version.
17 *
18 * Novelist is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with Novelist. If not, see <http://www.gnu.org/licenses/>.
25 *
26 * Thanks to Easy Digital Downloads for serving as a great code base
27 * and resource, which a lot of Novelist's structure is based on.
28 * Easy Digital Downloads is made by Pippin Williamson and licensed
29 * under GPL2+.
30 *
31 * @package novelist
32 * @copyright Copyright (c) 2016 Nose Graze Ltd
33 * @license GPL2+
34 */
35
36 // Exit if accessed directly
37 if ( ! defined( 'ABSPATH' ) ) {
38 exit;
39 }
40
41 if ( ! class_exists( 'Novelist' ) ) :
42
43 class Novelist {
44
45 /**
46 * Novelist object
47 *
48 * @var Novelist Instance of the Novelist class.
49 * @since 1.0.0
50 */
51 private static $instance;
52
53 /**
54 * Novelist_Roles object
55 *
56 * @var object Instance of Novelist_Roles class.
57 * @since 1.0.0
58 */
59 public $roles;
60
61 /**
62 * HTML elements helper class.
63 *
64 * @var Novelist_HTML
65 * @since 1.1.0
66 */
67 public $html;
68
69 /**
70 * Novelist instance.
71 *
72 * Insures that only one instance of Novelist exists at any one time.
73 *
74 * @uses Novelist::setup_constants() Set up the plugin constants.
75 * @uses Novelist::includes() Include any required files.
76 * @uses Novelist::load_textdomain() Load the language files.
77 *
78 * @access public
79 * @since 1.0.0
80 * @return Novelist Instance of Novelist class
81 */
82 public static function instance() {
83
84 if ( ! isset( self::$instance ) && ! self::$instance instanceof Novelist ) {
85 self::$instance = new Novelist;
86 self::$instance->setup_constants();
87
88 add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) );
89
90 self::$instance->includes();
91 self::$instance->roles = new Novelist_Roles;
92 self::$instance->html = new Novelist_HTML;
93 }
94
95 return self::$instance;
96
97 }
98
99 /**
100 * Throw error on object clone.
101 *
102 * The whole idea of the singleton design pattern is that there is a single
103 * object therefore, we don't want the object to be cloned.
104 *
105 * @access protected
106 * @since 1.0.0
107 * @return void
108 */
109 public function __clone() {
110 // Cloning instances of the class is forbidden.
111 _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'novelist' ), '1.0.0' );
112 }
113
114 /**
115 * Disable unserializing of the class.
116 *
117 * @access protected
118 * @since 1.0.0
119 * @return void
120 */
121 public function __wakeup() {
122 // Unserializing instances of the class is forbidden.
123 _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'novelist' ), '1.0.0' );
124 }
125
126 /**
127 * Setup plugin constants.
128 *
129 * @access private
130 * @since 1.0.0
131 * @return void
132 */
133 private function setup_constants() {
134
135 // Plugin version.
136 if ( ! defined( 'NOVELIST_VERSION' ) ) {
137 define( 'NOVELIST_VERSION', '1.1.9' );
138 }
139
140 // Plugin Folder Path.
141 if ( ! defined( 'NOVELIST_PLUGIN_DIR' ) ) {
142 define( 'NOVELIST_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
143 }
144
145 // Plugin Folder URL.
146 if ( ! defined( 'NOVELIST_PLUGIN_URL' ) ) {
147 define( 'NOVELIST_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
148 }
149
150 // Plugin Root File.
151 if ( ! defined( 'NOVELIST_PLUGIN_FILE' ) ) {
152 define( 'NOVELIST_PLUGIN_FILE', __FILE__ );
153 }
154
155 }
156
157 /**
158 * Include Required Files
159 *
160 * @access private
161 * @since 1.0.0
162 * @return void
163 */
164 private function includes() {
165
166 global $novelist_options;
167
168 // Settings.
169 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/settings/register-settings.php';
170 if ( empty( $novelist_options ) ) {
171 $novelist_options = novelist_get_settings();
172 }
173
174 require_once NOVELIST_PLUGIN_DIR . 'includes/class-novelist-html.php';
175 require_once NOVELIST_PLUGIN_DIR . 'includes/class-novelist-roles.php';
176 require_once NOVELIST_PLUGIN_DIR . 'includes/post-types.php';
177 require_once NOVELIST_PLUGIN_DIR . 'includes/class-novelist-book.php';
178 require_once NOVELIST_PLUGIN_DIR . 'includes/class-novelist-shortcodes.php';
179 require_once NOVELIST_PLUGIN_DIR . 'includes/book-functions.php';
180 require_once NOVELIST_PLUGIN_DIR . 'includes/book-filters.php';
181 require_once NOVELIST_PLUGIN_DIR . 'includes/load-assets.php';
182 require_once NOVELIST_PLUGIN_DIR . 'includes/misc-functions.php';
183 require_once NOVELIST_PLUGIN_DIR . 'includes/template-functions.php';
184 require_once NOVELIST_PLUGIN_DIR . 'includes/widgets/widget-book.php';
185 require_once NOVELIST_PLUGIN_DIR . 'includes/widgets/widget-books-by-series.php';
186 require_once NOVELIST_PLUGIN_DIR . 'includes/widgets/widget-word-count.php';
187
188 if ( is_admin() ) {
189 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/admin-actions.php';
190 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/extensions.php';
191 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/thickbox.php';
192 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/tools.php';
193 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/admin-pages.php';
194 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/class-novelist-notices.php';
195 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/class-welcome.php';
196 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/settings/display-settings.php';
197 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/books/meta-box.php';
198 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/books/sanitize-meta-fields.php';
199 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/books/dashboard-columns.php';
200 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/books/demo-book.php';
201 require_once NOVELIST_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
202 }
203
204 require_once NOVELIST_PLUGIN_DIR . 'includes/install.php';
205
206 }
207
208 /**
209 * Loads the plugin language files.
210 *
211 * @access public
212 * @since 1.0.0
213 * @return void
214 */
215 public function load_textdomain() {
216
217 $lang_dir = dirname( plugin_basename( NOVELIST_PLUGIN_FILE ) ) . '/languages/';
218 $lang_dir = apply_filters( 'novelist/languages-directory', $lang_dir );
219 load_plugin_textdomain( 'novelist', false, $lang_dir );
220
221 }
222
223 }
224
225 endif; // End class exists check.
226
227 /**
228 * Get Novelist up and running.
229 *
230 * This function returns an instance of the Novelist class.
231 *
232 * @since 1.0.0
233 * @return Novelist
234 */
235 function Novelist() {
236 return Novelist::instance();
237 }
238
239 Novelist();