Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the question-answer domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/u845912282/domains/pickplugins.com/public_html/wp-includes/functions.php on line 6121
wishlist_settings_save

wishlist_settings_save

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;
}
wishlist_settings_save 1

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
    }
}
wishlist_settings_save 2

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);
}

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/u845912282/domains/pickplugins.com/public_html/wp-content/plugins/post-grid/includes/functions-builder.php on line 10