Advertisement
Guest User

Untitled

a guest
Jul 14th, 2012
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.17 KB | None | 0 0
  1. <?php
  2. /*
  3.  Template Name: Grid Gallery
  4.  Displays the portfolio items in a grid, separated by pages. The items can be also
  5.  filtered by a category.
  6.  */
  7. get_header();
  8.  
  9.  
  10. if(have_posts()){
  11.     while(have_posts()){
  12.         the_post();
  13.        
  14.         //get all the page meta data (settings) needed (function located in lib/functions/meta.php)
  15.         $page_settings=pexeto_get_post_meta($post->ID, array('show_filter', 'show_info', 'post_category', 'post_number', 'slider',
  16.         'order', 'image_width', 'desaturate', 'show_back_btn_end'));
  17.        
  18.         //create a data object that will be used globally by the other files that are included
  19.         $pex_page=new stdClass();
  20.         $pex_page->layout='grid-full';
  21.         $pex_page->show_title='off';
  22.         $pex_page->slider='none';
  23.        
  24.         //include the before content template
  25.         locate_template( array( 'includes/html-before-content.php'), true, true );
  26.         wp_reset_postdata();
  27.     }
  28. }
  29.  
  30. //ADD THE ADDITIONAL SCRIPTS NEEDED
  31. global $pexeto_scripts_to_print;
  32. if($page_settings['desaturate']=='true'){
  33.     //load the desaturation script
  34.     $pexeto_scripts_to_print[]='pexeto-desaturate';
  35. }
  36. $isiPad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');
  37. $isiPhone = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPhone');
  38. $isiPod = (bool) stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
  39.  
  40. if($isiPad || $isiPhone || $isiPod){
  41.     //load the iScroll script for the horizontal slider
  42.     $pexeto_scripts_to_print[]='pexeto-iscroll';
  43. }
  44.  
  45. $gallery_class=$page_settings['show_filter']!='false'?'with-filter':'no-filter';
  46. ?>
  47.  
  48. <div id="grid-gallery-wrapper" class="loading <?php echo $gallery_class; ?>">
  49. <div id="gallery-container">
  50.  
  51. <?php
  52. //generate the categories in JSON format
  53. if($page_settings['show_filter']!='false'){
  54.     $args=array("hide_empty"=>false, "hierarchical"=>true);
  55.     if($page_settings['post_category']!='-1'){
  56.         $args['parent']=$page_settings['post_category'];
  57.     }
  58.     $cats=get_terms('portfolio_category', $args);
  59.     $cat_arr=array();
  60.     foreach($cats as $cat){
  61.         $cat_arr[]=array("id"=>$cat->term_id, "name"=>$cat->name);
  62.     }
  63.     $cats_to_json = json_encode($cat_arr);
  64. }else{
  65.     $cats_to_json='[]';
  66. }
  67.  
  68. ?>
  69. </div>
  70. </div>
  71.  
  72. <script type="text/javascript">
  73. jQuery(document).ready(function($){
  74.     $('#grid-gallery-wrapper').pexetoGridGallery({
  75.         itemsPerPage:<?php echo $page_settings['post_number']; ?>,
  76.         showCategories:<?php echo $page_settings['show_filter']; ?>,
  77.         imageWidth:<?php echo $page_settings['image_width']; ?>,
  78.         showInfo:<?php echo $page_settings['show_info']; ?>,
  79.         ajaxUrl:"<?php echo admin_url( 'admin-ajax.php' ); ?>",
  80.         category:<?php echo $page_settings['post_category']; ?>,
  81.         categories:<?php echo $cats_to_json; ?>,
  82.         allText:"<?php echo pex_text("_all_text"); ?>",
  83.         filterText:"<?php echo pex_text("_filter_text"); ?>",
  84.         loadMoreText:"<?php echo pex_text("_load_more_text"); ?>",
  85.         backText:"<?php echo pex_text("_back_to_gallery_text"); ?>",
  86.         orderBy:"<?php echo $page_settings['order']; ?>",
  87.         desaturate:<?php echo $page_settings['desaturate']; ?>,
  88.         showBackBtnEnd:<?php echo $page_settings['show_back_btn_end']; ?>
  89.         });
  90. });
  91. </script>
  92. <?php
  93.  
  94. //include the after content template
  95. locate_template( array( 'includes/html-after-content.php'), true, true );
  96.  
  97. get_footer();
  98. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement