email working - remove clients - preview polish

This commit is contained in:
stack_admn committed 2026-11-01 21:41:37 -08:00
1 parent 2b1424d127
commit da83beaec3
19 files changed
+1342 -1060

No files matched your search

+113 -14
View File
@@ -108,6 +108,33 @@ function hssm_get_preview_request() {
$date_param = isset( $_GET['hssm_date'] ) ? sanitize_text_field( wp_unslash( $_GET['hssm_date'] ) ) : $today->format( 'Y-m-d' );
$site_param = isset( $_GET['hssm_site'] ) ? sanitize_text_field( wp_unslash( $_GET['hssm_site'] ) ) : '';
$show_past = isset( $_GET['hssm_past'] ) && $_GET['hssm_past'] === '1';
$slide_id = 0;
if ( isset( $_GET['hssm_preview'] ) ) {
$slide_id = absint( $_GET['hssm_preview'] );
} elseif ( isset( $_GET['hssm_slide'] ) ) {
$slide_id = absint( $_GET['hssm_slide'] );
}
if ( $slide_id ) {
$slide = get_post( $slide_id );
if ( $slide && 'hssm_slide' === $slide->post_type ) {
if ( empty( $_GET['hssm_date'] ) ) {
$start_date = get_post_meta( $slide_id, '_hssm_start_date', true );
if ( $start_date && preg_match( '/^(\d{4}-\d{2}-\d{2})/', $start_date, $matches ) ) {
$date_param = $matches[1];
}
}
if ( empty( $site_param ) ) {
$site_terms = wp_get_post_terms( $slide_id, HSSM_Slides_CPT::SITE_TAXONOMY );
if ( ! is_wp_error( $site_terms ) && ! empty( $site_terms ) ) {
$site_param = $site_terms[0]->slug;
}
}
} else {
$slide_id = 0;
}
}
// Validate date (YYYY-MM-DD)
$date_obj = DateTime::createFromFormat( 'Y-m-d', $date_param );
@@ -119,6 +146,7 @@ function hssm_get_preview_request() {
'date' => $date_obj->format( 'Y-m-d' ),
'site_slug' => $site_param,
'show_past' => $show_past,
'slide_id' => $slide_id,
);
}
@@ -317,6 +345,11 @@ function hssm_get_preview_slides_for_date( $date, $site_slug = '' ) {
$request = hssm_get_preview_request();
$sites = hssm_get_preview_sites();
$events = hssm_get_calendar_events( $request['site_slug'] );
$can_approve = current_user_can( 'edit_posts' );
$focused_slide = $request['slide_id'] ? get_post( $request['slide_id'] ) : null;
if ( $focused_slide && 'hssm_slide' !== $focused_slide->post_type ) {
$focused_slide = null;
}
$current_site_name = '';
if ( ! empty( $request['site_slug'] ) ) {
@@ -341,23 +374,69 @@ if ( empty( $current_site_name ) && ! empty( $sites ) ) {
<div class="container-fluid">
<div id="content-area" class="clearfix full-width">
<div class="hssm-header-bar">
<div class="hssm-header-content">
<div class="hssm-logo-section">
<h1 class="hssm-site-title"><?php esc_html_e( 'Slide Preview', 'hi-school-slide-manager' ); ?></h1>
</div>
<div class="hssm-header-nav">
<a href="<?php echo esc_url( hssm_get_page_url_by_template( 'page-slide-dashboard.php', '/slide-dashboard/' ) ); ?>" class="hssm-nav-btn hssm-nav-home">
<span class="dashicons dashicons-admin-home"></span>
<?php esc_html_e( 'Dashboard', 'hi-school-slide-manager' ); ?>
</a>
<a href="<?php echo esc_url( admin_url() ); ?>" class="hssm-nav-btn hssm-nav-admin">
<span class="dashicons dashicons-admin-generic"></span>
<?php esc_html_e( 'Admin', 'hi-school-slide-manager' ); ?>
</a>
<div class="hssm-user-menu">
<span class="hssm-user-name"><?php echo esc_html( wp_get_current_user()->display_name ); ?></span>
<a href="<?php echo esc_url( wp_logout_url( home_url() ) ); ?>" class="hssm-nav-btn hssm-nav-logout">
<span class="dashicons dashicons-exit"></span>
<?php esc_html_e( 'Logout', 'hi-school-slide-manager' ); ?>
</a>
</div>
</div>
</div>
</div>
<?php
// Render the live slider preview using the modular shortcode
echo do_shortcode( sprintf(
'[hssm_slider site="%s" date="%s"]',
'[hssm_slider site="%s" date="%s" slide="%d" include_pending="1"]',
esc_attr( $request['site_slug'] ),
esc_attr( $request['date'] )
esc_attr( $request['date'] ),
absint( $request['slide_id'] )
) );
// Normal page content (Divi builder, header, etc.).
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
// the_content(); // We might not want the_content if we're replacing it with the shortcode,
// but let's keep it in case there's other content.
endwhile;
endif;
?>
if ( $focused_slide && 'pending' === $focused_slide->post_status && $can_approve ) :
$focus_start = get_post_meta( $focused_slide->ID, '_hssm_start_date', true );
$start_ts = $focus_start ? strtotime( $focus_start ) : false;
$is_future = $start_ts && $start_ts > current_time( 'timestamp' );
?>
<div class="hssm-preview-approve-bar">
<div class="hssm-preview-approve-copy">
<strong><?php echo esc_html( get_the_title( $focused_slide ) ); ?></strong>
<span><?php esc_html_e( 'This slide is pending approval.', 'hi-school-slide-manager' ); ?></span>
</div>
<div class="hssm-preview-approve-actions">
<?php if ( $is_future ) : ?>
<button type="button" class="hssm-btn hssm-btn-success hssm-approve-slide" data-id="<?php echo esc_attr( $focused_slide->ID ); ?>" data-approve-action="schedule">
<span class="dashicons dashicons-yes"></span>
<?php esc_html_e( 'Approve & Schedule', 'hi-school-slide-manager' ); ?>
</button>
<button type="button" class="hssm-btn hssm-btn-primary hssm-approve-slide" data-id="<?php echo esc_attr( $focused_slide->ID ); ?>" data-approve-action="publish">
<span class="dashicons dashicons-upload"></span>
<?php esc_html_e( 'Approve & Publish Now', 'hi-school-slide-manager' ); ?>
</button>
<?php else : ?>
<button type="button" class="hssm-btn hssm-btn-success hssm-approve-slide" data-id="<?php echo esc_attr( $focused_slide->ID ); ?>" data-approve-action="publish">
<span class="dashicons dashicons-yes"></span>
<?php esc_html_e( 'Approve & Publish', 'hi-school-slide-manager' ); ?>
</button>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<div class="hssm-dashboard-main hssm-mt-20">
<div class="hssm-tab-header">
@@ -374,6 +453,9 @@ if ( empty( $current_site_name ) && ! empty( $sites ) ) {
</div>
<form method="get" class="hssm-filters hssm-mt-20">
<?php if ( ! empty( $request['slide_id'] ) ) : ?>
<input type="hidden" name="hssm_preview" value="<?php echo esc_attr( $request['slide_id'] ); ?>" />
<?php endif; ?>
<div>
<label for="hssm_date"><strong><?php esc_html_e( 'Preview Date', 'hi-school-slide-manager' ); ?></strong></label><br>
<input type="text" id="hssm_date" name="hssm_date" class="hssm-input" value="<?php echo esc_attr( $request['date'] ); ?>" autocomplete="off" />
@@ -412,6 +494,23 @@ if ( empty( $current_site_name ) && ! empty( $sites ) ) {
<?php
$slides = hssm_get_preview_slides_for_date( $request['date'], $request['site_slug'] );
if ( ! empty( $request['slide_id'] ) ) {
$has_focus = false;
foreach ( $slides as $existing_slide ) {
if ( (int) $existing_slide->ID === (int) $request['slide_id'] ) {
$has_focus = true;
break;
}
}
if ( ! $has_focus ) {
$focus_slide = get_post( $request['slide_id'] );
if ( $focus_slide && 'hssm_slide' === $focus_slide->post_type ) {
array_unshift( $slides, $focus_slide );
}
}
}
if ( empty( $slides ) ) :
?>
<div class="hssm-empty-state">
@@ -434,7 +533,7 @@ if ( empty( $current_site_name ) && ! empty( $sites ) ) {
}
$thumb_url = get_the_post_thumbnail_url( $slide->ID, 'thumbnail' );
?>
<div class="hssm-slide-item">
<div class="hssm-slide-item<?php echo ( (int) $slide->ID === (int) $request['slide_id'] ) ? ' hssm-slide-item-focus' : ''; ?>">
<div class="hssm-slide-info">
<div class="hssm-list-slide-title">
<?php echo esc_html( get_the_title( $slide ) ); ?>
@@ -467,9 +566,9 @@ if ( empty( $current_site_name ) && ! empty( $sites ) ) {
<?php endif; ?>
</div>
<?php if ( $slide->post_status === 'pending' && current_user_can( 'edit_others_posts' ) ) : ?>
<?php if ( $slide->post_status === 'pending' && $can_approve ) : ?>
<div class="hssm-slide-actions hssm-mt-10">
<button type="button" class="hssm-btn hssm-btn-success hssm-approve-slide" data-id="<?php echo esc_attr( $slide->ID ); ?>">
<button type="button" class="hssm-btn hssm-btn-success hssm-approve-slide" data-id="<?php echo esc_attr( $slide->ID ); ?>" data-approve-action="schedule">
<span class="dashicons dashicons-yes"></span> <?php esc_html_e( 'Approve Slide', 'hi-school-slide-manager' ); ?>
</button>
</div>