Merge pull request #2090 from MWDelaney/master
Add searchform partial and function to replace default WordPress functionality
This commit is contained in:
@@ -13,6 +13,11 @@ add_filter('body_class', function (array $classes) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 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 */
|
/** Add class if sidebar is active */
|
||||||
if (display_sidebar()) {
|
if (display_sidebar()) {
|
||||||
$classes[] = 'sidebar-primary';
|
$classes[] = 'sidebar-primary';
|
||||||
@@ -68,3 +73,23 @@ add_filter('comments_template', function ($comments_template) {
|
|||||||
);
|
);
|
||||||
return template_path(locate_template(["views/{$comments_template}", $comments_template]) ?: $comments_template);
|
return template_path(locate_template(["views/{$comments_template}", $comments_template]) ?: $comments_template);
|
||||||
}, 100);
|
}, 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'),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|||||||
7
resources/views/partials/searchform.blade.php
Normal file
7
resources/views/partials/searchform.blade.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<form role="search" method="get" class="search-form" action="{{ $sf_action }}">
|
||||||
|
<label>
|
||||||
|
<span class="screen-reader-text">{{ $sf_screen_reader_text }}</span>
|
||||||
|
<input type="search" class="search-field" placeholder="{!! $sf_placeholder !!}" value="{{ $sf_current_query }}" name="s">
|
||||||
|
</label>
|
||||||
|
<input type="submit" class="search-submit" value="{{ $sf_submit_text }}">
|
||||||
|
</form>
|
||||||
Reference in New Issue
Block a user