Monday, October 17, 2022
HomeWordPress DevelopmentReplace customized settings area in plugin

Replace customized settings area in plugin


I’ve the code under for a easy Settings web page for my customized plugin, the place the person can enter their webhook URL. My challenge is that when the person first enters a price and hits the submit button, the whole lot works positive. But when they enter a brand new worth and hit the submit button, it doesn’t replace the beforehand saved worth.

So the query is – how do I replace the worth?

<?php
/*
That is the place all of the code that handles the Settings lives. e.g. the place the plugin lives within the WP Admin menu, the place a person provides their webhook URL and many others.
*/

// Fundamental Safety.
outlined('ABSPATH') or die('Unauthorised Entry');

perform wppostwebhook_register_settings()
{

    register_setting('wppostwebhook_options', 'webhook_url_field_name');
}
add_action('admin_menu', 'wppostwebhook_options_page');
add_action('admin_init', 'wppostwebhook_register_settings');

perform wppostwebhook_options_page_html()
{
    // verify person capabilities
    if (!current_user_can('manage_options')) {
        return;
    }

?>
    <div class="wrap">
        <h1><?php echo esc_html(get_admin_page_title()); ?></h1>
        <type motion="choices.php" methodology="publish">
            <?php // output safety fields for the registered setting "wppostwebhook_options"
            settings_fields('wppostwebhook_options');
            // output setting sections and their fields
            // (sections are registered for "wppostwebhook", every area is registered to a particular part) 
            ?>
            <desk class="form-table">
                <tr>
                    <th><label for="url_field_id">Webhook URL:</label></th>
                    <td>
                        <enter sort="url" class="webhook-url" id="webhook_url_field_id" title="webhook_url_field_name" dimension="100" placeholder="e.g. https://hook.integromat.com/j2bb812345678" worth="<?php echo get_option('url_field_name'); ?>">
                    </td>
                </tr>
            </desk>
            <h4><?php echo 'Add the URL for the third occasion webhook you want to ship your Submit and Web page knowledge to.'; ?></h4>
            <?php do_settings_sections('wppostwebhook');
            // output save settings button
            submit_button(__('Save Webhook URL', 'textdomain'));
            ?>
        </type>
        <h3><?php echo 'This plugin outputs publish & web page knowledge to the webhook you present above, for full instrustions and examples please go to <a href="http://jonathan-wright.com/web page.html">jonathan-wright.com</a>'; ?></h3>
    </div>
<?php
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments