public function manage_fancy_products()
 {
     if (class_exists('FPD_Admin_Manage_Fancy_Products')) {
         $page = new FPD_Admin_Manage_Fancy_Products();
         $page->output();
     }
 }
 public function create_views_from_template()
 {
     if (!isset($_POST['id']) || !isset($_POST['product_id'])) {
         exit;
     }
     check_ajax_referer('fpd_ajax_nonce', '_ajax_nonce');
     $id = trim($_POST['id']);
     $product_id = trim($_POST['product_id']);
     header('Content-Type: application/json');
     try {
         $views = json_decode(FPD_Admin_Template::get_views($id), true);
         $fancy_product = new Fancy_Product($product_id);
         $html = '';
         foreach ($views as $view) {
             $view_id = $fancy_product->add_view($view['title'], serialize($view['elements']), $view['thumbnail']);
             $html .= FPD_Admin_Manage_Fancy_Products::get_view_item_html($view_id, $view['thumbnail'], $view['title'], '');
         }
         echo json_encode(array('html' => $html, 'message' => __('Product successfully created!', 'radykal')));
     } catch (Exception $e) {
         echo json_encode(array('error' => 1, 'message' => __('Fancy Product could not be stored. Please try again!', 'radykal')));
     }
     die;
 }
<div class="fpd-modal-wrapper" id="fpd-modal-load-template">
	<div class="fpd-modal-dialog">
		<a href="#" class="fpd-close-modal">&times;</a>
		<h3><?php 
_e('Load a template', 'radykal');
?>
</h3>
		<div class="fpd-modal-content">
			<?php 
$no_templates_info = '<p>' . __('No templates created. You can create a template via the action bar in a product list item.', 'radykal') . '</p>';
if (fpd_table_exists(FPD_TEMPLATES_TABLE)) {
    $templates = $wpdb->get_results("SELECT * FROM " . FPD_TEMPLATES_TABLE . " ORDER BY title ASC");
    if (sizeof($templates) == 0) {
        echo $no_templates_info;
    }
    echo '<ul>';
    foreach ($templates as $template) {
        // double quotes required
        echo FPD_Admin_Manage_Fancy_Products::get_template_link_html($template->ID, $template->title);
    }
    echo '</ul>';
} else {
    echo $no_templates_info;
}
?>
			</ul>
		</div>
	</div>
</div>