Skip to content

Commit

Permalink
Add back the can-load file
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Apr 10, 2023
1 parent 99de875 commit b4c1f6f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions modules/database/sqlite/can-load.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Can load function to determine if SQLite can be activated.
*
* @since 1.8.0
* @package performance-lab
*/

/**
* Checks whether the given module can be activated.
*
* @since 1.8.0
*/
return function() {

// If the PERFLAB_SQLITE_DB_DROPIN_VERSION or SQLITE_DB_DROPIN_VERSION constants
// are defined, then the module is already active.
if ( defined( 'PERFLAB_SQLITE_DB_DROPIN_VERSION' ) || defined( 'SQLITE_DB_DROPIN_VERSION' ) ) {
return true;
}

// If a db.php file already exists in the wp-content directory, then the module cannot be activated.
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
return false;
}

// If the SQLite3 class does not exist, then the module cannot be activated.
if ( ! class_exists( 'SQLite3' ) ) {
return false;
}

// If the db.php file can't be written to the wp-content directory, then the module cannot be activated.
if ( ! wp_is_writable( WP_CONTENT_DIR ) ) {
return false;
}
return true;
};

0 comments on commit b4c1f6f

Please sign in to comment.