PluginProbe
Orderable – Restaurant & Food Ordering System / 0.1.5
Orderable – Restaurant & Food Ordering System v0.1.5
0.1.4 0.1.5 0.2.0 1.0.0 1.1.0 1.1.1 1.10.0 1.10.1 1.11.0 1.12.0 1.12.1 1.12.2 1.13.0 1.14.0 1.15.0 1.16.0 1.17.0 1.17.1 1.18.0 1.19.0 1.19.1 1.19.2 1.2.0 1.20.0 1.20.1 All 44 releases
orderable / orderable.php

orderable.php in Orderable – Restaurant & Food Ordering System 0.1.5, at orderable.php

168 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Orderable - Local Ordering System
4 * Author URI: https://orderable.com
5 * Description: Take local online ordering to a whole new level with Orderable.
6 * Version: 0.1.5
7 * Author: Orderable
8 * Text Domain: orderable
9 * WC requires at least: 5.4.0
10 * WC tested up to: 5.5.2
11 */
12
13 defined( 'ABSPATH' ) || exit;
14
15 /**
16 * Orderable main class.
17 */
18 class Orderable {
19 /**
20 * @var string Plugin version.
21 */
22 public static $version = '0.1.5';
23
24 /**
25 * @var string Required pro version.
26 */
27 public static $required_pro_version = '0.1.4-beta1';
28
29 /**
30 * Construct the plugin.
31 */
32 public function __construct() {
33 $this->define_constants();
34
35 load_plugin_textdomain( 'orderable', false, ORDERABLE_LANGUAGES_PATH );
36
37 add_action( 'plugins_loaded', array( $this, 'run' ), 20 );
38 }
39
40 /**
41 * Run.
42 */
43 public function run() {
44 if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
45 add_action( 'admin_notices', array( __CLASS__, 'orderable_notice_woocommerce' ) );
46
47 return;
48 }
49
50 $this->load_classes();
51 $this->update_check();
52
53 if ( ! $this->validate_pro_version() ) {
54 add_action( 'admin_notices', array( __CLASS__, 'orderable_notice_pro_version' ) );
55
56 $this->define( 'ORDERABLE_PRO_INVALID', true );
57 }
58
59 do_action( 'orderable_init' );
60 }
61
62 /**
63 * Run script sif plugin version has changed.
64 */
65 private function update_check() {
66 if ( ORDERABLE_VERSION === get_site_option( 'orderable_version' ) ) {
67 return;
68 }
69
70 Orderable_Helpers::delete_orderable_transients();
71 update_option( 'orderable_version', ORDERABLE_VERSION );
72 }
73
74 /**
75 * Activate WooCommerce notice.
76 */
77 public static function orderable_notice_woocommerce() {
78 ?>
79 <div class="notice notice-error">
80 <p>
81 <?php _e( 'Orderable requires WooCommerce to be installed and activated.', 'orderable' ); ?>
82 </p>
83 </div>
84 <?php
85 }
86
87 /**
88 * Get Orderable pro version notice.
89 */
90 public static function orderable_notice_pro_version() {
91 ?>
92 <div class="notice notice-error">
93 <p>
94 <?php printf( __( 'Orderable Pro needs to be at least v%s for compatibility. Please update the Orderable Pro plugin.', 'orderable' ), self::$required_pro_version ); ?>
95 <a href="<?php echo esc_url( admin_url( 'update-core.php' ) ); ?>"><?php _e( 'Update now', 'orderable' ); ?></a>.
96 </p>
97 </div>
98 <?php
99 }
100
101 /**
102 * Define Constants.
103 */
104 private function define_constants() {
105 $this->define( 'ORDERABLE_PATH', plugin_dir_path( __FILE__ ) );
106 $this->define( 'ORDERABLE_URL', plugin_dir_url( __FILE__ ) );
107 $this->define( 'ORDERABLE_ASSETS_URL', ORDERABLE_URL . 'assets/' );
108 $this->define( 'ORDERABLE_INC_PATH', ORDERABLE_PATH . 'inc/' );
109 $this->define( 'ORDERABLE_MODULES_PATH', ORDERABLE_INC_PATH . 'modules/' );
110 $this->define( 'ORDERABLE_VENDOR_PATH', ORDERABLE_INC_PATH . 'vendor/' );
111 $this->define( 'ORDERABLE_LANGUAGES_PATH', ORDERABLE_INC_PATH . 'languages/' );
112 $this->define( 'ORDERABLE_TEMPLATES_PATH', ORDERABLE_PATH . 'templates/' );
113 $this->define( 'ORDERABLE_TPL_PATH', ORDERABLE_PATH . 'templates/' );
114 $this->define( 'ORDERABLE_BASENAME', plugin_basename( __FILE__ ) );
115 $this->define( 'ORDERABLE_VERSION', self::$version );
116 }
117
118 /**
119 * Define constant if not already set.
120 *
121 * @param string $name
122 * @param string|bool $value
123 */
124 private function define( $name, $value ) {
125 if ( ! defined( $name ) ) {
126 define( $name, $value );
127 }
128 }
129
130 /**
131 * Load classes.
132 */
133 private function load_classes() {
134 require_once( ORDERABLE_INC_PATH . 'class-helpers.php' );
135 require_once( ORDERABLE_INC_PATH . 'class-settings.php' );
136 require_once( ORDERABLE_INC_PATH . 'class-modules.php' );
137 require_once( ORDERABLE_INC_PATH . 'class-assets.php' );
138 require_once( ORDERABLE_INC_PATH . 'class-products.php' );
139 require_once( ORDERABLE_INC_PATH . 'class-ajax.php' );
140 require_once( ORDERABLE_INC_PATH . 'class-orders.php' );
141 require_once( ORDERABLE_INC_PATH . 'class-admin-notices.php' );
142
143 Orderable_Settings::run();
144 Orderable_Assets::run();
145 Orderable_Modules::run();
146 Orderable_Products::run();
147 Orderable_Ajax::run();
148 Orderable_Admin_Notices::run();
149 }
150
151 /**
152 * Validate the Orderable core version number.
153 *
154 * @return bool
155 */
156 private static function validate_pro_version() {
157 if ( ! defined( 'ORDERABLE_PRO_VERSION' ) ) {
158 // Pro version is valid because it doesn't exist.
159 return true;
160 }
161
162 $pro_version = explode( '-', ORDERABLE_PRO_VERSION );
163
164 return version_compare( $pro_version[0], self::$required_pro_version, '>=' );
165 }
166 }
167
168 $orderable = new Orderable();