Skip to content

Commit

Permalink
create deletion filter method
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Feb 5, 2025
1 parent ad9f878 commit f5567f7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions inc/Engine/Media/PreloadFonts/Database/Queries/PreloadFonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,7 @@ public function delete_old_rows() {
return false;
}

/**
* Filters the interval (in months) to determine when a Preload Fonts(PLF) entry is considered 'old'.
* Old PLF entries are eligible for deletion. By default, a PLF entry is considered old if it hasn't been accessed in the last month.
*
* @param int $delete_interval The interval in months after which an PLF entry is considered old. Default is 1 month.
*/
$delete_interval = wpm_apply_filters_typed( 'integer', 'rocket_preload_fonts_cleanup_interval', 1 );
$delete_interval = $this->deletion_interval();

if ( $delete_interval <= 0 ) {
return false;
Expand All @@ -98,4 +92,14 @@ public function delete_old_rows() {

return $db->query( $query );
}

private function deletion_interval() {
/**
* Filters the interval (in months) to determine when a Preload Fonts(PLF) entry is considered 'old'.
* Old PLF entries are eligible for deletion. By default, a PLF entry is considered old if it hasn't been accessed in the last month.
*
* @param int $delete_interval The interval in months after which an PLF entry is considered old. Default is 1 month.
*/
return wpm_apply_filters_typed( 'integer', 'rocket_preload_fonts_cleanup_interval', 1 );

Check failure on line 103 in inc/Engine/Media/PreloadFonts/Database/Queries/PreloadFonts.php

View workflow job for this annotation

GitHub Actions / WPRocket lint with PHP Stan. PHP 8.4 on ubuntu-latest.

Hooks should not be used in ORM classes: WP_Rocket\Engine\Media\PreloadFonts\Database\Queries\PreloadFonts::wpm_apply_filters_typed
}
}

0 comments on commit f5567f7

Please sign in to comment.