option-tree-theme
option-tree-theme copied to clipboard
Some data is deleted when updating.
I am developing WordPress site using Option Tree. Sometimes it works fine. But when I try to save many options, some of the data from the end is missing. I tried several times, but couldn't find an error. Here is my theme options file.
'slot_desc', 'label' => __('Description', 'discoverslots'), 'desc' => __('Please add some words for this slot.', 'discoverslots'), 'type' => 'textarea', ); $slot_info[] = array( 'id' => 'slot_image', 'label' => __('Image', 'discoverslots'), 'desc' => __('Upload slot image. Best size is 500 x 375.', 'discoverslots'), 'type' => 'upload' ); if (is_array($theme_array)) { foreach ($theme_array as $theme) { $slot_themes[] = array( 'value' => strtolower(preg_replace('/\s+/', '_', $theme['title'])), 'label' => $theme['title'] ); } $slot_info[] = array( 'id' => 'slot_theme', 'label' => __('Theme', 'discoverslots'), 'desc' => __('Please choose theme(s) this slot belongs to.', 'discoverslots'), 'type' => 'checkbox', 'choices' => $slot_themes, ); } $slot_info[] = array( 'id' => 'slot_type', 'label' => __('Type', 'discoverslots'), 'desc' => __('Please choose type(s) this slot belongs to.', 'discoverslots'), 'type' => 'checkbox', 'choices' => array( array( 'value' => 'bonus', 'label' => 'Bonus'), array( 'value' => 'jackpot', 'label' => 'Jackpot'), ) ); $slot_info[] = array( 'id' => 'minimum', 'label' => __('Minimum Value', 'discoverslots'), 'desc' => __('Minimum Bet value', 'discoverslots'), 'type' => 'text', 'std' => '0.1', ); $slot_info[] = array( 'id' => 'risky', 'label' => __('Riskiness', 'discoverslots'), 'desc' => __('Riskiness value', 'discoverslots'), 'type' => 'text', 'std' => '1', ); if (is_array($casino_array)) { foreach ($casino_array as $casino) { $slot_casinos[] = array( 'value' => strtolower(preg_replace('/\s+/', '_', $casino['title'])), 'label' => $casino['title'] ); } $slot_info[] = array( 'id' => 'slot_casino', 'label' => __('Casino', 'discoverslots'), 'desc' => __('Please choose casino(s) this slot can be played.', 'discoverslots'), 'type' => 'checkbox', 'choices' => $slot_casinos, ); } $slot_info[] = array( 'id' => 'popularity', 'label' => __('Popularity', 'discoverslots'), 'desc' => __('Caution! Modifying this value can affect site behavior.', 'discoverslots'), 'type' => 'text', 'std' => '1', ); $slot_info[] = array( 'id' => 'updated', 'label' => __('Last updated', 'discoverslots'), 'desc' => __('Caution! Modifying this value can affect site behavior.', 'discoverslots'), 'type' => 'date-picker', 'std' => date("Y-m-d"), ); // Themes Tab array_push($sections, array( 'id' => 'settings_themes', 'title' => __('Themes', 'discoverslots') )); array_push($settings, array( 'id' => 'theme', 'label' => __('Themes', 'discoverslots'), 'desc' => __('All slots are belong to at least one theme.', 'discoverslots'), 'type' => 'list-item', 'settings' => array( array( 'id' => 'theme_desc', 'label' => __('Description', 'discoverslots'), 'desc' => __('Please add some words for this theme.', 'discoverslots'), 'type' => 'textarea' ), ), 'section' => 'settings_themes', ) ); // Slots Tab array_push($sections, array( 'id' => 'settings_slots', 'title' => __('Slots', 'discoverslots') )); array_push($settings, array( 'id' => 'slot', 'label' => __('Slots', 'discoverslots'), 'desc' => __('Please prepare more slot images!', 'discoverslots'), 'type' => 'list-item', 'settings' => $slot_info, 'section' => 'settings_slots', ) ); // Casinos Tab array_push($sections, array( 'id' => 'settings_casinos', 'title' => __('Casinos', 'discoverslots') )); array_push($settings, array( 'id' => 'casino', 'label' => __('Casinos', 'discoverslots'), 'desc' => __('Please add destination places for customers!', 'discoverslots'), 'type' => 'list-item', 'settings' => array( array( 'id' => 'casino_image', 'label' => __('Casino Image', 'discoverslots'), 'desc' => __('Upload casino image. Best size is 300 x 150.', 'discoverslots'), 'type' => 'upload' ), array( 'id' => 'casino_link', 'label' => __('URL', 'discoverslots'), 'desc' => __('Casino Site URL', 'discoverslots'), 'type' => 'text' ), ), 'section' => 'settings_casinos', ) ); ///////////////////////////////////////////////////////////////////////////////////////////// $saved_settings = get_option(ot_settings_id(), array()); // Custom settings array that will eventually be passes to the OptionTree Settings API Class. $custom_settings = array( 'parent_slug' => apply_filters('ot_theme_options_parent_slug', ''), 'sections' => $sections, 'settings' => $settings ); // allow settings to be filtered before saving $custom_settings = apply_filters(ot_settings_id().'_args', $custom_settings); // settings are not the same update the DB if ($saved_settings !== $custom_settings) { update_option(ot_settings_id(), $custom_settings); } ``` } ?>