Use this code to create a new tab on the wishlist setting page.
add_action('wishlist_settings_tabs', 'wishlist_settings_tabs_custom'); function wishlist_settings_tabs_custom($settings_tab) { $current_tab = isset($_REQUEST['tab']) ? sanitize_text_field($_REQUEST['tab']) : 'general'; $settings_tab[] = array( 'id' => 'custom', 'title' => sprintf(__('%s custom', 'wishlist'), '<i class="fas fa-hands-helping"></i>'), 'priority' => 95, 'active' => ($current_tab == 'custom') ? true : false, ); return $settings_tab; }
Then use this code to generate some options on the newly created tab.
add_action('wishlist_settings_content_custom', 'wishlist_settings_content_custom'); if (!function_exists('wishlist_settings_content_custom')) { function wishlist_settings_content_custom($tab) { $settings_tabs_field = new settings_tabs_field(); $wishlist_settings = get_option('wishlist_settings'); $custom_option = isset($wishlist_settings['custom']['custom_option']) ? $wishlist_settings['custom']['custom_option'] : ''; ?> <div class="section"> <div class="section-title"><?php echo __('Custom tab title', 'post-grid'); ?></div> <p class="description section-description"><?php echo __('Custom tab details', 'post-grid'); ?></p> <?php $args = array( 'id' => 'custom_option', 'parent' => 'wishlist_settings[custom]', 'title' => __('Custom Option title', 'wishlist'), 'details' => __('Custom option details.', 'wishlist'), 'type' => 'text', 'value' => $custom_option, 'default' => '', 'placeholder' => __('', 'wishlist'), ); $settings_tabs_field->generate_field($args); ?> </div> <?php } }
Now, add this code to save the custom setting to merge with our default wishlist setting.
add_action('wishlist_settings_save', 'wishlist_settings_save_custom'); function wishlist_settings_save_custom() { $wishlist_settings = isset($_POST['wishlist_settings']) ? wishlist_recursive_sanitize_arr($_POST['wishlist_settings']) : array(); $custom_settings = isset($_POST['custom']) ? ($_POST['custom']) : ''; $wishlist_settings = array_merge($wishlist_settings, $custom_settings); update_option('wishlist_settings', $custom_settings); }