GamerSK

get_telnumbers()

Sep 7th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. // Telnumbers function
  2. function get_telnumbers() {
  3.  
  4.     switch_to_blog( 1 );
  5.  
  6.     $output = '';
  7.  
  8.     $posts = get_posts( array( 'post_type' => 'telnumbers',
  9.                                'posts_per_page' => -1 ) );
  10.  
  11.     foreach ( $posts as $post ) {
  12.         if ( ip_info( 'Visitor', 'Country Code' ) == $post->post_title ) {
  13.             $output = '<p>'.ip_info( 'Visitor', 'Country Code' ).': '.$post->post_content.'</p>';
  14.             break;
  15.         }
  16.     }
  17.  
  18.     if ( $output == '' ) {
  19.         foreach ( $posts as $post ) {
  20.             if ( $post->post_title == 'Unset' ) {
  21.                 $output = '<p>'.ip_info( 'Visitor', 'Country Code' ).': '.$post->post_content.'</p>';
  22.                 break;
  23.             }
  24.         }
  25.     }
  26.  
  27.     restore_current_blog();
  28.  
  29.     return $output;
  30.  
  31.     unset( $posts, $post );
  32. }
  33. add_shortcode( 'get-telnumbers', 'get_telnumbers' );
Advertisement
Add Comment
Please, Sign In to add comment