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

Fix: Social Icons Blocks > link attributes rel values inconsistencies #68944

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

dhananjaykuber
Copy link
Contributor

Fixes #53873

What?

Updates the Social Links block to improve handling of rel attributes in social links, particularly focusing on security attributes for links that open in new tabs while allowing proper customization of rel values.

Why?

Currently, the Social Links block has several issues with rel attribute handling:

  • When "Open in New Tab" is enabled, it adds both noopener nofollow by default
  • The nofollow value is unnecessarily applied and can negatively impact SEO
  • When overriding rel attributes via Advanced settings, values are cumulative with no way to remove nofollow

How?

Modifies the render_block_core_social_link function to:

  • Always include noopener noreferrer for security when target="_blank" is used
  • Remove automatic nofollow
  • Allow custom rel values to override defaults while preserving security attributes

Testing Instructions

  • Create a new post or page
  • Add a Social Links block
  • Add any social link (e.g., WordPress)

Test the following scenarios:

Scenario 1: Default Behavior

  • Add a social link
  • View source code
  • Verify no rel attributes are added by default

Scenario 2: Open in New Tab

  • Enable "Open in New Tab" setting
  • View source code
  • Verify only noopener noreferrer are added (no nofollow)

Scenario 3: Custom Rel Attributes

  • Open Advanced settings
  • Add custom rel value (e.g., nofollow)
  • View source code
  • Verify custom value appears
  • Enable "Open in New Tab"
  • Verify custom value remains along with noopener noreferrer

Screenshots or screencast

After adding custom rel attribute when "Open in New Tab" is enabled

Screenshot 2025-01-29 at 6 53 40 PM

Screenshot 2025-01-29 at 6 55 08 PM

After not adding anything in custom rel attribute when "Open in New Tab" is enabled

Screenshot 2025-01-29 at 6 56 11 PM
Screenshot 2025-01-29 at 6 56 24 PM

No nofollow rel attribute is added by default

Copy link

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dhananjaykuber <[email protected]>
Co-authored-by: Marc-pi <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

It has been proposed to remove the noreferrer and nofollow noopener attributes: #26914

Before moving forward with this PR, it would be a good idea to agree up front on how the entire Gutenberg project will handle these attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Social Icons Blocks > link attributes rel values inconsistencies
2 participants