PluginProbe
Performance Lab / 1.8.0
Performance Lab v1.8.0
trunk 1.0.0 1.0.0-beta.1 1.0.0-beta.2 1.0.0-beta.3 1.0.0-rc.1 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.6.1 2.7.0 2.8.0 All 44 releases
performance-lab / modules / database / sqlite / site-health.php

site-health.php in Performance Lab 1.8.0, at modules/database/sqlite/site-health.php

69 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Adds and filters data in the site-health screen.
4 *
5 * @package performance-lab
6 * @since 1.8.0
7 */
8
9 // Require the constants file.
10 require_once __DIR__ . '/constants.php';
11
12 /**
13 * Filter debug data in site-health screen.
14 *
15 * When the plugin gets merged in wp-core, these should be merged in src/wp-admin/includes/class-wp-debug-data.php
16 * See https://github.com/WordPress/wordpress-develop/pull/3220/files
17 *
18 * @since 1.8.0
19 *
20 * @param array $info The debug data.
21 * @return array The filtered debug data.
22 */
23 function perflab_sqlite_plugin_filter_debug_data( $info ) {
24 $database_type = defined( 'DATABASE_TYPE' ) && 'sqlite' === DATABASE_TYPE ? 'sqlite' : 'mysql';
25
26 $info['wp-constants']['fields']['DATABASE_TYPE'] = array(
27 'label' => 'DATABASE_TYPE',
28 'value' => ( defined( 'DATABASE_TYPE' ) ? DATABASE_TYPE : __( 'Undefined', 'performance-lab' ) ),
29 'debug' => ( defined( 'DATABASE_TYPE' ) ? DATABASE_TYPE : 'undefined' ),
30 );
31
32 $info['wp-database']['fields']['database_type'] = array(
33 'label' => __( 'Database type', 'performance-lab' ),
34 'value' => 'sqlite' === $database_type ? 'SQLite' : 'MySQL/MariaDB',
35 );
36
37 if ( 'sqlite' === $database_type ) {
38 $info['wp-database']['fields']['database_version'] = array(
39 'label' => __( 'SQLite version', 'performance-lab' ),
40 'value' => class_exists( 'SQLite3' ) ? SQLite3::version()['versionString'] : null,
41 );
42
43 $info['wp-database']['fields']['database_file'] = array(
44 'label' => __( 'Database file', 'performance-lab' ),
45 'value' => FQDB,
46 'private' => true,
47 );
48
49 $info['wp-database']['fields']['database_size'] = array(
50 'label' => __( 'Database size', 'performance-lab' ),
51 'value' => size_format( filesize( FQDB ) ),
52 );
53
54 unset( $info['wp-database']['fields']['extension'] );
55 unset( $info['wp-database']['fields']['server_version'] );
56 unset( $info['wp-database']['fields']['client_version'] );
57 unset( $info['wp-database']['fields']['database_host'] );
58 unset( $info['wp-database']['fields']['database_user'] );
59 unset( $info['wp-database']['fields']['database_name'] );
60 unset( $info['wp-database']['fields']['database_charset'] );
61 unset( $info['wp-database']['fields']['database_collate'] );
62 unset( $info['wp-database']['fields']['max_allowed_packet'] );
63 unset( $info['wp-database']['fields']['max_connections'] );
64 }
65
66 return $info;
67 }
68 add_filter( 'debug_information', 'perflab_sqlite_plugin_filter_debug_data' ); // Filter debug data in site-health screen.
69