Skip to content

Commit bb3ba4b

Browse files
committed
Fixes #29
1 parent 65c50f4 commit bb3ba4b

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

db.copy

+18-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,16 @@
1414
define( 'SQLITE_DB_DROPIN_VERSION', '1.8.0' );
1515

1616
// 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+
}
1927
}
2028

2129
// Constant for backward compatibility.
@@ -28,20 +36,24 @@ if ( ! defined( 'DB_ENGINE' ) ) {
2836
}
2937

3038
// 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;
3240

3341
// Activate the performance-lab plugin if it is not already activated.
3442
add_action(
3543
'admin_footer',
36-
function() {
44+
function() use ( $sqlite_db_plugin_main_file ) {
3745
if ( defined( 'SQLITE_MAIN_FILE' ) ) {
3846
return;
3947
}
4048
if ( ! function_exists( 'activate_plugin' ) ) {
4149
require_once ABSPATH . 'wp-admin/includes/plugin.php';
4250
}
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+
}
4557
}
4658
}
4759
);

0 commit comments

Comments
 (0)