Skip to content

Commit

Permalink
Add language filter to Lesson Plan archive
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwoodnz committed Apr 18, 2023
1 parent f8be467 commit 948c26f
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
'current' => filter_input( INPUT_GET, 'wp_version', FILTER_VALIDATE_INT, FILTER_REQUIRE_ARRAY ) ?: array(),
),
);

$locales = \WPOrg_Learn\Post_Meta\get_available_post_type_locales( 'language', 'lesson-plan', 'native' );
?>

<form class="sidebar-filters col-3" method="get" action="<?php echo esc_url( get_post_type_archive_link( 'lesson-plan' ) ); ?>">
Expand All @@ -45,6 +47,38 @@
</a>
</div>

<h4 class="h5"><?php esc_html_e( 'Language', 'wporg-learn' ); ?></h4>
<div class="filter-group">
<label for="<?php echo esc_attr( 'language' ); ?>" class="filter-group-label">
<?php esc_html_e( 'Language', 'wporg-learn' ); ?>
<select
id="<?php echo esc_attr( 'language' ); ?>"
class="filter-group-select"
name="<?php echo esc_attr( 'language' ); ?>"
style="width: 100%;"
data-placeholder="<?php esc_attr_e( 'Select', 'wporg-learn' ); ?>"
>
<option value="">Select</option>
<?php foreach ( $locales as $item_value => $item_label ) : ?>
<option
value="<?php echo esc_attr( $item_value ); ?>"
<?php selected( $item_value, filter_input( INPUT_GET, 'language' ) ); ?>
>
<?php if ( in_array( 'language', array( 'language', 'captions' ), true ) ) :
printf(
'%s [%s]',
esc_html( $item_label ),
esc_html( $item_value ),
);
else :
echo esc_html( $item_label );
endif; ?>
</option>
<?php endforeach; ?>
</select>
</label>
</div>

<?php foreach ( $taxonomies as $txnmy ) : ?>
<h4 class="h5"><?php echo esc_html( $txnmy['label'] ); ?></h4>
<ul>
Expand Down

0 comments on commit 948c26f

Please sign in to comment.