diff --git a/source/wp-content/themes/wporg-themes-2024/functions.php b/source/wp-content/themes/wporg-themes-2024/functions.php index 3bc14f0..93b510f 100644 --- a/source/wp-content/themes/wporg-themes-2024/functions.php +++ b/source/wp-content/themes/wporg-themes-2024/functions.php @@ -52,6 +52,14 @@ function( $should_show ) { 2000 ); +add_action( + 'init', + function() { + // Don't swap author link with w.org profile link. + remove_all_filters( 'author_link' ); + } +); + /** * Temporary fix for permission problem during local install. */ @@ -253,17 +261,20 @@ function redirect_term_archives() { global $wp_query, $wp; $url = false; $query_vars = []; - $is_browse_url = str_starts_with( $wp->request, 'browse/' ); - $is_tags_url = str_starts_with( $wp->request, 'tags/' ); + + // Return early if we're already on an author or browse page. + if ( str_starts_with( $wp->request, 'author/' ) || str_starts_with( $wp->request, 'browse/' ) ) { + return; + } $browse = sanitize_text_field( $wp_query->query['browse'] ?? '' ); $terms = array_map( 'sanitize_text_field', get_query_tags() ); - if ( ! empty( $browse ) && ! $is_browse_url ) { + if ( ! empty( $browse ) ) { $url = home_url( '/browse/' . $browse . '/' ); $query_vars = [ 's', 'tag', 'tag_slug__and' ]; - } else if ( count( $terms ) && ! $is_browse_url && ! $is_tags_url ) { + } else if ( count( $terms ) && ! str_starts_with( $wp->request, 'tags/' ) ) { if ( count( $terms ) === 1 ) { $url = get_term_link( $terms[0], 'post_tag' ); } else { diff --git a/source/wp-content/themes/wporg-themes-2024/inc/block-config.php b/source/wp-content/themes/wporg-themes-2024/inc/block-config.php index 6b963ca..4dddecc 100644 --- a/source/wp-content/themes/wporg-themes-2024/inc/block-config.php +++ b/source/wp-content/themes/wporg-themes-2024/inc/block-config.php @@ -27,6 +27,19 @@ function update_query_total_label( $label, $found_posts ) { return _n( '%s theme', '%s themes', $found_posts, 'wporg-themes' ); } +/** + * Get the destination for query-filter submission based on the current page. + * + * @return string + */ +function get_filter_action_url() { + global $wp; + if ( is_author() ) { + return home_url( $wp->request ); + } + return home_url( '/' ); +} + /** * Provide a list of layout options. * @@ -49,7 +62,7 @@ function get_layouts_options( $options ) { 'label' => $label, 'title' => __( 'Layout', 'wporg-themes' ), 'key' => 'tag_slug__and', - 'action' => home_url( '/' ), + 'action' => get_filter_action_url(), 'options' => $layouts, 'selected' => $selected, ); @@ -77,7 +90,7 @@ function get_features_options( $options ) { 'label' => $label, 'title' => __( 'Features', 'wporg-themes' ), 'key' => 'tag_slug__and', - 'action' => home_url( '/' ), + 'action' => get_filter_action_url(), 'options' => $features, 'selected' => $selected, ); @@ -105,7 +118,7 @@ function get_subjects_options( $options ) { 'label' => $label, 'title' => __( 'Subjects', 'wporg-themes' ), 'key' => 'tag_slug__and', - 'action' => home_url( '/' ), + 'action' => get_filter_action_url(), 'options' => $subjects, 'selected' => $selected, );