-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathuninstall.php
52 lines (42 loc) · 1.23 KB
/
uninstall.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
<?php
/**
* Uninstall script for the plugin.
*
* @since 0.1.0
* @package ai-services
*/
// This loader file should remain compatible with PHP 5.2.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit; // Prevent execution from directly accessing the file.
}
require_once plugin_dir_path( __FILE__ ) . 'constants.php';
if ( ! function_exists( 'ai_services_uninstall' ) ) {
/**
* Checks basic requirements and uninstalls the plugin.
*
* @since 0.1.0
*/
function ai_services_uninstall() /* @phpstan-ignore-line */ {
$plugin_main_file = plugin_dir_path( __FILE__ ) . 'ai-services.php';
// Check for supported PHP version.
if (
version_compare( phpversion(), AI_SERVICES_MINIMUM_PHP, '<' )
|| version_compare( get_bloginfo( 'version' ), AI_SERVICES_MINIMUM_WP, '<' )
) {
return;
}
// Register the autoloader.
if ( ! ai_services_register_autoloader() ) {
return;
}
// Assemble the plugin services.
$class_name = 'Felix_Arntz\AI_Services\Plugin_Service_Container_Builder';
$builder = new $class_name();
$services = $builder->build_env( $plugin_main_file )
->build_services()
->get();
// Run the plugin data uninstaller.
$services['plugin_installer']->uninstall();
}
}
ai_services_uninstall();