forked from wp-plugins/all-in-one-event-calendar
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopen-source-event-calendar.php
More file actions
110 lines (97 loc) · 3.28 KB
/
open-source-event-calendar.php
File metadata and controls
110 lines (97 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* Plugin Name: Open Source Event Calendar
* Plugin URI: https://github.com/digitaldonkey/open-source-event-calendar
* Description: An event calendar with native iCal / ICS import and export
* Author: digitaldonkey, Time.ly Network Inc
* Author URI: https://github.com/digitaldonkey
* Donate link: https://www.paypal.com/donate/?hosted_button_id=ZNWEQRQNJBTE6
* Contributors: digitaldonkey, hubrik, vtowel, yaniiliev, nicolapeluchetti, jbutkus, lpawlik, bangelov
* Tags: calendar, events, ics, ical importer
* Requires at least: 6.6
* Tested up to: 6.9
* Requires PHP: 8.2
* Stable Tag: 1.1.4
* License: GPL-3.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: open-source-event-calendar
* Domain Path: /languages
* Version: 1.1.4
*/
if (! defined('ABSPATH')) {
exit;
}
use Osec\App\Controller\BootstrapController;
use Osec\App\Controller\FrontendCssController;
use Osec\App\Controller\Scheduler;
use Osec\App\Model\DatabaseSchema;
use Osec\App\Model\PostTypeEvent\EventType;
use Osec\App\Model\Settings;
use Osec\Exception\BootstrapException;
use Osec\Exception\DatabaseSchemaException;
use Osec\Exception\DatabaseUpdateException;
use Osec\Theme\ThemeLoader;
// phpcs:disable PSR1.Files.SideEffects
// PHP Composer @see package.json.
if (
// Try fixing a bug where
! class_exists('\Osec\App\Controller\BootstrapController')) {
require_once __DIR__ . '/vendor/autoload.php';
add_action('init', function () {
BootstrapController::createApp(__DIR__);
}, -100);
}
/**
* Activate plugin.
*
* Note:
* Required as a function in this file to be able to bootstrap our phpunit
* and use register_activation_hook().
*
* @return void
* @throws BootstrapException
* @throws DatabaseSchemaException
* @throws DatabaseUpdateException
*/
function osec_plugin_activate()
{
global $osec_app;
if (is_null($osec_app)) {
BootstrapController::createApp(__DIR__);
}
DatabaseSchema::factory($osec_app)->verifySqlSchema();
$osec_app->options->set('osec_force_flush_rewrite_rules', true);
}
register_activation_hook(__FILE__, 'osec_plugin_activate');
register_deactivation_hook(
__FILE__,
function () {
global $osec_app;
$purge = (bool)OSEC_UNINSTALL_PLUGIN_DATA;
Scheduler::factory($osec_app)->uninstall($purge);
FrontendCssController::factory($osec_app)->uninstall($purge);
EventType::factory($osec_app)->uninstall($purge);
ThemeLoader::factory($osec_app)->clear_cache();
DatabaseSchema::factory($osec_app)->uninstall($purge);
// Purges all $app->options & $app->settings
Settings::factory($osec_app)->uninstall($purge);
// Flush rewrite rules.
$GLOBALS['wp_rewrite']->flush_rules();
}
);
if (defined('WP_CLI') && WP_CLI) {
require_once __DIR__ . '/src/WpCli/MakeReadme.php';
WP_CLI::add_command('osec', '\Osec\WpCli\MakeReadme');
}
/**
* Autosaving Event Data does not currently work.
* Only post data is saved.
* If editing a Event Instance autosave is disabled when calling get_instance_id().
* EventEditing->save_post() is not receiving Event Data.
*/
add_action('admin_enqueue_scripts', function () {
$type = get_post_type();
if ($type && $type === OSEC_POST_TYPE) {
wp_dequeue_script('autosave');
}
});