Skip to content

Commit 0ceba34

Browse files
committed
Fixed bug where we checked for true/false for slider settings, but WooCommerce stores it as 'yes'/'no'
1 parent 5fe5637 commit 0ceba34

3 files changed

+15
-8
lines changed

admin/class-wdevs-gallery-slider-admin.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,21 @@ public function get_settings() {
7373
'type' => 'checkbox',
7474
'desc' => __( 'Enable scrollbar for the slider', 'wdevs-gallery-slider' ),
7575
'id' => 'wdevs_gallery_slider_scrollbar',
76-
'default' => '1'
76+
'default' => 'yes'
7777
),
7878
array(
7979
'name' => __( 'Enable pagination', 'wdevs-gallery-slider' ),
8080
'type' => 'checkbox',
8181
'desc' => __( 'Enable pagination for the slider', 'wdevs-gallery-slider' ),
8282
'id' => 'wdevs_gallery_slider_pagination',
83-
'default' => '0'
83+
'default' => 'no'
8484
),
8585
array(
8686
'name' => __( 'Enable navigation', 'wdevs-gallery-slider' ),
8787
'type' => 'checkbox',
8888
'desc' => __( 'Enable navigation for the slider', 'wdevs-gallery-slider' ),
8989
'id' => 'wdevs_gallery_slider_navigation',
90-
'default' => '0'
90+
'default' => 'no'
9191
),
9292
array(
9393
'name' => __( 'Disable slider from', 'wdevs-gallery-slider' ),

includes/class-wdevs-gallery-slider-activator.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Wdevs_Gallery_Slider_Activator {
3232
public static function activate() {
3333
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
3434
deactivate_plugins( plugin_basename( __FILE__ ) );
35-
35+
3636
wp_die( esc_html__( 'This plugin requires WooCommerce. Please install and activate WooCommerce before activating this plugin.', 'wdevs-gallery-slider' ) );
3737
}
3838

@@ -65,7 +65,14 @@ private static function migrate_settings() {
6565
// Update each setting individually
6666
foreach ( $settings_mapping as $old_key => $new_key ) {
6767
if ( isset( $old_settings[ $old_key ] ) ) {
68-
update_option( $new_key, $old_settings[ $old_key ] );
68+
if ( $old_key !== 'woo_swiper_breakpoint' ) {
69+
// Convert checkbox values to WooCommerce format, which is 'yes'/'no'
70+
$new_value = $old_settings[ $old_key ] == '1' ? 'yes' : 'no';
71+
} else {
72+
// For non-checkbox settings, just use the old value
73+
$new_value = $old_settings[ $old_key ];
74+
}
75+
update_option( $new_key, $new_value );
6976
}
7077
}
7178

public/class-wdevs-gallery-slider-public.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ public function enqueue_scripts() {
9393

9494
$localized_settings = [
9595
'swiper' => [
96-
'scrollbar' => ! empty( get_option('wdevs_gallery_slider_scrollbar') ),
97-
'pagination' => ! empty( get_option('wdevs_gallery_slider_pagination') ),
98-
'navigation' => ! empty( get_option('wdevs_gallery_slider_navigation') ),
96+
'scrollbar' => get_option( 'wdevs_gallery_slider_scrollbar', 'yes' ) === 'yes',
97+
'pagination' => get_option( 'wdevs_gallery_slider_pagination', 'no' ) === 'yes',
98+
'navigation' => get_option( 'wdevs_gallery_slider_navigation', 'no' ) === 'yes',
9999
'breakpoint' => $this->parse_breakpoint( get_option( 'wdevs_gallery_slider_breakpoint', '' ) ),
100100
]
101101
];

0 commit comments

Comments
 (0)