: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Function gets heading/title html for current module
* @param array $module Module data
* @return string HTML output
if ( !function_exists( 'herald_get_module_heading' ) ):
function herald_get_module_heading( $module ) {
if ( !empty( $module['cat'] ) && count( $module['cat'] ) == 1 && $module['cat_inc_exc'] == 'in') {
$args['cat'] = $module['cat'][0];
if ( isset( $args['cat'] ) && isset( $module['cat_nav'] ) && !empty( $module['cat_nav'] ) ) {
$sub_cats = get_categories( array( 'parent' => $args['cat'], 'hide_empty' => false ) );
if ( !empty( $sub_cats ) ) {
foreach ( $sub_cats as $child ) {
$args['subnav'] .= '<a href="'.esc_url( get_category_link( $child ) ).'">'.$child->name.'</a>';
if ( !empty( $module['title'] ) && empty( $module['hide_title'] ) ) {
$icon_responsive_class = !empty( $sub_cats ) ? 'herald-mobile-hidden' : '';
if ( !empty( $module['title_link'] ) ) {
$module['title'] = '<a href="'.esc_url( $module['title_link'] ).'">'.$module['title'].'<i class="fa fa-chevron-right '.$icon_responsive_class.'"></i></a>';
if ( !empty( $sub_cats ) ) {
$module['title'] .= '<i class="fa fa-angle-down herald-sub-cat-icon" aria-hidden="true"></i><div class="herald-mod-subnav-mobile">'.$args['subnav'].'</div>';
$args['title'] = '<h2 class="h6 herald-mod-h herald-color">'.$module['title'].'</h2>';
if ( isset( $module['more_text'] ) && !empty( $module['more_text'] ) && !empty( $module['more_url'] ) ) {
$args['actions'].= '<a class="herald-all-link" href="'.esc_url( $module['more_url'] ).'">'.$module['more_text'].'</a>';
if ( herald_module_is_slider( $module ) ) {
$args['actions'].= '<div class="herald-slider-controls" data-col="'.esc_attr( herald_layout_columns( $module['layout'] ) ).'" data-autoplay="'.absint( $module['autoplay'] ).'"></div>';
return !empty( $args ) ? herald_print_heading( $args ) : '';
* @param array $module Module data
* @return object WP_query
if ( !function_exists( 'herald_get_module_query' ) ):
function herald_get_module_query( $module, $paged = false ) {
global $herald_unique_module_posts;
$module = wp_parse_args( $module, herald_get_module_defaults( $module['type'] ) );
$args['ignore_sticky_posts'] = 1;
if ( !empty( $module['manual'] ) ) {
$args['posts_per_page'] = absint( count( $module['manual'] ) );
$args['orderby'] = 'post__in';
$args['post__in'] = $module['manual'];
$args['post_type'] = array_keys( get_post_types( array( 'public' => true ) ) ); //support all existing public post types
$args['post_type'] = 'post';
$args['posts_per_page'] = absint( $module['limit'] );
if ( !empty( $module['cat'] ) ) {
if ( $module['cat_child'] ) {
$child_cat_temp = array();
foreach ( $module['cat'] as $parent ) {
$child_cats = get_categories( array( 'child_of' => $parent ) );
if ( !empty( $child_cats ) ) {
foreach ( $child_cats as $child ) {
$child_cat_temp[] = $child->term_id;
$module['cat'] = array_merge( $module['cat'], $child_cat_temp );
$args['category__'.$module['cat_inc_exc']] = $module['cat'];
if ( !empty( $module['tag'] ) ) {
$args['tag__'.$module['tag_inc_exc']] = herald_get_tax_term_id_by_slug( $module['tag'] );
$args['tax_query'] = array();
if ( !empty( $module['tax'] ) ) {
foreach ( $module['tax'] as $k => $v ) {
$temp['operator'] = $module["{$k}_inc_exc"] == 'not_in' ? 'NOT IN' : 'IN';
$args['tax_query'] = $taxonomies;
if ( !empty( $module['author'] ) ) {
$args['author__'.$module['author_inc_exc']] = $module['author'];
if ( !empty( $module['format'] ) ) {
if ( $module['format'] == 'standard' ) {
$formats = get_theme_support( 'post-formats' );
if ( !empty( $formats ) && is_array( $formats[0] ) ) {
foreach ( $formats[0] as $format ) {
$terms[] = 'post-format-'.$format;
$terms = array( 'post-format-'.$module['format'] );
$args['tax_query'][] = array(
'taxonomy' => 'post_format',
$args['orderby'] = $module['order'];
if ( $args['orderby'] == 'views' && function_exists( 'ev_get_meta_key' ) ) {
$args['orderby'] = 'meta_value_num';
$args['meta_key'] = ev_get_meta_key();
} else if ( strpos( $args['orderby'], 'reviews' ) !== false && herald_is_wp_review_active() ) {
if ( strpos( $args['orderby'], 'user' ) !== false ) {
$review_type = substr( $args['orderby'], 13, strlen( $args['orderby'] ) );
$args['orderby'] = 'meta_value_num';
$args['meta_key'] = 'wp_review_user_reviews';
$args['meta_query'] = array(
'key' => 'wp_review_user_review_type',
$review_type = substr( $args['orderby'], 8, strlen( $args['orderby'] ) );
$args['orderby'] = 'meta_value_num';
$args['meta_key'] = 'wp_review_total';
$args['meta_query'] = array(
'key' => 'wp_review_type',
if ( count( $args['tax_query'] ) > 1 ) {
$args['tax_query']['relation'] = 'OR';
$args['order'] = $module['sort'];
if ( $time_diff = $module['time'] ) {
$args['date_query'] = array( 'after' => date( 'Y-m-d', herald_calculate_time_diff( $time_diff ) ) );
if ( !empty( $herald_unique_module_posts ) ) {
$args['post__not_in'] = $herald_unique_module_posts;
if ( !empty( $module['exclude_by_id'] ) ) {
if ( !empty( $args['post__not_in'] ) ) {
$args['post__not_in'] = array_unique( array_merge( $args['post__not_in'], $module['exclude_by_id'] ) ) ;
$args['post__not_in'] = $module['exclude_by_id'];
$args = apply_filters('herald_modify_module_query_args', $args ); //Allow child themes or plugins to modify
$query = new WP_Query( $args );
if ( $module['unique'] && !is_wp_error( $query ) && !empty( $query ) ) {
foreach ( $query->posts as $p ) {
$herald_unique_module_posts[] = $p->ID;
* Get featured module query
* @param array $module Module data
* @return object WP_query
if ( !function_exists( 'herald_get_featured_module_query' ) ):
function herald_get_featured_module_query( $module ) {
global $herald_unique_module_posts;
$module = wp_parse_args( $module, herald_get_module_defaults( $module['type'] ) );
$args['ignore_sticky_posts'] = 1;
if ( !empty( $module['manual'] ) ) {
$args['orderby'] = 'post__in';
$args['post__in'] = $module['manual'];
$args['post_type'] = array_keys( get_post_types( array( 'public' => true ) ) ); //support all existing public post types
$args['post_type'] = $module['post_type'];
$post_type_with_taxonomies = herald_get_post_type_with_taxonomies($module['post_type']);
$args['posts_per_page'] = absint( herald_get_featured_area_numposts( $module['layout'] ) );
if(!empty($post_type_with_taxonomies->taxonomies)){
foreach ( $post_type_with_taxonomies->taxonomies as $taxonomy ) {
$taxonomy_id = herald_patch_taxonomy_id($taxonomy['id']);
if(empty($module[$taxonomy_id . '_inc_exc']) || empty($module[$taxonomy_id])){
$operator = $module[$taxonomy_id . '_inc_exc'] === 'not_in' ? 'NOT IN' : 'IN';
if($taxonomy['hierarchical']){
$include_children = !empty($module[$taxonomy_id . '_child']) ? boolval($module[$taxonomy_id . '_child']) : false;
$args['tax_query'][] = array(
'taxonomy' => $taxonomy['id'],
'terms' => $module[$taxonomy_id],
'include_children' => $include_children
$args['tax_query'][] = array(
'taxonomy' => $taxonomy['id'],
'terms' => herald_get_tax_term_id_by_slug( $module[$taxonomy_id], $taxonomy['id']),
if ( !empty( $module['author'] ) ) {
$args['author__'.$module['author_inc_exc']] = $module['author'];
if ( !empty( $module['format'] ) && $module['post_type'] == 'post' ) {
if ( $module['format'] == 'standard' ) {
$formats = get_theme_support( 'post-formats' );
if ( !empty( $formats ) && is_array( $formats[0] ) ) {
foreach ( $formats[0] as $format ) {
$terms[] = 'post-format-'.$format;
$terms = array( 'post-format-'.$module['format'] );
'taxonomy' => 'post_format',
$args['orderby'] = $module['order'];
if ( $args['orderby'] == 'views' && function_exists( 'ev_get_meta_key' ) ) {
$args['orderby'] = 'meta_value_num';
$args['meta_key'] = ev_get_meta_key();
} else if ( strpos( $args['orderby'], 'reviews' ) !== false && herald_is_wp_review_active() ) {
if ( strpos( $args['orderby'], 'user' ) !== false ) {
$review_type = substr( $args['orderby'], 13, strlen( $args['orderby'] ) );
$args['orderby'] = 'meta_value_num';
$args['meta_key'] = 'wp_review_user_reviews';
$args['meta_query'] = array(
'key' => 'wp_review_user_review_type',
$review_type = substr( $args['orderby'], 8, strlen( $args['orderby'] ) );
$args['orderby'] = 'meta_value_num';
$args['meta_key'] = 'wp_review_total';
$args['meta_query'] = array(
'key' => 'wp_review_type',
$args['order'] = $module['sort'];
if ( $time_diff = $module['time'] ) {
$args['date_query'] = array( 'after' => date( 'Y-m-d', herald_calculate_time_diff( $time_diff ) ) );
if ( !empty( $herald_unique_module_posts ) ) {
$args['post__not_in'] = $herald_unique_module_posts;
if ( !empty( $module['exclude_by_id'] ) ) {
if ( !empty( $args['post__not_in'] ) ) {
$args['post__not_in'] = array_unique( array_merge( $args['post__not_in'], $module['exclude_by_id'] ) ) ;
$args['post__not_in'] = $module['exclude_by_id'];
$args = apply_filters('herald_modify_featured_module_query_args', $args ); //Allow child themes or plugins to modify
$query = new WP_Query( $args );
if ( $module['unique'] && !is_wp_error( $query ) && !empty( $query ) ) {
foreach ( $query->posts as $p ) {
$herald_unique_module_posts[] = $p->ID;
* Get module products query
* @param array $module Module data
* @return object WP_query
if ( !function_exists( 'herald_get_module_products_query' ) ):
function herald_get_module_products_query( $module ) {
$module = wp_parse_args( $module, herald_get_module_defaults( $module['type'] ) );
$args['ignore_sticky_posts'] = 1;
if ( !empty( $module['manual'] ) ) {
$args['posts_per_page'] = absint( count( $module['manual'] ) );
$args['orderby'] = 'post__in';
$args['post__in'] = $module['manual'];
$args['post_type'] = 'product';
$args['post_type'] = 'product';
$args['posts_per_page'] = absint( $module['limit'] );
$args['tax_query'] = array();
if ( !empty( $module['cat'] ) ) {
$args['tax_query'][] = array(
'taxonomy' => 'product_cat',
'terms' => $module['cat'],
'operator' => $module["cat_inc_exc"] == 'not_in' ? 'NOT IN' : 'IN'
if ( !empty( $module['tag'] ) ) {
$args['tax_query'][] = array(
'taxonomy' => 'product_tag',
'terms' => $module['tag'],
'operator' => $module["tag_inc_exc"] == 'not_in' ? 'NOT IN' : 'IN'
if ( count( $args['tax_query'] ) > 1 ) {
$args['tax_query']['relation'] = 'AND';
$args['orderby'] = $module['order'];
if ( $args['orderby'] == 'views' && function_exists( 'ev_get_meta_key' ) ) {
$args['orderby'] = 'meta_value_num';
$args['meta_key'] = ev_get_meta_key();
if ( $time_diff = $module['time'] ) {
$args['date_query'] = array( 'after' => date( 'Y-m-d', herald_calculate_time_diff( $time_diff ) ) );
$args = apply_filters('herald_modify_products_module_query_args', $args ); //Allow child themes or plugins to modify
$query = new WP_Query( $args );
* @param array $module Module data
* @return object WP_query
if ( !function_exists( 'herald_get_module_cpt_query' ) ):
function herald_get_module_cpt_query( $module, $paged = false ) {