|
14 | 14 | require_once __DIR__ . '/site-health.php'; |
15 | 15 |
|
16 | 16 | /** |
17 | | - * Add admin notices. |
| 17 | + * Adds admin notices. |
18 | 18 | * |
19 | 19 | * When the plugin gets merged in wp-core, this is not to be ported. |
20 | 20 | * |
@@ -60,18 +60,32 @@ function perflab_sqlite_plugin_admin_notice() { |
60 | 60 | add_action( 'admin_notices', 'perflab_sqlite_plugin_admin_notice' ); // Add the admin notices. |
61 | 61 |
|
62 | 62 | /** |
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. |
64 | 68 | * |
65 | 69 | * @param WP_Admin_Bar $admin_bar The admin bar object. |
66 | 70 | */ |
67 | 71 | 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 | + |
68 | 85 | $args = array( |
69 | 86 | 'id' => 'performance-lab-sqlite', |
70 | 87 | '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, |
75 | 89 | 'href' => esc_url( admin_url( 'options-general.php?page=' . PERFLAB_MODULES_SCREEN ) ), |
76 | 90 | 'meta' => false, |
77 | 91 | ); |
|
0 commit comments