File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,3 +90,34 @@ function sqlite_integration_admin_screen() {
9090 </div>
9191 <?php
9292}
93+
94+ /**
95+ * Adds a link to the admin bar.
96+ *
97+ * @since n.e.x.t
98+ *
99+ * @global wpdb $wpdb WordPress database abstraction object.
100+ *
101+ * @param WP_Admin_Bar $admin_bar The admin bar object.
102+ */
103+ function sqlite_plugin_adminbar_item ( $ admin_bar ) {
104+ global $ wpdb ;
105+
106+ if ( defined ( 'SQLITE_DB_DROPIN_VERSION ' ) && defined ( 'DATABASE_TYPE ' ) && 'sqlite ' === DATABASE_TYPE ) {
107+ $ title = '<span style="color:#46B450;"> ' . __ ( 'Database: SQLite ' , 'performance-lab ' ) . '</span> ' ;
108+ } elseif ( stripos ( $ wpdb ->db_server_info (), 'maria ' ) !== false ) {
109+ $ title = '<span style="color:#DC3232;"> ' . __ ( 'Database: MariaDB ' , 'performance-lab ' ) . '</span> ' ;
110+ } else {
111+ $ title = '<span style="color:#DC3232;"> ' . __ ( 'Database: MySQL ' , 'performance-lab ' ) . '</span> ' ;
112+ }
113+
114+ $ args = array (
115+ 'id ' => 'sqlite-db-integration ' ,
116+ 'parent ' => 'top-secondary ' ,
117+ 'title ' => $ title ,
118+ 'href ' => esc_url ( admin_url ( 'options-general.php?page=sqlite-integration ' ) ),
119+ 'meta ' => false ,
120+ );
121+ $ admin_bar ->add_node ( $ args );
122+ }
123+ add_action ( 'admin_bar_menu ' , 'sqlite_plugin_adminbar_item ' , 999 );
You can’t perform that action at this time.
0 commit comments