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

adds skip links check for block themes #457

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

MaggieCabrera
Copy link

@MaggieCabrera MaggieCabrera commented Sep 3, 2024

This PR adds a check only for block themes to see if templates have a main tag present. If they don't they will be missing the skip links from said template.

I need to check when a template is made out of a pattern and the main tag will be inside the pattern instead of the template file

@MaggieCabrera
Copy link
Author

We might want to check if there's multiple tags too

@MaggieCabrera MaggieCabrera marked this pull request as ready for review September 5, 2024 15:10
Copy link
Collaborator

@matiasbenedetto matiasbenedetto left a comment

Choose a reason for hiding this comment

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

the <main> tag is being rendered in the HTML instead of being printed as text:

image

@matiasbenedetto
Copy link
Collaborator

It would be nice to make the main tag search recusive for nested patterns.

@MaggieCabrera
Copy link
Author

I fixed those! ready for another review

Co-authored-by: Matias Benedetto <[email protected]>
$theme_dir = $this->wp_theme->get_stylesheet_directory();

// Get all HTML files in the directory
$files = glob( $theme_dir . '/' . $directory . '/*.html' );
Copy link
Collaborator

@matiasbenedetto matiasbenedetto Sep 16, 2024

Choose a reason for hiding this comment

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

Accessing the file system from the check function doesn't seems to be necesary and it looks like it's not in line with the other implementation. The check function is already getting 3 arrays as parameters containing the list of file paths of the theme.

https://github.com/MaggieCabrera/theme-check/blob/17ee4214ab4331440865f75ab27b0aa17e212fda/checks/class-skip-links.php#L47

return false;
}

$files = glob( $theme_dir . '/' . $directory . '/*.php' );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as in #457 (comment)

@kafleg
Copy link
Member

kafleg commented Sep 17, 2024

I checked by removing "tagName":"main" from the template files in Twenty Twenty Four theme but this PR won't show anything.

Would you please let me know how did you test that?

@kafleg
Copy link
Member

kafleg commented Sep 17, 2024

I checked by removing "tagName":"main" from the template files in Twenty Twenty Four theme but this PR won't show anything.

Would you please let me know how did you test that?

I find it. I was checking different PR. Sorry!

@kafleg
Copy link
Member

kafleg commented Sep 17, 2024

REQUIRED Skip links are missing from the following templates: single.html, single.html Please make sure the templates have a

tag.

Why the message show single.html, single.html twice?

@MaggieCabrera
Copy link
Author

REQUIRED Skip links are missing from the following templates: single.html, single.html Please make sure the templates have a
tag.

Why the message show single.html, single.html twice?

I haven't seen that on my tests, what did you try to get that to happen?

@kafleg
Copy link
Member

kafleg commented Sep 17, 2024

In single.html file of TT4 theme, I simply changed <main class="wp-block-group alignfull"> to <div class="wp-block-group alignfull">

@kafleg
Copy link
Member

kafleg commented Sep 17, 2024

I think I found the reason,
I changed on index.html and single.html in two files and it is happended.

Comment on lines +81 to +89
$this->error[] = sprintf(
'<span class="tc-lead tc-required">%s</span> %s ',
__( 'REQUIRED', 'theme-check' ),
sprintf(
__( 'Skip links are missing from the following templates: %s Please make sure the templates have a &lt;main&gt; tag.', 'theme-check' ),
$info
)
);
}
Copy link
Collaborator

@matiasbenedetto matiasbenedetto Sep 17, 2024

Choose a reason for hiding this comment

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

When a REQUIRED change is returned by the check function, it should return false:
See #465 as reference

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

Successfully merging this pull request may close these issues.

3 participants