| 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 | */ |
| 1027 | function 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 | /** |
| 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 | */ |
| 1100 | function 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 | /** |
| 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 | |
| 1230 | function 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 | /** |