PluginProbe
Orderable – Restaurant & Food Ordering System / 0.2.0
Orderable – Restaurant & Food Ordering System v0.2.0
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.2.0, at orderable.php

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