Skip to content

Commit bb6f4f9

Browse files
committed
Update path and version inferring to work in Plaayground managed SQLite
1 parent c31e09e commit bb6f4f9

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

‎src/SQLiteDatabaseIntegrationLoader.php‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,19 @@ final class SQLiteDatabaseIntegrationLoader {
1212
* @return false|string The version of the SQLite integration plugin or false if not found/activated.
1313
*/
1414
public static function get_plugin_version() {
15-
// Check if there is a db.php file in the wp-content directory.
16-
if ( ! file_exists( ABSPATH . '/wp-content/db.php' ) ) {
17-
return false;
18-
}
19-
20-
// If the file is found, we need to check that it is the sqlite integration plugin.
21-
$plugin_file = file_get_contents( ABSPATH . '/wp-content/db.php' );
22-
if ( ! preg_match( '/define\( \'SQLITE_DB_DROPIN_VERSION\', \'([0-9.]+)\' \)/', $plugin_file ) ) {
23-
return false;
24-
}
25-
2615
$plugin_path = self::get_plugin_directory();
2716
if ( ! $plugin_path ) {
2817
return false;
2918
}
3019

31-
// Try to get the version number from readme.txt
32-
$plugin_file = file_get_contents( $plugin_path . '/readme.txt' );
20+
$version_file = $plugin_path . '/wp-includes/database/version.php';
21+
if ( ! file_exists( $version_file ) ) {
22+
return false;
23+
}
3324

34-
preg_match( '/^Stable tag:\s*?(.+)$/m', $plugin_file, $matches );
25+
require_once $version_file;
3526

36-
return isset( $matches[1] ) ? trim( $matches[1] ) : false;
27+
return defined( 'SQLITE_DRIVER_VERSION' ) ? SQLITE_DRIVER_VERSION : false;
3728
}
3829

3930
/**
@@ -45,6 +36,7 @@ protected static function get_plugin_directory() {
4536
$plugin_folders = [
4637
ABSPATH . '/wp-content/plugins/sqlite-database-integration',
4738
ABSPATH . '/wp-content/mu-plugins/sqlite-database-integration',
39+
'/internal/shared/sqlite-database-integration',
4840
];
4941

5042
foreach ( $plugin_folders as $folder ) {

0 commit comments

Comments
 (0)