| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: SQLite integration (Drop-in) |
| 4 |
* Version: 1.0.0 |
| 5 |
* Author: WordPress Performance Team |
| 6 |
* Author URI: https://make.wordpress.org/performance/ |
| 7 |
* |
| 8 |
* This file is auto-generated and copied from the sqlite plugin. |
| 9 |
* Please don't edit this file directly. |
| 10 |
* |
| 11 |
* @package wp-sqlite-integration |
| 12 |
*/ |
| 13 |
|
| 14 |
define( 'SQLITE_DB_DROPIN_VERSION', '1.8.0' ); |
| 15 |
|
| 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 |
|
| 22 |
// Bail early if the SQLite implementation was not located in the plugin. |
| 23 |
if ( ! $sqlite_plugin_implementation_folder_path || ! file_exists( $sqlite_plugin_implementation_folder_path . '/wp-includes/sqlite/db.php' ) ) { |
| 24 |
return; |
| 25 |
} |
| 26 |
|
| 27 |
// Constant for backward compatibility. |
| 28 |
if ( ! defined( 'DATABASE_TYPE' ) ) { |
| 29 |
define( 'DATABASE_TYPE', 'sqlite' ); |
| 30 |
} |
| 31 |
// Define SQLite constant. |
| 32 |
if ( ! defined( 'DB_ENGINE' ) ) { |
| 33 |
define( 'DB_ENGINE', 'sqlite' ); |
| 34 |
} |
| 35 |
|
| 36 |
// Require the implementation from the plugin. |
| 37 |
require_once $sqlite_plugin_implementation_folder_path . '/wp-includes/sqlite/db.php'; |
| 38 |
|
| 39 |
// Activate the performance-lab plugin if it is not already activated. |
| 40 |
add_action( |
| 41 |
'admin_footer', |
| 42 |
function() { |
| 43 |
if ( defined( 'SQLITE_MAIN_FILE' ) ) { |
| 44 |
return; |
| 45 |
} |
| 46 |
if ( ! function_exists( 'activate_plugin' ) ) { |
| 47 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 48 |
} |
| 49 |
if ( is_plugin_inactive( '{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 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
); |
| 59 |
|