/', '', $text)) <= $length) { return $text; } // splits all html-tags to scanable lines preg_match_all('/(<.+?>)?([^<>]*)/s', $text, $lines, PREG_SET_ORDER); $total_length = strlen($ending); $open_tags = array(); $truncate = ''; foreach ($lines as $line_matchings) { // if there is any html-tag in this line, handle it and add it (uncounted) to the output if (!empty($line_matchings[1])) { // if it's an "empty element" with or without xhtml-conform closing slash if (preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) { // do nothing // if tag is a closing tag } else if (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { // delete tag from $open_tags list $pos = array_search($tag_matchings[1], $open_tags); if ($pos !== false) { unset($open_tags[$pos]); } // if tag is an opening tag } else if (preg_match('/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) { // add tag to the beginning of $open_tags list array_unshift($open_tags, strtolower($tag_matchings[1])); } // add html-tag to $truncate'd text $truncate .= $line_matchings[1]; } // calculate the length of the plain text part of the line; handle entities as one character $content_length = strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); if ($total_length+$content_length> $length) { // the number of characters which are left $left = $length - $total_length; $entities_length = 0; // search for html entities if (preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, PREG_OFFSET_CAPTURE)) { // calculate the real length of all entities in the legal range foreach ($entities[0] as $entity) { if ($entity[1]+1-$entities_length <= $left) { $left--; $entities_length += strlen($entity[0]); } else { // no more characters left break; } } } $truncate .= substr($line_matchings[2], 0, $left+$entities_length); // maximum lenght is reached, so get off the loop break; } else { $truncate .= $line_matchings[2]; $total_length += $content_length; } // if the maximum length is reached, get off the loop if($total_length>= $length) { break; } } } else { if (strlen($text) <= $length) { return $text; } else { $truncate = substr($text, 0, $length - strlen($ending)); } } // if the words shouldn't be cut in the middle... if (!$exact) { // ...search the last occurance of a space... $spacepos = strrpos($truncate, ' '); if (isset($spacepos)) { // ...and cut the text in this position $truncate = substr($truncate, 0, $spacepos); } } // add the defined ending to the text $truncate .= $ending; if($considerHtml) { // close all unclosed html-tags foreach ($open_tags as $tag) { $truncate .= ''; } } return $truncate; } function app_landing_page_breadcrumbs_cb() { $showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show $delimiter = esc_html( get_theme_mod( 'app_landing_page_breadcrumb_separator', __( '/', 'app-landing-page' ) ) ); // delimiter between crumbs $home = esc_html( get_theme_mod( 'app_landing_page_breadcrumb_home_text', __( 'Home', 'app-landing-page' ) ) ); // text for the 'Home' link $showCurrent = get_theme_mod( 'app_landing_page_ed_current', '1' ); // 1 - show current post/page title in breadcrumbs, 0 - don't show $before = ''; // tag before the current crumb $after = ''; // tag after the current crumb global $post; $homeLink = esc_url( home_url( ) ); if (is_home() || is_front_page()) { if ($showOnHome == 1) echo '
' . $home . '
'; } else { echo '
' . $home . ' ' . $delimiter . ' '; if ( is_category() ) { $thisCat = get_category(get_query_var('cat'), false); if ($thisCat->parent != 0) echo get_category_parents($thisCat->parent, TRUE, ' ' . $delimiter . ' '); echo $before . single_cat_title('', false) . $after; } elseif ( is_search() ) { echo $before . esc_html__( 'Search Result', 'app-landing-page' ) . $after; } elseif ( is_day() ) { echo '' . esc_html( get_the_time('Y') ) . ' ' . $delimiter . ' '; echo '' . esc_html( get_the_time('F') ) . ' ' . $delimiter . ' '; echo $before . esc_html( get_the_time('d') ) . $after; } elseif ( is_month() ) { echo '' . esc_html( get_the_time('Y') ) . ' ' . $delimiter . ' '; echo $before . esc_html( get_the_time('F') ) . $after; } elseif ( is_year() ) { echo $before . esc_html( get_the_time('Y') ) . $after; } elseif ( is_single() && !is_attachment() ) { if ( get_post_type() != 'post' ) { $post_type = get_post_type_object(get_post_type()); $slug = $post_type->rewrite; echo '' . esc_html( $post_type->labels->singular_name ) . ''; if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . esc_html( get_the_title() ) . $after; } else { $cat = get_the_category(); $cat = $cat[0]; $cats = get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); if ($showCurrent == 0) $cats = preg_replace("#^(.+)\s$delimiter\s$#", "$1", $cats); echo $cats; if ($showCurrent == 1) echo $before . esc_html( get_the_title() ) . $after; } } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) { $post_type = get_post_type_object(get_post_type()); echo $before . esc_html( $post_type->labels->singular_name ) . $after; } elseif ( is_attachment() ) { $parent = get_post($post->post_parent); $cat = get_the_category($parent->ID); $cat = $cat[0]; echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); echo '' . esc_html( $parent->post_title ) . ''; if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . esc_html( get_the_title() ) . $after; } elseif ( is_page() && !$post->post_parent ) { if ($showCurrent == 1) echo $before . esc_html( get_the_title() ) . $after; } elseif ( is_page() && $post->post_parent ) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = '' . esc_html( get_the_title( $page->ID ) ) . ''; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); for ($i = 0; $i < count($breadcrumbs); $i++) { echo $breadcrumbs[$i]; if ($i != count($breadcrumbs)-1) echo ' ' . $delimiter . ' '; } if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . esc_html( get_the_title() ) . $after; } elseif ( is_tag() ) { echo $before . esc_html( single_tag_title('', false) ) . $after; } elseif ( is_author() ) { global $author; $userdata = get_userdata($author); echo $before . esc_html( $userdata->display_name ) . $after; } if ( get_query_var('paged') ) { if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' ('; echo __( 'Page', 'app-landing-page' ) . ' ' . get_query_var('paged'); if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')'; } echo '
'; } } // end app_landing_page_breadcrumbs() add_action( 'app_landing_page_breadcrumbs', 'app_landing_page_breadcrumbs_cb' ); /** Filter for Body Class **/ function app_landing_page_layout_class( $app_landing_page_classes ){ global $post; $app_landing_page_ed_slider = get_theme_mod( 'app_landing_page_ed_slider' ); if( !( is_active_sidebar( 'right-sidebar' )) || is_page_template( 'template-home.php' ) || is_404() ) { $app_landing_page_classes[] = 'full-width'; }elseif( is_search() ){ $app_landing_page_classes[] = ''; }elseif(is_singular()){ $app_landing_page_post_class = get_post_meta( $post->ID, 'app_landing_page_sidebar_layout', true ); if( $app_landing_page_post_class == 'no-sidebar' ) $app_landing_page_classes[] = 'full-width'; }elseif( $app_landing_page_ed_slider ){ $app_landing_page_classes[] = 'has-slider'; }else{ $app_landing_page_classes[] = ''; } return $app_landing_page_classes; } // if( !is_page_template( 'template-home.php' ) ) { echo 'header-inner'; } add_filter( 'body_class', 'app_landing_page_layout_class' ); /** * Hook to move comment text field to the bottom in WP 4.4 * * @link http://www.wpbeginner.com/wp-tutorials/how-to-move-comment-text-field-to-bottom-in-wordpress-4-4/ */ function app_landing_page_move_comment_field_to_bottom( $fields ) { $comment_field = $fields['comment']; unset( $fields['comment'] ); $fields['comment'] = $comment_field; return $fields; } add_filter( 'comment_form_fields', 'app_landing_page_move_comment_field_to_bottom' ); /** * Callback function for Comment List * * * @link https://codex.wordpress.org/Function_Reference/wp_list_comments */ function app_landing_page_theme_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; extract($args, EXTR_SKIP); if ( 'div' == $args['style'] ) { $tag = 'div'; $add_below = 'comment'; } else { $tag = 'li'; $add_below = 'div-comment'; } ?> < id="comment-">
$add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
array( 'class' => 'banner', 'id' => 'banner' ), 'featured-section' => array( 'class' => 'featured-on', 'id' => 'featured' ), 'features-section' => array( 'class' => 'features', 'id' => 'features' ), 'vedio-section' => array( 'class' => 'vedio', 'id' => 'vedio' ), 'intro-section' => array( 'class' => 'section-4', 'id' => 'intro' ), 'promotional-section' => array( 'class' => 'section-5', 'id' => 'service' ), 'counter-section' => array( 'class' => 'count-down', 'id' => 'stats' ), 'social-section' => array( 'class' => 'stay-tuned', 'id' => 'social' ), ); $app_landing_page_enabled_section = array(); foreach ( $app_landing_page_sections as $app_landing_page_section ) { if ( esc_attr( get_theme_mod( 'app_landing_page_ed_' . $app_landing_page_section['id'] . '_section' ) ) == 1 ){ $app_landing_page_enabled_section[] = array( 'id' => $app_landing_page_section['id'], 'class' => $app_landing_page_section['class'] ); } } return $app_landing_page_enabled_section; } add_action( 'app_landing_page_author_info_box', 'app_landing_page_author_info_box_cb' ); // Remove [...] from the excerpt and repace with ... function trim_excerpt($text) { $text = str_replace('[', '', $text); $text = str_replace(']', '', $text); return $text; } add_filter('get_the_excerpt', 'trim_excerpt'); function app_landing_page_author_info_box( ) { global $post; $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); $posted_on = sprintf( esc_html_x( '%s', 'post date', 'app-landing-page' ), '' . $time_string . '' ); // Detect if it is a single post with a post author //if ( is_single() && isset( $post->post_author ) ) { if(isset( $post->post_author )){ // Get author's display name $display_name = get_the_author_meta( 'display_name', $post->post_author ); // If display name is not available then use nickname as display name if ( empty( $display_name ) ) $display_name = get_the_author_meta( 'nickname', $post->post_author ); // Get author's biographical information or description $user_description = get_the_author_meta( 'user_description', $post->post_author ); // Get link to the author archive page $user_posts = get_author_posts_url( get_the_author_meta( 'ID' , $post->post_author)); if ( ! empty( $display_name ) ) $author_details = '' . $display_name . ''; if ( ! empty( $user_description ) ){ // Author avatar and bio $author_details .= ''; $author_details .= '

'.nl2br( $user_description ).'

'; //$author_details .= 'Read More'; } } // Pass all this info to post content ?>