Skip to content

Commit

Permalink
Merge pull request sudweb#122 from goulvench/108-speaker-description-…
Browse files Browse the repository at this point in the history
…language

Wrap speaker description with a div specifying language, fixes sudweb#108
  • Loading branch information
DirtyF committed Apr 15, 2012
2 parents 4e96011 + 8501e0b commit 114c9f8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
13 changes: 13 additions & 0 deletions functions.php
Expand Up @@ -293,3 +293,16 @@ function theme_excerpt_more($more) {
global $post;
return '… <a href="'. get_permalink($post->ID) . '" title="'. get_the_title($post->ID) .'" rel="bookmark">'.__('(more...)').'</a>';
}

/**
* Echoes the lang attribute, whatever the post type
* @return null
*/
function sudweb_the_lang_attribute() {
global $post;
$func = $post->post_type . '_lang_attribute';
if (function_exists($func)){
$func();
}
return;
}
15 changes: 15 additions & 0 deletions lib/plugin/speaker.php
Expand Up @@ -49,3 +49,18 @@ function sudweb_register_speaker()
)
));
}

/**
* Displays the lang attribute for a given speaker
*
* @param null $speaker_id
* @return null
*/
function speaker_lang_attribute($speaker_id = null)
{
echo str_replace(
array('Français', 'Anglais', 'English'),
array('fr', 'en', 'en'),
trim(get_field('language', $speaker_id === null ? get_the_ID() : $speaker_id))
);
}
3 changes: 2 additions & 1 deletion page-article.php
Expand Up @@ -9,6 +9,7 @@
<?php endif; ?>
</h1>
</header>

<div lang="<?php sudweb_the_lang_attribute() ?>">
<?php the_content() ?>
</div>
</article>

0 comments on commit 114c9f8

Please sign in to comment.