forked from newfold-labs/wp-module-coming-soon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
68 lines (55 loc) · 2.04 KB
/
bootstrap.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
<?php
use NewfoldLabs\WP\Module\ComingSoon\ComingSoon;
use NewfoldLabs\WP\Module\ComingSoon\Service;
use NewfoldLabs\WP\ModuleLoader\Container;
use WP_Forge\UpgradeHandler\UpgradeHandler;
use function NewfoldLabs\WP\ModuleLoader\register;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
return;
}
// Do not allow multiple copies of the module to be activated.
if ( defined( 'NFD_COMING_SOON_MODULE_VERSION' ) ) {
return;
}
define( 'NFD_COMING_SOON_MODULE_VERSION', '1.1.17' );
require __DIR__ . '/includes/functions.php';
$old_coming_soon_module_version = get_option( 'nfd_coming_soon_module_version' );
// Allow the initial upgrade routine to run on the front-end, but only once.
if ( ! $old_coming_soon_module_version || is_admin() ) {
$upgrade_handler = new UpgradeHandler(
__DIR__ . '/upgrades',
$old_coming_soon_module_version,
NFD_DATA_MODULE_VERSION
);
if ( $upgrade_handler->maybe_upgrade() ) {
// If an upgrade occurred, update the new version in the database to prevent running the routine(s) again.
update_option( 'nfd_coming_soon_module_version', NFD_COMING_SOON_MODULE_VERSION, true );
}
}
// Register the module
add_action(
'plugins_loaded',
function () {
register(
array(
'name' => 'coming-soon',
'label' => __( 'Coming Soon', 'newfold-module-coming-soon' ),
'callback' => function ( Container $container ) {
if ( ! defined( 'NFD_COMING_SOON_BUILD_DIR' ) && defined( 'NFD_COMING_SOON_MODULE_VERSION' ) ) {
define( 'NFD_COMING_SOON_BUILD_DIR', __DIR__ . '/build/' . NFD_COMING_SOON_MODULE_VERSION );
}
if ( ! defined( 'NFD_COMING_SOON_BUILD_URL' ) && defined( 'NFD_COMING_SOON_MODULE_VERSION' ) ) {
define( 'NFD_COMING_SOON_BUILD_URL', $container->plugin()->url . 'vendor/newfold-labs/wp-module-coming-soon/build/' . NFD_COMING_SOON_MODULE_VERSION );
}
$container->set( 'comingSoon', $container->service( function () {
return new Service();
} ) );
return new ComingSoon( $container );
},
'isActive' => true,
'isHidden' => true,
)
);
}
);