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

Allow rel customizations in social link block #38630

Closed
circlecube opened this issue Feb 8, 2022 · 0 comments · Fixed by #45469
Closed

Allow rel customizations in social link block #38630

circlecube opened this issue Feb 8, 2022 · 0 comments · Fixed by #45469
Assignees
Labels
[Block] Social Affects the Social Block - used to display Social Media accounts [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@circlecube
Copy link
Contributor

Currently, the social link block has some hard-coded rel attributes that are applied only if the parent social links block is set to open in a new tab. When the open in new tab toggle is set to true, each link receives rel="noopener nofollow" if it is not selected there is no rel attribute. For example, it's not a guarantee that if a link will open in a new tab that it should be marked nofollow and that if it is not set to open in a new tab it shouldn't have a nofollow rel. The use case would be a theme block with template parts loading social links in a theme, the user may want to edit the rel values for SEO or other purposes. See the implementation here:

$rel_target_attributes = 'rel="noopener nofollow" target="_blank"';

Ideally, the social link block can have a custom rel attribute. This is a pattern established in the button block already, and users will expect consistency in how link patterns are treated and managed. The social link should apply smart rel attributes automatically but also allow the user to customize the attribute. Placing the rel field within the advanced block settings is a great pattern to follow established by the button block.

Existing implementation of established pattern in button block:

const NEW_TAB_REL = 'noreferrer noopener';

const onSetLinkRel = useCallback(
( value ) => {
setAttributes( { rel: value } );
},
[ setAttributes ]
);
function onToggleOpenInNewTab( value ) {
const newLinkTarget = value ? '_blank' : undefined;
let updatedRel = rel;
if ( newLinkTarget && ! rel ) {
updatedRel = NEW_TAB_REL;
} else if ( ! newLinkTarget && rel === NEW_TAB_REL ) {
updatedRel = undefined;
}
setAttributes( {
linkTarget: newLinkTarget,
rel: updatedRel,
} );
}

<TextControl
label={ __( 'Link rel' ) }
value={ rel || '' }
onChange={ onSetLinkRel }
/>

@Mamaduka Mamaduka added [Block] Social Affects the Social Block - used to display Social Media accounts [Type] Enhancement A suggestion for improvement. labels Feb 8, 2022
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Nov 1, 2022
georgeh pushed a commit that referenced this issue Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Social Affects the Social Block - used to display Social Media accounts [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants