setDefault( $default ); $option->setTitle( $title ); return $option; } public static function boolean( $id, $default = "", $title = null ) { if ( ! $id ) { return null; } $option = new BooleanOption( $id ); $option->setDefault( $default ); $option->setTitle( $title ); return $option; } public static function integer( $id, $default = "", $title = null ) { if ( ! $id ) { return null; } $option = new IntegerNumberOption( $id ); $option->setDefault( $default ); $option->setTitle( $title ); return $option; } public static function htmlText( $id, $default = "", $title = null ) { if ( ! $id ) { return null; } $option = new ShortTextOption( $id ); $option->setSanitizeCallback( function ( $value ) { $value = filter_var( $value, FILTER_SANITIZE_SPECIAL_CHARS ); if ( $value === false ) { throw new OptionValueFilterFailed(); } return (string) $value; } ); $option->setDefault( $default ); $option->setTitle( $title ); return $option; } /** * @param string $id * @param string $title * @param mixed[] $selections * @param mixed $default * * @return SelectiveOption */ public static function selective( $id, $title, $selections, $default = null ) { if ( ! $id || ! $title || ! $selections ) { return null; } $option = new SelectiveOption( $id ); $option->setTitle( $title ); foreach ( $selections as $value => $title ) { $option->addSelection( $value, $value ); } if ( isset( $default ) ) { $option->setDefault( $default ); } return $option; } }