Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.29 KB | None | 0 0
  1. <?php
  2. if(isset($_REQUEST["um_load_more"]) && $_REQUEST["um_load_more"]):
  3. if(is_tax()){
  4. $the_query = $wp_query;
  5. }else{
  6. $arguments = array();
  7. $arguments["post_type"] = "portfolio";
  8. $exlucde_cats = get_field("exclude_categories");
  9. $exlucde_cats_arr = array();
  10. if($exlucde_cats){
  11. foreach($exlucde_cats as $cat){
  12. array_push($exlucde_cats_arr,$cat->slug);
  13. }
  14. $filter_categories = array();
  15. if($_REQUEST['filter'] != 'popular' && $_REQUEST['filter'] != 'recent'){
  16. $filter_categories = array(
  17. 'taxonomy' => 'portfolio_category',
  18. 'field' => 'slug',
  19. 'terms' => $_REQUEST['filter'],
  20. 'operator' => 'IN'
  21. );
  22. }
  23. $arguments["tax_query"] = array(
  24. 'relation' => 'AND',
  25. array(
  26. 'taxonomy' => 'portfolio_category',
  27. 'field' => 'slug',
  28. 'terms' => $exlucde_cats_arr,
  29. 'operator' => 'NOT IN'
  30. )
  31. );
  32. if($filter_categories){
  33. array_push($arguments["tax_query"],$filter_categories);
  34. }
  35. }else{
  36. if($_REQUEST['filter'] != 'popular' && $_REQUEST['filter'] != 'recent'){
  37. $filter_categories = array(
  38. 'taxonomy' => 'portfolio_category',
  39. 'field' => 'slug',
  40. 'terms' => $_REQUEST['filter'],
  41. 'operator' => 'IN'
  42. );
  43. $arguments["tax_query"] = array(
  44. $filter_categories
  45. );
  46. }
  47. }
  48. $arguments["posts_per_page"] = get_field("number_of_projects") ? get_field("number_of_projects") : 6;
  49. /*Recent Posts Order*/
  50. if($_REQUEST['filter'] == 'popular'){
  51. $arguments["meta_key"] = "um_project_views";
  52. $arguments["orderby"] = "meta_value_num";
  53. }
  54. $arguments["paged"] = $_REQUEST['um_page'];
  55. /*Recent Posts Order*/
  56. $the_query = new WP_Query( $arguments );
  57. }
  58. while ( $the_query->have_posts() ) : $the_query->the_post();
  59. global $post;
  60. setup_postdata($post);
  61. $img = get_post_featured_image_src();
  62. $terms = wp_get_post_terms( $post->ID,"portfolio_category" );
  63. $terms_html_array = array();
  64. $terms_id_array = array();
  65. $term_classes = "";
  66. foreach($terms as $t){
  67. $term_name = $t->name;
  68. $term_link = get_term_link($t->slug,$t->taxonomy);
  69. array_push($terms_html_array,"<span>{$term_name}</span>");
  70. array_push($terms_id_array,$t->slug);
  71. $term_classes .= "um_".$t->slug." ";
  72. }
  73. $terms_html_array = implode(", ",$terms_html_array);
  74. ?>
  75. <div class="project_con col-xs-12 col-sm-6 col-md-4 animated fadeIn">
  76. <a href="<?php the_permalink(); ?>">
  77. <div class="post_thumb_hover_holder">
  78. <div class="post_thumb_hover">
  79. <div class="p_hover_el ">
  80. <ul>
  81. <?php echo $GLOBALS["um_hover_state"]; ?>
  82. <li><?php the_title(); ?></li>
  83. <li><?php echo $terms_html_array; ?></li>
  84. </ul>
  85. </div>
  86. </div>
  87. </div>
  88. </a>
  89. <div class="post_thumb">
  90. <a href="<?php the_permalink(); ?>">
  91. <?php if($img): ?>
  92. <img src="<?php echo aq_resize($img,350 * 2); ?>" alt=""/>
  93. <?php endif; ?>
  94. </a>
  95. </div>
  96. </div>
  97. <?php
  98. endwhile;
  99. if($the_query->post_count):
  100. ?>
  101. <script type="text/javascript">
  102. jQuery(document).ready(function($){
  103. function center_hovers(){
  104. $(".project_con").each(function(){
  105. var hover_child = $(this).find(".p_hover_el");
  106. var hover_parent = $(this).find(".post_thumb_hover");
  107. center_vertically(hover_parent,hover_child,0);
  108. center_horizontally(hover_parent,hover_child,0);
  109. });
  110. }
  111.  
  112. $(".masonry_works").waitForImages(function(){
  113. center_hovers();
  114. });
  115. });
  116. </script>
  117. <?php
  118. endif;die;endif;
  119. /*Template Name:Home Masonry*/
  120. get_header();
  121. ?>
  122. <div class="col-sm-12 home_top">
  123. <?php
  124. if(is_tax()):
  125. $portfolio_category = get_query_var("portfolio_category");
  126. $portfolio_category = get_term_by("slug",$portfolio_category,"portfolio_category");
  127. ?>
  128. <h2><?php echo $portfolio_category->name; ?></h2>
  129. <?php endif; ?>
  130. <?php if(get_field("heading_text")): ?>
  131. <h2><?php the_field("heading_text"); ?></h2>
  132. <?php endif; ?>
  133. <?php if(get_field("subheading_text")): ?>
  134. <p><?php the_field("subheading_text"); ?></p>
  135. <?php endif; ?>
  136. <?php if(get_field("button_text") && get_field("button_url")): ?>
  137. <a class="button_u" href="<?php the_field("button_url"); ?>"><?php the_field("button_text"); ?></a>
  138. <?php endif; ?>
  139. </div>
  140. <?php if(!is_tax()): ?>
  141. <div class="filters">
  142. <ul class="col-sm-12">
  143. <li><a class="filter_popular" href="#"><?php _e("Popular","um_lang"); ?></a></li>
  144. <li><a class="filter_recent" href="#"><?php _e("Recent","um_lang"); ?></a></li>
  145. <li><a class="show_sort_categories" href="#"><?php _e("Category","um_lang"); ?><i class="fa fa-sort"></i></a>
  146. <div class="filter_category">
  147. <ul>
  148. <?php
  149. $exlucde_cats = get_field("exclude_categories");
  150. $exlucde_cats_arr = array();
  151. if($exlucde_cats){
  152. foreach($exlucde_cats as $cat){
  153. array_push($exlucde_cats_arr,$cat->term_id);
  154. }
  155. }
  156. $list_terms = get_terms("portfolio_category",array('exclude'=>$exlucde_cats_arr));
  157. foreach($list_terms as $term):
  158. ?>
  159. <li><a class="filter_cat" href="<?php echo $term->slug; ?>"><?php echo $term->name; ?></a></li>
  160. <?php endforeach; ?>
  161. </ul>
  162. </div>
  163. </li>
  164. </ul>
  165. </div>
  166. <?php endif; ?>
  167. <div class="clearfix"></div>
  168. <div class="masonry_works load_posts">
  169. <?php
  170. if(is_tax()){
  171. $the_query = $wp_query;
  172. }else{
  173. $arguments = array();
  174. $arguments["post_type"] = "portfolio";
  175. $exlucde_cats = get_field("exclude_categories");
  176. $exlucde_cats_arr = array();
  177. if($exlucde_cats){
  178. foreach($exlucde_cats as $cat){
  179. array_push($exlucde_cats_arr,$cat->slug);
  180. }
  181. $arguments["tax_query"] = array(array(
  182. 'taxonomy' => 'portfolio_category',
  183. 'field' => 'slug',
  184. 'terms' => $exlucde_cats_arr,
  185. 'operator' => 'NOT IN'
  186. ));
  187. }
  188. $arguments["posts_per_page"] = get_field("number_of_projects") ? get_field("number_of_projects") : 6;
  189. /*Recent Posts Order*/
  190. if(get_field("order_of_projects") != "Recent"){
  191. $arguments["meta_key"] = "um_project_views";
  192. $arguments["orderby"] = "meta_value_num";
  193. }
  194. /*Recent Posts Order*/
  195. $the_query = new WP_Query( $arguments );
  196. }
  197. while ( $the_query->have_posts() ) : $the_query->the_post();
  198. global $post;
  199. setup_postdata($post);
  200. $img = get_post_featured_image_src();
  201. $terms = wp_get_post_terms( $post->ID,"portfolio_category" );
  202. $terms_html_array = array();
  203. $terms_id_array = array();
  204. $term_classes = "";
  205. foreach($terms as $t){
  206. $term_name = $t->name;
  207. $term_link = get_term_link($t->slug,$t->taxonomy);
  208. array_push($terms_html_array,"<span>{$term_name}</span>");
  209. array_push($terms_id_array,$t->slug);
  210. $term_classes .= "um_".$t->slug." ";
  211. }
  212. $terms_html_array = implode(", ",$terms_html_array);
  213. ?>
  214. <div class="project_con col-xs-12 col-sm-6 col-md-4 animated fadeIn">
  215. <a href="<?php the_permalink(); ?>">
  216. <div class="post_thumb_hover_holder">
  217. <div class="post_thumb_hover">
  218. <div class="p_hover_el ">
  219. <ul>
  220. <?php echo $GLOBALS["um_hover_state"]; ?>
  221. <li><?php the_title(); ?></li>
  222. <li><?php echo $terms_html_array; ?></li>
  223. </ul>
  224. </div>
  225. </div>
  226. </div>
  227. </a>
  228. <div class="post_thumb">
  229. <a href="<?php the_permalink(); ?>">
  230. <?php if($img): ?>
  231. <img src="<?php echo aq_resize($img,350 * 2); ?>" alt=""/>
  232. <?php endif; ?>
  233. </a>
  234. </div>
  235. </div>
  236. <?php endwhile; ?>
  237. </div>
  238. <div class="clearfix"></div>
  239. <div class="col-sm-12 load_more_btn">
  240. <?php if($the_query->max_num_pages > 1): ?>
  241. <a class="button_u load_more" href="#"><i class="fa fa-repeat"></i><?php _e("Load More","um_lang"); ?></a>
  242. <div class="spinner"></div>
  243. <?php endif;wp_reset_postdata(); ?>
  244. </div>
  245. <?php if(get_field("display_footer") != "Disabled"): ?>
  246. <div class="sidebar1">
  247. <?php dynamic_sidebar('sidebar'); ?>
  248. </div>
  249. <?php endif; ?>
  250. <script type="text/javascript">
  251. paged_projects = 1;
  252. filter = '<?php echo get_field("order_of_projects") == "Recent" ? "recent" : "popular"; ?>';
  253. jQuery(document).ready(function($){
  254. $("body").attr("class",$(".body_class_container a").attr("class"));
  255. function center_hovers(){
  256. $(".project_con").each(function(){
  257. var hover_child = $(this).find(".p_hover_el");
  258. var hover_parent = $(this).find(".post_thumb_hover");
  259. center_vertically(hover_parent,hover_child,0);
  260. center_horizontally(hover_parent,hover_child,0);
  261. });
  262. }
  263.  
  264. $(".inner_content").waitForImages(function(){
  265. $(".masonry_works").masonry({
  266. itemSelector: '.project_con',
  267. isResizable: false
  268. });
  269. center_hovers();
  270. });
  271.  
  272. $(window).load(function(){
  273. $(".masonry_works").masonry({
  274. itemSelector: '.project_con',
  275. isResizable: false
  276. });
  277. center_hovers();
  278. });
  279.  
  280. $(window).smartresize(function(){
  281. center_hovers();
  282. });
  283. });
  284. </script>
  285. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement