PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.29
Booktics – Appointment Booking Calendar for Service Businesses v1.0.29
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 -8 1.0.0 → 1.0.29 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.0';
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
@@ -124,15 +126,18 @@
124 126 *
125 127 * @return void
126 128 */
127 129 public function init_classes() {
128 - if ( ! session_id() ) {
129 - session_start();
130 - }
130 + self::register_custom_post_type();
131 +
132 + ( new \Booktics\Base\Services\Post_Status_Service() )->register();
133 +
131 134 $service_provider = $this->get_container()->get( 'global' );
132 135
133 136 // Initilize Plugin Banner Notice.
134 137 Plugin_Notice::run();
138 +
139 + self::version_check();
135 140 }
136 141
137 142 /**
138 143 * Get container
@@ -185,6 +190,68 @@
185 190 * @return string
186 191 */
187 192 public static function assets_url(): string {
188 193 return trailingslashit( plugins_url( '', BOOKTICS_FILE ) . '/assets' );
194 + }
195 +
196 + /**
197 + * Check if the plugin version is up to date
198 + *
199 + * @return void
200 + */
201 + public static function version_check() {
202 + $latest_version = BOOKTICS_VERSION;
203 + if ( is_multisite() ) {
204 + $sites = get_sites();
205 +
206 + foreach ( $sites as $site ) {
207 + switch_to_blog( $site->blog_id );
208 +
209 + $installed_version = booktics_get_option( 'booktics_version' );
210 + if ( $installed_version < $latest_version ) {
211 + self::run_migration();
212 + booktics_update_option( 'booktics_version', booktics()->version );
213 + }
214 +
215 + restore_current_blog();
216 + }
217 + } else {
218 + $installed_version = booktics_get_option( 'booktics_version' );
219 + if ( $installed_version < $latest_version ) {
220 + self::run_migration();
221 + booktics_update_option( 'booktics_version', booktics()->version );
222 + }
223 + }
224 + }
225 +
226 + /**
227 + * Run migration
228 + *
229 + * @return void
230 + */
231 + public static function run_migration() {
232 + Installer::create_tables();
233 + }
234 +
235 + /**
236 + * Register post type
237 + *
238 + * @return void
239 + */
240 + public static function register_custom_post_type() {
241 + register_post_type(
242 + 'booktics-service', array(
243 + 'labels' => array(
244 + 'name' => __( 'Services', 'booktics' ),
245 + 'singular_name' => __( 'Service', 'booktics' ),
246 + ),
247 + 'public' => true,
248 + 'has_archive' => true,
249 + 'has_single' => true,
250 + 'rewrite' => true,
251 + 'supports' => array( 'title', 'editor', 'thumbnail' ),
252 + 'show_in_rest' => true,
253 + 'show_in_menu' => false,
254 + )
255 + );
189 256 }
190 257 }