: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Wrapper function for __()
* It checks if specific text is translated via options panel
* If option is set, it returns translated text from theme options
* If option is not set, it returns default translation string (from language file)
* @param string $string_key Key name (id) of translation option
* @return string Returns translated string
if ( !function_exists( '__herald' ) ):
function __herald( $string_key ) {
if ( ( $translated_string = herald_get_option( 'tr_'.$string_key ) ) && herald_get_option( 'enable_translate' ) ) {
if ( $translated_string == '-1' ) {
return $translated_string;
$translate = herald_get_translate_options();
return $translate[$string_key]['text'];
* Function gets featured image depending on the size and post id.
* If image is not set, it gets the default featured image placehloder from theme options.
* @param string $size Image size ID
* @param int $post_id Post ID - if not passed it gets current post id by default
* @param bool $ignore_default_img Wheter to apply default featured image post doesn't have featured image
* @return string Image HTML output
if ( !function_exists( 'herald_get_featured_image' ) ):
function herald_get_featured_image( $size = 'large', $post_id = false, $ignore_default_img = false, $ignore_size_suffix = false ) {
global $herald_sidebar_opts, $herald_img_flag, $herald_image_matches;
if ( empty( $post_id ) ) {
//Check if we need to force "full" or "with sidebar" size
if ( (!$ignore_size_suffix && $herald_img_flag == 'full') || ( !$ignore_size_suffix && $herald_sidebar_opts['use_sidebar'] == 'none' && $herald_img_flag != 'sid' ) ) {
if( get_post_type() == 'attachment'){
return '<img src="'.esc_attr( wp_get_attachment_url( $post_id ) ).'" alt="'.esc_attr( get_the_title( $post_id ) ).'" />';
//Check if has a matched image size
if ( !empty( $herald_image_matches ) && array_key_exists( $size, $herald_image_matches ) ) {
$size = $herald_image_matches[$size];
if ( has_post_thumbnail( $post_id ) ) {
return get_the_post_thumbnail( $post_id, $size );
} else if ( !$ignore_default_img && ( $placeholder = herald_get_option( 'default_fimg' ) ) ) {
//If there is no featured image, try to get default from theme options
global $placeholder_img, $placeholder_imgs;
if ( empty( $placeholder_img ) ) {
$img_id = herald_get_image_id_by_url( $placeholder );
$img_id = $placeholder_img;
if ( !empty( $img_id ) ) {
if ( !isset( $placeholder_imgs[$size] ) ) {
$def_img = wp_get_attachment_image( $img_id, $size );
$def_img = $placeholder_imgs[$size];
if ( !empty( $def_img ) ) {
$placeholder_imgs[$size] = $def_img;
return '<img src="'.esc_attr( $placeholder ).'" alt="'.esc_attr( get_the_title( $post_id ) ).'" />';
* Function gets categories for current post and displays and slightly modifies
* HTML output of category list so we can have category id in class parameter
* @return string HTML output of category links
if ( !function_exists( 'herald_get_category' ) ):
function herald_get_category() {
$primary_category = herald_is_yoast_active() ? herald_get_option('primary_category') : false;
$primary_term_id = $primary_category ? get_post_meta( $post->ID, '_yoast_wpseo_primary_category', true ) : false;
$allow_on_single = is_single() && get_queried_object_id() == $post->ID;
if ( $primary_category && isset($primary_term_id) && !empty($primary_term_id) && !$allow_on_single ) {
$term = get_term( $primary_term_id );
if(!is_wp_error( $term ) && !empty($term)){
return '<a href="'.esc_url( get_term_link( $term->term_id ) ).'" class="herald-cat-'.$term->term_id.'">'.$term->name.'</a>';
$taxonomies = get_post_taxonomies( $post->ID );
if ( !empty( $taxonomies ) ) {
foreach ( $taxonomies as $tax ) {
if ( is_taxonomy_hierarchical( $tax ) ) {
$terms = get_the_terms( $post->ID, $tax );
if ( !empty( $terms ) ) {
foreach ( $taxs as $tax ) {
foreach ( $tax as $term ) {
$output[] = '<a href="'.esc_url( get_term_link( $term->term_id ) ).'" class="herald-cat-'.$term->term_id.'">'.$term->name.'</a>';
if ( !empty( $output ) ) {
$output = implode( ' <span>•</span> ', $output );
* Function outputs meta data HTML based on theme options for specifi layout
* @param string $layout Layout ID
* @param array $force_meta Force specific meta instead of using options
* @return string HTML output of meta data
if ( !function_exists( 'herald_get_meta_data' ) ):
function herald_get_meta_data( $layout = 'a', $force_meta = false ) {
$meta_data = $force_meta !== false ? $force_meta : array_keys( array_filter( herald_get_option( 'lay_'.$layout .'_meta' ) ) );
if ( !empty( $meta_data ) ) {
$has_time = in_array( 'time', $meta_data ) ? true : false;
$has_date = in_array( 'date', $meta_data ) ? true : false;
foreach ( $meta_data as $mkey ) {
$time = ' '.get_the_time();
$meta = '<span class="updated">'.get_the_date().$time.'</span>';
$time = ' '.get_the_modified_time();
$meta = '<span class="updated">'.get_the_modified_date().$time.'</span>';
if ( !$time_added && !$has_date ) {
$meta = '<span class="updated">'.get_the_time().'</span>';
if ( herald_is_co_authors_active() && $coauthors_meta = get_coauthors() ) {
foreach ( $coauthors_meta as $key ) {
$temp .= '<span class="vcard author"><span class="fn"><a href="'.esc_url( get_author_posts_url( $key->ID, $key->user_nicename ) ).'">'.$key->display_name.'</a></span></span>';
$multi_class = count( $coauthors_meta ) > 1 ? "couauthors-icon" : '';
$meta = '<div class="coauthors '.esc_attr( $multi_class ).'">'.$temp.'</div>';
$author_id = get_post_field( 'post_author', get_the_ID() );
$meta = '<span class="vcard author"><span class="fn"><a href="'.esc_url( get_author_posts_url( get_the_author_meta( 'ID', $author_id ) ) ).'">'.get_the_author_meta( 'display_name', $author_id ).'</a></span></span>';
$thousands_sep = isset( $wp_locale->number_format['thousands_sep'] ) ? $wp_locale->number_format['thousands_sep'] : ',';
if ( strlen( $thousands_sep ) > 1 ) {
$thousands_sep = trim( $thousands_sep );
$meta = function_exists( 'ev_get_post_view_count' ) ? number_format_i18n( absint( str_replace( $thousands_sep, '', ev_get_post_view_count( get_the_ID() ) ) + absint( herald_get_option( 'views_forgery' ) ) ) ) . ' '.__herald( 'views' ) : '';
$meta = herald_read_time( get_post_field( 'post_content', get_the_ID() ) );
$meta .= ' '.__herald( 'min_read' );
if ( comments_open() || get_comments_number() ) {
comments_popup_link( __herald( 'no_comments' ), __herald( 'one_comment' ), __herald( 'multiple_comments' ) );
$meta = ob_get_contents();
if ( herald_is_wp_review_active() ) {
$meta = function_exists( 'wp_review_show_total' ) ? wp_review_show_total( false, '' ) : '';
$output .= '<div class="meta-item herald-'.$mkey.'">'.$meta.'</div>';
* Function outputs post excerpt for specific layout
* @param string $layout Layout ID
* @param string $force_meta Force specific meta instead of using options for layout
* @return string HTML output of category links
if ( !function_exists( 'herald_get_excerpt' ) ):
function herald_get_excerpt( $layout = 'a' ) {
$content = get_the_excerpt();
$text = get_the_content( '' );
$text = strip_shortcodes( $text );
$text = apply_filters( 'the_content', $text );
$content = str_replace( ']]>', ']]>', $text );
if ( !empty( $content ) ) {
$limit = herald_get_option( 'lay_'.$layout.'_excerpt_limit' );
if ( !empty( $limit ) || !$manual_excerpt ) {
$more = herald_get_option( 'more_string' );
$content = wp_strip_all_tags( $content );
$content = preg_replace( '/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $content );
$content = herald_trim_chars( $content, $limit, $more );
return wpautop( $content );
* Function gets title and description for current template
* @return string Uses herald_print_heading() to generate HTML output
if ( !function_exists( 'herald_get_archive_heading' ) ):
function herald_get_archive_heading() {
$obj = get_queried_object();
$args['title'] = __herald( 'category' ).single_cat_title( '', false );
$args['desc'] = herald_get_option( 'category_desc' ) ? category_description() : '';
$args['cat'] = $obj->term_id;
if ( herald_get_option( 'category_sub' ) ) {
$sub = get_categories( array( 'parent' => $obj->term_id, 'hide_empty' => false ) );
foreach ( $sub as $child ) {
$args['subnav'] .= '<a href="'.esc_url( get_category_link( $child ) ).'">'.$child->name.'</a>';
$args['title'] .= '<i class="fa fa-angle-down herald-sub-cat-icon" aria-hidden="true"></i><div class="herald-mod-subnav-mobile">'.$args['subnav'].'</div>';
if ( !empty( $obj->parent ) ) {
$parent = get_category( $obj->parent );
$args['actions'] = '<a href="'.esc_url( get_category_link( $parent->term_id ) ).'">'.$parent->name.'</a>';
} else if ( is_author() ) {
$obj = get_queried_object();
$obj = isset( $_GET['author_name'] ) ? get_user_by( 'slug', $author_name ) : get_userdata( intval( $author ) );
if ( herald_is_co_authors_active() ) {
$args['title'] = __herald( 'author' ).$obj->display_name;
if ( herald_get_option( 'author_desc' ) ) {
$args['desc'] = wpautop( get_avatar( $obj->ID, 80 ) . get_the_author_meta( 'description' ) );
if ( herald_get_option( 'author_social' ) ) {
$args['subnav'] = herald_get_author_social( $obj->ID );
$args['title'] = __herald( 'author' ).$obj->display_name;
if ( herald_get_option( 'author_desc' ) ) {
$args['desc'] = wpautop( get_avatar( $obj->ID, 80 ) . get_the_author_meta( 'description', $obj->ID ) );
if ( herald_get_option( 'author_social' ) ) {
$args['subnav'] = herald_get_author_social( $obj->ID );
$args['title'] = single_term_title( '', false );
} else if ( is_home() && ( $posts_page = get_option( 'page_for_posts' ) ) && !is_page_template( 'template-modules.php' ) ) {
$args['title'] = get_the_title( $posts_page );
} else if ( is_search() ) {
$args['title'] = __herald( 'search_results_for' ).get_search_query();
$args['desc'] = get_search_form( false );
$args['title'] = __herald( 'tag' ).single_tag_title( '', false );
$args['desc'] = tag_description();
$args['title'] = __herald( 'archive' ).get_the_date();
} else if ( is_month() ) {
$args['title'] = __herald( 'archive' ).get_the_date( 'F Y' );
} else if ( is_year() ) {
$args['title'] = __herald( 'archive' ).get_the_date( 'Y' );
if ( !empty( $args['title'] ) ) {
$args['title'] = '<h1 class="h6 herald-mod-h herald-color">'.$args['title'].'</h1>';
if ( !empty( $args['desc'] ) ) {
$args['desc'] = wpautop( $args['desc'] );
return herald_print_heading( $args );
* Checks format of current post and returns icon class.
* @return string Icon HTML output
if ( !function_exists( 'herald_post_format_icon' ) ):
function herald_post_format_icon() {
$format = get_post_format();
'audio' => 'fa-volume-up',
'image' => 'fa-picture-o',
//Allow plugins or child themes to modify icons
$icons = apply_filters( 'herald_post_format_icons', $icons );
if ( $format && array_key_exists( $format, $icons ) ) {
return '<span class="herald-format-icon"><i class="fa '.esc_attr( $icons[$format] ).'"></i></span>';
* Get post display option
* Checks if specific option is ovewritten in single post
* so we know if we pull this options from global options or particular post
* @param string $option Option id string