PluginProbe
SQLite Database Integration / 3.1.0
SQLite Database Integration v3.1.0
3.1.0 3.0.2 3.0.1 trunk 2.1.13 2.1.14 2.1.15 2.1.16 2.2.0 2.2.1 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.17 2.2.18 2.2.19 2.2.2 2.2.20 2.2.21 2.2.22 2.2.23 All 33 releases
sqlite-database-integration / health-check.php

health-check.php in SQLite Database Integration 3.1.0, at health-check.php

83 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Tweaks for the health-check screens.
4 */
5
6 /**
7 * Filter debug data in site-health screen.
8 *
9 * When the plugin gets merged in wp-core, these should be merged in src/wp-admin/includes/class-wp-debug-data.php
10 * See https://github.com/WordPress/wordpress-develop/pull/3220/files
11 *
12 * @param array $info The debug data.
13 */
14 function sqlite_plugin_filter_debug_data( $info ) {
15 $db_engine = defined( 'DB_ENGINE' ) && 'sqlite' === DB_ENGINE ? 'sqlite' : 'mysql';
16
17 $info['wp-constants']['fields']['DB_ENGINE'] = array(
18 'label' => 'DB_ENGINE',
19 'value' => ( defined( 'DB_ENGINE' ) ? DB_ENGINE : __( 'Undefined', 'sqlite-database-integration' ) ),
20 'debug' => ( defined( 'DB_ENGINE' ) ? DB_ENGINE : 'undefined' ),
21 );
22
23 $info['wp-database']['fields']['db_engine'] = array(
24 'label' => __( 'Database type', 'sqlite-database-integration' ),
25 'value' => 'sqlite' === $db_engine ? 'SQLite' : 'MySQL/MariaDB',
26 );
27
28 if ( 'sqlite' === $db_engine ) {
29 $info['wp-database']['fields']['database_version'] = array(
30 'label' => __( 'SQLite version', 'sqlite-database-integration' ),
31 'value' => $info['wp-database']['fields']['server_version'] ?? null,
32 );
33
34 $info['wp-database']['fields']['database_file'] = array(
35 'label' => __( 'Database file', 'sqlite-database-integration' ),
36 'value' => DB_PATH,
37 'private' => true,
38 );
39
40 $info['wp-database']['fields']['database_size'] = array(
41 'label' => __( 'Database size', 'sqlite-database-integration' ),
42 'value' => ':memory:' === DB_PATH
43 ? __( 'Not available', 'sqlite-database-integration' )
44 : size_format( filesize( DB_PATH ) ),
45 );
46
47 unset( $info['wp-database']['fields']['extension'] );
48 unset( $info['wp-database']['fields']['server_version'] );
49 unset( $info['wp-database']['fields']['client_version'] );
50 unset( $info['wp-database']['fields']['database_host'] );
51 unset( $info['wp-database']['fields']['database_user'] );
52 unset( $info['wp-database']['fields']['database_name'] );
53 unset( $info['wp-database']['fields']['database_charset'] );
54 unset( $info['wp-database']['fields']['database_collate'] );
55 unset( $info['wp-database']['fields']['max_allowed_packet'] );
56 unset( $info['wp-database']['fields']['max_connections'] );
57 }
58
59 return $info;
60 }
61 add_filter( 'debug_information', 'sqlite_plugin_filter_debug_data' ); // Filter debug data in site-health screen.
62
63 /**
64 * Filter site_status tests in site-health screen.
65 *
66 * When the plugin gets merged in wp-core, these should be merged in src/wp-admin/includes/class-wp-site-health.php
67 *
68 * @param array $tests The tests.
69 * @return array
70 */
71 function sqlite_plugin_filter_site_status_tests( $tests ) {
72 $db_engine = defined( 'DB_ENGINE' ) && 'sqlite' === DB_ENGINE ? 'sqlite' : 'mysql';
73
74 if ( 'sqlite' === $db_engine ) {
75 unset( $tests['direct']['utf8mb4_support'] );
76 unset( $tests['direct']['sql_server'] );
77 unset( $tests['direct']['persistent_object_cache'] ); // Throws an error because DB_NAME is not defined.
78 }
79
80 return $tests;
81 }
82 add_filter( 'site_status_tests', 'sqlite_plugin_filter_site_status_tests' );
83