post_excerpt ); if ( 'on' == et_get_option( $shortname . '_use_excerpt' ) && '' != $post_excerpt ) { if ( $echo ) echo $post_excerpt; else return $post_excerpt; } else { // get the post content $truncate = $post->post_content; // remove caption shortcode from the post content $truncate = preg_replace('@\[caption[^\]]*?\].*?\[\/caption]@si', '', $truncate); // apply content filters $truncate = apply_filters( 'the_content', $truncate ); // decide if we need to append dots at the end of the string if ( strlen( $truncate ) <= $amount ) { $echo_out = ''; } else { $echo_out = '...'; // $amount = $amount - 3; } // trim text to a certain number of characters, also remove spaces from the end of a string ( space counts as a character ) $truncate = rtrim( et_wp_trim_words( $truncate, $amount, '' ) ); // remove the last word to make sure we display all words correctly if ( '' != $echo_out ) { $new_words_array = (array) explode( ' ', $truncate ); array_pop( $new_words_array ); $truncate = implode( ' ', $new_words_array ); // append dots to the end of the string $truncate .= $echo_out; } if ( $echo ) echo $truncate; else return $truncate; }; } } if ( ! function_exists( 'et_wp_trim_words' ) ){ function et_wp_trim_words( $text, $num_words = 55, $more = null ) { if ( null === $more ) $more = __( '…' ); $original_text = $text; $text = wp_strip_all_tags( $text ); $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); preg_match_all( '/./u', $text, $words_array ); $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); $sep = ''; if ( count( $words_array ) > $num_words ) { array_pop( $words_array ); $text = implode( $sep, $words_array ); $text = $text . $more; } else { $text = implode( $sep, $words_array ); } return $text; } } /*this function truncates titles to create preview excerpts*/ if ( ! function_exists( 'truncate_title' ) ){ function truncate_title( $amount, $echo = true, $post = '' ) { if ( $post == '' ) $truncate = get_the_title(); else $truncate = $post->post_title; if ( strlen( $truncate ) <= $amount ) $echo_out = ''; else $echo_out = '...'; $truncate = et_wp_trim_words( $truncate, $amount, '' ); if ( '' != $echo_out ) $truncate .= $echo_out; if ( $echo ) echo $truncate; else return $truncate; } } /*this function allows users to use the first image in their post as their thumbnail*/ if ( ! function_exists( 'et_first_image' ) ){ function et_first_image() { global $post; $img = ''; $output = preg_match_all('//i', $post->post_content, $matches); if ( isset($matches[1][0]) ) $img = $matches[1][0]; return trim($img); } } /* this function gets thumbnail from Post Thumbnail or Custom field or First post image */ if ( ! function_exists( 'get_thumbnail' ) ) { function get_thumbnail($width=100, $height=100, $class='', $alttext='', $titletext='', $fullpath=false, $custom_field='', $post='') { if ( $post == '' ) global $post; global $shortname; $thumb_array['thumb'] = ''; $thumb_array['use_timthumb'] = true; if ($fullpath) $thumb_array['fullpath'] = ''; //full image url for lightbox $new_method = true; if ( has_post_thumbnail( $post->ID ) ) { $thumb_array['use_timthumb'] = false; $et_fullpath = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); $thumb_array['fullpath'] = $et_fullpath[0]; $thumb_array['thumb'] = $thumb_array['fullpath']; } if ($thumb_array['thumb'] == '') { if ($custom_field == '') $thumb_array['thumb'] = esc_attr( get_post_meta($post->ID, 'Thumbnail', $single = true) ); else { $thumb_array['thumb'] = esc_attr( get_post_meta($post->ID, $custom_field, $single = true) ); if ($thumb_array['thumb'] == '') $thumb_array['thumb'] = esc_attr( get_post_meta($post->ID, 'Thumbnail', $single = true) ); } if (($thumb_array['thumb'] == '') && ((et_get_option($shortname.'_grab_image')) == 'on')) { $thumb_array['thumb'] = esc_attr( et_first_image() ); if ( $fullpath ) $thumb_array['fullpath'] = $thumb_array['thumb']; } #if custom field used for small pre-cropped image, open Thumbnail custom field image in lightbox if ($fullpath) { $thumb_array['fullpath'] = $thumb_array['thumb']; if ($custom_field == '') $thumb_array['fullpath'] = apply_filters('et_fullpath', et_path_reltoabs(esc_attr($thumb_array['thumb']))); elseif ( $custom_field <> '' && get_post_meta($post->ID, 'Thumbnail', $single = true) ) $thumb_array['fullpath'] = apply_filters( 'et_fullpath', et_path_reltoabs(esc_attr(get_post_meta($post->ID, 'Thumbnail', $single = true))) ); } } return $thumb_array; } } /* this function prints thumbnail from Post Thumbnail or Custom field or First post image */ if ( ! function_exists( 'print_thumbnail' ) ) { function print_thumbnail($thumbnail = '', $use_timthumb = true, $alttext = '', $width = 100, $height = 100, $class = '', $echoout = true, $forstyle = false, $resize = true, $post='', $et_post_id = '' ) { if ( is_array( $thumbnail ) ){ extract( $thumbnail ); } if ( $post == '' ) global $post, $et_theme_image_sizes; $output = ''; $et_post_id = '' != $et_post_id ? (int) $et_post_id : $post->ID; if ( has_post_thumbnail( $et_post_id ) ) { $thumb_array['use_timthumb'] = false; $image_size_name = $width . 'x' . $height; $et_size = isset( $et_theme_image_sizes ) && array_key_exists( $image_size_name, $et_theme_image_sizes ) ? $et_theme_image_sizes[$image_size_name] : array( $width, $height ); $et_attachment_image_attributes = wp_get_attachment_image_src( get_post_thumbnail_id( $et_post_id ), $et_size ); $thumbnail = $et_attachment_image_attributes[0]; } else { $thumbnail_orig = $thumbnail; $thumbnail = et_multisite_thumbnail( $thumbnail ); $cropPosition = ''; $allow_new_thumb_method = false; $new_method = true; $new_method_thumb = ''; $external_source = false; $allow_new_thumb_method = !$external_source && $new_method && $cropPosition == ''; if ( $allow_new_thumb_method && $thumbnail <> '' ){ $et_crop = get_post_meta( $post->ID, 'et_nocrop', true ) == '' ? true : false; $new_method_thumb = et_resize_image( et_path_reltoabs($thumbnail), $width, $height, $et_crop ); if ( is_wp_error( $new_method_thumb ) ) $new_method_thumb = ''; } $thumbnail = $new_method_thumb; } if ( false === $forstyle ) { $output = ' '') $output .= " class='" . esc_attr( $class ) . "' "; $dimensions = apply_filters( 'et_print_thumbnail_dimensions', " width='" . esc_attr( $width ) . "' height='" .esc_attr( $height ) . "'" ); $output .= " alt='" . esc_attr( strip_tags( $alttext ) ) . "'{$dimensions} />"; if ( ! $resize ) $output = $thumbnail; } else { $output = $thumbnail; } if ($echoout) echo $output; else return $output; } } if ( ! function_exists( 'et_new_thumb_resize' ) ){ function et_new_thumb_resize( $thumbnail, $width, $height, $alt='', $forstyle = false ){ global $shortname; $new_method = true; $new_method_thumb = ''; $external_source = false; $allow_new_thumb_method = !$external_source && $new_method; if ( $allow_new_thumb_method && $thumbnail <> '' ){ $et_crop = true; $new_method_thumb = et_resize_image( $thumbnail, $width, $height, $et_crop ); if ( is_wp_error( $new_method_thumb ) ) $new_method_thumb = ''; } $thumb = esc_attr( $new_method_thumb ); $output = '' . esc_attr( $alt ) . ''; return ( !$forstyle ) ? $output : $thumb; } } if ( ! function_exists( 'et_multisite_thumbnail' ) ){ function et_multisite_thumbnail( $thumbnail = '' ) { // do nothing if it's not a Multisite installation or current site is the main one if ( is_main_site() ) return $thumbnail; # get the real image url preg_match( '#([_0-9a-zA-Z-]+/)?files/(.+)#', $thumbnail, $matches ); if ( isset( $matches[2] ) ){ $file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $matches[2] ); if ( is_file( $file ) ) $thumbnail = str_replace( ABSPATH, trailingslashit( get_site_url( 1 ) ), $file ); else $thumbnail = ''; } return $thumbnail; } } if ( ! function_exists( 'et_is_portrait' ) ){ function et_is_portrait($imageurl, $post='', $ignore_cfields = false){ if ( $post == '' ) global $post; if ( get_post_meta($post->ID,'et_disable_portrait',true) == 1 ) return false; if ( !$ignore_cfields ) { if ( get_post_meta($post->ID,'et_imagetype',true) == 'l' ) return false; if ( get_post_meta($post->ID,'et_imagetype',true) == 'p' ) return true; } $imageurl = et_path_reltoabs(et_multisite_thumbnail($imageurl)); $et_thumb_size = @getimagesize($imageurl); if ( empty($et_thumb_size) ) { $et_thumb_size = @getimagesize( str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $imageurl ) ); if ( empty($et_thumb_size) ) return false; } $et_thumb_width = $et_thumb_size[0]; $et_thumb_height = $et_thumb_size[1]; $result = ($et_thumb_width < $et_thumb_height) ? true : false; return $result; } } if ( ! function_exists( 'et_path_reltoabs' ) ){ function et_path_reltoabs( $imageurl ){ if ( strpos(strtolower($imageurl), 'http://') !== false || strpos(strtolower($imageurl), 'https://') !== false ) return $imageurl; if ( strpos( strtolower($imageurl), $_SERVER['HTTP_HOST'] ) !== false ) return $imageurl; else { $imageurl = esc_url( apply_filters( 'et_path_relative_image', site_url() . '/' ) . $imageurl ); } return $imageurl; } } if ( ! function_exists( 'in_subcat' ) ){ function in_subcat($blogcat,$current_cat='') { $in_subcategory = false; if (cat_is_ancestor_of($blogcat,$current_cat) || $blogcat == $current_cat) $in_subcategory = true; return $in_subcategory; } } if ( ! function_exists( 'show_page_menu' ) ){ function show_page_menu($customClass = 'nav clearfix', $addUlContainer = true, $addHomeLink = true){ global $shortname, $themename, $exclude_pages, $strdepth, $page_menu, $is_footer; //excluded pages if (et_get_option($shortname.'_menupages') <> '') $exclude_pages = implode(",", et_get_option($shortname.'_menupages')); //dropdown for pages $strdepth = ''; if (et_get_option($shortname.'_enable_dropdowns') == 'on') $strdepth = "depth=".et_get_option($shortname.'_tiers_shown_pages'); if ($strdepth == '') $strdepth = "depth=1"; if ($is_footer) { $strdepth="depth=1"; $strdepth2 = $strdepth; } $page_menu = wp_list_pages("sort_column=".et_get_option($shortname.'_sort_pages')."&sort_order=".et_get_option($shortname.'_order_page')."&".$strdepth."&exclude=".$exclude_pages."&title_li=&echo=0"); if ($addUlContainer) echo('