Skip to content

Commit 72edbd0

Browse files
authored
Fix (Performance): Improve performance for getting custom breakpoints (#3479)
* improve performance * use has_custom_breakpoints fn
1 parent 6df8f39 commit 72edbd0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/dynamic-breakpoints.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Stackable_Dynamic_Breakpoints {
2525

2626
// Holds the value of the saved or default breakpoints
2727
private $dynamic_breakpoints = false;
28+
private $has_custom_breakpoints = false;
2829

2930
/**
3031
* Add our hooks.
@@ -78,7 +79,7 @@ public function get_dynamic_breakpoints() {
7879
}
7980

8081
$this->dynamic_breakpoints = $breakpoints;
81-
return $this->dynamic_breakpoints;
82+
$this->has_custom_breakpoints = ! empty( $breakpoints['tablet'] ) || ! empty( $breakpoints['mobile'] );
8283
}
8384

8485
/**
@@ -141,11 +142,10 @@ public function sanitize_array_setting( $input ) {
141142
* @return boolean
142143
*/
143144
public function has_custom_breakpoints() {
144-
$breakpoints = $this->dynamic_breakpoints;
145-
if ( $breakpoints == false ) {
146-
$breakpoints = $this->get_dynamic_breakpoints();
145+
if ( $this->dynamic_breakpoints === false ) {
146+
$this->get_dynamic_breakpoints();
147147
}
148-
return ! empty( $breakpoints['tablet'] ) || ! empty( $breakpoints['mobile'] );
148+
return $this->has_custom_breakpoints;
149149
}
150150

151151
/**

0 commit comments

Comments
 (0)