collector->get_data();
$db_query_num = null;
/** @var QM_Collector_DB_Queries|null $db_queries */
$db_queries = QM_Collectors::get( 'db_queries' );
if ( $db_queries ) {
/** @var QM_Data_DB_Queries $db_queries_data */
$db_queries_data = $db_queries->get_data();
if ( ! empty( $db_queries_data->types ) ) {
$db_query_num = $db_queries_data->types;
}
}
/** @var QM_Collector_Raw_Request|null $raw_request */
$raw_request = QM_Collectors::get( 'raw_request' );
/** @var QM_Collector_Cache|null $cache */
$cache = QM_Collectors::get( 'cache' );
/** @var QM_Collector_HTTP|null $http */
$http = QM_Collectors::get( 'http' );
$qm_broken = __( 'A JavaScript problem on the page is preventing Query Monitor from working correctly. jQuery may have been blocked from loading.', 'query-monitor' );
$ajax_errors = __( 'PHP errors were triggered during an Ajax request. See your browser developer console for details.', 'query-monitor' );
$this->before_non_tabular_output();
echo ' ' . QueryMonitor::icon( 'warning' ) . esc_html( $qm_broken ) . ' ' . QueryMonitor::icon( 'warning' ) . esc_html( $ajax_errors ) . '%1$s %2$s → %3$s
',
esc_html( $raw_data->request['method'] ),
esc_html( $raw_data->request['url'] ),
esc_html( $status )
);
echo '
';
echo esc_html(
sprintf(
/* translators: %s: A time in seconds with a decimal fraction. No space between value and unit. */
_x( '%ss', 'Time in seconds', 'query-monitor' ),
number_format_i18n( $data->time_taken, 4 )
)
);
if ( $data->time_limit > 0 ) {
if ( $data->display_time_usage_warning ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '
' . QueryMonitor::icon( 'warning' );
} else {
echo '
';
}
echo esc_html( sprintf(
/* translators: 1: Percentage of time limit used, 2: Time limit in seconds */
__( '%1$s%% of %2$ss limit', 'query-monitor' ),
number_format_i18n( $data->time_usage, 1 ),
number_format_i18n( $data->time_limit )
) );
echo '';
} else {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '
' . QueryMonitor::icon( 'warning' );
printf(
/* translators: 1: Name of the PHP directive, 2: Value of the PHP directive */
esc_html__( 'No execution time limit. The %1$s PHP configuration directive is set to %2$s.', 'query-monitor' ),
'max_execution_time
',
'0'
);
echo '';
}
echo '
';
if ( empty( $data->memory ) ) {
esc_html_e( 'Unknown', 'query-monitor' );
} else {
echo esc_html( sprintf(
/* translators: 1: Memory used in bytes, 2: Memory used in megabytes */
__( '%1$s bytes (%2$s MB)', 'query-monitor' ),
number_format_i18n( $data->memory ),
number_format_i18n( ( $data->memory / 1024 / 1024 ), 1 )
) );
if ( $data->memory_limit > 0 ) {
if ( $data->display_memory_usage_warning ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '
' . QueryMonitor::icon( 'warning' );
} else {
echo '
';
}
echo esc_html( sprintf(
/* translators: 1: Percentage of memory limit used, 2: Memory limit in megabytes */
__( '%1$s%% of %2$s MB server limit', 'query-monitor' ),
number_format_i18n( $data->memory_usage, 1 ),
number_format_i18n( $data->memory_limit / 1024 / 1024 )
) );
echo '';
} else {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '
' . QueryMonitor::icon( 'warning' );
printf(
/* translators: 1: Name of the PHP directive, 2: Value of the PHP directive */
esc_html__( 'No memory limit. The %1$s PHP configuration directive is set to %2$s.', 'query-monitor' ),
'memory_limit
',
'0'
);
echo '';
}
}
echo '
'; echo esc_html( sprintf( /* translators: %s: A time in seconds with a decimal fraction. No space between value and unit. */ _x( '%ss', 'Time in seconds', 'query-monitor' ), number_format_i18n( $db_queries_data->total_time, 4 ) ) ); echo '
'; echo '';
if ( ! isset( $db_query_num['SELECT'] ) || count( $db_query_num ) > 1 ) {
foreach ( $db_query_num as $type_name => $type_count ) {
$label = sprintf(
'%1$s: %2$s',
esc_html( $type_name ),
esc_html( number_format_i18n( $type_count ) )
);
echo self::build_filter_trigger( 'db_queries', 'type', (string) $type_name, esc_html( $label ) ); // WPCS: XSS ok;
echo '
';
}
}
$label = sprintf(
'%1$s: %2$s',
esc_html( _x( 'Total', 'database queries', 'query-monitor' ) ),
esc_html( number_format_i18n( $db_queries_data->total_qs ) )
);
echo self::build_filter_trigger( 'db_queries', 'type', '', esc_html( $label ) ); // WPCS: XSS ok;
echo '
%s
', esc_html__( 'None', 'query-monitor' ) ); } echo ''; echo esc_html( sprintf( /* translators: %s: A time in seconds with a decimal fraction. No space between value and unit. */ _x( '%ss', 'Time in seconds', 'query-monitor' ), number_format_i18n( $http_data->ltime, 4 ) ) ); echo '
'; $label = sprintf( '%1$s: %2$s', esc_html( _x( 'Total', 'HTTP API calls', 'query-monitor' ) ), esc_html( number_format_i18n( count( $http_data->http ) ) ) ); echo self::build_filter_trigger( 'http', 'type', '', esc_html( $label ) ); // WPCS: XSS ok; } else { printf( '%s
', esc_html__( 'None', 'query-monitor' ) ); } echo ''; echo esc_html( sprintf( /* translators: 1: Cache hit rate percentage, 2: number of cache hits, 3: number of cache misses */ __( '%1$s%% hit rate (%2$s hits, %3$s misses)', 'query-monitor' ), number_format_i18n( $cache_hit_percentage, 1 ), number_format_i18n( $cache_data->stats['cache_hits'], 0 ), number_format_i18n( $cache_data->stats['cache_misses'], 0 ) ) ); echo '
'; } if ( $cache_data->has_object_cache ) { echo ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo self::build_link( network_admin_url( 'plugins.php?plugin_status=dropins' ), esc_html__( 'Persistent object cache plugin in use', 'query-monitor' ) ); echo '
'; } else { echo ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo QueryMonitor::icon( 'warning' ); echo esc_html__( 'Persistent object cache plugin not in use', 'query-monitor' ); echo '
'; $potentials = array_filter( $cache_data->object_cache_extensions ); if ( ! empty( $potentials ) ) { foreach ( $potentials as $name => $value ) { $url = sprintf( 'https://wordpress.org/plugins/search/%s/', strtolower( $name ) ); echo ''; echo wp_kses( sprintf( /* translators: 1: PHP extension name, 2: URL to plugin directory */ __( 'The %1$s object cache extension for PHP is installed but is not in use by WordPress. You should install a %1$s plugin.', 'query-monitor' ), esc_html( $name ), esc_url( $url ) ), array( 'a' => array( 'href' => array(), 'target' => array(), 'class' => array(), ), ) ); echo '
'; } } else { echo ''; echo esc_html__( 'Speak to your web host about enabling an object cache extension such as Redis or Memcached.', 'query-monitor' ); echo '
'; } } } else { echo ''; echo esc_html__( 'Object cache statistics are not available', 'query-monitor' ); echo '
'; } echo ''; echo esc_html( sprintf( /* translators: %s: Name of cache driver */ __( 'Opcode cache in use: %s', 'query-monitor' ), $opcache_name ) ); echo '
'; } } else { echo ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo QueryMonitor::icon( 'warning' ); echo esc_html__( 'Opcode cache not in use', 'query-monitor' ); echo '
'; echo ''; echo esc_html__( 'Speak to your web host about enabling an opcode cache such as OPcache.', 'query-monitor' ); echo '
'; } echo '