Skip to content

Commit

Permalink
#16 added teasertext in both languages and fixed the person display
Browse files Browse the repository at this point in the history
  • Loading branch information
deabokshi committed Sep 27, 2024
1 parent 4e87567 commit cc53f29
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 62 deletions.
2 changes: 1 addition & 1 deletion assets/css/rrze-faudir.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 22 additions & 9 deletions includes/custom-post-type/custom-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,34 @@ function render_person_additional_fields($post) {
wp_nonce_field('save_person_additional_fields', 'person_additional_fields_nonce');

$fields = [
'_content_lang' => __('Content (Second Language)', 'text-domain'),
'_teasertext_lang' => __('Teaser Text (Second Language)', 'text-domain'),
'_content_en' => __('Content (Second Language)', 'text-domain'),
'_teasertext_en' => __('Teaser Text (English)', 'text-domain'),
'_teasertext_de' => __('Teaser Text (German)', 'text-domain'),
'person_id' => __('Person ID', 'text-domain'),
'person_name' => __('Name', 'text-domain'),
'person_email' => __('Email', 'text-domain'),
'person_telephone' => __('Telephone', 'text-domain'),
'person_given_name' => __('Given Name', 'text-domain'),
'person_family_name' => __('Family Name', 'text-domain'),
'person_title' => __('Title', 'text-domain'),
'person_pronoun' => __('Pronoun', 'text-domain'),
'person_suffix' => __('Suffix', 'text-domain'),
'person_nobility_name' => __('Nobility Name', 'text-domain'),
'person_organization' => __('Organization', 'text-domain'),
'person_function' => __('Function', 'text-domain'),
];

foreach ($fields as $meta_key => $label) {
$value = get_post_meta($post->ID, $meta_key, true);
echo "<label for='{$meta_key}'>{$label}</label>";
echo "<input type='text' name='{$meta_key}' id='{$meta_key}' value='" . esc_attr($value) . "' style='width: 100%;' /><br><br>";
}
// Check if the field should be rendered as a textarea
if ($meta_key === '_content_en' || $meta_key === '_teasertext_en' || $meta_key === '_teasertext_de') {
echo "<label for='{$meta_key}'>{$label}</label>";
echo "<textarea name='{$meta_key}' id='{$meta_key}' style='width: 100%; height: 100px;'>" . esc_textarea($value) . "</textarea><br><br>";
} else {
// Render as a regular text input field
echo "<label for='{$meta_key}'>{$label}</label>";
echo "<input type='text' name='{$meta_key}' id='{$meta_key}' value='" . esc_attr($value) . "' style='width: 100%;' /><br><br>";
}
}
}

