refactor: restructure dashboard UX and migrate logos to provider level

- Move job submission form to separate view (?action=new_job)
- Replace inline form with prominent green button on main dashboard
- Migrate logos from per-job (post thumbnail) to per-provider (user meta)
- Add logo upload/removal functionality to provider dashboard
- Display provider logo on single job pages instead of per-job logo
- Add back link to archive on single job pages
- Remove logo handling from form submission/edit processors
- Improve button styling with proper CSS specificity

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-29 14:03:47 +09:00
parent d907878143
commit 08b9ad24a5
3 changed files with 226 additions and 42 deletions

View File

@@ -474,7 +474,6 @@ class DDHH_JM_Formidable {
$job_type = '';
$job_deadline = '';
$job_contact_email = '';
$job_logo = '';
foreach ( $entry->metas as $field_id => $value ) {
$field = FrmField::getOne( $field_id );
@@ -501,9 +500,6 @@ class DDHH_JM_Formidable {
case 'job_contact_email':
$job_contact_email = sanitize_email( $value );
break;
case 'job_logo':
$job_logo = $value; // File ID
break;
}
}
@@ -541,12 +537,6 @@ class DDHH_JM_Formidable {
update_post_meta( $post_id, 'job_deadline', $job_deadline );
}
// Handle logo upload if present
if ( ! empty( $job_logo ) && is_numeric( $job_logo ) ) {
set_post_thumbnail( $post_id, absint( $job_logo ) );
error_log( 'DDHH Job Submission: Logo set as featured image' );
}
error_log( 'DDHH Job Submission: Job offer created successfully' );
do_action( 'ddhh_job_submitted', $post_id, $entry_id );
@@ -599,7 +589,6 @@ class DDHH_JM_Formidable {
$job_type = '';
$job_deadline = '';
$job_contact_email = '';
$job_logo = '';
foreach ( $entry->metas as $field_id => $value ) {
$field = FrmField::getOne( $field_id );
@@ -632,10 +621,6 @@ class DDHH_JM_Formidable {
case 'job_contact_email2':
$job_contact_email = sanitize_email( $value );
break;
case 'job_logo':
case 'job_logo2':
$job_logo = $value; // File ID
break;
}
}
@@ -672,12 +657,6 @@ class DDHH_JM_Formidable {
update_post_meta( $post_id, 'job_deadline', $job_deadline );
}
// Handle logo upload if present
if ( ! empty( $job_logo ) && is_numeric( $job_logo ) ) {
set_post_thumbnail( $post_id, absint( $job_logo ) );
error_log( 'DDHH Job Edit: Logo updated' );
}
error_log( 'DDHH Job Edit: Job offer updated successfully' );
do_action( 'ddhh_job_edited', $post_id, $entry_id );
@@ -1159,11 +1138,6 @@ class DDHH_JM_Formidable {
case 'job_contact_email2':
$value = get_post_meta( $post_id, 'job_contact_email', true );
return $value ? $value : $default_value;
case 'job_logo':
case 'job_logo2':
$value = get_post_thumbnail_id( $post_id );
return $value ? $value : $default_value;
}
return $default_value;

View File

@@ -40,7 +40,8 @@ class DDHH_JM_Template {
$job_type = get_post_meta( $post->ID, 'job_type', true );
$job_deadline = get_post_meta( $post->ID, 'job_deadline', true );
$job_contact_email = get_post_meta( $post->ID, 'job_contact_email', true );
$job_logo = get_the_post_thumbnail( $post->ID, 'job-logo' );
$provider_logo_id = get_user_meta( $post->post_author, 'ddhh_provider_logo', true );
$job_logo = $provider_logo_id ? wp_get_attachment_image( absint( $provider_logo_id ), 'job-logo' ) : '';
// Get author/organization info
$author = get_userdata( $post->post_author );
@@ -50,6 +51,9 @@ class DDHH_JM_Template {
// Build job details HTML
ob_start();
?>
<div class="ddhh-back-to-archive">
<a href="<?php echo esc_url( get_post_type_archive_link( 'job_offer' ) ); ?>">← Alle Jobangebote</a>
</div>
<div class="ddhh-job-offer-details">
<?php if ( $job_logo ) : ?>
<div class="job-logo">
@@ -118,6 +122,18 @@ class DDHH_JM_Template {
<?php endif; ?>
<style>
.ddhh-back-to-archive {
margin-bottom: 1.5rem;
}
.ddhh-back-to-archive a {
color: #3b82f6;
text-decoration: none;
font-weight: 500;
}
.ddhh-back-to-archive a:hover {
color: #2563eb;
text-decoration: underline;
}
.ddhh-job-offer-details {
margin: 2em 0;
}

View File

@@ -26,12 +26,58 @@ if ( ! in_array( 'ddhh_provider', $current_user->roles, true ) ) {
return;
}
// Handle logo upload
if ( isset( $_POST['ddhh_upload_logo'] ) && isset( $_POST['ddhh_logo_nonce'] ) && wp_verify_nonce( $_POST['ddhh_logo_nonce'], 'ddhh_logo_upload' ) ) {
if ( ! empty( $_FILES['ddhh_logo_file'] ) && $_FILES['ddhh_logo_file']['error'] === UPLOAD_ERR_OK ) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
require_once( ABSPATH . 'wp-admin/includes/image.php' );
require_once( ABSPATH . 'wp-admin/includes/media.php' );
// Validate file type
$allowed_types = array( 'image/jpeg', 'image/png', 'image/jpg' );
$file_type = $_FILES['ddhh_logo_file']['type'];
if ( in_array( $file_type, $allowed_types, true ) ) {
$upload = wp_handle_upload( $_FILES['ddhh_logo_file'], array( 'test_form' => false ) );
if ( isset( $upload['file'] ) && ! isset( $upload['error'] ) ) {
// Insert attachment
$attachment = array(
'post_mime_type' => $upload['type'],
'post_title' => sanitize_file_name( $_FILES['ddhh_logo_file']['name'] ),
'post_content' => '',
'post_status' => 'inherit',
);
$attachment_id = wp_insert_attachment( $attachment, $upload['file'] );
if ( ! is_wp_error( $attachment_id ) ) {
// Generate metadata
$attachment_data = wp_generate_attachment_metadata( $attachment_id, $upload['file'] );
wp_update_attachment_metadata( $attachment_id, $attachment_data );
// Save to user meta
update_user_meta( get_current_user_id(), 'ddhh_provider_logo', $attachment_id );
}
}
}
}
}
// Handle logo removal
if ( isset( $_POST['ddhh_remove_logo'] ) && isset( $_POST['ddhh_logo_nonce'] ) && wp_verify_nonce( $_POST['ddhh_logo_nonce'], 'ddhh_logo_upload' ) ) {
delete_user_meta( get_current_user_id(), 'ddhh_provider_logo' );
}
// Check if we're in edit mode
$is_edit_mode = isset( $_GET['action'] ) && $_GET['action'] === 'edit_job' && isset( $_GET['job_id'] );
// Check if we're in deactivate mode
$is_deactivate_mode = isset( $_GET['action'] ) && $_GET['action'] === 'deactivate_job' && isset( $_GET['job_id'] );
// Check if we're in new job mode
$is_new_job_mode = isset( $_GET['action'] ) && $_GET['action'] === 'new_job';
if ( $is_edit_mode ) {
$job_id = absint( $_GET['job_id'] );
$form_id = DDHH_JM_Formidable::get_job_edit_form_id();
@@ -69,9 +115,6 @@ if ( $is_edit_mode ) {
case 'job_contact_email2':
$field_value = get_post_meta( $job_id, 'job_contact_email', true );
break;
case 'job_logo2':
$field_value = get_post_thumbnail_id( $job_id );
break;
}
if ( ! empty( $field_value ) ) {
@@ -214,6 +257,32 @@ if ( $is_deactivate_mode ) {
}
}
if ( $is_new_job_mode ) {
$form_id = DDHH_JM_Formidable::get_job_submission_form_id();
if ( $form_id ) {
?>
<div class="ddhh-provider-dashboard">
<div class="ddhh-dashboard-header">
<div class="ddhh-user-info">
<span class="welcome-text">Angemeldet als: <strong><?php echo esc_html( $current_user->display_name ); ?></strong></span>
</div>
<div class="ddhh-logout-link">
<a href="<?php echo esc_url( wp_logout_url( home_url( '/anbieter-login/' ) ) ); ?>" class="logout-button">Abmelden</a>
</div>
</div>
<div class="ddhh-job-submit-section">
<h2>Neues Stellenangebot erstellen</h2>
<p><a href="<?php echo esc_url( home_url( '/anbieter-dashboard/' ) ); ?>" class="back-to-dashboard">← Zurück zur Übersicht</a></p>
<?php echo do_shortcode( "[formidable id={$form_id}]" ); ?>
</div>
</div>
<?php
return;
}
}
// Query current user's job_offer posts
$args = array(
'post_type' => 'job_offer',
@@ -237,16 +306,33 @@ $job_query = new WP_Query( $args );
</div>
</div>
<div class="ddhh-job-submit-section">
<h2>Neues Stellenangebot erstellen</h2>
<div class="ddhh-logo-section">
<h3>Ihr Logo</h3>
<?php
$form_id = DDHH_JM_Formidable::get_job_submission_form_id();
if ( $form_id ) {
echo do_shortcode( "[formidable id={$form_id}]" );
} else {
echo '<p>Formular konnte nicht geladen werden.</p>';
$provider_logo_id = get_user_meta( get_current_user_id(), 'ddhh_provider_logo', true );
if ( $provider_logo_id ) {
echo '<div class="ddhh-current-logo">';
echo wp_get_attachment_image( absint( $provider_logo_id ), 'medium' );
echo '</div>';
}
?>
<form method="post" enctype="multipart/form-data" class="ddhh-logo-upload-form">
<?php wp_nonce_field( 'ddhh_logo_upload', 'ddhh_logo_nonce' ); ?>
<div class="ddhh-logo-controls">
<input type="file" name="ddhh_logo_file" accept="image/png,image/jpeg,image/jpg" class="ddhh-logo-input">
<button type="submit" name="ddhh_upload_logo" class="ddhh-logo-button ddhh-upload-button">
<?php echo $provider_logo_id ? 'Logo ändern' : 'Logo hochladen'; ?>
</button>
<?php if ( $provider_logo_id ) : ?>
<button type="submit" name="ddhh_remove_logo" class="ddhh-logo-button ddhh-remove-button" onclick="return confirm('Möchten Sie das Logo wirklich entfernen?');">Logo entfernen</button>
<?php endif; ?>
</div>
<p class="ddhh-logo-hint">Erlaubte Formate: JPG, PNG (max. 2 MB)</p>
</form>
</div>
<div class="ddhh-dashboard-actions">
<a href="<?php echo esc_url( add_query_arg( 'action', 'new_job', home_url( '/anbieter-dashboard/' ) ) ); ?>" class="ddhh-new-job-button">+ Neues Stellenangebot erstellen</a>
</div>
<div class="ddhh-job-listings-section">
@@ -383,16 +469,124 @@ $job_query = new WP_Query( $args );
text-decoration: none;
}
.ddhh-job-submit-section {
margin-bottom: 3rem;
padding: 2rem;
background: #f5f5f5;
.ddhh-logo-section {
padding: 1.5rem 2rem;
background: #fff;
border-radius: 8px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
margin-bottom: 2rem;
}
.ddhh-logo-section h3 {
margin-top: 0;
margin-bottom: 1rem;
font-size: 1.125rem;
color: #111827;
font-weight: 600;
}
.ddhh-current-logo {
margin-bottom: 1rem;
padding: 1rem;
background: #f9fafb;
border-radius: 4px;
display: inline-block;
}
.ddhh-current-logo img {
max-width: 200px;
height: auto;
display: block;
}
.ddhh-logo-upload-form {
margin: 0;
}
.ddhh-logo-controls {
display: flex;
align-items: center;
gap: 0.75rem;
flex-wrap: wrap;
margin-bottom: 0.5rem;
}
.ddhh-logo-input {
flex: 1;
min-width: 200px;
padding: 0.5rem;
border: 1px solid #d1d5db;
border-radius: 0.375rem;
font-size: 0.875rem;
}
.ddhh-logo-button {
padding: 0.5rem 1rem;
border: none;
border-radius: 0.375rem;
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
transition: background-color 0.2s;
}
.ddhh-upload-button {
background-color: #3b82f6;
color: #fff;
}
.ddhh-upload-button:hover {
background-color: #2563eb;
}
.ddhh-remove-button {
background-color: #ef4444;
color: #fff;
}
.ddhh-remove-button:hover {
background-color: #dc2626;
}
.ddhh-logo-hint {
margin: 0;
font-size: 0.8125rem;
color: #6b7280;
}
.ddhh-dashboard-actions {
margin-bottom: 2rem;
text-align: left;
}
.ddhh-provider-dashboard .ddhh-new-job-button {
display: inline-block;
padding: 0.875rem 2rem;
background-color: #10b981;
color: #fff;
text-decoration: none;
border-radius: 0.5rem;
font-size: 1rem;
font-weight: 600;
transition: background-color 0.2s;
}
.ddhh-provider-dashboard .ddhh-new-job-button:hover {
background-color: #059669;
color: #fff;
text-decoration: none;
}
.ddhh-job-submit-section {
padding: 2rem;
background: #fff;
border-radius: 8px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.ddhh-job-submit-section h2 {
margin-top: 0;
margin-bottom: 1.5rem;
margin-bottom: 1rem;
font-size: 1.5rem;
color: #333;
}