-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |