Skip to content

Commit

Permalink
Refactored Transient::get() method to reproduce the same WP filters…
Browse files Browse the repository at this point in the history
… behaviour
  • Loading branch information
GiuseppeArcifa committed Dec 4, 2024
1 parent 0ec2a6f commit 914bcf9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions includes/Helpers/Transient.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,17 @@ public static function get( string $key ) {
$data = \get_option( $key );
if ( is_array( $data ) && isset( $data['expires_at'], $data['value'] ) ) {
if ( $data['expires_at'] > time() ) {
/**
* Implement the filters as used in {@see get_transient()}.
*/
return apply_filters( "transient_{$key}", $data['value'], $key );
$value = $data['value'];
} else {
\delete_option( $key );
$value = false;
}
}

return false;
/**
* Implement the filters as used in {@see get_transient()}.
*/
return apply_filters( "transient_{$key}", $value, $key );
}

/**
Expand Down

0 comments on commit 914bcf9

Please sign in to comment.