/**
  * Turn a string of serialized data into HTML recursively.
  *
  * @since    1.0
  *
  * @param mixed $data The data to be converted to HTML.
  * @param int   $recursion_level
  *
  * @return string of HTML or empty string if there was no serialized data.
  */
 private static function _to_html($data, $recursion_level = 0)
 {
     $html = '';
     if (is_array($data)) {
         // Normally data needing conversion to an array is passed.
         // However, if the passed data is already an array bump the recursion level to start showing its children properly.
         if (0 === $recursion_level) {
             $recursion_level = 1;
         }
         $array_class = '';
         foreach ($data as $key => $value) {
             if (!is_int($key)) {
                 $array_class = ' associative';
                 break;
             }
         }
         if (1 < $recursion_level) {
             $html .= '<span class="array count">';
             $html .= '<span class="dashicons dashicons-arrow-right collapsed"></span>';
             $html .= '<span class="dashicons dashicons-arrow-down expanded hidden"></span>';
             $html .= sprintf(_x('(%1$d items)', 'count of array entries', 'options-pixie'), count($data));
             $html .= '</span>';
             $array_class .= ' hidden';
         }
         $html .= '<dl class="array' . $array_class . '">';
         foreach ($data as $key => $value) {
             $html .= '<dt class="key">' . $key . '</dt>';
             $html .= '<dd class="value">' . Options_Pixie_Data_Format::_to_html($value, $recursion_level + 1) . '</dd>';
         }
         $html .= '</dl>';
     } elseif (Options_Pixie_Data_Format::is_broken_serialized($data)) {
         $html .= preg_replace_callback('/s:(\\d+):"(.*?)";/', array('Options_Pixie_Data_Format', '_highlight_broken_serialized_string'), $data);
     } elseif (is_serialized($data)) {
         $value = unserialize($data);
         $html .= Options_Pixie_Data_Format::_to_html($value, $recursion_level + 1);
     } elseif (is_object($data)) {
         // The top level object should not be treated as an expandable array.
         if (1 === $recursion_level) {
             $recursion_level = 0;
         }
         $object_array = Options_Pixie_Data_Format::_object_to_array($data);
         $html .= Options_Pixie_Data_Format::_to_html($object_array, $recursion_level + 1);
     } elseif (Options_Pixie_Data_Format::is_json($data)) {
         $value = json_decode($data, true);
         $html .= Options_Pixie_Data_Format::_to_html($value, $recursion_level + 1);
     } elseif (Options_Pixie_Data_Format::is_base64($data)) {
         $value = base64_decode($data, true);
         $html .= Options_Pixie_Data_Format::_to_html($value, $recursion_level);
     } else {
         $html .= esc_html(print_r($data, true));
     }
     return $html;
 }