14
14
define( 'SQLITE_DB_DROPIN_VERSION', '1.8.0' );
15
15
16
16
// Bail early if the SQLite implementation was not located in the plugin.
17
- if ( ! file_exists( '{SQLITE_IMPLEMENTATION_FOLDER_PATH}/wp-includes/sqlite/db.php' ) ) {
18
- return;
17
+ $sqlite_db_plugin_folder = '{SQLITE_IMPLEMENTATION_FOLDER_PATH}';
18
+ $sqlite_db_plugin_db_file = $sqlite_db_plugin_folder . '/wp-includes/sqlite/db.php';
19
+ $sqlite_db_plugin_main_file = WP_PLUGIN_DIR . '/{SQLITE_PLUGIN}';
20
+ if ( ! file_exists( $sqlite_db_plugin_db_file ) ) {
21
+ $sqlite_db_plugin_folder = WP_PLUGIN_DIR . '/sqlite-database-integration';
22
+ $sqlite_db_plugin_db_file = $sqlite_db_plugin_folder . '/wp-includes/sqlite/db.php';
23
+ $sqlite_db_plugin_main_file = $sqlite_db_plugin_folder . '/load.php';
24
+ if ( ! file_exists( $sqlite_db_plugin_db_file ) ) {
25
+ return;
26
+ }
19
27
}
20
28
21
29
// Constant for backward compatibility.
@@ -28,20 +36,24 @@ if ( ! defined( 'DB_ENGINE' ) ) {
28
36
}
29
37
30
38
// Require the implementation from the plugin.
31
- require_once '{SQLITE_IMPLEMENTATION_FOLDER_PATH}/wp-includes/sqlite/db.php' ;
39
+ require_once $sqlite_db_plugin_db_file ;
32
40
33
41
// Activate the performance-lab plugin if it is not already activated.
34
42
add_action(
35
43
'admin_footer',
36
- function() {
44
+ function() use ( $sqlite_db_plugin_main_file ) {
37
45
if ( defined( 'SQLITE_MAIN_FILE' ) ) {
38
46
return;
39
47
}
40
48
if ( ! function_exists( 'activate_plugin' ) ) {
41
49
require_once ABSPATH . 'wp-admin/includes/plugin.php';
42
50
}
43
- if ( is_plugin_inactive( '{SQLITE_PLUGIN}' ) ) {
44
- activate_plugin( '{SQLITE_PLUGIN}' );
51
+
52
+ if ( file_exists( $sqlite_db_plugin_main_file ) ) {
53
+ $plugin_file = str_replace( WP_PLUGIN_DIR . '/', '', $sqlite_db_plugin_main_file );
54
+ if ( is_plugin_inactive( $plugin_file ) ) {
55
+ activate_plugin( $plugin_file );
56
+ }
45
57
}
46
58
}
47
59
);
0 commit comments