wp/wp-content/plugins/portfolio/template/portfolio.php
changeset 0 d970ebf37754
child 5 5e2f62d02dcd
equal deleted inserted replaced
-1:000000000000 0:d970ebf37754
       
     1 <?php
       
     2 /*
       
     3 Template Name: Portfolio template
       
     4 */
       
     5 
       
     6 get_header(); ?>
       
     7 
       
     8 <?php global $wp_query;
       
     9 $portfolio_options = get_option( 'prtfl_options' ); ?>
       
    10 		<div id="container" class="site-content">
       
    11 			<div id="content" class="hentry">
       
    12 				<div class="breadcrumbs home_page_title entry-header">
       
    13 				<?php if( isset( $wp_query->query_vars["technologies"] ) ) {
       
    14 					$term = get_term_by('slug', $wp_query->query_vars["technologies"], 'portfolio_technologies');
       
    15 					echo $portfolio_options['prtfl_technologies_text_field']." ".( $term->name );
       
    16 				} else {
       
    17 					the_title(); 
       
    18 				} ?>
       
    19 				</div>
       
    20 				<?php				
       
    21 				$paged = isset( $wp_query->query_vars['paged'] ) ? $wp_query->query_vars['paged'] : 1;
       
    22 				$technologies = isset( $wp_query->query_vars["technologies"] ) ? $wp_query->query_vars["technologies"] : "";
       
    23 				if( $technologies != "" ) {
       
    24 					$args = array(
       
    25 						'post_type'					=> 'portfolio',
       
    26 						'post_status'				=> 'publish',
       
    27 						'orderby'					=> $portfolio_options['prtfl_order_by'],
       
    28 						'order'						=> $portfolio_options['prtfl_order'],
       
    29 						'posts_per_page'			=> get_option( 'posts_per_page' ),
       
    30 						'paged'						=> $paged,
       
    31 						'tax_query' => array(
       
    32 								array(
       
    33 									'taxonomy' => 'portfolio_technologies',
       
    34 									'field' => 'slug',
       
    35 									'terms' => $technologies
       
    36 								)
       
    37 							)
       
    38 						);
       
    39 				} else {
       
    40 					$args = array(
       
    41 						'post_type'					=> 'portfolio',
       
    42 						'post_status'				=> 'publish',
       
    43 						'orderby'					=> $portfolio_options['prtfl_order_by'],
       
    44 						'order'						=> $portfolio_options['prtfl_order'],
       
    45 						'posts_per_page'			=> get_option( 'posts_per_page' ),
       
    46 						'paged'						=> $paged
       
    47 						);
       
    48 				}
       
    49 
       
    50 				query_posts( $args );
       
    51 				
       
    52 				while ( have_posts() ) : the_post(); ?>
       
    53 					<div class="portfolio_content entry-content">
       
    54 						<div class="entry">
       
    55 							<?php global $post;
       
    56 							$meta_values				= get_post_custom($post->ID);
       
    57 							$post_thumbnail_id	= get_post_thumbnail_id( $post->ID );
       
    58 							if ( empty ( $post_thumbnail_id ) ) {
       
    59 								$args = array(
       
    60 									'post_parent' => $post->ID,
       
    61 									'post_type' => 'attachment',
       
    62 									'post_mime_type' => 'image',
       
    63 									'numberposts' => 1
       
    64 								);
       
    65 								$attachments				= get_children( $args );
       
    66 								$post_thumbnail_id	= key($attachments);
       
    67 							}
       
    68 							$image						= wp_get_attachment_image_src( $post_thumbnail_id, 'portfolio-thumb' );
       
    69 							$image_large			= wp_get_attachment_image_src( $post_thumbnail_id, 'large' );
       
    70 							$image_alt				= get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
       
    71 							$image_desc 			= get_post($post_thumbnail_id);
       
    72 							$image_desc				= $image_desc->post_content;
       
    73 							if ( get_option( 'prtfl_postmeta_update' ) == '1' ) {
       
    74 								$post_meta		= get_post_meta( $post->ID, 'prtfl_information', true);
       
    75 								$date_compl		= $post_meta['_prtfl_date_compl'];
       
    76 								if( ! empty( $date_compl ) && 'in progress' != $date_compl) {
       
    77 									$date_compl		= explode( "/", $date_compl );
       
    78 									$date_compl		= date( get_option( 'date_format' ), strtotime( $date_compl[1]."-".$date_compl[0].'-'.$date_compl[2] ) );
       
    79 								}
       
    80 								$link					= $post_meta['_prtfl_link'];
       
    81 								$short_descr	= $post_meta['_prtfl_short_descr'];
       
    82 							} else {
       
    83 								$date_compl		= get_post_meta( $post->ID, '_prtfl_date_compl', true );
       
    84 								if( ! empty( $date_compl ) && 'in progress' != $date_compl) {
       
    85 									$date_compl		= explode( "/", $date_compl );
       
    86 									$date_compl		= date( get_option( 'date_format' ), strtotime( $date_compl[1]."-".$date_compl[0].'-'.$date_compl[2] ) );
       
    87 								}
       
    88 								$link					= get_post_meta($post->ID, '_prtfl_link', true);
       
    89 								$short_descr	= get_post_meta($post->ID, '_prtfl_short_descr', true); 
       
    90 							} ?>
       
    91 
       
    92 							<div class="portfolio_thumb">
       
    93 								<a rel="bookmark" href="<?php echo get_permalink(); ?>" title="<?php echo get_the_title(); ?>">
       
    94 									<img src="<?php echo $image[0]; ?>" width="<?php echo $portfolio_options['prtfl_custom_size_px'][0][0]; ?>" height="<?php echo $portfolio_options['prtfl_custom_size_px'][0][1]; ?>" alt="<?php echo $image_alt; ?>" />
       
    95 								</a>
       
    96 							</div>
       
    97 							<div class="portfolio_short_content">
       
    98 								<div class="item_title">
       
    99 									<p>
       
   100 										<a href="<?php echo get_permalink(); ?>" rel="bookmark"><?php echo get_the_title(); ?></a>
       
   101 									</p>
       
   102 								</div> <!-- .item_title -->
       
   103 								<?php if( 1 == $portfolio_options['prtfl_date_additional_field'] ) { ?>
       
   104 										<p>
       
   105 											<span class="lable"><?php echo $portfolio_options['prtfl_date_text_field']; ?></span> <?php echo $date_compl; ?>
       
   106 										</p>
       
   107 								<?php } 
       
   108 								$user_id = get_current_user_id();
       
   109 								if ( 1 == $portfolio_options['prtfl_link_additional_field'] ) {
       
   110 									if( parse_url( $link ) !== false ) { ?>
       
   111 										<?php if ( ( $user_id == 0 && 0 == $portfolio_options['prtfl_link_additional_field_for_non_registered'] ) || $user_id != 0 ) { ?>
       
   112 											<p><span class="lable"><?php echo $portfolio_options['prtfl_link_text_field']; ?></span> <a href="<?php echo $link; ?>"><?php echo $link; ?></a></p>
       
   113 										<?php } else { ?>
       
   114 											<p><span class="lable"><?php echo $portfolio_options['prtfl_link_text_field']; ?></span> <?php echo $link; ?></p>
       
   115 										<?php } ?>										
       
   116 									<?php } else { ?>
       
   117 											<p><span class="lable"><?php echo $portfolio_options['prtfl_link_text_field']; ?></span> <?php echo $link; ?></p>
       
   118 									<?php } ?>
       
   119 								<?php }
       
   120 								if( 1 == $portfolio_options['prtfl_shrdescription_additional_field'] ) { ?>
       
   121 										<p><span class="lable"><?php echo $portfolio_options['prtfl_shrdescription_text_field']; ?></span> <?php echo $short_descr; ?></p>
       
   122 								<?php } ?>
       
   123 							</div> <!-- .portfolio_short_content -->
       
   124 						</div> <!-- .entry -->
       
   125 						<div class="entry_footer">
       
   126 							<div class="read_more">
       
   127 								<a href="<?php the_permalink(); ?>" rel="bookmark"><?php _e( 'Read more', 'portfolio' ); ?></a>
       
   128 							</div> <!-- .read_more -->
       
   129 							<?php $terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' ) ;
       
   130 							if ( is_array( $terms ) && count( $terms ) > 0) { ?>
       
   131 								<div class="portfolio_terms"><?php echo $portfolio_options['prtfl_technologies_text_field']; ?>
       
   132 								<?php $count = 0;
       
   133 								foreach ( $terms as $term ) {
       
   134 									if( $count > 0 ) 
       
   135 										echo ', '; 
       
   136 									echo '<a href="'. get_term_link( $term->slug, 'portfolio_technologies') . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a>';
       
   137 									$count++;
       
   138 								} ?>
       
   139 								</div>
       
   140 							<?php } ?>
       
   141 						</div> <!-- .entry_footer -->
       
   142 					</div> <!-- .portfolio_content -->
       
   143 			<?php endwhile; 
       
   144 			$portfolio_options = get_option( 'prtfl_options' ); ?>			
       
   145 				<script type="text/javascript">
       
   146 				(function($){
       
   147 					$(document).ready(function(){
       
   148 						$("a[rel=portfolio_fancybox]").fancybox({
       
   149 							'transitionIn'		: 'elastic',
       
   150 							'transitionOut'		: 'elastic',
       
   151 							'titlePosition' 	: 'inside',
       
   152 							'speedIn'					:	500, 
       
   153 							'speedOut'				:	300,
       
   154 							'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
       
   155 								return '<span id="fancybox-title-inside">' + (title.length ? title + '<br />' : '') + 'Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
       
   156 							}
       
   157 						});
       
   158 					});
       
   159 				})(jQuery);
       
   160 				</script>
       
   161 			</div><!-- #content -->
       
   162 			<div id="portfolio_pagenation">
       
   163 				<?php if( function_exists( 'prtfl_pagination' ) ) prtfl_pagination(); ?>
       
   164 				<input type="hidden" value="Version=2.09" />
       
   165 			</div>
       
   166 		</div><!-- #container -->
       
   167 <?php get_sidebar(); ?>
       
   168 <?php get_footer(); ?>