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

Remove unnecessary has_filter() calls #414

Merged
merged 1 commit into from
Dec 12, 2023

Conversation

aristath
Copy link
Collaborator

There's no need to check if has_filter before applying filters.
This PR removes the cases where has_filter() was not required.

Comment on lines -1659 to +1657
$simplified_summary_heading = 'Simplified Summary';

// filter title.
if ( has_filter( 'edac_filter_simplified_summary_heading' ) ) {
$simplified_summary_heading = apply_filters( 'edac_filter_simplified_summary_heading', $simplified_summary_heading );
}
$simplified_summary_heading = apply_filters(
'edac_filter_simplified_summary_heading',
esc_html__( 'Simplified Summary', 'accessibility-checker' )
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also made the text translatable

Comment on lines -327 to +338
$notice = 'Whoops! It looks like your website is currently password protected. The free version of Accessibility Checker can only scan live websites. To scan this website for accessibility problems either remove the password protection or <a href="https://equalizedigital.com/accessibility-checker/pricing/" target="_blank" aria-label="upgrade to accessibility checker pro, opens in a new window">upgrade to pro</a>. Scan results may be stored from a previous scan.';

if ( has_filter( 'edac_filter_password_protected_notice_text' ) ) {
$notice = apply_filters( 'edac_filter_password_protected_notice_text', $notice );
}

return $notice;
return apply_filters(
'edac_filter_password_protected_notice_text',
sprintf(
// translators: %s is the link to upgrade to pro, with "upgrade to pro" as the anchor text.
esc_html__( 'Whoops! It looks like your website is currently password protected. The free version of Accessibility Checker can only scan live websites. To scan this website for accessibility problems either remove the password protection or %s. Scan results may be stored from a previous scan.', 'accessibility-checker' ),
sprintf(
'<a href="https://equalizedigital.com/accessibility-checker/pricing/" target="_blank" aria-label="%1$s">%2$s</a>',
esc_attr__( 'Upgrade to accessibility checker pro. Opens in a new window.', 'accessibility-checker' ),
esc_html__( 'upgrade to pro', 'accessibility-checker' )
)
)
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also made sure the text for this notice is translatable and properly escaped.

if ( has_filter( 'replace_editor', 'gutenberg_init' ) ) {
// Gutenberg is installed and activated.
$gutenberg = true;
}
$gutenberg = has_filter( 'replace_editor', 'gutenberg_init' );
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ideally we'd check if Gutenberg is active using a check like the one below:

$gutenberg = defined( 'IS_GUTENBERG_PLUGIN' );

That's something we can do in a followup PR when we rething a bit how we check for plugins 👍

@SteveJonesDev SteveJonesDev self-requested a review December 12, 2023 15:27
@SteveJonesDev SteveJonesDev merged commit 878c97a into equalizedigital:develop Dec 12, 2023
10 checks passed
@SteveJonesDev SteveJonesDev added this to the v1.8.0 milestone Dec 21, 2023
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.

2 participants