/*******************************
* 5. SHORTCODE [job_details] - UPDATED WITH BETTER CONTRAST
********************************/
function job_details_shortcode() {
if ( ! is_single() ) return '';
$enable_job = get_post_meta( get_the_ID(), 'enable_job', true );
if ( $enable_job !== 'on' ) return '';
$icons = [
'company' => '',
'location' => '',
'salary' => '',
'post' => '',
'qual' => '',
'exp' => '',
'age' => '',
'exam' => '',
'deadline' => '',
'visa' => '',
'hours' => '',
'type' => '',
'apply' => '',
];
$pid = get_the_ID();
$d = [
'company' => get_post_meta( $pid, 'job_company', true ),
'location' => get_post_meta( $pid, 'job_location', true ),
'desc' => get_post_meta( $pid, 'job_desc', true ),
'salary' => get_post_meta( $pid, 'job_salary', true ),
'post' => get_post_meta( $pid, 'job_post', true ),
'qual' => get_post_meta( $pid, 'qualification', true ),
'exp' => get_post_meta( $pid, 'experience', true ),
'age' => get_post_meta( $pid, 'age_limit', true ),
'exam' => get_post_meta( $pid, 'exam_date', true ),
'deadline' => get_post_meta( $pid, 'last_apply', true ),
'apply_url' => get_post_meta( $pid, 'apply_url', true ),
'visa' => get_post_meta( $pid, 'job_visa', true ),
'hours' => get_post_meta( $pid, 'job_hours', true ),
'type' => get_post_meta( $pid, 'job_type', true ),
'logo_id' => get_post_meta( $pid, 'job_logo_id', true ),
];
if ( ! empty( $d['exam'] ) ) $d['exam'] = date( 'd M, Y', strtotime( $d['exam'] ) );
if ( ! empty( $d['deadline'] ) ) $d['deadline'] = date( 'd M, Y', strtotime( $d['deadline'] ) );
if ( ! empty( $d['salary'] ) ) $d['salary'] = '€' . $d['salary'];
$visa_label = '';
if ( $d['visa'] === 'yes' ) $visa_label = '✔ Available';
if ( $d['visa'] === 'no' ) $visa_label = '✘ Not Available';
$logo_url = '';
if ( ! empty( $d['logo_id'] ) ) {
$src = wp_get_attachment_image_src( $d['logo_id'], 'medium' );
if ( $src ) $logo_url = $src[0];
}
$tile = function( $icon, $label, $value, $bg, $fg ) {
$out = '
';
$out .= '
'
. $icon . '
';
$out .= '
';
$out .= '
' . esc_html( $label ) . '
';
$out .= '
' . esc_html( $value ) . '
';
$out .= '
';
return $out;
};
$html = '';
// Header
$html .= '
';
$html .= '
';
$html .= '
' . $icons['post'] . ' Job Details
';
if ( $logo_url ) {
$html .= '
';
$html .= '
![' . esc_attr( $d['company'] ) . ' Logo](' . esc_url( $logo_url ) . ')
';
$html .= '
';
}
$html .= '
';
$html .= '
';
$html .= '
';
$html .= '
';
// Description
if ( ! empty( $d['desc'] ) ) {
$html .= '
';
$html .= '
';
$html .= wp_kses_post( $d['desc'] );
$html .= '
';
}
// Grid
$html .= '
';
if ( ! empty( $d['company'] ) ) $html .= $tile( $icons['company'], 'Company', $d['company'], '#e0f2fe', '#0284c7' );
if ( ! empty( $d['location'] ) ) $html .= $tile( $icons['location'], 'Location', $d['location'], '#fef9c3', '#ca8a04' );
if ( ! empty( $d['salary'] ) ) $html .= $tile( $icons['salary'], 'Salary', $d['salary'], '#dbeafe', '#2563eb' );
if ( ! empty( $d['post'] ) ) $html .= $tile( $icons['post'], 'Job Post', $d['post'], '#dbeafe', '#2563eb' );
if ( ! empty( $d['type'] ) ) $html .= $tile( $icons['type'], 'Job Type', $d['type'], '#f0fdf4', '#16a34a' );
if ( ! empty( $d['hours'] ) ) $html .= $tile( $icons['hours'], 'Working Hours', $d['hours'], '#fff7ed', '#ea580c' );
if ( ! empty( $d['qual'] ) ) $html .= $tile( $icons['qual'], 'Qualification', $d['qual'], '#f3e8ff', '#9333ea' );
// Experience tile with HIGH CONTRAST colors - dark background with white text
if ( ! empty( $d['exp'] ) ) $html .= $tile( $icons['exp'], 'Experience', $d['exp'], '#1e40af', '#ffffff' );
if ( ! empty( $d['age'] ) ) $html .= $tile( $icons['age'], 'Age Limit', $d['age'], '#fce7f3', '#db2777' );
if ( $visa_label ) $html .= $tile( $icons['visa'], 'Visa Sponsorship', $visa_label, '#f0f9ff', '#0369a1' );
if ( ! empty( $d['exam'] ) ) $html .= $tile( $icons['exam'], 'Exam Date', $d['exam'], '#dcfce7', '#16a34a' );
if ( ! empty( $d['deadline'] ) ) $html .= $tile( $icons['deadline'], 'Last Apply Date', $d['deadline'], '#ffedd5', '#ea580c' );
$html .= '
';
// Apply button
if ( ! empty( $d['apply_url'] ) ) {
$html .= '
';
}
$html .= '
';
return $html;
}
add_shortcode( 'job_details', 'job_details_shortcode' );