generated from mt-support/tec-labs-extension-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.php
74 lines (66 loc) · 2.66 KB
/
plugin.php
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
<?php
/**
* Plugin Name: The Events Calendar Extension: Remove Past Events
* Plugin URI: https://theeventscalendar.com/extensions/remove-past-events
* GitHub Plugin URI: https://github.com/mt-support/tec-labs-remove-past-events
* Description: Additional frequencies to remove past events.
* Version: 1.2.2
* Author: The Events Calendar
* Author URI: https://evnt.is/1971
* License: GPL version 3 or any later version
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: tec-labs-remove-past-events
*
* This plugin is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/**
* Define the base file that loaded the plugin for determining plugin path and other variables.
*
* @since 1.0.0
*
* @var string Base file that loaded the plugin.
*/
define( 'TRIBE_EXTENSION_REMOVE_PAST_EVENTS_FILE', __FILE__ );
/**
* Register and load the service provider for loading the extension.
*
* @since 1.0.0
*/
function tribe_extension_remove_past_events() {
// When we don't have autoloader from common we bail.
if ( ! class_exists( 'Tribe__Autoloader' ) ) {
return;
}
// Register the namespace so we can the plugin on the service provider registration.
Tribe__Autoloader::instance()->register_prefix(
'\\Tribe\\Extensions\\Remove_Past_Events\\',
__DIR__ . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Tec',
'remove-past-events'
);
// Deactivates the plugin in case of the main class didn't autoload.
if ( ! class_exists( '\Tribe\Extensions\Remove_Past_Events\Plugin' ) ) {
tribe_transient_notice(
'remove-past-events',
'<p>' . esc_html__( 'Couldn\'t properly load "The Events Calendar Extension: Remove Past Events" the extension was deactivated.', 'tec-labs-remove-past-events' ) . '</p>',
[],
// 1 second after that make sure the transient is removed.
1
);
if ( ! function_exists( 'deactivate_plugins' ) ) {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}
deactivate_plugins( __FILE__, true );
return;
}
tribe_register_provider( '\Tribe\Extensions\Remove_Past_Events\Plugin' );
}
// Loads after common is already properly loaded.
add_action( 'tribe_common_loaded', 'tribe_extension_remove_past_events' );