| 1 |
<?php |
| 2 |
/** |
| 3 |
* Can load function to determine if SQLite can be activated. |
| 4 |
* |
| 5 |
* @since 1.8.0 |
| 6 |
* @package performance-lab |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Checks whether the given module can be activated. |
| 11 |
* |
| 12 |
* @since 1.8.0 |
| 13 |
*/ |
| 14 |
return function() { |
| 15 |
|
| 16 |
// If the PERFLAB_SQLITE_DB_DROPIN_VERSION constant is defined, then the module is already active. |
| 17 |
if ( defined( 'PERFLAB_SQLITE_DB_DROPIN_VERSION' ) ) { |
| 18 |
return true; |
| 19 |
} |
| 20 |
|
| 21 |
// If a db.php file already exists in the wp-content directory, then the module cannot be activated. |
| 22 |
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) { |
| 23 |
return false; |
| 24 |
} |
| 25 |
|
| 26 |
// If the SQLite3 class does not exist, then the module cannot be activated. |
| 27 |
if ( ! class_exists( 'SQLite3' ) ) { |
| 28 |
return false; |
| 29 |
} |
| 30 |
|
| 31 |
// If the db.php file can't be written to the wp-content directory, then the module cannot be activated. |
| 32 |
if ( ! wp_is_writable( WP_CONTENT_DIR ) ) { |
| 33 |
return false; |
| 34 |
} |
| 35 |
return true; |
| 36 |
}; |
| 37 |
|