Skip to content

Component: View

Mostafa Soufi edited this page Sep 1, 2024 · 1 revision

The View class is used for loading view files and passing data to them.

Load a single view

use WP_Statistics\Components\View;

View::load('admin/dashboard', [
    'user_count' => $user_count,
    'page_views' => $page_views,
]);

Load multiple views

View::load(['header', 'content', 'footer'], [
    'title' => 'Dashboard',
    'content' => $dashboard_content,
]);

Load a view and return the content

$email_content = View::load('emails/weekly-report', [
    'stats' => $weekly_stats,
], true);

Clone this wiki locally