Skip to content

Commit 539b5d8

Browse files
refactor: memoize result within request
1 parent 545e62f commit 539b5d8

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

inc/settings.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,13 +527,18 @@ private function is_main_mu_site() {
527527
* @return array Site settings.
528528
*/
529529
public function get_site_settings() {
530+
static $cache = null;
531+
if ( $cache !== null ) {
532+
return $cache;
533+
}
534+
530535
$service_data = $this->get( 'service_data' );
531536
$whitelist = [];
532537
if ( isset( $service_data['whitelist'] ) ) {
533538
$whitelist = $service_data['whitelist'];
534539
}
535540

536-
return [
541+
$cache = [
537542
'quality' => $this->get_quality(),
538543
'admin_bar_item' => $this->get( 'admin_bar_item' ),
539544
'lazyload' => $this->get( 'lazyload' ),
@@ -578,6 +583,7 @@ public function get_site_settings() {
578583
'show_badge_icon' => $this->get( 'show_badge_icon' ),
579584
'badge_position' => $this->get( 'badge_position' ),
580585
];
586+
return $cache;
581587
}
582588

583589
/**

0 commit comments

Comments
 (0)