public static function es_optimize_setdetails()
 {
     global $wpdb;
     $prefix = $wpdb->prefix;
     $total = es_cls_sentmail::es_sentmail_count($id = 0);
     if ($total > 10) {
         $delete = $total - 10;
         $sSql = "DELETE FROM `" . $prefix . "es_sentdetails` ORDER BY es_sent_id ASC LIMIT " . $delete;
         $wpdb->query($sSql);
     }
     $sSql = "DELETE FROM `" . $prefix . "es_deliverreport` WHERE es_deliver_sentguid NOT IN";
     $sSql = $sSql . " (SELECT es_sent_guid FROM `" . $prefix . "es_sentdetails`)";
     $wpdb->query($sSql);
     return true;
 }
<?php

if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
    die('You are not allowed to call this page directly.');
}
$did = isset($_GET['did']) ? $_GET['did'] : '0';
es_cls_security::es_check_number($did);
$pagenum = isset($_GET['pagenum']) ? $_GET['pagenum'] : 1;
es_cls_security::es_check_number($pagenum);
// First check if ID exist with requested ID
$result = es_cls_sentmail::es_sentmail_count($did);
if ($result != '1') {
    ?>
<div class="error fade"><p><strong><?php 
    _e('Oops, selected details doesnt exist.', 'email-subscribers');
    ?>
</strong></p></div><?php 
}
?>
<script language="javaScript" src="<?php 
echo ES_URL;
?>
template/template.js"></script>
<div class="wrap">
  <div id="icon-plugins" class="icon32"></div>
    <h2><?php 
_e(ES_PLUGIN_DISPLAY, 'email-subscribers');
?>
</h2>
	<h3><?php 
_e('Preview Mail', 'email-subscribers');
  <div id="icon-plugins" class="icon32"></div>
    <h2><?php 
_e(ES_PLUGIN_DISPLAY, 'email-subscribers');
?>
</h2>
	<h3><?php 
_e('Sent Mails', 'email-subscribers');
?>
</h3>
    <div class="tool-box">
	<?php 
$pagenum = isset($_GET['pagenum']) ? absint($_GET['pagenum']) : 1;
es_cls_security::es_check_number($pagenum);
$limit = 30;
$offset = ($pagenum - 1) * $limit;
$total = es_cls_sentmail::es_sentmail_count(0);
$fulltotal = $total;
$total = ceil($total / $limit);
$myData = array();
$myData = es_cls_sentmail::es_sentmail_select(0, $offset, $limit);
?>
	<form name="frm_es_display" method="post" onsubmit="return _es_bulkaction()">
      <table width="100%" class="widefat" id="straymanage">
        <thead>
          <tr>
			<th scope="col"><?php 
_e('View Reports', 'email-subscribers');
?>
</th>
			<th scope="col"><?php 
_e('Preview', 'email-subscribers');