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