PluginProbe
Timetable and Event Schedule by MotoPress / 2.4.13
Timetable and Event Schedule by MotoPress v2.4.13
2.4.19 2.4.18 trunk 2.3.19 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.9
mp-timetable / mp-timetable.php

mp-timetable.php in Timetable and Event Schedule by MotoPress 2.4.13, at mp-timetable.php

297 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Timetable and Event Schedule
5 * Plugin URI: https://motopress.com/products/timetable-event-schedule/
6 * Description: Smart time-management tool with a clean minimalist design for featuring your timetables and upcoming events.
7 * Version: 2.4.13
8 * Author: MotoPress
9 * Author URI: https://motopress.com
10 * License: GPLv2 or later
11 * Text Domain: mp-timetable
12 * Domain Path: /languages
13 */
14
15 /*
16 * This plugin contains hooks that allow you to edit, add and move content without the need to edit template files.
17 * This method protects against upgrade issues. There are several actions and filters you can use to modify content output.
18 * You can check \mp-timetable\classes\class-hooks.php for the list of hooks.
19 *
20 * Alternatively in "Developer Mode", you can copy template files from '/mp-timetable/templates/' folder to '/your-theme/mp-timetable/' to override them.
21 *
22 * The Timetable plugin also supports default WordPress templates hierarchy:
23 * https://developer.wordpress.org/themes/basics/template-hierarchy/#visual-overview
24 */
25
26 defined( 'ABSPATH' ) || exit;
27
28 use mp_timetable\plugin_core\classes\Core;
29
30 if ( ! defined( 'MP_TT_DEBUG' ) ) {
31 define( 'MP_TT_DEBUG', false );
32 }
33
34 if ( ! defined( 'MP_TT_PLUGIN_FILE' ) ) {
35 define( 'MP_TT_PLUGIN_FILE', __FILE__ );
36 }
37
38 if ( ! defined( 'MP_TT_PLUGIN_BASENAME' ) ) {
39 define( 'MP_TT_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
40 }
41
42 register_activation_hook( __FILE__, array( Mp_Time_Table::init(), 'on_activation' ) );
43 register_deactivation_hook( __FILE__, array( 'Mp_Time_Table', 'on_deactivation' ) );
44 register_uninstall_hook( __FILE__, array( 'Mp_Time_Table', 'on_uninstall' ) );
45
46 add_action( 'plugins_loaded', array( 'Mp_Time_Table', 'init' ) );
47
48 if ( version_compare( get_bloginfo( 'version' ), '5.1', '>=' ) ) {
49 add_action( 'wp_insert_site', array( 'Mp_Time_Table', 'on_create_blog' ) );
50 } else {
51 add_action( 'wpmu_new_blog', array( 'Mp_Time_Table', 'on_create_blog' ) );
52 }
53
54 add_filter( 'wpmu_drop_tables', array( 'Mp_Time_Table', 'on_delete_blog' ) );
55
56 /**
57 * Class Mp_Time_Table
58 */
59 class Mp_Time_Table {
60
61 protected static $instance;
62
63 /**
64 * Mp_Time_Table constructor.
65 */
66 public function __construct() {
67 $this->include_all();
68 Core::get_instance()->init_plugin( 'mp_timetable' );
69 }
70
71 /**
72 * Include all files
73 */
74 public function include_all() {
75 /**
76 * Include Gump
77 */
78 require_once self::get_plugin_path() . 'classes/libs/class-gump.php';
79 /**
80 * Install Parsers
81 */
82 require_once self::get_plugin_path() . 'classes/libs/parsers.php';
83 /**
84 * Include Permalinks
85 */
86 require_once self::get_plugin_path() . 'classes/class-permalinks.php';
87 /**
88 * Include Core
89 */
90 require_once self::get_plugin_path() . 'classes/class-core.php';
91 /**
92 * Include module
93 */
94 require_once self::get_plugin_path() . 'classes/class-module.php';
95 /**
96 * Include Model
97 */
98 require_once self::get_plugin_path() . 'classes/class-model.php';
99
100 /**
101 * Include Controller
102 */
103 require_once self::get_plugin_path() . 'classes/class-controller.php';
104 /**
105 * Include State factory
106 */
107 require_once self::get_plugin_path() . 'classes/class-state-factory.php';
108
109 /**
110 * Include Preprocessor
111 */
112 require_once self::get_plugin_path() . 'classes/class-preprocessor.php';
113
114 /**
115 * include shortcodes
116 */
117 require_once( self::get_plugin_path() . 'classes/class-shortcode.php' );
118 /**
119 * include Widgets
120 */
121 require_once self::get_plugin_path() . 'classes/widgets/class-mp-timetable-widget.php';
122 /**
123 * Include view
124 */
125 require_once self::get_plugin_path() . 'classes/class-view.php';
126 /**
127 * Include hooks
128 */
129 require_once self::get_plugin_path() . 'classes/class-hooks.php';
130
131 /**
132 * Include blocks
133 */
134 require_once self::get_plugin_path() . 'classes/blocks/class-timetable-block.php';
135
136 /**
137 * Include Widgets Managers
138 */
139 require_once self::get_plugin_path() . 'classes/class-widgets-manager.php';
140 }
141
142 /**
143 * Get plugin path
144 */
145 public static function get_plugin_path() {
146 return plugin_dir_path( __FILE__ );
147 }
148
149 /**
150 * @return Mp_Time_Table
151 */
152 public static function init() {
153 if ( null === self::$instance ) {
154 self::$instance = new self();
155 }
156
157 return self::$instance;
158 }
159
160 /**
161 * Retrieve relative to theme root path to templates.
162 *
163 * @return string
164 */
165 public static function get_template_path() {
166 return apply_filters( 'mptt_template_path', 'mp-timetable/' );
167 }
168
169 /**
170 * Retrieve relative to plugin root path to templates.
171 *
172 * @return string
173 */
174 public static function get_templates_path() {
175 return self::get_plugin_path() . 'templates/';
176 }
177
178 /**
179 * Get plugin part path
180 *
181 * @param string $part
182 *
183 * @return string
184 */
185 public static function get_plugin_part_path( $part = '' ) {
186 return self::get_plugin_path() . $part;
187 }
188
189 /**
190 * On activation
191 */
192 public static function on_activation( $network_wide = false ) {
193
194 if ( $network_wide && is_multisite() ) {
195
196 $sites = get_sites();
197
198 foreach( $sites as $site ) {
199
200 $blog_id = $site->blog_id;
201
202 switch_to_blog( $blog_id );
203 Mp_Time_Table::install();
204 restore_current_blog();
205
206 }
207 } else {
208
209 Mp_Time_Table::install();
210
211 }
212 }
213
214 /**
215 * Install
216 */
217 public static function install() {
218 // Register post type
219 Core::get_instance()->register_all_post_type();
220
221 // Register taxonomy all
222 Core::get_instance()->register_all_taxonomies();
223
224 flush_rewrite_rules( false );
225
226 //Create table in not exists
227 Core::get_instance()->create_table();
228 }
229
230 /**
231 * On deactivation
232 */
233 public static function on_deactivation() {
234 flush_rewrite_rules( false );
235 }
236
237 /**
238 * On uninstall
239 */
240 public static function on_uninstall() {
241 do_action( 'mptt_on_uninstall' );
242 }
243
244 /**
245 * On create blog
246 *
247 * @param int|WP_Site $blog
248 */
249 public static function on_create_blog( $blog ) {
250
251 if ( is_plugin_active_for_network( MP_TT_PLUGIN_BASENAME ) ) {
252
253 if ( ! is_int( $blog ) ) {
254 $blog = $blog->id;
255 }
256
257 switch_to_blog( $blog );
258 Mp_Time_Table::install();
259 restore_current_blog();
260 }
261 }
262
263 /**
264 * On blog creation
265 */
266 public static function on_delete_blog( $tables ) {
267
268 $tables[] = self::get_datatable();
269
270 return $tables;
271 }
272
273 /**
274 * Get data table name
275 *
276 * @return string
277 */
278 public static function get_datatable() {
279 global $wpdb;
280
281 return $wpdb->prefix . "mp_timetable_data";
282 }
283
284 /**
285 * Get plugin url
286 *
287 * @param string $path
288 *
289 * @return string
290 */
291 static function get_plugin_url( $path = '' ) {
292
293 return plugin_dir_url( __FILE__ ) . $path;
294 }
295
296 }
297