Created
July 25, 2014 07:21
-
-
Save caercam/cf57b979d795ba3e83aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Show some info about movies in post view. | |
* | |
* Add a filter on the_content hook to display infos selected in options | |
* about the movie: year, director, actors... | |
* | |
* @since 1.0.0 | |
* | |
* @param string $content The original post content | |
* | |
* @return string The filtered content containing original content plus movie infos if available, the untouched original content else. | |
*/ | |
function wpml_movies_infos( $content ) { | |
if ( 'movie' != get_post_type() ) | |
return $content; | |
$template = <<<EOF | |
<table style="width: 290px; float: left; margin: 10px; height: 303px;"> | |
<tbody> | |
<tr> | |
<td class="titre" style="background: #0F1718; height: 65px; text-align: center; font-size: 18pt; line-height: 25px; -moz-border-radius: 5px; border-radius: 5px;"><span style="color: #ffffff;">[movie_title label="no"]</span></td> | |
</tr> | |
<tr> | |
<td class="infos" style="background: #192122; height: 168px; -moz-border-radius: 5px;"> | |
<address style="font-size: 8.5pt;"><span style="color: #ffffff;">[movie_poster] Réalisé par [movie_director label="no"]</span></address><address style="font-size: 8.5pt;"><span style="color: #ffffff;"> Avec [movie_actors label="no" count="4"]</span></address> | |
<address style="font-size: 8.5pt;"> </address> | |
<address style="font-size: 8.5pt;"><span style="color: #ffffff;">Long-métrage [movie_country label="no"]<br></span></address> <address style="font-size: 8.5pt;"><span style="color: #ffffff;">Genres : [movie_genres label="no"]<br></span></address> <address style="font-size: 8.5pt;"><span style="color: #ffffff;">Durée : [movie_runtime label="no"]</span></address> | |
<address style="font-size: 8.5pt;"><span style="color: #ffffff;">Année de production : [movie_release_date label="no"]</span></address> | |
</td> | |
</tr> | |
<tr> | |
<td class="note" style="background: #232B2C; text-align: center; font-size: 24pt; height: 50px; color: green; -moz-border-radius: 5px;"><span style="color: #008000;">[movie_rating raw="yes"]/5</span></td> | |
</tr> | |
</tbody> | |
</table> | |
EOF; | |
$content = $template . $content; | |
return $content; | |
} | |
add_filter( 'the_content', 'wpml_movies_infos' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment