Skip to content

Commit 0801b8a

Browse files
committed
fix: add additional checks
1 parent 9bca657 commit 0801b8a

File tree

1 file changed

+18
-17
lines changed
  • src/plugins/global-settings/preset-controls

1 file changed

+18
-17
lines changed

src/plugins/global-settings/preset-controls/index.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,29 +87,30 @@ public function use_size_presets_by_default_set_default( $old_version, $new_vers
8787
* @since 3.16.0
8888
*/
8989
public function migrate_global_typography_font_size( $old_version, $new_version ) {
90-
if ( ! empty( $old_version ) && version_compare( $old_version, "3.16.0", "<" )
91-
&& ! empty( $typography_option ) && isset( $typography_option[ 0 ] )
92-
) {
90+
if ( ! empty( $old_version ) && version_compare( $old_version, "3.16.0", "<" ) ) {
9391
$typography_option = get_option( 'stackable_global_typography' );
94-
$typography = $typography_option[ 0 ];
95-
$updated = false;
9692

97-
foreach ( $typography as $key => $item ) {
98-
if ( ! is_array( $item ) ) {
99-
continue;
100-
}
93+
if ( ! empty( $typography_option ) && isset( $typography_option[ 0 ] ) && is_array( $typography_option[ 0 ] ) ) {
94+
$typography = $typography_option[ 0 ];
95+
$updated = false;
96+
97+
foreach ( $typography as $key => $item ) {
98+
if ( ! is_array( $item ) ) {
99+
continue;
100+
}
101101

102-
foreach ( [ 'fontSize', 'tabletFontSize', 'mobileFontSize' ] as $size_key ) {
103-
if ( isset( $item[ $size_key ] ) && is_numeric( $item[ $size_key ] ) ) {
104-
$typography[ $key ][ $size_key ] = strval( $item[ $size_key ] );
105-
$updated = true;
102+
foreach ( [ 'fontSize', 'tabletFontSize', 'mobileFontSize' ] as $size_key ) {
103+
if ( isset( $item[ $size_key ] ) && is_numeric( $item[ $size_key ] ) ) {
104+
$typography[ $key ][ $size_key ] = strval( $item[ $size_key ] );
105+
$updated = true;
106+
}
106107
}
107108
}
108-
}
109109

110-
if ( $updated ) {
111-
$typography_option[ 0 ] = $typography;
112-
update_option( 'stackable_global_typography', $typography_option );
110+
if ( $updated ) {
111+
$typography_option[ 0 ] = $typography;
112+
update_option( 'stackable_global_typography', $typography_option );
113+
}
113114
}
114115
}
115116
}

0 commit comments

Comments
 (0)