Skip to content

Commit bd25ae3

Browse files
committed
activate plugin in SQLite db
1 parent 55aa187 commit bd25ae3

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

activate.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,14 @@ function sqlite_plugin_copy_db_file() {
7070

7171
// Get the db.copy.php file contents, replace placeholders and write it to the destination.
7272
$file_contents = str_replace(
73-
'{SQLITE_IMPLEMENTATION_FOLDER_PATH}',
74-
__DIR__,
73+
array(
74+
'{SQLITE_IMPLEMENTATION_FOLDER_PATH}',
75+
'{SQLITE_PLUGIN}',
76+
),
77+
array(
78+
__DIR__,
79+
str_replace( WP_PLUGIN_DIR . '/', '', SQLITE_MAIN_FILE ),
80+
),
7581
file_get_contents( __DIR__ . '/db.copy' )
7682
);
7783

db.copy

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,19 @@ if ( ! defined( 'DATABASE_TYPE' ) ) {
2525

2626
// Require the implementation from the plugin.
2727
require_once '{SQLITE_IMPLEMENTATION_FOLDER_PATH}/wp-includes/sqlite/db.php';
28+
29+
// Activate the performance-lab plugin if it is not already activated.
30+
add_action(
31+
'init',
32+
function() {
33+
if ( defined( 'SQLITE_MAIN_FILE' ) ) {
34+
return;
35+
}
36+
if ( ! function_exists( 'activate_plugin' ) ) {
37+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
38+
}
39+
if ( is_plugin_inactive( '{SQLITE_PLUGIN}' ) ) {
40+
activate_plugin( '{SQLITE_PLUGIN}' );
41+
}
42+
}
43+
);

0 commit comments

Comments
 (0)