WordPress.org

Make WordPress Core

Ticket #15865: removal_functions_3.diff

File removal_functions_3.diff, 3.3 KB (added by unknowndomain, 3 years ago)
  • wp-admin/includes/template.php

     
    10121012} 
    10131013 
    10141014/** 
     1015 * Remove a section from a settings page. 
     1016 * 
     1017 * Part of the Settings API. Use this to remove settings sections from an admin page. 
     1018 * 
     1019 * @since 3.6 
     1020 * 
     1021 * @global $wp_settings_sections Storage array of all settings sections added to admin pages 
     1022 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections 
     1023 * 
     1024 * @param string $id Slug-name to identify the section. 
     1025 * @param string $page The slug-name of the settings page on which to remove the section. 
     1026 */ 
     1027function remove_settings_section( $id, $page ) { 
     1028        global $wp_settings_sections, $wp_settings_fields; 
     1029 
     1030        unset( $wp_settings_sections[$page][$id] ); 
     1031         
     1032        if ( empty( $wp_settings_sections[$page] ) ) 
     1033                unset( $wp_settings_sections[$page] ); 
     1034                 
     1035        unset( $wp_settings_fields[$page][$id] ); 
     1036         
     1037        if ( empty( $wp_settings_fields[$page] )  ) 
     1038                unset( $wp_settings_fields[$page] ); 
     1039} 
     1040 
     1041/** 
    10151042 * Add a new field to a section of a settings page 
    10161043 * 
    10171044 * Part of the Settings API. Use this to define a settings field that will show 
     
    10571084} 
    10581085 
    10591086/** 
     1087 * Remove a field from a section of a settings page 
     1088 * 
     1089 * Part of the Settings API. Use this to remove a settings field from a 
     1090 * settings section inside a settings page. 
     1091 * 
     1092 * @since 3.6 
     1093 * 
     1094 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections. 
     1095 * 
     1096 * @param string $id Slug-name to identify the field. 
     1097 * @param string $page The slug-name of the settings page on which to remove the section. 
     1098 * @param string $section The slug-name of the section of the settings page in which to remove the box. 
     1099 */ 
     1100function remove_settings_field( $id, $page, $section = 'default' ) { 
     1101        global $wp_settings_fields; 
     1102         
     1103        unset( $wp_settings_fields[$page][$section][$id] ); 
     1104         
     1105        if ( empty( $wp_settings_fields[$page][$section] ) ) 
     1106                unset( $wp_settings_fields[$page][$section] ); 
     1107         
     1108        if ( empty( $wp_settings_fields[$page] ) ) 
     1109                unset( $wp_settings_fields[$page] ); 
     1110} 
     1111 
     1112/** 
    10601113 * Prints out all settings sections added to a particular settings page 
    10611114 * 
    10621115 * Part of the Settings API. Use this in a settings page callback function 
     
    11611214} 
    11621215 
    11631216/** 
     1217 * Remove a settings error to be displayed to the user 
     1218 * 
     1219 * Part of the Settings API. Use this to remove messages to users about settings validation 
     1220 * problems, missing settings, etc... 
     1221 * 
     1222 * @since 3.6 
     1223 * 
     1224 * @global array $wp_settings_errors Storage array of errors registered during this pageload 
     1225 * 
     1226 * @param string $setting Slug title of the setting to which this error applies 
     1227 * @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output. 
     1228 */ 
     1229 
     1230function remove_settings_error( $setting, $code ) { 
     1231        global $wp_settings_errors; 
     1232         
     1233        if ( count( $wp_settings_errors ) ) { 
     1234                foreach ( $wp_settings_errors as $index => $error ) { 
     1235                        if ( $error['setting'] == $setting && $error['setting'] == $code ) 
     1236                                unset( $wp_settings_errors[$index] ); 
     1237                }                
     1238        } 
     1239} 
     1240 
     1241/** 
    11641242 * Fetch settings errors registered by add_settings_error() 
    11651243 * 
    11661244 * Checks the $wp_settings_errors array for any errors declared during the current