PluginProbe
Orderable – Restaurant & Food Ordering System / 1.0.0
Orderable – Restaurant & Food Ordering System v1.0.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 1.0.0, at orderable.php

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