Skip to content

Commit

Permalink
Allow deregistering more styles with `air_helper_styles_to_deregister…
Browse files Browse the repository at this point in the history
…` filter (T-23392)
  • Loading branch information
ronilaukkarinen committed Dec 11, 2024
1 parent 1dcaffd commit 8fc1703
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 3.1.5: 2024-12-11

* Allow deregistering more styles with `air_helper_styles_to_deregister` filter (T-23392)

### 3.1.4: 2024-12-05

* Remove Optimole dashboard widget (T-23392)
Expand Down
8 changes: 4 additions & 4 deletions air-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Air helper
* Plugin URI: https://github.com/digitoimistodude/air-helper
* Description: Plugin provides helpful functions and modifications for WordPress projects.
* Version: 3.1.4
* Version: 3.1.5
* Author: Digitoimisto Dude Oy
* Author URI: https://www.dude.fi
* Requires at least: 5.5
Expand All @@ -28,9 +28,9 @@
* @return integer current version of plugin
*/
function air_helper_version() {
// Version: 3.1.4
// 5 integers, e. g. 3.1.4 -> 31004
return 31004;
// Version: 3.1.5
// 5 integers, e. g. 3.1.5 -> 31005
return 31005;
} // end air_helper_version

/**
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"plugin"
],
"license": "GPL-3.0+",
"version": "3.1.4",
"version": "3.1.5",
"authors": [
{
"name": "Timi Wahalahti",
Expand Down Expand Up @@ -45,4 +45,4 @@
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"phpcompatibility/phpcompatibility-wp": "*"
}
}
}
26 changes: 13 additions & 13 deletions inc/clean-ups.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,20 @@ function air_helper_strip_tags_menu_item( $title, $arg_2 = null, $arg_3 = null,
/**
* Remove unnecessary WordPress default styles in front end (T-13957)
*
* Turn off with:
* Turn off completely with:
* add_action( 'init', function() {
* remove_action( 'wp_enqueue_scripts', 'air_helper_dequeue_default_styles' );
* }, 999 );
*
* Enable specific styles with filter:
* add_filter( 'air_helper_enabled_frontend_styles', function( $enabled_styles ) {
* $enabled_styles[] = 'dashicons';
* return $enabled_styles;
* Modify styles to deregister:
* add_filter( 'air_helper_styles_to_deregister', function( $styles ) {
* // Remove a style from default list
* $styles = array_diff( $styles, ['dashicons'] );
*
* // Or add new ones to deregister
* $styles[] = 'wp-block-library';
*
* return $styles;
* });
*
* @since 3.1.2
Expand All @@ -70,19 +75,14 @@ function air_helper_dequeue_default_styles() {
return;
}

$styles_to_deregister = [
$styles_to_deregister = apply_filters( 'air_helper_styles_to_deregister', [
'dashicons',
'wp-block-library',
'wp-block-library-theme',
'classic-theme-styles',
'global-styles',
];

$enabled_styles = apply_filters( 'air_helper_enabled_frontend_styles', [] );
] );

foreach ( $styles_to_deregister as $style ) {
if ( ! in_array( $style, $enabled_styles, true ) ) {
wp_deregister_style( $style );
}
wp_deregister_style( $style );
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "air-helper",
"version": "3.1.4",
"version": "3.1.5",
"description": "Plugin provides helpful functions and modifications for WordPress projects.",
"main": "air-helper.php",
"dependencies": {},
Expand All @@ -18,4 +18,4 @@
"url": "https://github.com/digitoimistodude/air-helper/issues"
},
"homepage": "https://github.com/digitoimistodude/air-helper"
}
}

0 comments on commit 8fc1703

Please sign in to comment.