Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filters: Add prefix label to the single query filters #2804

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions wp-content/themes/pub/wporg-learn-2024/inc/block-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ function get_content_type_options( $options ) {
$label = $options[ $selected_slug ] ?? $options['any'];

return array(
'label' => $label,
'title' => __( 'Content Type', 'wporg-learn' ),
'label' => sprintf( __( 'Type: %s', 'wporg-learn' ), $label ),
'title' => __( 'Content type', 'wporg-learn' ),
'key' => 'post_type',
'action' => get_filtered_url(),
'options' => $options,
Expand Down Expand Up @@ -100,28 +100,22 @@ function ( $a, $b ) {
$levels,
);

$label = __( 'Level', 'wporg-learn' );
$label = __( 'All', 'wporg-learn' );

$selected_slug = $wp_query->get( 'wporg_lesson_level' );
if ( $selected_slug ) {
// Find the selected level from $levels by slug and then get the name.
$selected_level = array_filter(
$levels,
function ( $level ) use ( $selected_slug ) {
return $level->slug === $selected_slug;
}
);
$selected_level = wp_list_filter( $levels, array( 'slug' => $selected_slug ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

if ( ! empty( $selected_level ) ) {
$selected_level = array_shift( $selected_level );
$label = $selected_level->name;
}
} else {
$selected_slug = 'all';
$label = __( 'All', 'wporg-learn' );
}

return array(
'label' => $label,
'label' => sprintf( __( 'Level: %s', 'wporg-learn' ), $label ),
'title' => __( 'Level', 'wporg-learn' ),
'key' => 'wporg_lesson_level',
'action' => get_filtered_url(),
Expand Down Expand Up @@ -534,7 +528,7 @@ function get_student_course_options( $options ) {
$label = $options[ $selected_slug ] ?? $options['all'];

return array(
'label' => $label,
'label' => sprintf( __( 'Status: %s', 'wporg-learn' ), $label ),
'title' => __( 'Completion status', 'wporg-learn' ),
Copy link
Contributor

@renintw renintw Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the first letter of "status" to uppercase to make it consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use sentence case across the site, so leaving "status" lowercase in "Completion status" is correct. "Content Type" and "Skill Level" should probably be updated to "Content type" and "Skill level" instead. Unless I'm using that rule too broadly — maybe a check from @thetinyl would help.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's use sentence case. Thanks for checking!

'key' => $key,
'action' => get_filtered_url(),
Expand Down