Add expanded param to fictioneer_search shortcode
This commit is contained in:
parent
267109fff2
commit
5635fe33cc
@ -1288,6 +1288,7 @@ Renders the search form with advanced options (if not disabled in the settings).
|
||||
* **simple:** Set `true` to hide the advanced search options. Default `false`.
|
||||
* **placeholder:** Change the placeholder text.
|
||||
* **type:** Preselect either "any", "story", "chapter", "recommendation", "collection", or "post".
|
||||
* **expanded:** Whether the advanced form is expanded. Default `false`.
|
||||
* **tags:** Preselect tags as comma-separated list of term IDs.
|
||||
* **genres:** Preselect genres as comma-separated list of term IDs.
|
||||
* **fandoms:** Preselect fandoms as comma-separated list of term IDs.
|
||||
|
@ -1378,6 +1378,8 @@ function fictioneer_shortcode_search( $attr ) {
|
||||
$pre_warnings = fictioneer_explode_list( $attr['warnings'] ?? '' );
|
||||
|
||||
// Prepare arguments
|
||||
$args['expanded'] = filter_var( $attr['expanded'] ?? 0, FILTER_VALIDATE_BOOLEAN );
|
||||
|
||||
if ( $simple ) {
|
||||
$args['simple'] = $simple;
|
||||
}
|
||||
|
@ -7,8 +7,10 @@
|
||||
* @since 5.0.0
|
||||
* @since 5.11.0 - Added 'fictioneer_search_form_filters' action hook.
|
||||
* @since 5.19.0 - Added taxonomy preselect arguments.
|
||||
* @since 5.23.1 - Added expanded argument.
|
||||
*
|
||||
* @internal $args['simple'] Optional. Hide advanced options.
|
||||
* @internal $args['expanded'] Optional. Whether the advanced form should be expanded. Default null|false.
|
||||
* @internal $args['placeholder'] Optional. Change search placeholder.
|
||||
* @internal $args['preselect_type'] Optional. Default post type to query.
|
||||
* @internal $args['preselect_tags'] Optional. Default tag IDs to query.
|
||||
@ -109,7 +111,13 @@ if ( $show_advanced ) {
|
||||
method="get"
|
||||
class="search-form <?php if ( ! $show_advanced ) echo '_simple'; ?>"
|
||||
action="<?php echo esc_url( home_url( '/' ) ); ?>"
|
||||
data-advanced="<?php echo ( is_search() && $show_advanced && $no_params ) ? 'true' : 'false'; ?>"
|
||||
data-advanced="<?php
|
||||
if ( $args['expanded'] ?? 0 ) {
|
||||
echo 'true';
|
||||
} else {
|
||||
echo ( is_search() && $show_advanced && $no_params ) ? 'true' : 'false';
|
||||
}
|
||||
?>"
|
||||
>
|
||||
|
||||
<?php if ( $show_advanced ) : ?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user