| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
Plugin Name: Cooked - Recipe Management |
| 5 |
Plugin URI: https://wordpress.org/plugins/cooked/ |
| 6 |
Description: A recipe plugin for WordPress. |
| 7 |
Author: Boxy Studio |
| 8 |
Author URI: https://boxystudio.com |
| 9 |
Version: 1.7.15.4 |
| 10 |
Text Domain: cooked |
| 11 |
Domain Path: languages |
| 12 |
License: GPL2 |
| 13 |
|
| 14 |
Cooked is free software: you can redistribute it and/or modify |
| 15 |
it under the terms of the GNU General Public License as published by |
| 16 |
the Free Software Foundation, either version 2 of the License, or |
| 17 |
any later version. |
| 18 |
|
| 19 |
Cooked is distributed in the hope that it will be useful, |
| 20 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
GNU General Public License for more details. |
| 23 |
|
| 24 |
You should have received a copy of the GNU General Public License |
| 25 |
along with Cooked. If not, see http://www.gnu.org/licenses/. |
| 26 |
*/ |
| 27 |
|
| 28 |
// Exit if accessed directly. |
| 29 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 30 |
|
| 31 |
require_once __DIR__ . '/vendor/autoload.php'; |
| 32 |
|
| 33 |
define( 'COOKED_VERSION', '1.7.15.4' ); |
| 34 |
define( 'COOKED_DEV', false ); |
| 35 |
|
| 36 |
if ( ! class_exists( 'Cooked_Plugin' ) ) : |
| 37 |
|
| 38 |
/** |
| 39 |
* Cooked_Plugin Class. |
| 40 |
* |
| 41 |
* @since 1.0.0 |
| 42 |
*/ |
| 43 |
final class Cooked_Plugin { |
| 44 |
|
| 45 |
/** |
| 46 |
* @var Cooked_Plugin |
| 47 |
* @since 1.0.0 |
| 48 |
*/ |
| 49 |
private static $instance; |
| 50 |
|
| 51 |
/** |
| 52 |
* Cooked Roles Object. |
| 53 |
* |
| 54 |
* @var object|Cooked_Roles |
| 55 |
* @since 1.0.0 |
| 56 |
*/ |
| 57 |
public $roles; |
| 58 |
|
| 59 |
/** |
| 60 |
* Cooked Admin Menus Object. |
| 61 |
* |
| 62 |
* @var object|Cooked_Admin_Menus |
| 63 |
* @since 1.0.0 |
| 64 |
*/ |
| 65 |
public $admin_menus; |
| 66 |
|
| 67 |
/** |
| 68 |
* Cooked Admin Enqueues Object. |
| 69 |
* |
| 70 |
* @var object|Cooked_Admin_Enqueues |
| 71 |
* @since 1.0.0 |
| 72 |
*/ |
| 73 |
public $admin_enqueues; |
| 74 |
|
| 75 |
/** |
| 76 |
* Cooked Enqueues Object. |
| 77 |
* |
| 78 |
* @var object|Cooked_Enqueues |
| 79 |
* @since 1.0.0 |
| 80 |
*/ |
| 81 |
public $enqueues; |
| 82 |
|
| 83 |
/** |
| 84 |
* Cooked Settings Object. |
| 85 |
* |
| 86 |
* @var object|Cooked_Settings |
| 87 |
* @since 1.0.0 |
| 88 |
*/ |
| 89 |
public $admin_settings; |
| 90 |
|
| 91 |
/** |
| 92 |
* Cooked Migration Object. |
| 93 |
* |
| 94 |
* @var object|Cooked_Migration |
| 95 |
* @since 1.0.0 |
| 96 |
*/ |
| 97 |
public $migration; |
| 98 |
|
| 99 |
/** |
| 100 |
* Cooked Post Types Object. |
| 101 |
* |
| 102 |
* @var object|Cooked_Post_Types |
| 103 |
* @since 1.0.0 |
| 104 |
*/ |
| 105 |
public $post_types; |
| 106 |
|
| 107 |
/** |
| 108 |
* Cooked Recipe Meta Object. |
| 109 |
* |
| 110 |
* @var object|Cooked_Recipe_Meta |
| 111 |
* @since 1.0.0 |
| 112 |
*/ |
| 113 |
public $recipe_meta; |
| 114 |
|
| 115 |
/** |
| 116 |
* Cooked Measurements Object. |
| 117 |
* |
| 118 |
* @var object|Cooked_Measurements |
| 119 |
* @since 1.0.0 |
| 120 |
*/ |
| 121 |
public $measurements; |
| 122 |
|
| 123 |
/** |
| 124 |
* Cooked Users Object. |
| 125 |
* |
| 126 |
* @var object|Cooked_Users |
| 127 |
* @since 1.0.0 |
| 128 |
*/ |
| 129 |
public $users; |
| 130 |
|
| 131 |
/** |
| 132 |
* Cooked Recipes Object. |
| 133 |
* |
| 134 |
* @var object|Cooked_Recipes |
| 135 |
* @since 1.0.0 |
| 136 |
*/ |
| 137 |
public $recipes; |
| 138 |
|
| 139 |
/** |
| 140 |
* Cooked Shortcodes Object. |
| 141 |
* |
| 142 |
* @var object|Cooked_Shortcodes |
| 143 |
* @since 1.0.0 |
| 144 |
*/ |
| 145 |
public $shortcodes; |
| 146 |
|
| 147 |
/** |
| 148 |
* Cooked Ajax Object. |
| 149 |
* |
| 150 |
* @var object|Cooked_Ajax |
| 151 |
* @since 1.0.0 |
| 152 |
*/ |
| 153 |
public $ajax; |
| 154 |
|
| 155 |
/** |
| 156 |
* Cooked Functions Object. |
| 157 |
* |
| 158 |
* @var object|Cooked_Functions |
| 159 |
* @since 1.0.0 |
| 160 |
*/ |
| 161 |
public $functions; |
| 162 |
|
| 163 |
/** |
| 164 |
* Cooked Widgets Object. |
| 165 |
* |
| 166 |
* @var object|Cooked_Widgets |
| 167 |
* @since 1.0.0 |
| 168 |
*/ |
| 169 |
public $widget; |
| 170 |
|
| 171 |
/** |
| 172 |
* Cooked Gutenberg Object. |
| 173 |
* |
| 174 |
* @var object|Cooked_Gutenberg |
| 175 |
* @since 1.0.0 |
| 176 |
*/ |
| 177 |
public $gutenberg; |
| 178 |
|
| 179 |
/** |
| 180 |
* Cooked Elementor Object. |
| 181 |
* |
| 182 |
* @var object|Cooked_Elementor |
| 183 |
* @since 1.0.0 |
| 184 |
*/ |
| 185 |
public $elementor; |
| 186 |
|
| 187 |
/** |
| 188 |
* Main Cooked_Plugin Instance. |
| 189 |
* |
| 190 |
* Insures that only one instance of Cooked_Plugin exists in memory at any one |
| 191 |
* time. Also prevents needing to define globals everywhere. |
| 192 |
* |
| 193 |
* @since 1.0.0 |
| 194 |
* @static |
| 195 |
* @staticvar array $instance |
| 196 |
* @uses Cooked_Plugin::setup_constants() Setup the constants needed. |
| 197 |
* @uses Cooked_Plugin::includes() Include the required files. |
| 198 |
* @uses Cooked_Plugin::load_textdomain() load the language files. |
| 199 |
* @see Cooked() |
| 200 |
* @return object|Cooked_Plugin |
| 201 |
*/ |
| 202 |
public static function instance() { |
| 203 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Cooked_Plugin ) ) { |
| 204 |
self::$instance = new Cooked_Plugin; |
| 205 |
self::$instance->setup_constants(); |
| 206 |
|
| 207 |
add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) ); |
| 208 |
|
| 209 |
self::$instance->includes(); |
| 210 |
self::$instance->roles = new Cooked_Roles(); |
| 211 |
self::$instance->admin_menus = new Cooked_Admin_Menus(); |
| 212 |
|
| 213 |
if (is_admin()) { |
| 214 |
self::$instance->admin_enqueues = new Cooked_Admin_Enqueues(); |
| 215 |
} else { |
| 216 |
self::$instance->enqueues = new Cooked_Enqueues(); |
| 217 |
} |
| 218 |
|
| 219 |
self::$instance->admin_settings = new Cooked_Settings(); |
| 220 |
self::$instance->migration = new Cooked_Migration(); |
| 221 |
self::$instance->post_types = new Cooked_Post_Types(); |
| 222 |
self::$instance->recipe_meta = new Cooked_Recipe_Meta(); |
| 223 |
self::$instance->recipe_meta = new Cooked_Measurements(); |
| 224 |
self::$instance->users = new Cooked_Users(); |
| 225 |
self::$instance->recipes = new Cooked_Recipes(); |
| 226 |
self::$instance->shortcodes = new Cooked_Shortcodes(); |
| 227 |
self::$instance->ajax = new Cooked_Ajax(); |
| 228 |
self::$instance->functions = new Cooked_Functions(); |
| 229 |
self::$instance->widget = new Cooked_Widgets(); |
| 230 |
self::$instance->gutenberg = new Cooked_Gutenberg(); |
| 231 |
self::$instance->elementor = new Cooked_Elementor(); |
| 232 |
|
| 233 |
self::$instance->module_setup(); |
| 234 |
} |
| 235 |
|
| 236 |
return self::$instance; |
| 237 |
} |
| 238 |
|
| 239 |
private function module_setup() { |
| 240 |
// Look for Cooked Modules |
| 241 |
$modules = file_exists( COOKED_DIR . 'modules' ) ? scandir( COOKED_DIR . 'modules' ) : false; |
| 242 |
if ($modules): |
| 243 |
foreach($modules as $module_name): |
| 244 |
if ($module_name !== '.' && $module_name !== '..'): |
| 245 |
if ( file_exists( COOKED_DIR . 'modules/'.esc_attr( $module_name ).'/'.esc_attr( $module_name ).'.php' ) ): |
| 246 |
require_once COOKED_DIR . 'modules/'.esc_attr( $module_name ).'/'.esc_attr( $module_name ).'.php'; |
| 247 |
endif; |
| 248 |
endif; |
| 249 |
endforeach; |
| 250 |
endif; |
| 251 |
|
| 252 |
// Look for Cooked Modules in Parent Theme |
| 253 |
$parent_theme_folder = trailingslashit( get_template_directory() ); |
| 254 |
$modules = file_exists( $parent_theme_folder . 'cooked-modules' ) ? scandir( $parent_theme_folder . 'cooked-modules' ) : false; |
| 255 |
if ($modules): |
| 256 |
foreach($modules as $module_name): |
| 257 |
if ($module_name !== '.' && $module_name !== '..'): |
| 258 |
if ( file_exists( $parent_theme_folder . 'cooked-modules/'.esc_attr( $module_name ).'/'.esc_attr( $module_name ).'.php' ) ): |
| 259 |
require_once $parent_theme_folder . 'cooked-modules/'.esc_attr( $module_name ).'/'.esc_attr( $module_name ).'.php'; |
| 260 |
endif; |
| 261 |
endif; |
| 262 |
endforeach; |
| 263 |
endif; |
| 264 |
|
| 265 |
// Look for Cooked Modules in Child Theme (if one is active) |
| 266 |
$child_theme_folder = trailingslashit( get_stylesheet_directory() ); |
| 267 |
if ($child_theme_folder != $parent_theme_folder): |
| 268 |
$modules = file_exists( $child_theme_folder . 'cooked-modules' ) ? scandir( $child_theme_folder . 'cooked-modules' ) : false; |
| 269 |
if ($modules): |
| 270 |
foreach($modules as $module_name): |
| 271 |
if ($module_name !== '.' && $module_name !== '..'): |
| 272 |
if ( file_exists( $child_theme_folder . 'cooked-modules/'.esc_attr( $module_name ).'/'.esc_attr( $module_name ).'.php' ) ): |
| 273 |
require_once $child_theme_folder . 'cooked-modules/'.esc_attr( $module_name ).'/'.esc_attr( $module_name ).'.php'; |
| 274 |
endif; |
| 275 |
endif; |
| 276 |
endforeach; |
| 277 |
endif; |
| 278 |
endif; |
| 279 |
} |
| 280 |
|
| 281 |
/** |
| 282 |
* Throw error on object clone. |
| 283 |
* |
| 284 |
* The whole idea of the singleton design pattern is that there is a single |
| 285 |
* object therefore, we don't want the object to be cloned. |
| 286 |
* |
| 287 |
* @since 1.0.0 |
| 288 |
* @access protected |
| 289 |
* @return void |
| 290 |
*/ |
| 291 |
public function __clone() { |
| 292 |
// Nope, can't do that. |
| 293 |
return false; |
| 294 |
} |
| 295 |
|
| 296 |
/** |
| 297 |
* Disable unserializing of the class. |
| 298 |
* |
| 299 |
* @since 1.0.0 |
| 300 |
* @access protected |
| 301 |
* @return void |
| 302 |
*/ |
| 303 |
public function __wakeup() { |
| 304 |
// Nope, can't do that either. |
| 305 |
return false; |
| 306 |
} |
| 307 |
|
| 308 |
/** |
| 309 |
* Setup plugin constants. |
| 310 |
* |
| 311 |
* @access private |
| 312 |
* @since 1.0.0 |
| 313 |
* @return void |
| 314 |
*/ |
| 315 |
private function setup_constants() { |
| 316 |
// Plugin Folder Path. |
| 317 |
if ( ! defined( 'COOKED_DIR' ) ) { |
| 318 |
define( 'COOKED_DIR', plugin_dir_path( __FILE__ ) ); |
| 319 |
} |
| 320 |
|
| 321 |
// Plugin Folder Name. |
| 322 |
if ( ! defined( 'COOKED_FOLDER' ) ) { |
| 323 |
$foldername = untrailingslashit( str_replace( 'cooked.php', '', plugin_basename( __FILE__ ) ) ); |
| 324 |
define( 'COOKED_FOLDER', $foldername ); |
| 325 |
} |
| 326 |
|
| 327 |
// Plugin Root File. |
| 328 |
if ( ! defined( 'COOKED_PLUGIN_FILE' ) ) { |
| 329 |
define( 'COOKED_PLUGIN_FILE', __FILE__ ); |
| 330 |
} |
| 331 |
|
| 332 |
// Plugin Folder URL. |
| 333 |
if ( ! defined( 'COOKED_URL' ) ) { |
| 334 |
define( 'COOKED_URL', plugin_dir_url( __FILE__ ) ); |
| 335 |
} |
| 336 |
|
| 337 |
// WordPress Ajax URL. |
| 338 |
if ( ! defined( 'COOKED_AJAX_URL' ) ) { |
| 339 |
define( 'COOKED_AJAX_URL', admin_url('admin-ajax.php') ); |
| 340 |
} |
| 341 |
|
| 342 |
// Make sure CAL_GREGORIAN is defined. |
| 343 |
if ( ! defined( 'CAL_GREGORIAN' ) ) { |
| 344 |
define( 'CAL_GREGORIAN', 1 ); |
| 345 |
} |
| 346 |
|
| 347 |
// Time Format |
| 348 |
if ( ! defined( 'COOKED_TIME_FORMAT' ) ) { |
| 349 |
define( 'COOKED_TIME_FORMAT', get_option('time_format','g:ia') ); |
| 350 |
} |
| 351 |
|
| 352 |
// Date Format |
| 353 |
if ( ! defined( 'COOKED_DATE_FORMAT' ) ) { |
| 354 |
define( 'COOKED_DATE_FORMAT', get_option('date_format','F j, Y') ); |
| 355 |
} |
| 356 |
} |
| 357 |
|
| 358 |
/** |
| 359 |
* Include required files. |
| 360 |
* |
| 361 |
* @access private |
| 362 |
* @since 1.0.0 |
| 363 |
* @return void |
| 364 |
*/ |
| 365 |
private function includes() { |
| 366 |
require_once COOKED_DIR . 'includes/class.cooked-users.php'; |
| 367 |
require_once COOKED_DIR . 'includes/class.cooked-roles.php'; |
| 368 |
require_once COOKED_DIR . 'includes/class.cooked-taxonomies.php'; |
| 369 |
require_once COOKED_DIR . 'includes/class.cooked-post-types.php'; |
| 370 |
require_once COOKED_DIR . 'includes/class.cooked-seo.php'; |
| 371 |
require_once COOKED_DIR . 'includes/class.cooked-recipes.php'; |
| 372 |
require_once COOKED_DIR . 'includes/class.cooked-recipe-meta.php'; |
| 373 |
require_once COOKED_DIR . 'includes/class.cooked-shortcodes.php'; |
| 374 |
require_once COOKED_DIR . 'includes/class.cooked-measurements.php'; |
| 375 |
require_once COOKED_DIR . 'includes/class.cooked-admin-enqueues.php'; |
| 376 |
require_once COOKED_DIR . 'includes/class.cooked-enqueues.php'; |
| 377 |
require_once COOKED_DIR . 'includes/class.cooked-admin-menus.php'; |
| 378 |
require_once COOKED_DIR . 'includes/class.cooked-settings.php'; |
| 379 |
require_once COOKED_DIR . 'includes/class.cooked-migration.php'; |
| 380 |
require_once COOKED_DIR . 'includes/class.cooked-ajax.php'; |
| 381 |
require_once COOKED_DIR . 'includes/class.cooked-functions.php'; |
| 382 |
require_once COOKED_DIR . 'includes/class.cooked-widgets.php'; |
| 383 |
require_once COOKED_DIR . 'includes/class.cooked-gutenberg.php'; |
| 384 |
require_once COOKED_DIR . 'includes/class.cooked-elementor.php'; |
| 385 |
} |
| 386 |
|
| 387 |
/** |
| 388 |
* Loads the plugin language files. |
| 389 |
* |
| 390 |
* @access public |
| 391 |
* @since 1.0.0 |
| 392 |
* @return void |
| 393 |
*/ |
| 394 |
public function load_textdomain() { |
| 395 |
/* |
| 396 |
* When translating Cooked, be sure to move your language file into the proper location: |
| 397 |
* |
| 398 |
* - wp-content/languages/plugins/cooked |
| 399 |
* |
| 400 |
* If you do not move custom language files here, they will be lost when updating Cooked. Boxy Studio |
| 401 |
* recommends Loco Translate for easy translations: https://boxystudio.ticksy.com/article/3235/ |
| 402 |
*/ |
| 403 |
|
| 404 |
// Set filter for plugin's languages directory. |
| 405 |
$cooked_lang_dir = apply_filters( 'cooked_languages_directory', COOKED_DIR . 'languages/' ); |
| 406 |
|
| 407 |
// Traditional WordPress plugin locale filter. |
| 408 |
$locale = apply_filters( 'plugin_locale', get_locale(), 'cooked' ); |
| 409 |
$mofile = sprintf( '%1$s-%2$s.mo', 'cooked', $locale ); |
| 410 |
|
| 411 |
// Look in wp-content/languages/plugins/cooked |
| 412 |
$lang_file_ext = WP_LANG_DIR . '/plugins/cooked/' . $mofile; |
| 413 |
|
| 414 |
if ( file_exists( $lang_file_ext ) ) { |
| 415 |
// Load the externally located language files. |
| 416 |
load_textdomain( 'cooked', $lang_file_ext ); |
| 417 |
} else { |
| 418 |
// Load the default language files. |
| 419 |
load_plugin_textdomain( 'cooked', false, COOKED_FOLDER . '/languages' ); |
| 420 |
} |
| 421 |
} |
| 422 |
|
| 423 |
} |
| 424 |
|
| 425 |
endif; // End if class_exists check. |
| 426 |
|
| 427 |
// Uninstall Hook |
| 428 |
register_uninstall_hook( __FILE__, 'cooked_uninstall' ); |
| 429 |
function cooked_uninstall(){ |
| 430 |
Cooked_Roles::remove_caps(); |
| 431 |
Cooked_Roles::remove_roles(); |
| 432 |
flush_rewrite_rules(); |
| 433 |
} |
| 434 |
|
| 435 |
/** |
| 436 |
* The main function for that returns Cooked_Plugin |
| 437 |
* |
| 438 |
* The main function responsible for returning the Cooked_Plugin |
| 439 |
* Instance to functions everywhere. |
| 440 |
* |
| 441 |
* Use this function like you would a global variable, except without needing |
| 442 |
* to declare the global. |
| 443 |
* |
| 444 |
* Example: <?php $cooked = Cooked(); ?> |
| 445 |
* |
| 446 |
* @since 1.0.0 |
| 447 |
* @return object|Cooked_Plugin |
| 448 |
*/ |
| 449 |
function Cooked() { |
| 450 |
return Cooked_Plugin::instance(); |
| 451 |
} |
| 452 |
|
| 453 |
// Let's get cooking! |
| 454 |
$CookedPlugin = Cooked(); |
| 455 |
|