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

Add skip link for Full Site Editing themes #6823

Merged
merged 11 commits into from
Jan 26, 2022
Merged

Conversation

dhaval-parekh
Copy link
Collaborator

@dhaval-parekh dhaval-parekh commented Jan 7, 2022

Summary

Fixes #6115

This PR adds a skip link for full site editing themes without causing AMP compatibility issues. The PR uses the similar approach implemented in WordPress/gutenberg#30336 but in PHP.

Checklist

  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@dhaval-parekh dhaval-parekh marked this pull request as ready for review January 10, 2022 06:14
@github-actions
Copy link
Contributor

github-actions bot commented Jan 10, 2022

Plugin builds for 03f03d8 are ready 🛎️!

@codecov
Copy link

codecov bot commented Jan 10, 2022

Codecov Report

Merging #6823 (9581d55) into develop (c2b9b38) will increase coverage by 0.02%.
The diff coverage is 96.15%.

❗ Current head 9581d55 differs from pull request most recent head 6a40a1c. Consider uploading reports for the commit 6a40a1c to get more accurate results
Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #6823      +/-   ##
=============================================
+ Coverage      78.31%   78.33%   +0.02%     
- Complexity      6708     6713       +5     
=============================================
  Files            202      202              
  Lines          20210    20236      +26     
=============================================
+ Hits           15827    15852      +25     
- Misses          4383     4384       +1     
Flag Coverage Δ
php 78.33% <96.15%> (+0.02%) ⬆️
unit 78.33% <96.15%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...s/sanitizers/class-amp-accessibility-sanitizer.php 90.69% <96.15%> (+8.34%) ⬆️

…skip-link

* 'develop' of github.com:ampproject/amp-wp: (43 commits)
  Ensure Navigation block script is registered to fix tests
  Add missing test coverage for dequeue_block_navigation_view_script
  Use function exists check for render_block_core_navigation to determine if test should be skipped
  Add attribute value escaping for good measure
  Fix phpcs warnings
  Fix indentation
  Add assertions that no SQL queries run when data deletion is disabled
  Add test specifically for transient deletion
  Harden term deletion logic for WP<4.4
  Add assertions for term deletion
  Flesh out tests specifically for post and term deletion
  Add test specific to delete_user_metadata
  Add test specifically for the delete_options function
  Remove deletion of non-option
  Add test assertions for terms table
  Use constant for taxonomy slug in test
  Add formatting for SQL statements
  Normalize config.allow-plugins in composer.json
  Update database queries to delete data during uninstalltion
  Revert changes from delete_user_metadata()
  ...
return;
}

$skip_link_target = $this->dom->getElementId( $main_tag, 'wp--skip-link--target' );
Copy link
Member

Choose a reason for hiding this comment

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

Good use of getElementId.

Why the extra hyphens? Why not just:

Suggested change
$skip_link_target = $this->dom->getElementId( $main_tag, 'wp--skip-link--target' );
$skip_link_target = $this->dom->getElementId( $main_tag, 'wp-skip-link-target' );

Copy link
Collaborator

@delawski delawski Jan 26, 2022

Choose a reason for hiding this comment

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

I think the double hyphens are here to match the JS implementation you'll find in Gutenberg:

https://github.com/WordPress/gutenberg/blob/33af5c0206566c8d76d17e21c11ad7635991881c/lib/compat/wordpress-5.9/templates.php#L236

Copy link
Collaborator

Choose a reason for hiding this comment

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

That being said, I just noticed that AMP adds a suffix to the skip link ID attribute (e.g. wp--skip-link--target-0). So it seems that the ID attributes won't be the same on AMP and on non-AMP versions. I guess it doesn't matter in any way.

Copy link
Collaborator

@delawski delawski left a comment

Choose a reason for hiding this comment

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

I've tested it on my local - everything is working as expected, the skip links are added on AMP pages just like on the non-AMP pages.

@westonruter westonruter added this to the v2.2.1 milestone Jan 26, 2022
@westonruter westonruter changed the title Add skip link for Full Site Editing themes. Add skip link for Full Site Editing themes Jan 26, 2022
@westonruter westonruter merged commit b311b57 into develop Jan 26, 2022
@westonruter westonruter deleted the bug/6115-skip-link branch January 26, 2022 19:36
@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelogged Whether the issue/PR has been added to release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make skip link for Full Site Editing themes AMP compatible
3 participants