function save_person_additional_fields($post_id) {
Expand Down Expand Up @@ -111,16 +121,19 @@ function save_person_additional_fields($post_id) {

// List of fields to save from the form
$fields = [
'_content_lang',
'_teasertext_lang',
'_content_en',
'_teasertext_en',
'_teasertext_de',
'person_id',
'person_name',
'person_email',
'person_telephone',
'person_given_name',
'person_family_name',
'person_title',
'person_pronoun',
'person_suffix',
'person_nobility_name',
'person_organization',
'person_function',
];

Expand Down
1 change: 1 addition & 0 deletions src/scss/rrze-faudir.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ body {
background-color: var(--color-white);
box-shadow: 0 4px 8px var(--color-ContentBorders);
margin-bottom: 20px; border-radius: 8px;
margin:10px;
}
.contact-page-img-container{
display: flex;
Expand Down
128 changes: 76 additions & 52 deletions templates/single-custom_person.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,95 @@
?>

<main id="main" class="site-main">
<?php

<?php
while (have_posts()) :
the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<h1 class="entry-title"><?php the_title(); ?></h1>
</header>

<div class="entry-content">
<?php the_content(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div>
<div class="contact-page">
<div class="contact-page-img-container">
<div style="flex-grow: 1; max-width:70%">
<!-- Full name with title -->
<?php

<h2><?php _e('Additional Information', 'text-domain'); ?></h2>
<ul>
<?php
$fields = [
'person_id' => __('Person ID', 'text-domain'),
'person_name' => __('Name', 'text-domain'),
'person_email' => __('Email', 'text-domain'),
'person_telephone' => __('Telephone', 'text-domain'),
'person_given_name' => __('Given Name', 'text-domain'),
'person_family_name' => __('Family Name', 'text-domain'),
'person_title' => __('Title', 'text-domain'),
'person_pronoun' => __('Pronoun', 'text-domain'),
'person_function' => __('Function', 'text-domain'),
];
$fields = [
'person_id' => __('Person ID', 'text-domain'),
'person_name' => __('Name', 'text-domain'),
'person_email' => __('Email', 'text-domain'),
'person_telephone' => __('Telephone', 'text-domain'),
'person_given_name' => __('Given Name', 'text-domain'),
'person_family_name' => __('Family Name', 'text-domain'),
'person_title' => __('Title', 'text-domain'),
'person_suffix' => __('Suffix', 'text-domain'),
'person_nobility_name' => __('Nobility Name', 'text-domain'),
'person_organization' => __('Organization', 'text-domain'),
'person_function' => __('Function', 'text-domain'),
];
$personal_title = get_post_meta(get_the_ID(), 'person_title', true);
$first_name = get_post_meta(get_the_ID(), 'person_given_name', true);
$nobility_title = get_post_meta(get_the_ID(), 'person_nobility_name', true);
$last_name = get_post_meta(get_the_ID(), 'person_family_name', true);
$title_suffix = get_post_meta(get_the_ID(), 'person_suffix', true);

foreach ($fields as $meta_key => $label) :
$value = get_post_meta(get_the_ID(), $meta_key, true);
if (!empty($value)) :
?>
<li><strong><?php echo esc_html($label); ?>:</strong> <?php echo esc_html($value); ?></li>
<?php
endif;
endforeach;
?>
</ul>
$fullName = trim( $personal_title . ' ' . $first_name. ' '. $nobility_title . ' ' . $last_name . ' ' . $title_suffix);
?>
<!-- We need to add condition for url when we add CPT -->
<section class="card-section-title" aria-label="<?php echo esc_html($fullName); ?>"><?php echo esc_html($fullName); ?></a></section>

<?php
// Initialize output strings for email and phone
$email_output = get_post_meta(get_the_ID(), 'person_email', true);
$phone_output = get_post_meta(get_the_ID(), 'person_telephone', true);
$function_label = get_post_meta(get_the_ID(), 'person_function', true);
$organization_name = get_post_meta(get_the_ID(), 'person_telephone', true);

echo $email_output = '<strong><p>' . __('Email:', 'rrze-faudir') .'</strong>'. esc_html($email_output) .'</p>';
echo $phone_output = '<strong><p>' . __('Phone:', 'rrze-faudir') . '</strong>'. esc_html($phone_output) .'</p>';

<?php
$content_lang = get_post_meta(get_the_ID(), '_content_lang', true);
if (!empty($content_lang)) :
?>
<h2><?php _e('Content (Second Language)', 'text-domain'); ?></h2>
<div class="content-second-language">
<?php echo wp_kses_post($content_lang); ?>
</div>
<?php
endif;
?>

$teaser_lang = get_post_meta(get_the_ID(), '_teasertext_lang', true);
if (!empty($teaser_lang)) :
?>
<h2><?php _e('Teaser Text (Second Language)', 'text-domain'); ?></h2>
<div class="teaser-second-language">
<?php echo wp_kses_post($teaser_lang); ?>
<strong><p><?php echo __('Organization:', 'rrze-faudir');?></strong> <?php echo esc_html($organization_name); ?><p>
<strong><p><?php echo __('Functions:', 'rrze-faudir');?></strong> <?php echo esc_html($function_label); ?><p>

<?php
$locale = get_locale();
$content_en = get_post_meta(get_the_ID(), '_content_en', true);

?>
<h2><?php _e('Content (Second Language)', 'text-domain'); ?></h2>
<div class="content-second-language">
<?php echo wp_kses_post((($locale === 'de_DE') ? get_the_content() : $content_en)); ?>
</div>
<?php
$teaser_text_key = ($locale === 'de_DE') ? '_teasertext_de' : '_teasertext_en';
$teaser_lang = get_post_meta(get_the_ID(), $teaser_text_key, true);
if (!empty($teaser_lang)) :
?>
<h2><?php _e('Teaser Text (Second Language)', 'text-domain'); ?></h2>
<div class="teaser-second-language">
<?php echo wp_kses_post($teaser_lang); ?>
</div>
<?php
endif;
?>
</div>
<?php
endif;
?>
<?php $image_url = get_the_post_thumbnail_url($post->ID, 'full'); // You can specify the size ('full', 'medium', 'thumbnail', etc.)

?>
<?php if (!empty($image_url)) : ?>
<img src="<?php echo esc_url($image_url); ?>" alt="Person Image" />
<?php endif; ?>
</div>
</div>
</article>
</div>
</article>
<?php
endwhile;
?>
</main>

<?php
get_footer();
get_footer();

0 comments on commit cc53f29

Please sign in to comment.