public function ajax_response()
 {
     if (!check_ajax_referer($this->plugin_name . '_import', false, false) || !current_user_can('edit_theme_options')) {
         wp_send_json_error(array('msg' => '<p>Insufficient user rights.</p>'));
     }
     if (empty($_POST['dummy'])) {
         wp_send_json_error(array('msg' => '<p>Unable to find dummy content.</p>'));
     }
     $plugin_path = plugin_dir_path(dirname(__FILE__)) . '/includes/dummy-content/' . $this->theme_name . '/';
     $dummy_content_obj = new DT_Dummy_Content($this->get_dummy_list(), $this->theme_name);
     $content_part_id = empty($_POST['content_part_id']) ? '0' : sanitize_key($_POST['content_part_id']);
     $dummy_content = array_merge($dummy_content_obj->get_main_content($content_part_id)->as_array(), $dummy_content_obj->get_wc_content($content_part_id)->as_array());
     $msg = '';
     foreach (explode(',', $_POST['dummy']) as $dummy_id) {
         $dummy_id = sanitize_key($dummy_id);
         if (!array_key_exists($dummy_id, $dummy_content)) {
             continue;
         }
         $import_options = array();
         if (isset($dummy_content[$dummy_id]['replace_attachments'])) {
             $import_options['replace_attachments'] = $dummy_content[$dummy_id]['replace_attachments'];
         }
         $file_name = $plugin_path . $dummy_content[$dummy_id]['file_name'];
         ob_start();
         $this->import_file($file_name, $import_options);
         $errors = ob_get_clean();
         $msg .= '<p>' . $errors . dt_dummy_get_content_nice_name($dummy_id, $dummy_content[$dummy_id]) . ' ' . __('dummy content was imported.', $this->plugin_name) . '</p>';
     }
     wp_send_json_success(array('msg' => $msg));
 }
    exit;
}
/**
 * Provide a dashboard view for the plugin
 *
 * This file is used to markup the public-facing aspects of the plugin.
 *
 * @link       http://example.com
 * @since      1.0.0
 *
 * @package    DT_Dummy
 * @subpackage DT_Dummy/admin/partials
 */
// $checkbox_status = ' checked="checked"';
$checkbox_status = '';
$dummy_content = new DT_Dummy_Content($this->get_dummy_list(), $this->theme_name);
?>
<div class="wrap">
	<h2><?php 
echo esc_html(get_admin_page_title());
?>
</h2>

	<?php 
foreach ($dummy_content->get_content_parts_ids() as $content_part_id) {
    ?>

		<?php 
    $dummy_info = $dummy_content->get_content_info($content_part_id);
    ?>
 public function ajax_response()
 {
     if (empty($_POST['dummy'])) {
         echo 'Unable to find dummy content.';
         exit;
     }
     $plugin_path = plugin_dir_path(dirname(__FILE__)) . '/includes/dummy-content/' . $this->theme_name . '/';
     $dummy_content_obj = new DT_Dummy_Content($this->get_dummy_list(), $this->theme_name);
     $content_part_id = empty($_POST['content_part_id']) ? '0' : sanitize_key($_POST['content_part_id']);
     $dummy_content = array_merge($dummy_content_obj->get_main_content($content_part_id)->as_array(), $dummy_content_obj->get_wc_content($content_part_id)->as_array());
     foreach (explode(',', $_POST['dummy']) as $dummy_id) {
         $dummy_id = sanitize_key($dummy_id);
         if (!array_key_exists($dummy_id, $dummy_content)) {
             continue;
         }
         $import_options = array();
         if (isset($dummy_content[$dummy_id]['replace_attachments'])) {
             $import_options['replace_attachments'] = $dummy_content[$dummy_id]['replace_attachments'];
         }
         $file_name = $plugin_path . $dummy_content[$dummy_id]['file_name'];
         $this->import_file($file_name, $import_options);
         echo '<p>' . dt_dummy_get_content_nice_name($dummy_id, $dummy_content[$dummy_id]) . ' ' . __('dummy content was imported.', $this->plugin_name) . '</p>';
     }
     exit;
 }