wp/wp-content/plugins/portfolio/template/portfolio.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
     1 <?php
     1 <?php
     2 /*
     2 /*
     3 Template Name: Portfolio template
     3 Template Name: Portfolio template
       
     4 * Version: 1.3
     4 */
     5 */
     5 
       
     6 get_header(); ?>
     6 get_header(); ?>
     7 
     7 	<div class="content-area">
     8 <?php global $wp_query;
     8 		<div id="container" class="site-content site-main">
     9 $portfolio_options = get_option( 'prtfl_options' ); ?>
       
    10 		<div id="container" class="site-content">
       
    11 			<div id="content" class="hentry">
     9 			<div id="content" class="hentry">
    12 				<div class="breadcrumbs home_page_title entry-header">
    10 				<div class="breadcrumbs home_page_title entry-header">
    13 				<?php if( isset( $wp_query->query_vars["technologies"] ) ) {
    11 					<?php global $post, $wpdb, $wp_query, $request;
    14 					$term = get_term_by('slug', $wp_query->query_vars["technologies"], 'portfolio_technologies');
    12 					$portfolio_options = get_option( 'prtfl_options' );
    15 					echo $portfolio_options['prtfl_technologies_text_field']." ".( $term->name );
    13 
       
    14 					if ( isset( $wp_query->query_vars["technologies"] ) ) {
       
    15 						$term = get_term_by( 'slug', $wp_query->query_vars["technologies"], 'portfolio_technologies' );
       
    16 						echo $portfolio_options['prtfl_technologies_text_field'] . " " . ( $term->name );
       
    17 					} elseif ( isset( $wp_query->query_vars["portfolio_executor_profile"] ) ) {
       
    18 						$term = get_term_by('slug', $wp_query->query_vars["portfolio_executor_profile"], 'portfolio_executor_profile');
       
    19 						echo __( 'Executor Profile', 'portfolio' ) . ": <h1>" . ( $term->name ) . "</h1>";
       
    20 						$_SESSION['prtfl_page_name'] = __( 'Executor Profile', 'portfolio' ) . ": " . ( $term->name );
       
    21 						$_SESSION['prtfl_page_url'] = get_pagenum_link( $wp_query->query_vars['paged'] );
       
    22 					} else {
       
    23 						the_title();
       
    24 					} ?>
       
    25 				</div>
       
    26 				<?php $count = 0;
       
    27 				if ( get_query_var( 'paged' ) ) {
       
    28 					$paged = get_query_var( 'paged' );
       
    29 				} elseif ( get_query_var( 'page' ) ) {
       
    30 					$paged = get_query_var( 'page' );
    16 				} else {
    31 				} else {
    17 					the_title(); 
    32 					$paged = 1;
    18 				} ?>
    33 				}
    19 				</div>
    34 				$per_page = $showitems = get_option( 'posts_per_page' ); 
    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"] : "";
    35 				$technologies = isset( $wp_query->query_vars["technologies"] ) ? $wp_query->query_vars["technologies"] : "";
    23 				if( $technologies != "" ) {
    36 				$executor_profile = isset( $wp_query->query_vars["portfolio_executor_profile"] ) ? $wp_query->query_vars["portfolio_executor_profile"] : "";
       
    37 				if ( "" != $technologies ) {
    24 					$args = array(
    38 					$args = array(
    25 						'post_type'					=> 'portfolio',
    39 						'post_type' 		=> 'portfolio',
    26 						'post_status'				=> 'publish',
    40 						'post_status' 		=> 'publish',
    27 						'orderby'					=> $portfolio_options['prtfl_order_by'],
    41 						'orderby' 			=> $portfolio_options['prtfl_order_by'],
    28 						'order'						=> $portfolio_options['prtfl_order'],
    42 						'order'			 	=> $portfolio_options['prtfl_order'],
    29 						'posts_per_page'			=> get_option( 'posts_per_page' ),
    43 						'posts_per_page'	=> $per_page,
    30 						'paged'						=> $paged,
    44 						'paged' 			=> $paged,
    31 						'tax_query' => array(
    45 						'tax_query' 		=> array(
    32 								array(
    46 							array(
    33 									'taxonomy' => 'portfolio_technologies',
    47 								'taxonomy' 	=> 'portfolio_technologies',
    34 									'field' => 'slug',
    48 								'field' 	=> 'slug',
    35 									'terms' => $technologies
    49 								'terms' 	=> $technologies
    36 								)
       
    37 							)
    50 							)
    38 						);
    51 						)
       
    52 					);
       
    53 				} else if ( "" != $executor_profile ) {
       
    54 					$args = array(
       
    55 						'post_type' 		=> 'portfolio',
       
    56 						'post_status' 		=> 'publish',
       
    57 						'orderby'			=> $portfolio_options['prtfl_order_by'],
       
    58 						'order' 			=> $portfolio_options['prtfl_order'],
       
    59 						'posts_per_page' 	=> $per_page,
       
    60 						'paged' 			=> $paged,
       
    61 						'tax_query' 		=> array(
       
    62 							array(
       
    63 								'taxonomy' 	=> 'portfolio_executor_profile',
       
    64 								'field' 	=> 'slug',
       
    65 								'terms' 	=> $executor_profile
       
    66 							)
       
    67 						)
       
    68 					);
    39 				} else {
    69 				} else {
    40 					$args = array(
    70 					$args = array(
    41 						'post_type'					=> 'portfolio',
    71 						'post_type'			=>	'portfolio',
    42 						'post_status'				=> 'publish',
    72 						'post_status'		=>	'publish',
    43 						'orderby'					=> $portfolio_options['prtfl_order_by'],
    73 						'orderby'			=>	$portfolio_options['prtfl_order_by'],
    44 						'order'						=> $portfolio_options['prtfl_order'],
    74 						'order'				=>	$portfolio_options['prtfl_order'],
    45 						'posts_per_page'			=> get_option( 'posts_per_page' ),
    75 						'posts_per_page'	=>	$per_page,
    46 						'paged'						=> $paged
    76 						'paged'				=>	$paged
    47 						);
    77 					);
    48 				}
    78 				}
    49 
    79 
    50 				query_posts( $args );
    80 				$second_query = new WP_Query( $args );
       
    81 
       
    82 				$pdfprnt_options = get_option('pdfprnt_options_array');
       
    83 				if ( empty( $pdfprnt_options ) )
       
    84 					$pdfprnt_options = get_option('pdfprntpr_options_array');
       
    85 				if (  isset( $pdfprnt_options ) && is_array( $pdfprnt_options ) && true === in_array( 'portfolio', $pdfprnt_options['use_types_posts'] ) ) {
       
    86 					if ( function_exists( 'pdfprnt_show_buttons_for_bws_portfolio_post' ) )
       
    87 						echo pdfprnt_show_buttons_for_bws_portfolio_post();
       
    88 					elseif ( function_exists( 'pdfprntpr_show_buttons_for_bws_portfolio_post' ) )
       
    89 						echo pdfprntpr_show_buttons_for_bws_portfolio_post();
       
    90 				}
    51 				
    91 				
    52 				while ( have_posts() ) : the_post(); ?>
    92 				$request = $second_query->request;
    53 					<div class="portfolio_content entry-content">
    93 
    54 						<div class="entry">
    94 				if ( $second_query->have_posts() ) : 
    55 							<?php global $post;
    95 					while ( $second_query->have_posts() ) : $second_query->the_post(); ?>
    56 							$meta_values				= get_post_custom($post->ID);
    96 						<div class="portfolio_content entry-content">
    57 							$post_thumbnail_id	= get_post_thumbnail_id( $post->ID );
    97 							<div class="entry">
    58 							if ( empty ( $post_thumbnail_id ) ) {
    98 								<?php $meta_values		=	get_post_custom( $post->ID );
    59 								$args = array(
    99 								$post_thumbnail_id	=	get_post_thumbnail_id( $post->ID );
    60 									'post_parent' => $post->ID,
   100 								if ( empty ( $post_thumbnail_id ) ) {
    61 									'post_type' => 'attachment',
   101 									$args = array(
    62 									'post_mime_type' => 'image',
   102 										'post_parent'		=>	$post->ID,
    63 									'numberposts' => 1
   103 										'post_type'			=>	'attachment',
    64 								);
   104 										'post_mime_type'	=>	'image',
    65 								$attachments				= get_children( $args );
   105 										'numberposts'		=>	1
    66 								$post_thumbnail_id	= key($attachments);
   106 									);
    67 							}
   107 									$attachments		=	get_children( $args );
    68 							$image						= wp_get_attachment_image_src( $post_thumbnail_id, 'portfolio-thumb' );
   108 									$post_thumbnail_id	=	key( $attachments );
    69 							$image_large			= wp_get_attachment_image_src( $post_thumbnail_id, 'large' );
   109 								}
    70 							$image_alt				= get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
   110 								$image			=	wp_get_attachment_image_src( $post_thumbnail_id, 'portfolio-thumb' );
    71 							$image_desc 			= get_post($post_thumbnail_id);
   111 								$image_large	=	wp_get_attachment_image_src( $post_thumbnail_id, 'large' );
    72 							$image_desc				= $image_desc->post_content;
   112 								$image_alt		=	get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
    73 							if ( get_option( 'prtfl_postmeta_update' ) == '1' ) {
   113 								$image_desc 	=	get_post($post_thumbnail_id);
    74 								$post_meta		= get_post_meta( $post->ID, 'prtfl_information', true);
   114 								$image_desc		=	$image_desc->post_content;
    75 								$date_compl		= $post_meta['_prtfl_date_compl'];
   115 								$post_meta		=	get_post_meta( $post->ID, 'prtfl_information', true);
    76 								if( ! empty( $date_compl ) && 'in progress' != $date_compl) {
   116 								$date_compl		=	isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : '';
       
   117 								if ( ! empty( $date_compl ) && 'in progress' != $date_compl) {
    77 									$date_compl		= explode( "/", $date_compl );
   118 									$date_compl		= explode( "/", $date_compl );
    78 									$date_compl		= date( get_option( 'date_format' ), strtotime( $date_compl[1]."-".$date_compl[0].'-'.$date_compl[2] ) );
   119 									$date_compl		= date( get_option( 'date_format' ), strtotime( $date_compl[1] . "-" . $date_compl[0] . '-' . $date_compl[2] ) );
    79 								}
   120 								}
    80 								$link					= $post_meta['_prtfl_link'];
   121 								$link			=	isset( $post_meta['_prtfl_link'] ) ? $post_meta['_prtfl_link'] : '';
    81 								$short_descr	= $post_meta['_prtfl_short_descr'];
   122 								$short_descr	=	isset( $post_meta['_prtfl_short_descr'] ) ? $post_meta['_prtfl_short_descr'] : '';
    82 							} else {
   123 								if ( empty( $short_descr ) )
    83 								$date_compl		= get_post_meta( $post->ID, '_prtfl_date_compl', true );
   124 									$short_descr = get_the_excerpt();
    84 								if( ! empty( $date_compl ) && 'in progress' != $date_compl) {
   125 								$title = get_the_title();
    85 									$date_compl		= explode( "/", $date_compl );
   126 								if ( empty( $title ) )
    86 									$date_compl		= date( get_option( 'date_format' ), strtotime( $date_compl[1]."-".$date_compl[0].'-'.$date_compl[2] ) );
   127 									$title = '(' . __( 'No title', 'portfolio-pro' ) . ')';
    87 								}
   128 								$permalink = get_permalink(); 
    88 								$link					= get_post_meta($post->ID, '_prtfl_link', true);
   129 								if ( ! empty( $image[0] ) ) { ?>
    89 								$short_descr	= get_post_meta($post->ID, '_prtfl_short_descr', true); 
   130 									<div class="portfolio_thumb">
    90 							} ?>
   131 										<a rel="bookmark" href="<?php echo $permalink; ?>" title="<?php echo $title; ?>">
    91 
   132 											<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; ?>" />
    92 							<div class="portfolio_thumb">
   133 										</a>
    93 								<a rel="bookmark" href="<?php echo get_permalink(); ?>" title="<?php echo get_the_title(); ?>">
   134 									</div><!-- .portfolio_thumb -->
    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; ?>" />
   135 								<?php } ?>
    95 								</a>
   136 								<div class="portfolio_short_content">
    96 							</div>
   137 									<div class="item_title">
    97 							<div class="portfolio_short_content">
   138 										<p>
    98 								<div class="item_title">
   139 											<a href="<?php echo $permalink; ?>" rel="bookmark"><?php echo $title; ?></a>
    99 									<p>
   140 										</p>
   100 										<a href="<?php echo get_permalink(); ?>" rel="bookmark"><?php echo get_the_title(); ?></a>
   141 									</div><!-- .item_title -->
   101 									</p>
   142 									<?php if ( 1 == $portfolio_options['prtfl_date_additional_field'] ) { ?>
   102 								</div> <!-- .item_title -->
       
   103 								<?php if( 1 == $portfolio_options['prtfl_date_additional_field'] ) { ?>
       
   104 										<p>
   143 										<p>
   105 											<span class="lable"><?php echo $portfolio_options['prtfl_date_text_field']; ?></span> <?php echo $date_compl; ?>
   144 											<span class="lable"><?php echo $portfolio_options['prtfl_date_text_field']; ?></span> <?php echo $date_compl; ?>
   106 										</p>
   145 										</p>
   107 								<?php } 
   146 									<?php }
   108 								$user_id = get_current_user_id();
   147 									$user_id = get_current_user_id();
   109 								if ( 1 == $portfolio_options['prtfl_link_additional_field'] ) {
   148 									if ( 1 == $portfolio_options['prtfl_link_additional_field'] ) {
   110 									if( parse_url( $link ) !== false ) { ?>
   149 										if ( false !== parse_url( $link ) ) { ?>
   111 										<?php if ( ( $user_id == 0 && 0 == $portfolio_options['prtfl_link_additional_field_for_non_registered'] ) || $user_id != 0 ) { ?>
   150 											<?php if ( ( 0 == $user_id && 0 == $portfolio_options['prtfl_link_additional_field_for_non_registered'] ) || 0 != $user_id ) { ?>
   112 											<p><span class="lable"><?php echo $portfolio_options['prtfl_link_text_field']; ?></span> <a href="<?php echo $link; ?>"><?php echo $link; ?></a></p>
   151 												<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 { ?>
   152 											<?php } else { ?>
       
   153 												<p><span class="lable"><?php echo $portfolio_options['prtfl_link_text_field']; ?></span> <?php echo $link; ?></p>
       
   154 											<?php }
       
   155 										} else { ?>
   114 											<p><span class="lable"><?php echo $portfolio_options['prtfl_link_text_field']; ?></span> <?php echo $link; ?></p>
   156 											<p><span class="lable"><?php echo $portfolio_options['prtfl_link_text_field']; ?></span> <?php echo $link; ?></p>
   115 										<?php } ?>										
   157 										<?php }
   116 									<?php } else { ?>
   158 									}
   117 											<p><span class="lable"><?php echo $portfolio_options['prtfl_link_text_field']; ?></span> <?php echo $link; ?></p>
   159 									if ( 1 == $portfolio_options['prtfl_shrdescription_additional_field'] ) { ?>
       
   160 										<p><span class="lable"><?php echo $portfolio_options['prtfl_shrdescription_text_field']; ?></span> <?php echo $short_descr; ?></p>
   118 									<?php } ?>
   161 									<?php } ?>
   119 								<?php }
   162 								</div><!-- .portfolio_short_content -->
   120 								if( 1 == $portfolio_options['prtfl_shrdescription_additional_field'] ) { ?>
   163 							</div><!-- .entry -->
   121 										<p><span class="lable"><?php echo $portfolio_options['prtfl_shrdescription_text_field']; ?></span> <?php echo $short_descr; ?></p>
   164 							<div class="entry_footer">
       
   165 								<div class="read_more">
       
   166 									<a href="<?php the_permalink(); ?>" rel="bookmark"><?php _e( 'Read more', 'portfolio' ); ?></a>
       
   167 								</div><!-- .read_more -->
       
   168 								<?php $terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' );
       
   169 								if ( is_array( $terms ) && 0 < count( $terms ) ) { ?>
       
   170 									<div class="portfolio_terms">
       
   171 										<?php echo $portfolio_options['prtfl_technologies_text_field'];
       
   172 										$count = 0;
       
   173 										foreach ( $terms as $term ) {
       
   174 											if ( 0 < $count )
       
   175 												echo ', ';
       
   176 											echo '<a href="' . get_term_link( $term->slug, 'portfolio_technologies') . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name . '</a>';
       
   177 											$count++;
       
   178 										} ?>
       
   179 									</div><!-- .portfolio_terms -->
   122 								<?php } ?>
   180 								<?php } ?>
   123 							</div> <!-- .portfolio_short_content -->
   181 							</div><!-- .entry_footer -->
   124 						</div> <!-- .entry -->
   182 						</div><!-- .portfolio_content -->
   125 						<div class="entry_footer">
   183 					<?php endwhile;
   126 							<div class="read_more">
   184 				endif; ?>
   127 								<a href="<?php the_permalink(); ?>" rel="bookmark"><?php _e( 'Read more', 'portfolio' ); ?></a>
   185 			</div><!-- #content -->	
   128 							</div> <!-- .read_more -->
   186 			<?php $count_all_albums = $second_query->found_posts;
   129 							<?php $terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' ) ;
   187 			wp_reset_query(); 
   130 							if ( is_array( $terms ) && count( $terms ) > 0) { ?>
   188 			$request = $wp_query->request;
   131 								<div class="portfolio_terms"><?php echo $portfolio_options['prtfl_technologies_text_field']; ?>
   189 			$pages = intval( $count_all_albums / $per_page );
   132 								<?php $count = 0;
   190 			if ( $count_all_albums % $per_page > 0 )
   133 								foreach ( $terms as $term ) {
   191 				$pages += 1;
   134 									if( $count > 0 ) 
   192 
   135 										echo ', '; 
   193 			$range = 2;
   136 									echo '<a href="'. get_term_link( $term->slug, 'portfolio_technologies') . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a>';
   194 
   137 									$count++;
   195 			if ( ! $pages )
   138 								} ?>
   196 				$pages = 1;
   139 								</div>
   197 
   140 							<?php } ?>
   198 			if ( 1 != $pages ) { ?>
   141 						</div> <!-- .entry_footer -->
   199 				<div class='clear'></div>
   142 					</div> <!-- .portfolio_content -->
   200 				<div id="portfolio_pagenation">
   143 			<?php endwhile; 
   201 					<div class='pagination'>
   144 			$portfolio_options = get_option( 'prtfl_options' ); ?>			
   202 						<?php if ( 2 < $paged && $paged > $range + 1 && $showitems < $pages )
   145 				<script type="text/javascript">
   203 							echo "<a href='" . get_pagenum_link( 1 ) . "'>&laquo;</a>";
   146 				(function($){
   204 						if ( 1 < $paged && $showitems < $pages )
   147 					$(document).ready(function(){
   205 							echo "<a href='" . get_pagenum_link( $paged - 1 ) . "'>&lsaquo;</a>";
   148 						$("a[rel=portfolio_fancybox]").fancybox({
   206 
   149 							'transitionIn'		: 'elastic',
   207 						for ( $i = 1; $i <= $pages; $i++ ) {
   150 							'transitionOut'		: 'elastic',
   208 							if ( 1 != $pages && ( ! ( $i >= $paged + $range + 1 || $i <= $paged - $range - 1 ) || $pages <= $showitems ) ) {
   151 							'titlePosition' 	: 'inside',
   209 								echo ( $paged == $i ) ? "<span class='current'>" . $i . "</span>":"<a href='" . get_pagenum_link( $i ) . "' class='inactive' >" . $i . "</a>";
   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 							}
   210 							}
   157 						});
   211 						}
   158 					});
   212 						if ( $paged < $pages && $showitems < $pages )
   159 				})(jQuery);
   213 							echo "<a href='" . get_pagenum_link( $paged + 1 ) . "'>&rsaquo;</a>";
   160 				</script>
   214 						if ( $paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages )
   161 			</div><!-- #content -->
   215 							echo "<a href='" . get_pagenum_link( $pages ) . "'>&raquo;</a>"; ?>
   162 			<div id="portfolio_pagenation">
   216 						<div class='clear'></div>
   163 				<?php if( function_exists( 'prtfl_pagination' ) ) prtfl_pagination(); ?>
   217 					</div><!-- .pagination -->
   164 				<input type="hidden" value="Version=2.09" />
   218 				</div><!-- #portfolio_pagenation -->
   165 			</div>
   219 			<?php } ?>
       
   220 			<?php comments_template(); ?>
   166 		</div><!-- #container -->
   221 		</div><!-- #container -->
       
   222 	</div><!-- .content-area -->
   167 <?php get_sidebar(); ?>
   223 <?php get_sidebar(); ?>
   168 <?php get_footer(); ?>
   224 <?php get_footer(); ?>