@@ -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.
@@ -35,6 +36,9 @@ function __construct() {
3536 add_action ( 'rest_api_init ' , array ( $ this , 'register_settings ' ) );
3637
3738 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+
3842 // Add a filter for replacing shortcut media queries before the breakpoint adjustment.
3943 add_filter ( 'stackable_frontend_css ' , array ( $ this , 'replace_shortcut_media_queries ' ), 9 );
4044
@@ -78,7 +82,7 @@ public function get_dynamic_breakpoints() {
7882 }
7983
8084 $ this ->dynamic_breakpoints = $ breakpoints ;
81- return $ this ->dynamic_breakpoints ;
85+ $ this ->has_custom_breakpoints = ! empty ( $ breakpoints [ ' tablet ' ] ) || ! empty ( $ breakpoints [ ' mobile ' ] ) ;
8286 }
8387
8488 /**
@@ -135,18 +139,18 @@ public function sanitize_array_setting( $input ) {
135139 return ! is_array ( $ input ) ? array ( array () ) : $ input ;
136140 }
137141
138- /**
139- * True if there are any custom breakpoints assigned by the user.
140- *
141- * @return boolean
142- */
143- public function has_custom_breakpoints () {
144- $ breakpoints = $ this ->dynamic_breakpoints ;
145- if ( $ breakpoints == false ) {
146- $ breakpoints = $ this ->get_dynamic_breakpoints ();
147- }
148- return ! empty ( $ breakpoints [ ' tablet ' ] ) || ! empty ( $ breakpoints [ ' mobile ' ] ) ;
149- }
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+ // }
150154
151155 /**
152156 * Replace shortcut media queries in the given CSS.
@@ -168,7 +172,7 @@ public function replace_shortcut_media_queries( $css ) {
168172 * @return String adjusted CSS
169173 */
170174 public function adjust_breakpoints ( $ css ) {
171- if ( ! $ this ->has_custom_breakpoints () ) {
175+ if ( ! $ this ->has_custom_breakpoints ) {
172176 return $ css ;
173177 }
174178
@@ -226,7 +230,7 @@ public function adjust_breakpoints( $css ) {
226230 * @return void
227231 */
228232 public function enqueue_adjusted_responsive_css () {
229- if ( ! $ this ->has_custom_breakpoints () ) {
233+ if ( ! $ this ->has_custom_breakpoints ) {
230234 return ;
231235 }
232236
@@ -245,7 +249,7 @@ public function enqueue_adjusted_responsive_css() {
245249 * @return void
246250 */
247251 public function adjust_block_styles ( $ block_content , $ block ) {
248- if ( ! $ this ->has_custom_breakpoints () ) {
252+ if ( ! $ this ->has_custom_breakpoints ) {
249253 return $ block_content ;
250254 }
251255
0 commit comments