Astra_Memory_Limit_Notice::site_health_memory_test()
Site Health test for memory usage
Description
Return
(array) Site Health test result.
Source
File: inc/class-astra-memory-limit-notice.php
public function site_health_memory_test() {
$memory_limit = $this->get_memory_limit_in_bytes();
$memory_usage = memory_get_peak_usage( true );
$memory_percentage = $memory_limit > 0 ? ( $memory_usage / $memory_limit * 100 ) : 0;
$memory_limit_formatted = $this->format_bytes( $memory_limit );
$memory_usage_formatted = $this->format_bytes( $memory_usage );
$memory_remaining_formatted = $this->format_bytes( $memory_limit - $memory_usage );
$percentage_formatted = number_format( $memory_percentage, 1 );
if ( $memory_percentage >= $this->warning_threshold ) {
$status = 'recommended';
$label = __( 'High memory usage detected', 'astra' );
$badge_color = 'orange';
} else {
$status = 'good';
$label = __( 'Memory usage is within acceptable limits', 'astra' );
$badge_color = 'green';
}
$description = $this->get_site_health_description( $memory_percentage, $memory_limit_formatted, $memory_usage_formatted, $memory_remaining_formatted, $percentage_formatted );
$actions = $this->get_site_health_actions( $memory_percentage );
return array(
'label' => $label,
'status' => $status,
'badge' => array(
'label' => __( 'Astra Theme', 'astra' ),
'color' => $badge_color,
),
'description' => $description,
'actions' => $actions,
'test' => 'astra_memory_usage',
);
}
Expand full source code Collapse full source code View on Trac