<?php
if ( ! defined( 'ABSPATH' ) ) exit;
global $wpdb;
$tableName = $wpdb->prefix . DB_TESTIMONIAL_TABLE_NAME; 
$id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : '';
if ( empty( $id ) ) {
    echo "<script>window.location='".esc_url( admin_url( 'edit.php')) ."?post_type=stars_testimonial&page=all-shortcodes'</script>";
}
$query = "SELECT id
        FROM {$tableName}
        WHERE id = '%d'";
$query = $wpdb->prepare($query, $id);

// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$result = $wpdb->get_row($query);
if ( empty( $result ) ) {
    echo "<script>window.location='".esc_url( admin_url( 'edit.php')) ."?post_type=stars_testimonial&page=all-shortcodes'</script>";
}
?>

<div class="wrap">
    <div class="testimonial-setting">
        <h1><?php esc_html_e('Shortcode Preview', 'stars-testimonials-with-slider-and-masonry-grid'); ?>  <?php echo "[testimonial_stars id=".esc_attr($id)."]" ?></h1>
        <div class="preview-box">
            <?php
                echo do_shortcode('[testimonial_stars id='.$id.']');
            ?>
        </div>
    </div>
</div>