Skip to content

Commit ffc0ab6

Browse files
committed
Fix: Ignore unused function parameter warnings in multiple files
1 parent 9935484 commit ffc0ab6

4 files changed

Lines changed: 31 additions & 30 deletions

File tree

default-cache-control.php

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* The structure follows the same pattern as the cache-control plugin.
2323
*
2424
* Available options for each entry:
25-
* - max_age: Cache duration in seconds for browsers (defined only 1 time on cache_control_default_settings function)
25+
* - max_age: Cache duration in seconds for browsers (defined only 1 time on default_settings function)
2626
* - s_maxage: Cache duration in seconds for CDN/proxies
2727
* - staleerror: Duration to serve stale content on server errors (auto-defined x3 s_maxage)
2828
* - stalereval: Duration to serve stale content while revalidating (auto-defined x5 s_maxage)
@@ -32,65 +32,66 @@
3232
* @return array Default cache control settings
3333
*/
3434
function get_default_cache_control_settings() {
35+
// WordPress constants: HOUR_IN_SECONDS = 3600, DAY_IN_SECONDS = 86400
3536
return [
3637
'front_page' => [
37-
's_maxage' => 10 * HOUR_IN_SECONDS, // 10 hours
38+
's_maxage' => 10 * \HOUR_IN_SECONDS, // 10 hours
3839
],
3940
'singles' => [
40-
's_maxage' => 10 * HOUR_IN_SECONDS, // 10 hours
41+
's_maxage' => 10 * \HOUR_IN_SECONDS, // 10 hours
4142
'mmulti' => 1, // Enable age multiplier
4243
],
4344
'pages' => [
44-
's_maxage' => 10 * HOUR_IN_SECONDS, // 10 hours
45+
's_maxage' => 10 * \HOUR_IN_SECONDS, // 10 hours
4546
],
4647
'home' => [
47-
's_maxage' => 10 * HOUR_IN_SECONDS, // 10 hours
48+
's_maxage' => 10 * \HOUR_IN_SECONDS, // 10 hours
4849
'paged' => 5, // 5 seconds pagination factor. Example : 10 pages * 5 seconds = 50 seconds
4950
],
5051
'categories' => [
51-
's_maxage' => 10 * HOUR_IN_SECONDS, // 10 hours
52+
's_maxage' => 10 * \HOUR_IN_SECONDS, // 10 hours
5253
'paged' => 8, // 8 seconds pagination factor
5354
],
5455
'tags' => [
55-
's_maxage' => 10 * HOUR_IN_SECONDS, // 10 hours
56+
's_maxage' => 10 * \HOUR_IN_SECONDS, // 10 hours
5657
'paged' => 10, // 10 seconds pagination factor
5758
],
5859
'authors' => [
59-
's_maxage' => 10 * HOUR_IN_SECONDS, // 10 hours
60+
's_maxage' => 10 * \HOUR_IN_SECONDS, // 10 hours
6061
'paged' => 10, // 10 seconds pagination factor
6162
],
6263
'dates' => [
63-
's_maxage' => 12 * HOUR_IN_SECONDS, // 12 hours
64+
's_maxage' => 12 * \HOUR_IN_SECONDS, // 12 hours
6465
],
6566
'feeds' => [
66-
's_maxage' => 10 * HOUR_IN_SECONDS, // 10 hours
67+
's_maxage' => 10 * \HOUR_IN_SECONDS, // 10 hours
6768
],
6869
'attachment' => [
69-
's_maxage' => 12 * HOUR_IN_SECONDS, // 12 hours
70+
's_maxage' => 12 * \HOUR_IN_SECONDS, // 12 hours
7071
],
7172
'search' => [
72-
's_maxage' => 10 * HOUR_IN_SECONDS, // 10 hours
73+
's_maxage' => 10 * \HOUR_IN_SECONDS, // 10 hours
7374
],
7475
'notfound' => [
75-
's_maxage' => 10 * HOUR_IN_SECONDS, // 10 hours
76+
's_maxage' => 10 * \HOUR_IN_SECONDS, // 10 hours
7677
],
7778
'redirect_permanent' => [
78-
's_maxage' => 7 * DAY_IN_SECONDS, // 1 week
79+
's_maxage' => 7 * \DAY_IN_SECONDS, // 1 week
7980
],
8081
// WooCommerce specific settings (if WooCommerce is active)
8182
'woocommerce_product' => [
82-
's_maxage' => 10 * HOUR_IN_SECONDS, // 10 hours
83+
's_maxage' => 10 * \HOUR_IN_SECONDS, // 10 hours
8384
],
8485
'woocommerce_category' => [
85-
's_maxage' => 10 * HOUR_IN_SECONDS, // 10 hours
86+
's_maxage' => 10 * \HOUR_IN_SECONDS, // 10 hours
8687
],
8788
];
8889
}
8990

