'array', 'sanitize_callback' => array( __CLASS__, 'sanitize' ), 'show_in_rest' => false, ) ); } /** * A checkbox: on only for "1" (or true); a missing field means unticked. Anything that is not * an array is not a form at all and keeps the factory default. * * @param mixed $input Raw value. * @return array{disable_emoji: bool} */ public static function sanitize( $input ) { if ( ! is_array( $input ) ) { return array( 'disable_emoji' => true ); } $value = $input['disable_emoji'] ?? ''; return array( 'disable_emoji' => true === $value || '1' === $value || 1 === $value ); } /** * Settings with the factory default (emoji script off) when nothing valid is stored. * * @return array{disable_emoji: bool} */ public static function settings() { $stored = get_option( self::OPTION, null ); return is_array( $stored ) ? self::sanitize( $stored ) : array( 'disable_emoji' => true ); } }