Skip to content

Commit

Permalink
use dynamic label on front of site
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Jan 4, 2023
1 parent eea7fa8 commit 2505367
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/block-library/src/navigation-link/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
$has_submenu = count( $block->inner_blocks ) > 0;
$is_active = ! empty( $attributes['id'] ) && ( get_queried_object_id() === (int) $attributes['id'] );

$theUrl = $post ? get_permalink( $post ) : $attributes['url'];
$dynamic_url = $post ? get_permalink( $post ) : $attributes['url'];
$dynamic_label = $post ? $post->post_title : $attributes['label'];

$wrapper_attributes = get_block_wrapper_attributes(
array(
Expand All @@ -172,8 +173,8 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
'<a class="wp-block-navigation-item__content" ';

// Start appending HTML attributes to anchor tag.
if ( isset( $theUrl ) ) {
$html .= ' href="' . esc_url( $theUrl ) . '"';
if ( isset( $dynamic_url ) ) {
$html .= ' href="' . esc_url( $dynamic_url ) . '"';
}

if ( $is_active ) {
Expand Down Expand Up @@ -201,8 +202,8 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
// Wrap title with span to isolate it from submenu icon.
'<span class="wp-block-navigation-item__label">';

if ( isset( $attributes['label'] ) ) {
$html .= wp_kses_post( $attributes['label'] );
if ( isset( $dynamic_label ) ) {
$html .= wp_kses_post( $dynamic_label );
}

$html .= '</span>';
Expand Down

1 comment on commit 2505367

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3845271769
📝 Reported issues:

Please sign in to comment.