diff --git a/app/filters.php b/app/filters.php index 57a6726fb9..6cf6de8377 100644 --- a/app/filters.php +++ b/app/filters.php @@ -13,6 +13,11 @@ } } + /** Add a global class to everything. + * We want it to come first, so stuff its filter does can be overridden. + */ + array_unshift($classes, 'app'); + /** Add class if sidebar is active */ if (display_sidebar()) { $classes[] = 'sidebar-primary'; @@ -68,3 +73,23 @@ ); return template_path(locate_template(["views/{$comments_template}", $comments_template]) ?: $comments_template); }, 100); + +/** + * Render WordPress searchform using Blade + */ +add_filter('get_search_form', function () { + return template('partials.searchform'); +}); + +/** + * 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'), + ]; +}); diff --git a/resources/views/partials/searchform.blade.php b/resources/views/partials/searchform.blade.php new file mode 100644 index 0000000000..d4b5847184 --- /dev/null +++ b/resources/views/partials/searchform.blade.php @@ -0,0 +1,7 @@ +