Make WordPress Core

Ticket #58925: 58925-remove-settings-function-01.patch

File 58925-remove-settings-function-01.patch, 1.3 KB (added by dcavins, 3 years ago)

Adds remove_settings_field() function

  • src/wp-admin/includes/template.php

    diff --git src/wp-admin/includes/template.php src/wp-admin/includes/template.php
    index 0771b7129e..4277ed4e2f 100644
    function add_settings_field( $id, $title, $callback, $page, $section = 'default'  
    17341734        );
    17351735}
    17361736
     1737/**
     1738 * Removes field from a section of a settings page.
     1739 *
     1740 * Part of the Settings API. Use this to remove a previously
     1741 * declared settings field.
     1742 *
     1743 *
     1744 * @since 6.3
     1745 *
     1746 * @global array $wp_settings_fields Storage array of settings fields and info about their pages/sections.
     1747 *
     1748 * @param string $id       Slug-name to identify the field.
     1749 * @param string $page     The slug-name of the settings page on which to show the section
     1750 *                         (general, reading, writing, ...).
     1751 * @param string $section  Optional. The slug-name of the section of the settings page
     1752 *                         with which the field is associated. Default 'default'.
     1753 */
     1754function remove_settings_field( $id, $page, $section = 'default' ) {
     1755        global $wp_settings_fields;
     1756
     1757        if ( isset( $wp_settings_fields[ $page ][ $section ][ $id ] ) ) {
     1758                unset( $wp_settings_fields[ $page ][ $section ][ $id ] );
     1759        }
     1760}
     1761
    17371762/**
    17381763 * Prints out all settings sections added to a particular settings page.
    17391764 *