Ask about passing data to the view

Hello, I have some misunderstanding about passing data to the view with the basic way not with Controller, so first what is “$class” refer to? and how to pass data to the specific page in this way?

and what this code should do?

/**
 * Collect data for searchform.
 */
add_filter('sage/template/app/data', function ($data) {
    return $data + [
        'sf_action' => esc_url(home_url('/')),
        'sf_screen_reader_text' => _x('Search for:', 'label', 'sage'),
        'sf_placeholder' => esc_attr_x('Search …', 'placeholder', 'sage'),
        'sf_current_query' => get_search_query(),
        'sf_submit_text' => esc_attr_x('Search', 'submit button', 'sage'),
    ];
});

as we expect this data passing to the searchForm page? but it does not do this, it’s show error in the page Undefined variable: sf_current_query

Hey @nuruddin_badawi,

The $class variable there should be replaced with any class that might be on the body tag of the resource being loaded. For example, if you’re viewing a page, it would have the ‘page’ class. The class ‘app’ would be used for any request.

And you are correct about the searchForm bug. Thanks for reporting it on Github as well!