diff --git a/modules/database/sqlite/load.php b/modules/database/sqlite/load.php index 40b452d122..0d9297eaed 100644 --- a/modules/database/sqlite/load.php +++ b/modules/database/sqlite/load.php @@ -14,7 +14,7 @@ require_once __DIR__ . '/site-health.php'; /** - * Add admin notices. + * Adds admin notices. * * When the plugin gets merged in wp-core, this is not to be ported. * @@ -58,3 +58,34 @@ function perflab_sqlite_plugin_admin_notice() { ); } add_action( 'admin_notices', 'perflab_sqlite_plugin_admin_notice' ); // Add the admin notices. + +/** + * Adds a link to the admin bar. + * + * @since n.e.x.t + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param WP_Admin_Bar $admin_bar The admin bar object. + */ +function perflab_sqlite_plugin_adminbar_item( $admin_bar ) { + global $wpdb; + + if ( defined( 'PERFLAB_SQLITE_DB_DROPIN_VERSION' ) && defined( 'DATABASE_TYPE' ) && 'sqlite' === DATABASE_TYPE ) { + $title = '' . __( 'Database: SQLite', 'performance-lab' ) . ''; + } elseif ( stripos( $wpdb->db_server_info(), 'maria' ) !== false ) { + $title = '' . __( 'Database: MariaDB', 'performance-lab' ) . ''; + } else { + $title = '' . __( 'Database: MySQL', 'performance-lab' ) . ''; + } + + $args = array( + 'id' => 'performance-lab-sqlite', + 'parent' => 'top-secondary', + 'title' => $title, + 'href' => esc_url( admin_url( 'options-general.php?page=' . PERFLAB_MODULES_SCREEN ) ), + 'meta' => false, + ); + $admin_bar->add_node( $args ); +} +add_action( 'admin_bar_menu', 'perflab_sqlite_plugin_adminbar_item', 999 );