PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.28
Booktics – Appointment Booking Calendar for Service Businesses v1.0.28
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
← All changes | base/booktics.php +75 -5 1.0.2 → 1.0.28 View file →
@@ -6,8 +6,10 @@
6 6 */
7 7
8 8 namespace Booktics;
9 9
10 +if ( ! defined( 'ABSPATH' ) ) exit;
11 +
10 12 use Booktics\Container\Container;
11 13
12 14 /**
13 15 * Class Booktics
@@ -95,9 +97,9 @@
95 97 *
96 98 * @return void
97 99 */
98 100 protected function init(): void {
99 - $this->version = '1.0.1';
101 + $this->version = BOOKTICS_VERSION;
100 102 $this->plugin_file = BOOKTICS_FILE;
101 103 $this->plugin_directory = BOOKTICS_DIR;
102 104 $this->basename = plugin_basename( $this->plugin_file );
103 105 $this->text_domain_directory = $this->plugin_directory . '/languages';
@@ -106,16 +108,16 @@
106 108 $this->assets_url = $this->plugin_url . '/assets';
107 109 $this->build_url = $this->plugin_url . '/build';
108 110 register_activation_hook(
109 111 $this->plugin_file, array(
110 - $this,
111 - 'activate',
112 + $this,
113 + 'activate',
112 114 )
113 115 );
114 116 register_deactivation_hook(
115 117 $this->plugin_file, array(
116 - $this,
117 - 'deactivate',
118 + $this,
119 + 'deactivate',
118 120 )
119 121 );
120 122 }
121 123
@@ -127,12 +129,18 @@
127 129 public function init_classes() {
128 130 if ( ! session_id() ) {
129 131 session_start();
130 132 }
133 + self::register_custom_post_type();
134 +
135 + ( new \Booktics\Base\Services\Post_Status_Service() )->register();
136 +
131 137 $service_provider = $this->get_container()->get( 'global' );
132 138
133 139 // Initilize Plugin Banner Notice.
134 140 Plugin_Notice::run();
141 +
142 + self::version_check();
135 143 }
136 144
137 145 /**
138 146 * Get container
@@ -185,6 +193,68 @@
185 193 * @return string
186 194 */
187 195 public static function assets_url(): string {
188 196 return trailingslashit( plugins_url( '', BOOKTICS_FILE ) . '/assets' );
197 + }
198 +
199 + /**
200 + * Check if the plugin version is up to date
201 + *
202 + * @return void
203 + */
204 + public static function version_check() {
205 + $latest_version = BOOKTICS_VERSION;
206 + if ( is_multisite() ) {
207 + $sites = get_sites();
208 +
209 + foreach ( $sites as $site ) {
210 + switch_to_blog( $site->blog_id );
211 +
212 + $installed_version = booktics_get_option( 'booktics_version' );
213 + if ( $installed_version < $latest_version ) {
214 + self::run_migration();
215 + booktics_update_option( 'booktics_version', booktics()->version );
216 + }
217 +
218 + restore_current_blog();
219 + }
220 + } else {
221 + $installed_version = booktics_get_option( 'booktics_version' );
222 + if ( $installed_version < $latest_version ) {
223 + self::run_migration();
224 + booktics_update_option( 'booktics_version', booktics()->version );
225 + }
226 + }
227 + }
228 +
229 + /**
230 + * Run migration
231 + *
232 + * @return void
233 + */
234 + public static function run_migration() {
235 + Installer::create_tables();
236 + }
237 +
238 + /**
239 + * Register post type
240 + *
241 + * @return void
242 + */
243 + public static function register_custom_post_type() {
244 + register_post_type(
245 + 'booktics-service', array(
246 + 'labels' => array(
247 + 'name' => __( 'Services', 'booktics' ),
248 + 'singular_name' => __( 'Service', 'booktics' ),
249 + ),
250 + 'public' => true,
251 + 'has_archive' => true,
252 + 'has_single' => true,
253 + 'rewrite' => true,
254 + 'supports' => array( 'title', 'editor', 'thumbnail' ),
255 + 'show_in_rest' => true,
256 + 'show_in_menu' => false,
257 + )
258 + );
189 259 }
190 260 }