1313
1414define( 'SQLITE_DB_DROPIN_VERSION', '1.8.0' );
1515
16+ // Tweak to allow copy-pasting the file without having to run string-replacements.
17+ $sqlite_plugin_implementation_folder_path = '{SQLITE_IMPLEMENTATION_FOLDER_PATH}';
18+ if ( ! file_exists( $sqlite_plugin_implementation_folder_path ) ) { // Check that the folder exists.
19+ $sqlite_plugin_implementation_folder_path = realpath( __DIR__ . '/plugins/sqlite-database-integration' );
20+ }
21+
1622// 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' ) ) {
23+ if ( ! $sqlite_plugin_implementation_folder_path || ! file_exists( $sqlite_plugin_implementation_folder_path . ' /wp-includes/sqlite/db.php' ) ) {
1824 return;
1925}
2026
@@ -28,7 +34,7 @@ if ( ! defined( 'DB_ENGINE' ) ) {
2834}
2935
3036// Require the implementation from the plugin.
31- require_once '{SQLITE_IMPLEMENTATION_FOLDER_PATH} /wp-includes/sqlite/db.php';
37+ require_once $sqlite_plugin_implementation_folder_path . ' /wp-includes/sqlite/db.php';
3238
3339// Activate the performance-lab plugin if it is not already activated.
3440add_action(
@@ -41,7 +47,12 @@ add_action(
4147 require_once ABSPATH . 'wp-admin/includes/plugin.php';
4248 }
4349 if ( is_plugin_inactive( '{SQLITE_PLUGIN}' ) ) {
44- activate_plugin( '{SQLITE_PLUGIN}' );
50+ // If `activate_plugin()` returns a value other than null (like WP_Error),
51+ // the plugin could not be found. Try with a hardcoded string,
52+ // because that probably means the file was directly copy-pasted.
53+ if ( null !== activate_plugin( '{SQLITE_PLUGIN}', '', false, true ) ) {
54+ activate_plugin( 'sqlite-database-integration/load.php', '', false, true );
55+ }
4556 }
4657 }
4758);
0 commit comments