Skip to content

Commit 6bf9328

Browse files
committed
Provide more accurate info about MariaDB vs MySQL, enhance doc block.
1 parent 5dfa9c2 commit 6bf9328

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

modules/database/sqlite/load.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
require_once __DIR__ . '/site-health.php';
1515

1616
/**
17-
* Add admin notices.
17+
* Adds admin notices.
1818
*
1919
* When the plugin gets merged in wp-core, this is not to be ported.
2020
*
@@ -60,18 +60,32 @@ function perflab_sqlite_plugin_admin_notice() {
6060
add_action( 'admin_notices', 'perflab_sqlite_plugin_admin_notice' ); // Add the admin notices.
6161

6262
/**
63-
* Add a link to the admin bar.
63+
* Adds a link to the admin bar.
64+
*
65+
* @since n.e.x.t
66+
*
67+
* @global wpdb $wpdb WordPress database abstraction object.
6468
*
6569
* @param WP_Admin_Bar $admin_bar The admin bar object.
6670
*/
6771
function perflab_sqlite_plugin_adminbar_item( $admin_bar ) {
72+
global $wpdb;
73+
74+
if ( defined( 'PERFLAB_SQLITE_DB_DROPIN_VERSION' ) && defined( 'DATABASE_TYPE' ) && 'sqlite' === DATABASE_TYPE ) {
75+
$title = '<span style="color:#46B450;">' . __( 'Database: SQLite', 'performance-lab' ) . '</span>';
76+
} else {
77+
$db_info = $wpdb->db_server_info();
78+
if ( stripos( $db_info, 'maria' ) !== false ) {
79+
$title = '<span style="color:#DC3232;">' . __( 'Database: MariaDB', 'performance-lab' ) . '</span>';
80+
} else {
81+
$title = '<span style="color:#DC3232;">' . __( 'Database: MySQL', 'performance-lab' ) . '</span>';
82+
}
83+
}
84+
6885
$args = array(
6986
'id' => 'performance-lab-sqlite',
7087
'parent' => 'top-secondary',
71-
/* translators: %s: SQLite icon. */
72-
'title' => defined( 'PERFLAB_SQLITE_DB_DROPIN_VERSION' ) && defined( 'DATABASE_TYPE' ) && 'sqlite' === DATABASE_TYPE
73-
? '<span style="color:#46B450;">' . __( 'Database: SQLite', 'performance-lab' ) . '</span>'
74-
: '<span style="color:#DC3232;">' . __( 'Database: MySQL', 'performance-lab' ) . '</span>',
88+
'title' => $title,
7589
'href' => esc_url( admin_url( 'options-general.php?page=' . PERFLAB_MODULES_SCREEN ) ),
7690
'meta' => false,
7791
);

0 commit comments

Comments
 (0)