This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Astra_Memory_Limit_Notice::get_memory_notice_data()

Get memory notice data including whether to show notice and notice type


Description


Return

(array) Array with memory data and notice information.


Source

File: inc/class-astra-memory-limit-notice.php

	private function get_memory_notice_data() {
		// Only show to administrators.
		if ( ! current_user_can( 'manage_options' ) ) {
			return array(
				'show_notice' => false,
				'notice_type' => '',
			);
		}

		$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;

		// Prepare base return data to avoid repetition.
		$return_data = array(
			'memory_limit'      => $memory_limit,
			'memory_usage'      => $memory_usage,
			'memory_percentage' => $memory_percentage,
		);

		// Show warning notice at threshold usage.
		if ( $memory_percentage >= $this->warning_threshold ) {
			return array_merge(
				$return_data,
				array(
					'show_notice' => true,
					'notice_type' => 'warning',
				)
			);
		}

		return array(
			'show_notice' => false,
			'notice_type' => '',
		);
	}


User Contributed Notes

You must log in before being able to contribute a note or feedback.