Skip to content

Commit

Permalink
Add static cache for edd_get_option()
Browse files Browse the repository at this point in the history
  • Loading branch information
zackkatz authored Jun 26, 2024
1 parent 252a23a commit 0334952
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion includes/admin/settings/register-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
function edd_get_option( $key = '', $default = false ) {
global $edd_options;

static $cached_options = array();

if( isset( $cached_options[ $key ] ) ) {
return $cached_options[ $key ];
}

$value = $default;

if ( isset( $edd_options[ $key ] ) ) {
Expand All @@ -36,7 +42,9 @@ function edd_get_option( $key = '', $default = false ) {

$value = apply_filters( 'edd_get_option', $value, $key, $default );

return apply_filters( 'edd_get_option_' . $key, $value, $key, $default );
$cached_options[ $key ] = apply_filters( 'edd_get_option_' . $key, $value, $key, $default );

return $cached_options[ $key ];
}

/**
Expand Down

0 comments on commit 0334952

Please sign in to comment.