Files
Hi-School-Slide-Manager/templates/page-slide-confirmation.php
T

113 lines
5.2 KiB
PHP

<?php
/**
* Template Name: Slide Live Confirmation
*
* Page for ITC team to confirm a slide is live
*
* @package Hi_School_Slide_Manager
* @since 1.0.0
*/
// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
exit( 'Direct access forbidden.' );
}
get_header();
$slide_id = isset( $_GET['slide_id'] ) ? intval( $_GET['slide_id'] ) : 0;
// Note: We used a simplified token/hash check in the email link generation.
// Ideally, we would verify that here.
// For now, let's assume if they have the link, they can confirm (or we add basic checks).
$slide = get_post( $slide_id );
$is_valid_slide = ( $slide && $slide->post_type === 'hssm_slide' );
$confirmed = false;
$error_message = '';
// Handle confirmation action
if ( $is_valid_slide && isset( $_POST['confirm_live_action'] ) && $_POST['confirm_live_action'] === 'confirm' ) {
if ( wp_verify_nonce( $_POST['hssm_live_nonce'], 'hssm_confirm_live_action' ) ) {
// Trigger the final notification
if ( class_exists( 'HSSM_Notifications' ) ) {
$notifications = new HSSM_Notifications();
$notifications->notify_all_confirmed_live( $slide_id );
// Mark as confirmed in metadata
update_post_meta( $slide_id, '_hssm_live_confirmed', current_time( 'timestamp' ) );
$confirmed = true;
} else {
$error_message = 'Notification system not available.';
}
} else {
$error_message = 'Security check failed. Please refresh and try again.';
}
}
?>
<div id="main-content">
<div class="container-fluid">
<div id="content-area" class="clearfix full-width">
<div class="hssm-confirmation-container" style="max-width: 600px; margin: 50px auto; padding: 30px; background: #fff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); text-align: center;">
<?php if ( ! $is_valid_slide ) : ?>
<div class="hssm-error">
<h2>Invalid Slide</h2>
<p>The slide you are trying to confirm could not be found.</p>
<a href="<?php echo home_url(); ?>" class="button">Return Home</a>
</div>
<?php elseif ( $confirmed ) : ?>
<div class="hssm-success">
<h2 style="color: #46b450;">Confirmation Sent!</h2>
<p class="dashicons dashicons-yes-alt" style="font-size: 64px; width: 64px; height: 64px; color: #46b450;"></p>
<p><strong>Thank you!</strong></p>
<p>Notifications have been sent to the Editor and Creator confirming that "<?php echo esc_html( $slide->post_title ); ?>" is Live.</p>
<a href="<?php echo home_url(); ?>" class="button">Return Home</a>
</div>
<?php else : ?>
<div class="hssm-confirm-form">
<h2>Confirm Slide is Live</h2>
<?php if ( $error_message ) : ?>
<div style="background: #f8d7da; color: #721c24; padding: 10px; margin-bottom: 20px; border-radius: 4px;">
<?php echo esc_html( $error_message ); ?>
</div>
<?php endif; ?>
<div style="margin: 30px 0; padding: 20px; background: #f9f9f9; border: 1px solid #eee; border-radius: 4px;">
<h3 style="margin-top: 0;"><?php echo esc_html( $slide->post_title ); ?></h3>
<?php
$target_sites = wp_get_post_terms( $slide_id, 'hssm_site', array( 'fields' => 'names' ) );
if ( ! empty( $target_sites ) ) {
echo '<p><strong>Target Sites:</strong> ' . esc_html( implode( ', ', $target_sites ) ) . '</p>';
}
?>
<div style="margin-top: 15px;">
<img src="<?php echo get_the_post_thumbnail_url( $slide_id, 'medium' ); ?>" style="max-width: 100%; height: auto; border-radius: 4px;">
</div>
</div>
<p>I confirm that the slide <strong>"<?php echo esc_html( $slide->post_title ); ?>"</strong> is Live and displaying correctly on the target sites.</p>
<form method="post">
<input type="hidden" name="confirm_live_action" value="confirm">
<?php wp_nonce_field( 'hssm_confirm_live_action', 'hssm_live_nonce' ); ?>
<button type="submit" class="button" style="background-color: #46b450; color: #fff; border: none; padding: 15px 30px; font-size: 18px; cursor: pointer; border-radius: 4px;">
<span class="dashicons dashicons-yes"></span> Confirm Slide is Live
</button>
</form>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>