9091
/**
9192
* Apply default cache control settings
9293
*/
93-
function cache_control_default_settings() {
94+
function default_settings() {
9495
global $cache_control_options;
9596

9697
if ( empty( $cache_control_options ) ) {
@@ -122,7 +123,7 @@ function cache_control_default_settings() {
122123
}
123124

124125
// Hook to apply default settings after plugins are loaded
125-
add_action( 'plugins_loaded', __NAMESPACE__ . '\\cache_control_default_settings' );
126+
\add_action( 'plugins_loaded', __NAMESPACE__ . '\\default_settings' );
126127

127128
/**
128129
* Filter cache-control options when they are read from database
@@ -132,7 +133,7 @@ function cache_control_default_settings() {
132133
* @param mixed $default_value Default value
133134
* @return mixed Filtered value
134135
*/
135-
function cache_control_filter_option( $pre, $option, $default_value ) {
136+
function filter_option( $pre, $option, $default_value ) {
136137
// Use always default value for cache-control options
137138
if ( str_contains( $option, 'cache_control_' ) ) {
138139
return $default_value;
@@ -142,29 +143,29 @@ function cache_control_filter_option( $pre, $option, $default_value ) {
142143
}
143144

144145
// Hook to filter options when they are read
145-
add_filter( 'pre_option', __NAMESPACE__ . '\\cache_control_filter_option', 10, 3 );
146+
\add_filter( 'pre_option', __NAMESPACE__ . '\\filter_option', 10, 3 );
146147

147148
/**
148149
* Disable cache-control admin page
149150
*/
150-
function cache_control_disable_admin_page() {
151+
function disable_admin_page() {
151152
// Remove the admin menu page
152-
remove_submenu_page( 'options-general.php', 'cache_control' );
153+
\remove_submenu_page( 'options-general.php', 'cache_control' );
153154

154155
// Remove action links from plugin list
155-
remove_filter( 'plugin_action_links_' . plugin_basename( 'cache-control/cache-control.php' ), 'cache_control_admin_action_links' );
156+
\remove_filter( 'plugin_action_links_' . \plugin_basename( 'cache-control/cache-control.php' ), 'cache_control_admin_action_links' );
156157

157158
// Remove meta links from plugin list
158-
remove_filter( 'plugin_row_meta', 'cache_control_admin_actions', 10 );
159+
\remove_filter( 'plugin_row_meta', 'cache_control_admin_actions', 10 );
159160
}
160161

161162
// Hook to disable admin page after it's been added
162-
add_action( 'admin_menu', __NAMESPACE__ . '\\cache_control_disable_admin_page', 999 );
163+
\add_action( 'admin_menu', __NAMESPACE__ . '\\disable_admin_page', 999 );
163164

164165
/**
165166
* Add warning notice on cache-control admin page
166167
*/
167-
function cache_control_add_admin_notice() {
168+
function add_admin_notice() {
168169
// Only show on cache-control admin page
169170
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only reading $_GET['page'], no action performed
170171
if ( 'cache_control' === ( isset( $_GET['page'] ) ? $_GET['page'] : '' ) ) {
@@ -180,4 +181,4 @@ function cache_control_add_admin_notice() {
180181
}
181182

182183
// Hook to add notice on admin pages
183-
add_action( 'admin_notices', __NAMESPACE__ . '\\cache_control_add_admin_notice' );
184+
\add_action( 'admin_notices', __NAMESPACE__ . '\\add_admin_notice' );

default-disable-gutenberg.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @return array
2020
* @author Egidio CORICA
2121
*/
22-
function disable_gutenberg_options( $options_gutenberg ): array {
22+
function disable_gutenberg_options( $options_gutenberg ): array { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
2323
return [
2424
'disable-all' => 0, // Disable Gutenberg everywhere
2525
'disable-nag' => 0, // Disable Gutenberg admin notice

default-login-url.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@
4242
* @return string
4343
* @author Milan RICOUL
4444
*/
45-
function custom_login_url( $url ) {
45+
function custom_login_url( $url ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
4646
return 'https://beapi.fr/';
4747
}

default-wpgb.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@
4343
*
4444
* @return string
4545
*/
46-
function facet_title_tag( string $title_tag ): string {
46+
function facet_title_tag( string $title_tag ): string { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
4747
return 'p';
4848
}

0 commit comments

Comments
 (0)