public function describe_ui()
    {
        ?>
		<div id="ITM" class="wrap">
			<h1 id="ITM-title"><?php 
        _e('Inherit Theme Mods', 'inherit-theme-mods');
        ?>
				<span id="ITM-instant-notifier" class="ITM-status-notifier ITM-aside"></span>
			</h1>

			<?php 
        $itm = new Inherit_Theme_Mods();
        if (!$itm->is_child_theme_active()) {
            # PHP5.3
            ?>
				<div id="ITM-notifier" class="notice notice-warning">
					<p>
						<?php 
            _e('The active theme is not child theme. To use this plugin, activate child theme. This plugin is simply working as inspector now.', 'inherit-theme-mods');
            ?>
					</p>
				</div>
				<?php 
            $this->describe_list_table_area();
        } else {
            $this->describe_header_area();
            $this->describe_list_table_area();
        }
        ?>
		</div><!--#ITM-->
		<?php 
    }
 function generate_data_array()
 {
     $child_mods = Inherit_Theme_Mods::get_theme_mods_of($this->child_slug);
     $parent_mods = Inherit_Theme_Mods::get_theme_mods_of($this->parent_slug);
     $stored_mods = Inherit_Theme_Mods::get_stored_mods();
     if (!$child_mods) {
         $child_mods = array();
     }
     if (!$parent_mods) {
         $parent_mods = array();
     }
     if (!$stored_mods) {
         $stored_mods = array();
     }
     $keys = array_unique(array_merge(array_keys($child_mods), array_keys($parent_mods), array_keys($stored_mods)));
     // helper function
     function decorate_mod($key, $mods, $col)
     {
         $data_key = 'data-key="' . esc_attr($key) . '"';
         $data_col = 'data-col="' . esc_attr($col) . '"';
         if (!array_key_exists($key, $mods)) {
             return "<span class=\"ITM-list-data\" {$data_key} {$data_col}><small class=\"no-value\">" . __('(no value)', 'inherit-theme-mods') . '</small></span>';
         }
         $value = esc_html(maybe_serialize($mods[$key]));
         $match_color = preg_match('/^#?([0-9,a-f,A-F]{3}|[0-9,a-f,A-F]{6})$/', $value);
         $match_inmageURL = preg_match('/\\.(jpg|jpeg|png|gif)$/i', $value);
         if (1 === $match_color) {
             # display color if color string
             $color_str = substr($value, 0, 1) === '#' ? $value : "#{$value}";
             $style_attr = ITM_Util::style_attr(array('background-color' => $color_str));
             # xss OK
             $value = esc_html($value);
             $value = "<div class=\"ITM-color-indication\" {$style_attr}></div><span class=\"ITM-list-data\" {$data_key} {$data_col}>{$value}</span>";
         } else {
             if (1 === $match_inmageURL) {
                 # display image if image url
                 $value = esc_url($value);
                 $value = "<img src=\"{$value}\" class=\"ITM-image-indication\" alt=\"\" /><br /><span class=\"ITM-list-data\" {$data_key} {$data_col}>{$value}</span>";
                 # xss OK
             } else {
                 $value = "<span class=\"ITM-list-data ITM-serialized-text\" {$data_key} {$data_col}>" . esc_html($value) . '</span>';
             }
         }
         return $value;
     }
     $result = array();
     foreach ($keys as $key) {
         // Eliminate unnecessary field to see
         if (is_int($key)) {
             continue;
         }
         // transform slug into maybe translatable text
         // 'translate_word' -> 'Translate Word'
         // (is there any slugify/unslugify standard function?)
         $key_elements = explode('_', $key);
         foreach ($key_elements as $index => $element) {
             $key_elements[$index] = strtoupper(substr($element, 0, 1)) . substr($element, 1);
         }
         // try translate
         $key_parsed = ITM_Util::__chained(implode(' ', $key_elements), array($this->child_slug, $this->parent_slug, 'inherit-theme-mods', 'default'));
         array_push($result, array('Key' => $key_parsed, 'key' => $key_parsed, 'native_key' => $key, 'parent-theme' => decorate_mod($key, $parent_mods, 'parent-theme'), 'child-theme' => decorate_mod($key, $child_mods, 'child-theme'), 'trashed' => decorate_mod($key, $stored_mods, 'trashed')));
     }
     $this->data = $result;
 }
 function test_inherit_and_restore_success()
 {
     $mods = new Mods($this->parent_slug, array('name1' => 'val1-parent', 'name2' => 'val2-parent'), $this->child_slug, array('name1' => 'val1-child', 'name3' => 'val3-child'));
     Inherit_theme_mods::set_theme_mods_of($this->parent_slug, $mods->assigned()->parent);
     Inherit_theme_mods::set_theme_mods_of($this->child_slug, $mods->assigned()->child);
     switch_theme($this->child_slug);
     $itm = new Inherit_Theme_Mods();
     //test if inheritted
     $this->assertTrue($itm->inherit());
     $this->assertArrayDeepEquals(array('name1' => 'val1-parent', 'name2' => 'val2-parent', 'name3' => 'val3-child'), $mods->actual()->child);
     // test if automatically stored
     $this->assertArrayDeepEquals($mods->assigned()->child, $mods->actual()->trashed);
     //test if restored
     $this->assertTrue($itm->restore());
     $this->assertArrayDeepEquals($mods->assigned()->child, $mods->actual()->child);
     //clean up.
     switch_theme($this->parent_slug);
     foreach ($mods->actual()->parent as $key => $value) {
         remove_theme_mod($key);
     }
     switch_theme($this->child_slug);
     foreach ($mods->actual()->parent as $key => $value) {
         remove_theme_mod($key);
     }
 }