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

Set pattern for including css in fixes #751

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions includes/classes/Fixes/Fix/FocusOutlineFix.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function ( $fields ) {
'description' => sprintf(
// translators: %1$s: a color code wrapped in a <code> tag.
__( 'Sets the color for the focus outline. Default is %1$s.', 'accessibility-checker' ),
'<code>#005FCC</code>'
'<code>#005FCC</code>'
),
'sanitize_callback' => 'sanitize_hex_color',
'section' => 'focus_outline',
Expand All @@ -95,7 +95,7 @@ public function run() {
return;
}

add_action( 'wp_head', [ $this, 'css' ] );
add_action( 'edac_action_enqueue_frontend_fixes_styles', [ $this, 'styles' ] );
}

/**
Expand All @@ -114,7 +114,7 @@ public function focus_outline_section_callback() {
*
* @return void
*/
public function css() {
public function styles() {
$styles = '';

$focus_color_option = get_option( 'edac_fix_focus_outline_color', false );
Expand All @@ -128,10 +128,11 @@ public function css() {
}
";

ob_start();
?>
<style id="edac-fix-focus-outline">
<?php echo esc_attr( $styles ); ?>
</style>
<?php
$styles = ob_get_clean();
wp_add_inline_style( 'edac-frontend-fixes-styles', $styles );
}
}
11 changes: 5 additions & 6 deletions includes/classes/Fixes/Fix/ReadMoreAddTitleFix.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function run() {
add_filter( 'excerpt_more', [ $this, 'add_title_to_excerpt_more' ], 100 );

if ( get_option( 'edac_fix_add_read_more_title_screen_reader_only', false ) ) {
add_action( 'wp_head', [ $this, 'add_screen_reader_styles' ] );
add_action( 'edac_action_enqueue_frontend_fixes_styles', [ $this, 'styles' ] );
}
}

Expand Down Expand Up @@ -162,9 +162,8 @@ public function add_title_to_excerpt_more(): string {
*
* @return void
*/
public function add_screen_reader_styles() {
?>
<style>
public function styles() {
$styles = <<<CSS
.edac-screen-reader-text {
position: absolute;
clip: rect(1px, 1px, 1px, 1px);
Expand All @@ -174,8 +173,8 @@ public function add_screen_reader_styles() {
overflow: hidden;
white-space: nowrap;
}
</style>
<?php
CSS;
wp_add_inline_style( 'edac-frontend-fixes-styles', $styles );
}

/**
Expand Down
15 changes: 9 additions & 6 deletions includes/classes/Fixes/Fix/SkipLinkFix.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,19 @@ function ( $data ) use ( $targets ) {
return $data;
}
);

if ( ! get_option( 'edac_fix_disable_skip_link_styles', false ) ) {
add_action( 'edac_action_enqueue_frontend_fixes_styles', [ $this, 'styles' ] );
}
}

/**
* Injects the style rules for the skip link.
*
* @return void
*/
public function add_skip_link_styles() {
?>
<style id="edac-fix-skip-link-styles">
public function styles() {
$styles = <<<CSS
.edac-bypass-block {
border: 0;
clip: rect(1px, 1px, 1px, 1px);
Expand Down Expand Up @@ -213,8 +216,9 @@ public function add_skip_link_styles() {
outline: 2px solid #000;
outline-offset: 2px;
}
</style>
<?php
CSS;

wp_add_inline_style( 'edac-frontend-fixes-styles', $styles );
}

/**
Expand Down Expand Up @@ -254,7 +258,6 @@ public function add_skip_link() {
?>
<a class="edac-skip-link--navigation" href="#<?php echo esc_attr( $nav_target ); ?>"><?php esc_html_e( 'Skip to navigation', 'accessibility-checker' ); ?></a>
<?php endif; ?>
<?php get_option( 'edac_fix_disable_skip_link_styles', false ) ? '' : $this->add_skip_link_styles(); ?>
</div>
</template>
<?php
Expand Down
2 changes: 2 additions & 0 deletions includes/classes/Fixes/FixesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ function () {
apply_filters( 'edac_filter_frontend_fixes_data', [] )
);
do_action( 'edac_action_enqueue_frontend_fixes' );
wp_enqueue_style( 'edac-frontend-fixes-styles', EDAC_PLUGIN_URL . 'build/css/frontendFixes.bundle.css', [], EDAC_VERSION );
do_action( 'edac_action_enqueue_frontend_fixes_styles' );
}
);
}
Expand Down
1 change: 1 addition & 0 deletions src/frontendFixes/sass/frontend-fixes.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* This is a holder file that may contain scss for frontend fixes. It is not inteded to be used generally unless a style is global. Use wp_inline_style() to add styles for individual fixes. */
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
],
frontendFixes: [
'./src/frontendFixes/index.js',
'/src/frontendFixes/sass/frontend-fixes.scss',
],

},
Expand Down
Loading