PluginProbe
SQLite Database Integration / 2.2.0
SQLite Database Integration v2.2.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 2.2.3 All 32 releases
sqlite-database-integration / health-check.php

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

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