Created DDHH_JM_Template class to display full job details on single job offer pages. Shows logo, organization, location, type, deadline, description, and contact information in a styled layout. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
144 lines
3.8 KiB
PHP
144 lines
3.8 KiB
PHP
<?php
|
|
/**
|
|
* Template functionality for job offers
|
|
*
|
|
* @package DDHH_Job_Manager
|
|
*/
|
|
|
|
// Exit if accessed directly.
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
/**
|
|
* Handles template display for job offers
|
|
*/
|
|
class DDHH_JM_Template {
|
|
|
|
/**
|
|
* Setup template hooks
|
|
*/
|
|
public static function setup_hooks() {
|
|
// Filter the content to add job details
|
|
add_filter( 'the_content', array( __CLASS__, 'add_job_details_to_content' ) );
|
|
}
|
|
|
|
/**
|
|
* Add job details to the content for single job_offer posts
|
|
*
|
|
* @param string $content Post content.
|
|
* @return string Modified content.
|
|
*/
|
|
public static function add_job_details_to_content( $content ) {
|
|
// Only modify content on single job_offer posts
|
|
if ( ! is_singular( 'job_offer' ) || ! in_the_loop() || ! is_main_query() ) {
|
|
return $content;
|
|
}
|
|
|
|
global $post;
|
|
|
|
// Get job meta data
|
|
$job_location = get_post_meta( $post->ID, 'job_location', true );
|
|
$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' );
|
|
|
|
// Get author/organization info
|
|
$author = get_userdata( $post->post_author );
|
|
$author_name = $author ? $author->display_name : '';
|
|
$author_org = get_user_meta( $post->post_author, 'ddhh_org_name', true );
|
|
|
|
// Build job details HTML
|
|
ob_start();
|
|
?>
|
|
<div class="ddhh-job-offer-details">
|
|
<?php if ( $job_logo ) : ?>
|
|
<div class="job-logo">
|
|
<?php echo $job_logo; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="job-meta">
|
|
<?php if ( $author_org ) : ?>
|
|
<div class="job-meta-item">
|
|
<strong>Anbieter:</strong> <?php echo esc_html( $author_org ); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ( $job_location ) : ?>
|
|
<div class="job-meta-item">
|
|
<strong>Standort:</strong> <?php echo esc_html( $job_location ); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ( $job_type ) : ?>
|
|
<div class="job-meta-item">
|
|
<strong>Art:</strong> <?php echo esc_html( $job_type ); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ( $job_deadline ) : ?>
|
|
<div class="job-meta-item">
|
|
<strong>Bewerbungsfrist:</strong> <?php echo esc_html( date( 'd.m.Y', strtotime( $job_deadline ) ) ); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="job-description">
|
|
<h3>Stellenbeschreibung</h3>
|
|
<?php echo wp_kses_post( $content ); ?>
|
|
</div>
|
|
|
|
<?php if ( $job_contact_email && is_user_logged_in() && current_user_can( 'read' ) ) : ?>
|
|
<div class="job-application-section">
|
|
<h3>Jetzt bewerben</h3>
|
|
<p>Interessiert? Kontaktieren Sie uns unter: <a href="mailto:<?php echo esc_attr( $job_contact_email ); ?>"><?php echo esc_html( $job_contact_email ); ?></a></p>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<style>
|
|
.ddhh-job-offer-details {
|
|
margin: 2em 0;
|
|
}
|
|
.ddhh-job-offer-details .job-logo {
|
|
margin-bottom: 2em;
|
|
}
|
|
.ddhh-job-offer-details .job-logo img {
|
|
max-width: 200px;
|
|
height: auto;
|
|
}
|
|
.ddhh-job-offer-details .job-meta {
|
|
background: #f5f5f5;
|
|
padding: 1.5em;
|
|
margin-bottom: 2em;
|
|
border-radius: 4px;
|
|
}
|
|
.ddhh-job-offer-details .job-meta-item {
|
|
margin-bottom: 0.75em;
|
|
}
|
|
.ddhh-job-offer-details .job-meta-item:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
.ddhh-job-offer-details .job-meta-item strong {
|
|
display: inline-block;
|
|
min-width: 150px;
|
|
}
|
|
.ddhh-job-offer-details .job-description {
|
|
margin-bottom: 2em;
|
|
}
|
|
.ddhh-job-offer-details .job-application-section {
|
|
background: #e8f4f8;
|
|
padding: 1.5em;
|
|
border-left: 4px solid #0073aa;
|
|
border-radius: 4px;
|
|
}
|
|
.ddhh-job-offer-details .job-application-section h3 {
|
|
margin-top: 0;
|
|
}
|
|
</style>
|
|
</div>
|
|
<?php
|
|
|
|
return ob_get_clean();
|
|
}
|
|
}
|