Skip to content

Commit 438b8c9

Browse files
committed
use has_custom_breakpoints fn
1 parent c29ea52 commit 438b8c9

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

src/dynamic-breakpoints.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ function __construct() {
3636
add_action( 'rest_api_init', array( $this, 'register_settings' ) );
3737

3838
if ( is_frontend() ) {
39-
// Get the dynamic breakpoints after the theme has loaded.
40-
add_action( 'after_setup_theme', array( $this, 'get_dynamic_breakpoints' ) );
41-
4239
// Add a filter for replacing shortcut media queries before the breakpoint adjustment.
4340
add_filter( 'stackable_frontend_css', array( $this, 'replace_shortcut_media_queries' ), 9 );
4441

@@ -139,18 +136,17 @@ public function sanitize_array_setting( $input ) {
139136
return ! is_array( $input ) ? array( array() ) : $input;
140137
}
141138

142-
// /**
143-
// * True if there are any custom breakpoints assigned by the user.
144-
// *
145-
// * @return boolean
146-
// */
147-
// public function has_custom_breakpoints( $count = 2 ) {
148-
// $breakpoints = $this->dynamic_breakpoints;
149-
// if ( $breakpoints === false ) {
150-
// $this->get_dynamic_breakpoints( $count );
151-
// }
152-
// return $this->has_dynamic_breakpoints;
153-
// }
139+
/**
140+
* True if there are any custom breakpoints assigned by the user.
141+
*
142+
* @return boolean
143+
*/
144+
public function has_custom_breakpoints() {
145+
if ( $this->dynamic_breakpoints === false ) {
146+
$this->get_dynamic_breakpoints();
147+
}
148+
return $this->has_custom_breakpoints;
149+
}
154150

155151
/**
156152
* Replace shortcut media queries in the given CSS.
@@ -172,7 +168,7 @@ public function replace_shortcut_media_queries( $css ) {
172168
* @return String adjusted CSS
173169
*/
174170
public function adjust_breakpoints( $css ) {
175-
if ( ! $this->has_custom_breakpoints ) {
171+
if ( ! $this->has_custom_breakpoints() ) {
176172
return $css;
177173
}
178174

@@ -230,7 +226,7 @@ public function adjust_breakpoints( $css ) {
230226
* @return void
231227
*/
232228
public function enqueue_adjusted_responsive_css() {
233-
if ( ! $this->has_custom_breakpoints ) {
229+
if ( ! $this->has_custom_breakpoints() ) {
234230
return;
235231
}
236232

@@ -249,7 +245,7 @@ public function enqueue_adjusted_responsive_css() {
249245
* @return void
250246
*/
251247
public function adjust_block_styles( $block_content, $block ) {
252-
if ( ! $this->has_custom_breakpoints ) {
248+
if ( ! $this->has_custom_breakpoints() ) {
253249
return $block_content;
254250
}
255251

src/global-settings.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ function __construct() {
7373
$typography = get_option( 'stackable_global_typography' );
7474
if ( ! empty( $typography ) && is_array( $typography ) ) {
7575
$this->force_typography = get_option( 'stackable_global_force_typography' );
76-
// Add a priority of 11 to ensure this runs after getting the dynamic breakpoints
77-
// So that we can correctly adjust the breakpoints if needed.
78-
add_action( 'after_setup_theme', array( $this, 'typography_parse_global_styles' ), 11 );
76+
add_action( 'after_setup_theme', array( $this, 'typography_parse_global_styles' ) );
7977
}
8078

8179
// For some native blocks, add a note that they're core blocks.

0 commit comments

Comments
 (0)