Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // get film rating from kinopoisk and imdb - example [get_rating film="6750" site="kp"]
- add_shortcode('get_rating', 'get_rating_func');
- function get_rating_func( $atts ) {
- $film = $atts['film'];
- $site = $atts['site'];
- $rating = [];
- $xml = simplexml_load_file( 'https://rating.kinopoisk.ru/' . $film . '.xml' );
- $names = ['kp_rating', 'imdb_rating'];
- foreach ( $names as $name ) {
- $new_name = str_replace( '_rating', '', $name );
- $rating[ $new_name ] = dom_import_simplexml( $xml->$name )->nodeValue;
- }
- return $rating[$site];
- }
Add Comment
Please, Sign In to add comment