Ejemplo n.º 1
0
 public static function get_post_data($posttype, $component, $id = false)
 {
     $info = array();
     if ($id !== false) {
         $post_link = get_permalink($id);
     } else {
         $post_link = '#';
     }
     $images = array();
     if ($component == 'theme') {
         $images = Voyage::get_voyage_images($id);
         $terms = get_the_terms($id, 'theme');
         $term = $terms[0];
         $info['post_link'] = $post_link;
         $info['title'] = ucwords(get_the_title($id));
         $info['subtitle'] = $term->name;
         $info['image_url'] = $images['image_url'];
         $info['thumbnail_image'] = $images['thumbnail_image'];
         $info['thumbnail_url'] = $images['thumbnail_url'];
     }
     if ($component == 'promotions') {
         $images = Voyage::get_voyage_images($id);
         if (!empty($images)) {
             $info['post_link'] = $post_link;
             $info['title'] = ucwords(get_the_title($id));
             $info['subtitle'] = get_post_meta($id, 'slogan')[0];
             $info['image_url'] = $images['image_url'];
             $info['thumbnail_image'] = $images['thumbnail_image'];
             $info['thumbnail_url'] = $images['thumbnail_url'];
         }
     }
     if ($component == 'brochures') {
         $images = Voyage::get_voyage_images($id);
         if (!empty($images)) {
             $info['post_link'] = $images['image_url'];
             $info['title'] = ucwords(get_the_title($id));
             $info['subtitle'] = get_post_meta($id, 'slogan')[0];
             $info['image_url'] = $images['image_url'];
             $info['thumbnail_image'] = $images['thumbnail_image'];
             $info['thumbnail_url'] = $images['thumbnail_url'];
         }
     }
     if ($component == 'all' && $posttype != 'team' && $posttype != 'jetpack-testimonial' && $posttype != 'facility') {
         $images = Voyage::get_voyage_images($id);
         if (!empty($images)) {
             $info['post_link'] = $post_link;
             $info['title'] = ucwords(get_the_title($id));
             $info['subtitle'] = '';
             $info['image_url'] = $images['image_url'];
             $info['thumbnail_image'] = $images['thumbnail_image'];
             $info['thumbnail_url'] = $images['thumbnail_url'];
         }
     }
     if ($posttype == 'team') {
         //Users
         $users = Users::getUserList(['contributor'], true);
         foreach ($users as $user) {
             $user_id = $user['ID'];
             $row['post_link'] = $post_link;
             $row['title'] = Users::getFullName($user_id);
             $row['image_url'] = Users::getProfilePicture($user_id);
             $row['thumbnail_image'] = Users::getProfilePicture($user_id, 'thumbnail_image');
             $row['thumbnail_url'] = Users::getProfilePicture($user_id, 'thumbnail_url');
             $job_title = Users::getJobTitle($user_id);
             $social = Users::getContactButtons($user);
             $subtitle = '';
             if (!empty($job_title)) {
                 if (!empty($social)) {
                     $subtitle = $job_title . '<br><br>' . $social;
                 } else {
                     $subtitle = $job_title;
                 }
             } else {
                 if (!empty($social)) {
                     $subtitle = $social;
                 }
             }
             $row['subtitle'] = $subtitle;
             $info[] = $row;
             $row = array();
         }
     }
     if ($posttype == 'jetpack-testimonial' || $posttype === 'facility') {
         $info['post_link'] = $post_link;
         $info['title'] = ucwords(get_the_title($id));
         $info['subtitle'] = Post::getPostContent($id);
         $images = Post::getImages($id);
         if (!empty($images)) {
             $info['image_url'] = $images['image_url'];
             $info['thumbnail_image'] = $images['thumbnail_image'];
             $info['thumbnail_url'] = $images['thumbnail_url'];
         } else {
             $info['image_url'] = '#';
             $info['thumbnail_image'] = '#';
             $info['thumbnail_url'] = '#';
         }
     }
     if ($component == 'location') {
         $images = Voyage::get_voyage_images($id);
         if (!empty($images)) {
             $terms = get_the_terms($id, 'location');
             $term = $terms[0];
             $info['post_link'] = $post_link;
             $info['title'] = ucwords(get_the_title($id));
             $info['subtitle'] = $term->name;
             $info['image_url'] = $images['image_url'];
             $info['thumbnail_image'] = $images['thumbnail_image'];
             $info['thumbnail_url'] = $images['thumbnail_url'];
         }
     }
     return $info;
 }
Ejemplo n.º 2
0
         <div class="content">
             Voyages
             <div class="sub header"></div>
         </div>
     </h1>
     <div id="search-results" class="search-results">
     <?php 
 $query = new WP_Query($args);
 $data = array();
 if ($query->have_posts()) {
     while ($query->have_posts()) {
         $query->the_post();
         $id = $query->post->ID;
         $title = get_the_title($id);
         $post_link = get_permalink($id);
         $images = Voyage::get_voyage_images($id);
         /*echo "Encontrado:".$title;
           echo"<pre>";
           print_r($images);
           echo"</pre>";*/
         $info['post_link'] = $post_link;
         $info['image_url'] = $images['image_url'];
         $info['title'] = $title;
         $data[] = $info;
     }
     /*echo"<pre>";
       print_r($data);
       echo"</pre>";*/
     Card::display_card_simple($data);
     //Showcase::get_component('card',$data);
     ?>