WordPress.org

Make WordPress Core

Ticket #14149: 14149.diff

File 14149.diff, 1.3 KB (added by nacin, 8 years ago)
  • wp-admin/includes/plugin.php

     
    14811481        }
    14821482
    14831483        $new_whitelist_options[ $option_group ][] = $option_name;
    1484         if ( $sanitize_callback != '' )
     1484        if ( $sanitize_callback )
    14851485                add_filter( "sanitize_option_{$option_name}", $sanitize_callback );
    14861486}
    14871487
    14881488/**
     1489 * Register settings and a sanitization callback
     1490 *
     1491 * @since 3.1.0
     1492 *
     1493 * @param string $option_group A settings group name.  Should correspond to a whitelisted option key name.
     1494 *      Default whitelisted option key names include "general," "discussion," and "reading," among others.
     1495 * @param array $options Option names to sanitize and save. If keyed as option names, the value would be
     1496 *      the sanitization callback.
     1497 
     1498 */
     1499function register_settings( $option_group, $options ) {
     1500        $has_callbacks = true;
     1501        $i = 0;
     1502
     1503        foreach ( array_keys( $options ) as $key ) {
     1504                if ( $key !== $i++ ) {
     1505                        $has_callbacks = false;
     1506                        break;
     1507                }
     1508        }
     1509
     1510        foreach ( $options as $key => $val ) {
     1511                if ( $has_callbacks )
     1512                        register_setting( $option_group, $key, $val );
     1513                else
     1514                        register_setting( $option_group, $val );
     1515        }
     1516}
     1517
     1518/**
    14891519 * Unregister a setting
    14901520 *
    14911521 * @since 2.7.0