Created
August 5, 2016 17:25
-
-
Save caercam/efc7c6ccb8b4680c98611bc79def6893 to your computer and use it in GitHub Desktop.
Format IMDb ID to create a link to IMDb.com
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
<?php | |
/** | |
* Format IMDb ID to create a link to IMDb.com | |
* | |
* @param string $imdb_id IMDb ID | |
* | |
* @return string | |
*/ | |
function wpmoly_format_movie_imdb_id( $imdb_id = '' ) { | |
$imdb_id = (string) $imdb_id; | |
if ( empty( $imdb_id ) ) { | |
return ''; | |
} | |
$url = "http://www.imdb.com/title/{$imdb_id}/"; | |
return '<a href="' . esc_url( $url ) . '">' . esc_html( $imdb_id ) . '</a>'; | |
} | |
add_filter( 'wpmoly_format_movie_imdb_id', 'wpmoly_format_movie_imdb_id', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment