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

+26 -123
View File
@@ -36,14 +36,6 @@ class HSSM_Slides_CPT {
*/
const SITE_TAXONOMY = 'hssm_site';
/**
* Client taxonomy slug
*
* @since 1.0.0
* @var string
*/
const CLIENT_TAXONOMY = 'hssm_client';
/**
* Constructor
*
@@ -99,7 +91,7 @@ class HSSM_Slides_CPT {
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'query_var' => 'hssm_slide_item',
'rewrite' => array( 'slug' => 'slide' ),
'capability_type' => 'post',
'has_archive' => true,
@@ -147,33 +139,6 @@ class HSSM_Slides_CPT {
register_taxonomy( self::SITE_TAXONOMY, array( self::POST_TYPE ), $site_args );
// Client taxonomy for organizing slides by client (optional)
$client_labels = array(
'name' => _x( 'Clients', 'taxonomy general name', 'hi-school-slide-manager' ),
'singular_name' => _x( 'Client', 'taxonomy singular name', 'hi-school-slide-manager' ),
'search_items' => __( 'Search Clients', 'hi-school-slide-manager' ),
'all_items' => __( 'All Clients', 'hi-school-slide-manager' ),
'parent_item' => __( 'Parent Client', 'hi-school-slide-manager' ),
'parent_item_colon' => __( 'Parent Client:', 'hi-school-slide-manager' ),
'edit_item' => __( 'Edit Client', 'hi-school-slide-manager' ),
'update_item' => __( 'Update Client', 'hi-school-slide-manager' ),
'add_new_item' => __( 'Add New Client', 'hi-school-slide-manager' ),
'new_item_name' => __( 'New Client Name', 'hi-school-slide-manager' ),
'menu_name' => __( 'Clients', 'hi-school-slide-manager' ),
);
$client_args = array(
'hierarchical' => false,
'labels' => $client_labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'slide-client' ),
'show_in_rest' => true,
);
register_taxonomy( self::CLIENT_TAXONOMY, array( self::POST_TYPE ), $client_args );
// Add default terms for the three companion sites
$this->create_default_site_terms();
}
@@ -535,7 +500,6 @@ class HSSM_Slides_CPT {
public function slide_targeting_meta_box( $post ) {
// Get current terms
$current_sites = wp_get_post_terms( $post->ID, self::SITE_TAXONOMY, array( 'fields' => 'ids' ) );
$current_clients = wp_get_post_terms( $post->ID, self::CLIENT_TAXONOMY, array( 'fields' => 'ids' ) );
// Get all available site terms
$site_terms = get_terms( array(
@@ -543,12 +507,6 @@ class HSSM_Slides_CPT {
'hide_empty' => false,
) );
// Get all available client terms
$client_terms = get_terms( array(
'taxonomy' => self::CLIENT_TAXONOMY,
'hide_empty' => false,
) );
?>
<div class="hssm-targeting-section">
<p><strong><?php _e( 'Target Sites', 'hi-school-slide-manager' ); ?></strong></p>
@@ -569,27 +527,6 @@ class HSSM_Slides_CPT {
<?php endif; ?>
</div>
<div class="hssm-targeting-section" style="margin-top: 20px; padding-top: 15px; border-top: 1px solid #ddd;">
<p><strong><?php _e( 'Client (Optional)', 'hi-school-slide-manager' ); ?></strong></p>
<?php if ( ! empty( $client_terms ) && ! is_wp_error( $client_terms ) ) : ?>
<select name="hssm_client" style="width: 100%;">
<option value=""><?php _e( 'Select a client (optional)', 'hi-school-slide-manager' ); ?></option>
<?php foreach ( $client_terms as $term ) : ?>
<option value="<?php echo esc_attr( $term->term_id ); ?>" <?php selected( in_array( $term->term_id, $current_clients ) ); ?>>
<?php echo esc_html( $term->name ); ?>
</option>
<?php endforeach; ?>
</select>
<?php else : ?>
<p class="description">
<?php _e( 'No clients available.', 'hi-school-slide-manager' ); ?>
<a href="<?php echo admin_url( 'edit-tags.php?taxonomy=' . self::CLIENT_TAXONOMY . '&post_type=' . self::POST_TYPE ); ?>">
<?php _e( 'Add clients here', 'hi-school-slide-manager' ); ?>
</a>
</p>
<?php endif; ?>
</div>
<style>
.hssm-targeting-section label {
display: flex;
@@ -682,14 +619,6 @@ class HSSM_Slides_CPT {
wp_set_post_terms( $post_id, array(), self::SITE_TAXONOMY );
}
// Save client taxonomy
if ( isset( $_POST['hssm_client'] ) && ! empty( $_POST['hssm_client'] ) ) {
$client_id = intval( $_POST['hssm_client'] );
wp_set_post_terms( $post_id, array( $client_id ), self::CLIENT_TAXONOMY );
} else {
wp_set_post_terms( $post_id, array(), self::CLIENT_TAXONOMY );
}
// Send email notification for new slides
if ( get_post_status( $post_id ) === 'publish' && ! get_post_meta( $post_id, '_hssm_notification_sent', true ) ) {
$this->send_new_slide_notification( $post_id );
@@ -709,7 +638,6 @@ class HSSM_Slides_CPT {
$new_columns['cb'] = $columns['cb'];
$new_columns['title'] = $columns['title'];
$new_columns['target_sites'] = __( 'Target Sites', 'hi-school-slide-manager' );
$new_columns['client'] = __( 'Client', 'hi-school-slide-manager' );
$new_columns['schedule'] = __( 'Schedule', 'hi-school-slide-manager' );
$new_columns['order'] = __( 'Order', 'hi-school-slide-manager' );
$new_columns['date'] = $columns['date'];
@@ -741,15 +669,6 @@ class HSSM_Slides_CPT {
}
break;
case 'client':
$client_terms = wp_get_post_terms( $post_id, self::CLIENT_TAXONOMY );
if ( ! empty( $client_terms ) && ! is_wp_error( $client_terms ) ) {
echo esc_html( $client_terms[0]->name );
} else {
echo '<em>' . __( 'No client', 'hi-school-slide-manager' ) . '</em>';
}
break;
case 'schedule':
$start_date = get_post_meta( $post_id, '_hssm_start_date', true );
$end_date = get_post_meta( $post_id, '_hssm_end_date', true );
@@ -782,30 +701,9 @@ class HSSM_Slides_CPT {
* @param int $post_id Post ID
*/
private function send_new_slide_notification( $post_id ) {
$notification_emails = get_option( 'hssm_notification_emails', array() );
if ( empty( $notification_emails ) ) {
return;
}
$post = get_post( $post_id );
$subject = sprintf( __( 'New Slide Created: %s', 'hi-school-slide-manager' ), $post->post_title );
$message = sprintf(
__( 'A new slide has been created and published on %s.' . "\n\n" .
'Title: %s' . "\n" .
'Content: %s' . "\n" .
'Edit URL: %s', 'hi-school-slide-manager' ),
get_bloginfo( 'name' ),
$post->post_title,
wp_strip_all_tags( $post->post_content ),
admin_url( 'post.php?post=' . $post_id . '&action=edit' )
);
$headers = array( 'Content-Type: text/plain; charset=UTF-8' );
foreach ( $notification_emails as $email ) {
wp_mail( $email, $subject, $message, $headers );
if ( class_exists( 'HSSM_Notifications' ) ) {
$notifications = new HSSM_Notifications();
$notifications->notify_editor_slide_created( $post_id, 'published' );
}
}
@@ -816,31 +714,31 @@ class HSSM_Slides_CPT {
*/
public function check_scheduled_slides() {
$current_time = current_time( 'mysql' );
// Auto-publish slides that should start now
$slides_to_publish = get_posts( array(
'post_type' => self::POST_TYPE,
// WordPress publishes `future` posts. Cron only handles auto-publish drafts.
$auto_publish = get_posts( array(
'post_type' => self::POST_TYPE,
'post_status' => 'draft',
'meta_query' => array(
'meta_query' => array(
'relation' => 'AND',
array(
'key' => '_hssm_auto_publish',
'value' => '1',
'compare' => '='
'key' => '_hssm_auto_publish',
'value' => '1',
'compare' => '=',
),
array(
'key' => '_hssm_start_date',
'value' => $current_time,
'compare' => '<='
)
'key' => '_hssm_start_date',
'value' => $current_time,
'compare' => '<=',
),
),
'numberposts' => -1
'numberposts' => -1,
) );
foreach ( $slides_to_publish as $slide ) {
foreach ( $auto_publish as $slide ) {
wp_update_post( array(
'ID' => $slide->ID,
'post_status' => 'publish'
'ID' => $slide->ID,
'post_status' => 'publish',
) );
}
@@ -870,6 +768,11 @@ class HSSM_Slides_CPT {
'post_status' => 'draft'
) );
}
if ( class_exists( 'HSSM_Notifications' ) ) {
$notifications = new HSSM_Notifications();
$notifications->notify_due_live_slides();
}
}
/**