Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- global $shortname;
- define('PER_PAGE_DEFAULT', get_option($shortname.'_general_posts_per_page'));
- /*-----------------------------------------------------------------------------------*/
- /* = Custom function for query posts
- /*-----------------------------------------------------------------------------------*/
- if ( ! function_exists( 'max_query_posts' ) ):
- function max_query_posts($showposts, $catArray, $random = false, $offset = false) {
- $off = !$offset ? "" : $offset;
- $rand = !$random ? "" : $random;
- $tag_id = !$tag_id ? "" : $tag_id;
- global $wp_query;
- wp_reset_query();
- $paged = get_query_var('paged') ? get_query_var('paged') : 1;
- // Check if catArray is a array or single cat
- $cat_string = is_array($catArray) ? implode( ',' , $catArray ) : $catArray;
- $defaults = array(
- 'paged' => $paged,
- 'posty_type' => 'gallery',
- 'posts_per_page' => PER_PAGE_DEFAULT,
- GALLERY_TAXONOMY => $cat_string,
- 'orderby' => $rand,
- 'offset' => $offset
- );
- $query = $defaults;
- $wp_query = new WP_Query($query);
- }
- endif;
- /*-----------------------------------------------------------------------------------*/
- /* = Custom function for query term posts
- /*-----------------------------------------------------------------------------------*/
- if ( ! function_exists( 'max_query_term_posts' ) ):
- function max_query_term_posts($showposts = PER_PAGE_DEFAULT, $id_array, $type = 'gallery', $random = false, $taxonomy = GALLERY_TAXONOMY, $order = false){
- $rand = !$random ? "" : $random;
- $order = !$order ? "" : $order;
- $posts_to_query = get_objects_in_term($id_array, $taxonomy);
- return query_posts( array( 'showposts'=> $showposts, 'post_type' => $type, 'post__in' => $posts_to_query, 'orderby' => $rand, 'order'=> $order) );
- }
- endif;
- /*-----------------------------------------------------------------------------------*/
- /* = Custom function for query posts by tags
- /*-----------------------------------------------------------------------------------*/
- if ( ! function_exists( 'max_query_tag_posts' ) ):
- function max_query_tag_posts($showposts = PER_PAGE_DEFAULT, $type = 'gallery', $tag_slug = false){
- $tag = !$tag_slug ? "" : $tag_slug;
- return query_posts( array( 'showposts'=> $showposts, 'post_type' => $type, 'tag'=> $tag) );
- }
- endif;
- /*-----------------------------------------------------------------------------------*/
- /* = Get a image url from post id
- /*-----------------------------------------------------------------------------------*/
- function max_get_post_image_url($id, $size = 'full'){
- return wp_get_attachment_image_src( get_post_thumbnail_id( $id ), $size);
- }
- /*-----------------------------------------------------------------------------------*/
- /* = Get a Post Image depending on Options set in Options Panel
- /*-----------------------------------------------------------------------------------*/
- function max_get_post_custom_image( $return = false, $p_id = false ){
- global $shortname, $post, $imgDimensions;
- $post_id = !$p_id ? $post->ID : $p_id;
- // check if its a lightbox or a project page link
- $photo_item_type = get_post_meta($post_id, $shortname.'_photo_item_type_value', true);
- // Get the post image via timthumb
- $imgUrl = max_get_post_image_url($post_id, "full");
- $output = "";
- if( !isset( $imgDimensions['width'] ) ) {
- $width = "";
- $imgWidth = "";
- }else{
- $width = "&w=".$imgDimensions['width'];
- $imgWidth = ' width="' . $imgDimensions['width'] . ' "';
- }
- if( !isset( $imgDimensions['height'] ) ) {
- $height = "";
- $imgHeight = "";
- }else{
- $height = "&h=".$imgDimensions['height'];
- $imgHeight = ' height="' . $imgDimensions['height'] . ' "';
- }
- if ( has_post_thumbnail( $post_id ) ) {
- // check if to show lightbox desc and title
- if ( get_option_max( 'pretty_title_show' ) == 'true' ){
- $title = ' title="' . get_the_excerpt() . '"';
- }
- $cat_list = array();
- foreach(get_the_category() as $category){
- $cat_list[] = $category->cat_ID;
- }
- if ( !in_array( get_option_max('general_blog_id'), $cat_list ) ) {
- // Photo Type is a Lightbox
- if($photo_item_type == "Lightbox" ){
- // Display Lightbox Photo
- if ( get_post_meta($post_id, $shortname.'_photo_lightbox_type_value', true) == "Photo" ){
- $output .= '<a href="' . $imgUrl[0] . '" rel="prettyPhoto[gal]"'.$title.'><img src="' . get_template_directory_uri() . '/timthumb.php?src=' . $imgUrl[0] . $width . $height . '&a=' . get_cropping_direction( get_post_meta($post_id, $shortname.'_photo_cropping_direction_value', true) ) . '&q=100" alt="' . get_the_title() .'"' . $imgWidth . $imgWidth . '" /></a>';
- }
- // Display Lightbox YouTube Video
- if ( get_post_meta($post_id, $shortname.'_photo_lightbox_type_value', true) == "YouTube-Video" ){
- $output .= '<a href="' . get_post_meta($post_id, $shortname.'_photo_video_youtube_value', true) . '" rel="prettyPhoto" title="' . get_the_title() . '"><img src="' . get_template_directory_uri() . '/timthumb.php?src=' . $imgUrl[0] . $width . $height . '&a=' . get_cropping_direction( get_post_meta($post_id, $shortname.'_photo_cropping_direction_value', true) ) . '&q=100" alt="' . get_the_title() .'"' . $imgWidth . $imgWidth . '" /></a>';
- }
- // Display Lightbox Vimeo Video
- if ( get_post_meta($post_id, $shortname.'_photo_lightbox_type_value', true) == "Vimeo-Video" ){
- $output .= '<a href="' . get_post_meta($post_id, $shortname.'_photo_video_vimeo_value', true) . '" rel="prettyPhoto" title="' . get_the_title() . '"><img src="' . get_template_directory_uri() . '/timthumb.php?src=' . $imgUrl[0] . $width . $height . '&a=' . get_cropping_direction( get_post_meta($post_id, $shortname.'_photo_cropping_direction_value', true) ) . '&q=100" alt="' . get_the_title() .'"' . $imgWidth . $imgWidth . '" /></a>';
- }
- }else if($photo_item_type == "Project Page" ){
- // Photo Type is a Project Page
- $output .= '<a href="' . get_permalink($post_id) . '" title="' . get_the_title() . '"><img src="' . get_template_directory_uri() . '/timthumb.php?src=' . $imgUrl[0] . $width . $height . '.&a=' . get_cropping_direction( get_post_meta($post_id, $shortname.'_photo_cropping_direction_value', true) ) . '&q=100"' . $imgWidth . $imgWidth . '" alt="' . get_the_title() . '" class="fade-image"/></a>';
- }else if($photo_item_type == "External Link" ){
- // Photo Type is an external Link
- $output .= '<a href="' . get_post_meta($post_id, $shortname.'_photo_external_link_value', true) . '" title="' . get_the_title() . '"><img src="' . get_template_directory_uri() . '/timthumb.php?src=' . $imgUrl[0] . $width . $height . '.&a=' . get_cropping_direction( get_post_meta($post_id, $shortname.'_photo_cropping_direction_value', true) ) . '&q=100"' . $imgWidth . $imgWidth . '" alt="' . get_the_title() . '" class="fade-image"/></a>';
- }else{
- // Get the timbthumb image
- $output .= '<a href="'. $imgUrl[0] .'" rel="prettyPhoto" title="'. get_the_excerpt() .'">
- <img src="' . get_template_directory_uri(). '/timthumb.php?src=' . $imgUrl[0] . $height . $width.'&a='. get_cropping_direction( get_post_meta($post_id, $shortname.'_photo_cropping_direction_value', 2313) ) . '&q=100"' . $imgWidth . $imgWidth . '" class="fade-image" alt="' . get_the_title() . '" title="' . get_the_title() . '" />
- </a>';
- }
- }else{
- // Get the timbthumb image
- $output .= '<a href="'. $imgUrl[0] .'" rel="prettyPhoto"'.$title.'>
- <img src="' . get_template_directory_uri(). '/timthumb.php?src=' . $imgUrl[0] . $height . $width.'&a='. get_cropping_direction( get_post_meta($post_id, $shortname.'_photo_cropping_direction_value', 2313) ) . '&q=100"' . $imgWidth . $imgWidth . '" class="fade-image" alt="' . get_the_title() . '" title="' . get_the_title() . '" />
- </a>';
- }
- }
- if($return === true){
- return $output;
- }else{
- echo $output;
- }
- }
- /*-----------------------------------------------------------------------------------*/
- /* = Get a Post Lightbox CSS Class
- /*-----------------------------------------------------------------------------------*/
- function max_get_post_lightbox_class(){
- global $shortname, $post, $imgDimensions;
- $lightbox_type = get_post_meta($post->ID, $shortname.'_photo_lightbox_type_value', true);
- switch($lightbox_type){
- case "Photo": $class = "photo";
- break;
- case "YouTube-Video": $class = "youtube-video";
- break;
- case "Vimeo-Video": $class = "vimeo-video";
- break;
- default: $class = "photo";
- break;
- }
- return $class;
- }
- /*-----------------------------------------------------------------------------------*/
- /* = Custom excerpt function
- /*-----------------------------------------------------------------------------------*/
- function max_get_the_excerpt( $echo = false ){
- global $shortname, $post;
- $excerpt = $post->post_excerpt;
- if ($excerpt != "" ) {
- if ( $echo === true ) {
- the_excerpt();
- }else{
- return $excerpt;
- }
- }
- return false;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement