1414define( '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.
3442add_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