diff --git a/public_html/wp-content/plugins/pattern-directory/tests/phpunit/class-theme-author-profile-link-test.php b/public_html/wp-content/plugins/pattern-directory/tests/phpunit/class-theme-author-profile-link-test.php
new file mode 100644
index 00000000..584c5b67
--- /dev/null
+++ b/public_html/wp-content/plugins/pattern-directory/tests/phpunit/class-theme-author-profile-link-test.php
@@ -0,0 +1,134 @@
+user->create_and_get(
+ array(
+ 'user_nicename' => 'pattern-author',
+ 'display_name' => 'Pattern Author',
+ )
+ );
+ foreach ( array( POST_TYPE, 'post' ) as $post_type ) {
+ $factory->post->create(
+ array(
+ 'post_type' => $post_type,
+ 'post_author' => self::$author->ID,
+ 'post_status' => 'publish',
+ )
+ );
+ }
+
+ self::load_theme();
+ }
+
+ /**
+ * Use pretty permalinks, as the site does.
+ */
+ public function set_up(): void {
+ parent::set_up();
+
+ $this->set_permalink_structure( '/%postname%/' );
+ }
+
+ /**
+ * Render a filter-type query title block through the theme.
+ *
+ * @param array $attrs Block attributes.
+ * @return WP_HTML_Tag_Processor A processor positioned before the output.
+ */
+ protected function render_title( array $attrs ): WP_HTML_Tag_Processor {
+ $block = array(
+ 'blockName' => 'core/query-title',
+ 'attrs' => array_merge( array( 'type' => 'filter' ), $attrs ),
+ 'innerBlocks' => array(),
+ 'innerHTML' => '',
+ 'innerContent' => array(),
+ );
+
+ return new WP_HTML_Tag_Processor( update_archive_title( '', $block ) );
+ }
+
+ /**
+ * Catches an author archive whose grid heading is hidden or has no link to the profile.
+ */
+ public function test_grid_title_links_to_profile(): void {
+ $this->go_to( get_author_posts_url( self::$author->ID ) );
+ $this->assertTrue( is_author() );
+
+ $tags = $this->render_title(
+ array(
+ 'level' => 1,
+ 'className' => 'screen-reader-text',
+ )
+ );
+
+ $this->assertTrue( $tags->next_tag( 'h1' ) );
+ $this->assertFalse( $tags->has_class( 'screen-reader-text' ) );
+ $this->assertTrue( $tags->next_tag( 'a' ) );
+ $this->assertSame( 'https://profiles.wordpress.org/pattern-author/', $tags->get_attribute( 'href' ) );
+ }
+
+ /**
+ * Catches the profile link leaking into the local navigation bar's title.
+ */
+ public function test_navigation_title_stays_plain(): void {
+ $this->go_to( get_author_posts_url( self::$author->ID ) );
+
+ $tags = $this->render_title( array( 'className' => 'wporg-local-navigation-bar__fade-in-scroll' ) );
+
+ $this->assertTrue( $tags->next_tag( 'h1' ) );
+ $this->assertFalse( $tags->next_tag( 'a' ) );
+ }
+
+ /**
+ * Catches the heading showing on archives that are not by an author.
+ */
+ public function test_front_page_title_stays_hidden(): void {
+ $this->go_to( home_url( '/' ) );
+
+ $tags = $this->render_title(
+ array(
+ 'level' => 1,
+ 'className' => 'screen-reader-text',
+ )
+ );
+
+ $this->assertTrue( $tags->next_tag( 'h1' ) );
+ $this->assertTrue( $tags->has_class( 'screen-reader-text' ) );
+ $this->assertFalse( $tags->next_tag( 'a' ) );
+ }
+}
diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php b/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php
index aad5034a..d94cbf72 100644
--- a/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php
+++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php
@@ -499,7 +499,8 @@ function update_archive_title( $block_content, $block ) {
return '';
}
- $term_names = get_applied_filter_list( false );
+ $author_link = '';
+ $term_names = get_applied_filter_list( false );
if ( ! empty( $term_names ) ) {
$term_names = wp_list_pluck( $term_names, 'name' );
// translators: %s list of terms used for filtering.
@@ -509,13 +510,32 @@ function update_archive_title( $block_content, $block ) {
if ( $author ) {
/* translators: %s: Author display name. */
$title = sprintf( __( 'Author: %s', 'wporg-patterns' ), $author->display_name );
+
+ $author_link = sprintf(
+ '%2$s',
+ esc_url( 'https://profiles.wordpress.org/' . $author->user_nicename . '/' ),
+ esc_html( $author->display_name )
+ );
} else {
$title = __( 'All patterns', 'wporg-patterns' );
}
}
if ( is_search() ) {
- $title = __( 'Search results', 'wporg-patterns' );
+ $title = __( 'Search results', 'wporg-patterns' );
+ $author_link = '';
+ }
+
+ $content = esc_html( $title );
+
+ // Show the author heading in the grid, with a link to the author's WordPress.org profile.
+ // The heading in the local navigation bar stays plain text.
+ $class_names = isset( $attributes['className'] ) ? explode( ' ', $attributes['className'] ) : array();
+ if ( $author_link && in_array( 'screen-reader-text', $class_names, true ) ) {
+ $block['attrs']['className'] = implode( ' ', array_diff( $class_names, array( 'screen-reader-text' ) ) ) . ' is-author-title';
+
+ /* translators: %s: Author display name, linked to their WordPress.org profile. */
+ $content = sprintf( esc_html__( 'Author: %s', 'wporg-patterns' ), $author_link );
}
$allowed_tags = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' );
@@ -533,7 +553,7 @@ function update_archive_title( $block_content, $block ) {
'<%1$s %2$s>%3$s%1$s>',
$tag_name,
$wrapper_attributes,
- esc_html( $title )
+ $content
);
}
return $block_content;
diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/style.css b/public_html/wp-content/themes/wporg-pattern-directory-2024/style.css
index fceb2d84..82a0ffe0 100644
--- a/public_html/wp-content/themes/wporg-pattern-directory-2024/style.css
+++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/style.css
@@ -48,6 +48,19 @@ body.page .wp-block-wporg-local-navigation-bar .wp-block-query-title {
display: none;
}
+/* Show the author archive heading, which links to the author's profile. */
+.wp-block-query-title.is-author-title {
+ margin-top: 0;
+ margin-bottom: var(--wp--preset--spacing--30);
+ font-family: var(--wp--preset--font-family--inter);
+ font-size: var(--wp--preset--font-size--large);
+ font-weight: 600;
+}
+
+.wp-block-query-title.is-author-title a {
+ color: inherit;
+}
+
/* Hide the grid `h1` on the homepage, as the header has an h1. */
body.blog:not(.paged) .wp-block-query .wp-block-query-title {
display: none;