<div class="middle-main content-cols2"> <?php } ?> <?php if ($sidebar_position == 'full') { ?> <div class="middle-main content-full"> <?php } ?> <div id="primary" class="content-area"> <div class="inner"> <?php $posts = tfuse_get_game_posts($post->ID, 'reviews'); ?> <section class="postlist postlist-blog ajax_section_load"> <!-- <h1><?php _e('About', 'tfuse'); ?> </h1> --> <?php if (!empty($posts)) { ?> <?php $k = 0; foreach ($posts as $id) { ?> <?php
function tfuse_ajax_get_game_posts() { $post_id = intval($_POST['post_id']); $posts_from = $_POST['posts_from']; $out = $out1 = $out2 = $out3 = $out4 = ''; //get news posts for current game post if ($posts_from == 'game_news') { $posts = tfuse_get_game_posts($post_id, 'news'); $out1 .= '<section class="postlist postlist-blog ajax_section_load"> <h1>' . __('News', 'tfuse') . '</h1>'; if (!empty($posts)) { $k = 0; foreach ($posts as $id) { $press_source = tfuse_page_options('press_source', '', $id); $press_author = tfuse_page_options('press_author', '', $id); $is_outer_link = !empty($press_source) ? true : false; $target_window = !empty($press_source) ? "_blank" : "_self"; $author_url = !empty($press_source) ? '' : get_author_posts_url($current_post->post_author, $user_data->data->user_nicename); $press_source = !empty($press_source) ? $press_source : get_permalink($post); $press_author = !empty($press_author) ? $press_author : $user_data->data->display_name; if ($k == get_option('posts_per_page')) { break; } $image = wp_get_attachment_url(get_post_thumbnail_id($id, 'post-thumbnails')); $img_pos = tfuse_page_options('single_img_position', '', $id); $current_post = get_post($id); $user_data = get_user_by('id', $current_post->post_author); $tmp_url = !empty($author_url) ? '<a href="' . $author_url . '">' . $press_author . '</a>' : '<span>' . $press_author . '</span>'; $out .= '<article class="post"> <div class="inner"> <div class="entry-aside"> <header class="entry-header"> <h1 class="entry-title"><a target="' . $target_window . '" href="' . $press_source . '">' . get_the_title($id) . '</a></h1> <div class="entry-meta"> ' . __('By ', 'tfuse') . '<span class="author">' . $tmp_url . '</span> ' . __(' on ', 'tfuse') . ' <time class="entry-date" datetime="">' . get_the_time(get_option('date_format'), $id) . '</time> </div> </header>'; if (!empty($image)) { $out .= '<a target="' . $target_window . '" class="post-thumbnail ' . $img_pos . ' clearfix" href="' . $press_source . '"><img src="' . $image . '" alt="' . get_the_title($id) . '"/></a>'; } $out .= '<div class="entry-content">'; if (tfuse_options('post_content') == 'content') { $out .= $current_post->post_content; } else { $out .= !empty($current_post->post_excerpt) ? $current_post->post_excerpt : strip_tags(tfuse_shorten_string(apply_filters('the_content', $current_post->post_content), 150)); } $tmp_comments = $is_outer_link ? '' : '<span class="comments-link"><a href="' . $author_url . '#comments"><i class="tficon-comment"></i> ' . get_comments_number($id) . '</a></span>'; $out .= '</div> <footer class="entry-meta"> <a target="' . $target_window . '" class="btn btn-default btn-xs" href="' . $press_source . '">' . __('Read more', 'tfuse') . '</a> ' . $tmp_comments . ' </footer> </div> </div> </article>'; $k++; } } else { $out .= '<h5>' . __('Sorry, no news for this game.', 'tfuse') . '</h5>'; } $out2 .= '</section>'; if (get_option('posts_per_page') < count($posts)) { $out3 .= '<div class="load_button"> <button type="submit" class="btn btn-main" id="load_game_posts" data-post-id="' . $post_id . '" data-from="game_news" >' . __('Load More', 'tfuse') . '</button> <button type="submit" class="btn btn-main" id="loading_game_posts">' . __('Loading...', 'tfuse') . '</button> </div>'; } } elseif ($posts_from == 'game_reviews') { $posts = tfuse_get_game_posts($post_id, 'reviews'); $out1 .= '<section class="postlist postlist-cols-1 ajax_section_load"> <h1>' . __('Description', 'tfuse') . '</h1>'; if (!empty($posts)) { $k = 0; foreach ($posts as $id) { if ($k == get_option('posts_per_page')) { break; } $rating = tfuse_page_options('rating', '', $id); $featured = tfuse_page_options('featured', '', $id); $current_post = get_post($id); $user_data = get_user_by('id', $current_post->post_author); $out .= '<article class="post"> <div class="inner"> <div class="entry-aside"> <header class="entry-header">'; //$out .= '<h1 class="entry-title">'.get_the_title($id).'</h1> // <div class="entry-meta"> $out .= ' </div> </header> <div class="entry-content">'; $out .= $current_post->post_content; $out .= '</div> </div> </div> </article>'; $k++; } } else { $out .= '<h5>' . __('Sorry, no reviews for this game.', 'tfuse') . '</h5>'; } $out2 .= '</section>'; if (get_option('posts_per_page') < count($posts)) { $out3 .= '<div class="load_button"> <button type="submit" class="btn btn-main" id="load_game_posts" data-post-id="' . $post_id . '" data-from="game_reviews">' . __('Load More', 'tfuse') . '</button> <button type="submit" class="btn btn-main" id="loading_game_posts">' . __('Loading...', 'tfuse') . '</button> </div>'; } } elseif ($posts_from == 'game_images') { $posts = tfuse_get_game_posts($post_id, 'images'); $terms = tfuse_get_game_filter_terms('gallery', 'galleries', $post_id); $out1 .= '<article class="post post-details portfolio"> <header class="entry-header"> <h1 class="entry-title">' . __('Images', 'tfuse') . '</h1> </header> <div class="entry-content"> <div class="top-filter terms-game-filter" id="gallery_filter"> <span class="top-filter-title">' . __('Filter', 'tfuse') . ':</span> <ul> <li><a href="" class="btn btn-simple btn-sm active" data-term="all" data-game-post="' . $post_id . '">' . __('All', 'tfuse') . '</a></li>'; if (!empty($terms)) { foreach ($terms as $term_id) { $term = get_term_by('id', $term_id, 'galleries'); $out1 .= '<li><a href="" class="btn btn-simple btn-sm" data-term="' . $term->term_id . '" data-game-post="' . $post_id . '">' . $term->name . '</a></li>'; } } $out1 .= '</ul> </div> <ul class="portfolio-list ajax_section_load" id="game-portfolio-list" >'; if (!empty($posts)) { $k = 0; $pretty = tfuse_options('portf_type'); foreach ($posts as $id) { if ($k == get_option('posts_per_page')) { break; } $image = wp_get_attachment_url(get_post_thumbnail_id($id, 'post-thumbnails')); if ($pretty == 'pretty') { $rel = 'data-rel="prettyPhoto[gallery]"'; $url = wp_get_attachment_url(get_post_thumbnail_id($id, 'post-thumbnails')); } else { $rel = ''; $url = get_permalink($id); } $out .= '<li> <a href="' . $url . '" ' . $rel . ' title="' . get_the_title($id) . '">'; if (!empty($image)) { $out .= '<img src="' . $image . '" />'; } else { $out .= '<img src="' . get_template_directory_uri() . '/images/gallery_small.jpg" width="166" height="166" alt=""/>'; } $out .= '</a> </li>'; $k++; } } else { $out .= '<h5>' . __('Sorry, no images for this game.', 'tfuse') . '</h5>'; } $out2 .= '</ul>'; if (get_option('posts_per_page') < count($posts)) { $out3 .= '<div class="load_button"> <button type="submit" class="btn btn-main" data-post-id="' . $post_id . '" data-from="game_images" id="load_game_posts" value="Send">' . __('Load More', 'tfuse') . '</button> <button type="submit" class="btn btn-main" id="loading_game_posts">' . __('Loading...', 'tfuse') . '</button> </div>'; } $out4 .= '</article>'; } elseif ($posts_from == 'game_videos') { $posts = tfuse_get_game_posts($post_id, 'videos'); $terms = tfuse_get_game_filter_terms('video', 'videos', $post_id); $out1 .= '<article class="post post-details portfolio portfolio-videos"> <header class="entry-header"> <h1 class="entry-title">' . __('Videos', 'tfuse') . '</h1> </header> <div class="entry-content"> <div class="top-filter terms-game-filter" id="video_filter"> <span class="top-filter-title">' . __('Filter', 'tfuse') . ':</span> <ul> <li><a href="" class="btn btn-simple btn-sm active" data-term="all" data-game-post="' . $post_id . '">' . __('All', 'tfuse') . '</a></li>'; if (!empty($terms)) { foreach ($terms as $term_id) { $term = get_term_by('id', $term_id, 'videos'); $out1 .= '<li><a href="" class="btn btn-simple btn-sm" data-term="' . $term->term_id . '" data-game-post="' . $post_id . '">' . $term->name . '</a></li>'; } } $out1 .= '</ul> </div> <ul class="portfolio-list ajax_section_load" id="game-portfolio-list">'; if (!empty($posts)) { $k = 0; foreach ($posts as $id) { if ($k == get_option('posts_per_page')) { break; } $video = tfuse_page_options('video_links', '', $id); $image = wp_get_attachment_url(get_post_thumbnail_id($id, 'post-thumbnails')); $video_link = !empty($video) ? $video : wp_get_attachment_url(get_post_thumbnail_id($id, 'post-thumbnails')); $out .= '<li> <a data-rel="prettyPhoto" title="' . get_the_title($id) . '" href="' . $video_link . '">'; if (!empty($image)) { $out .= '<img src="' . $image . '" />'; } else { $out .= '<img src="' . get_template_directory_uri() . '/images/gallery_medium.jpg" width="333" height="222" alt=""/>'; } $out .= '</a> <h4><a class="video_link" href="' . get_permalink($id) . '">' . get_the_title($id) . '</a></h4> </li>'; $k++; } } else { $out .= '<h5>' . __('Sorry, no images for this game.', 'tfuse') . '</h5>'; } $out2 .= '</ul>'; if (get_option('posts_per_page') < count($posts)) { $out3 .= '<div class="load_button"> <button type="submit" class="btn btn-main" data-post-id="' . $post_id . '" data-from="game_videos" id="load_game_posts" value="Send">' . __('Load More', 'tfuse') . '</button> <button type="submit" class="btn btn-main" id="loading_game_posts">' . __('Loading...', 'tfuse') . '</button> </div>'; } $out4 .= '</article>'; } elseif ($posts_from == 'game_guides') { $posts = $first_term = ''; $terms = tfuse_get_game_filter_terms('guide', 'guides', $post_id, true); if (!empty($terms)) { foreach ($terms as $term_id) { $term = get_term_by('id', $term_id, 'guides'); $posts = tfuse_get_game_posts($post_id, 'guides', $term->term_id); break; } } $out1 .= '<article class="post post-details portfolio"> <header class="entry-header"> <h1 class="entry-title">' . __('Guides', 'tfuse') . '</h1> </header> <div class="entry-content"> <div class="top-filter terms-game-filter" id="guides_filter"> <span class="top-filter-title">' . __('Filter', 'tfuse') . ':</span> <ul>'; if (!empty($terms)) { $k = 0; foreach ($terms as $term_id) { $k++; $term = get_term_by('id', $term_id, 'guides'); if ($k == 1) { $first_term = $term->term_id; $out1 .= '<li><a href="" class="btn btn-simple btn-sm active" data-term="' . $term->term_id . '" data-game-post="' . $post_id . '">' . $term->name . '</a></li>'; } else { $out1 .= '<li><a href="" class="btn btn-simple btn-sm" data-term="' . $term->term_id . '" data-game-post="' . $post_id . '">' . $term->name . '</a></li>'; } } } $out1 .= '</ul> </div> <div class="tab-content"> <div class="postlist postlist-simple ajax_section_load" id="game-portfolio-list">'; if (!empty($posts)) { $download = !empty($terms) ? tfuse_options('guides_posts', '', $terms[0]) : ''; $k = 0; if ($download == 'download') { foreach ($posts as $id) { if ($k == get_option('posts_per_page')) { break; } $current_post = get_post($id); //get download link $file = tfuse_page_options('upload_guide', '', $id); //get user data $user_data = get_user_by('id', $current_post->post_author); $out .= '<div class="post"> <h2 class="entry-title"><a href="' . get_permalink($id) . '">' . get_the_title($id) . '</a></h2>'; if (!empty($file)) { $out .= '<div class="entry-side-btn"> <a class="btn btn-default btn-xs" href="' . $file . '" target="_blank">' . __('Download', 'tfuse') . '</a> </div>'; } $out .= '<div class="entry-meta"> ' . __('By ', 'tfuse') . '<span class="author"><a href="' . get_author_posts_url($current_post->post_author, $user_data->data->user_nicename) . '">' . $user_data->data->display_name . '</a></span> ' . __(' on ', 'tfuse') . '<time class="entry-date" datetime="">' . get_the_time(get_option('date_format'), $id) . '</time> </div> </div>'; $k++; } } else { foreach ($posts as $id) { if ($k == get_option('posts_per_page')) { break; } $current_post = get_post($id); $out .= '<div class="post"> <h2 class="entry-title"><a href="' . get_permalink($id) . '">' . get_the_title($id) . '</a></h2> <div class="entry-content ">'; if (tfuse_options('post_content') == 'content') { $out .= $current_post->post_content; } else { $out .= !empty($current_post->post_excerpt) ? $current_post->post_excerpt : strip_tags(tfuse_shorten_string(apply_filters('the_content', $current_post->post_content), 150)); } $out .= '</div> </div>'; $k++; } } } else { $out .= '<h5>' . __('Sorry, no guides for this game.', 'tfuse') . '</h5>'; } $out2 .= '</div></div>'; if (get_option('posts_per_page') < count($posts)) { $out3 .= '<div class="load_button"> <button type="submit" class="btn btn-main" data-post-id="' . $post_id . '" data-term-id="' . $first_term . '" data-from="game_guides" id="load_game_posts" >' . __('Load More', 'tfuse') . '</button> <button type="submit" class="btn btn-main" id="loading_game_posts">' . __('Loading...', 'tfuse') . '</button> </div>'; } $out4 .= '</article>'; } $rsp = array('html' => $out1 . $out . $out2 . $out3 . $out4); echo json_encode($rsp); die; }