: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @param string $type Module type
* @return array Default arguments of a module
if ( !function_exists( 'herald_get_module_defaults' ) ):
function herald_get_module_defaults( $type = false ) {
'type_name' => esc_html__( 'Posts', 'herald' ),
'starter_layout' => 'none',
'author_inc_exc' => 'in',
'exclude_by_id' => array(),
'type_name' => esc_html__( 'Featured', 'herald' ),
'author_inc_exc' => 'in',
'exclude_by_id' => array(),
'type_name' => esc_html__( 'Categories', 'herald'),
'count_label' => esc_html__( 'articles', 'herald'),
'type_name' => esc_html__( 'Text', 'herald' ),
'type_name' => esc_html__( 'Authors', 'herald' ),
'orderby' => 'post_count',
$taxonomies = herald_get_taxonomies( 'post', false );
foreach ($taxonomies as $taxonomy) {
$defaults['posts'][$taxonomy['id'] . '_inc_exc'] = 'in';
if ( herald_is_woocommerce_active() ) {
$defaults['woocommerce'] = array(
'type_name' => esc_html__( 'Products', 'herald' ),
$custom_post_types = herald_get_custom_post_types();
if ( !empty( $custom_post_types ) ) {
foreach ( $custom_post_types as $custom_post_type ) {
$defaults[$custom_post_type] = array(
'type' => $custom_post_type,
'type_name' => esc_html__( 'CPT', 'herald' ) . ' '.ucfirst( $custom_post_type ),
'starter_layout' => 'none',
'exclude_by_id' => array(),
$custom_post_type_taxonomies = herald_get_taxonomies( $custom_post_type );
if(!empty($custom_post_type_taxonomies)){
foreach ($custom_post_type_taxonomies as $custom_post_type_taxonomy) {
$defaults[$custom_post_type][$custom_post_type_taxonomy['id'] . '_inc_exc'] = 'in';
if ( !empty( $type ) && array_key_exists( $type, $defaults ) ) {
* @param string $type Module type
* @return array Options for sepcific module
if ( !function_exists( 'herald_get_module_options' ) ):
function herald_get_module_options( $type = false ) {
'layouts' => herald_get_main_layouts(),
'starter_layouts' => herald_get_main_layouts( false, true ),
'columns' => herald_get_module_columns(),
'cats' => get_categories( array( 'hide_empty' => false, 'number' => 0 ) ),
'tax' => herald_get_taxonomies('post', false),
'time' => herald_get_time_diff_opts(),
'order' => herald_get_post_order_opts(),
'formats' => herald_get_post_format_opts(),
'layouts' => herald_get_featured_layouts(),
'cats' => get_categories( array( 'hide_empty' => false, 'number' => 0 ) ),
'time' => herald_get_time_diff_opts(),
'order' => herald_get_post_order_opts(),
'formats' => herald_get_post_format_opts(),
'post_types' => herald_get_posts_types_with_taxonomies(array('page'))
'layouts' => herald_get_main_layouts(false, false, array('a', 'a1', 'a2', 'a3', 'b', 'b1', 'd', 'd1', 'e', 'g', 'g1', 'h', 'j')),
'cats' => get_categories( array( 'hide_empty' => false, 'number' => 0 ) )
'columns' => herald_get_module_columns(),
'layouts' => herald_get_author_layouts(),
'time' => herald_get_time_diff_opts(),
if ( herald_is_woocommerce_active() ) {
$options['woocommerce'] = array(
'cats' => get_terms( 'product_cat', array( 'hide_empty' => false, 'number' => 0 ) ),
'order' => herald_get_product_order_opts(),
'time' => herald_get_time_diff_opts()
$custom_post_types = herald_get_custom_post_types();
if ( !empty( $custom_post_types ) ) {
foreach ( $custom_post_types as $custom_post_type ) {
$options[$custom_post_type] = array(
'layouts' => herald_get_main_layouts(),
'starter_layouts' => herald_get_main_layouts( false, true ),
'columns' => herald_get_module_columns(),
'time' => herald_get_time_diff_opts(),
'order' => herald_get_post_order_opts(),
'taxonomies' => herald_get_taxonomies( $custom_post_type )
if ( !empty( $type ) && array_key_exists( $type, $options ) ) {
* Functions gets current post layout for specific module
* @param array $module Module data
* @param int $i index of current post
* @return string id of current layout
if ( !function_exists( 'herald_get_module_layout' ) ):
function herald_get_module_layout( $module, $i ) {
if ( herald_module_is_slider( $module ) ) {
return $module['layout'];
} else if ( isset( $module['starter_layout'] ) && $module['starter_layout'] != 'none' && $i < absint( $module['starter_limit'] ) ) {
return $module['starter_layout'];
return $module['layout'];
* Check if slider is applied to module
* @param array $module Module data
if ( !function_exists( 'herald_module_is_slider' ) ):
function herald_module_is_slider( $module ) {
if ( isset( $module['slider'] ) && !empty( $module['slider'] ) ) {
* Check if module has starter posts
* @param array $module Module data
if ( !function_exists( 'herald_module_is_combined' ) ):
function herald_module_is_combined( $module ) {
if ( isset( $module['starter_layout'] ) && $module['starter_layout'] != 'none' && !empty( $module['starter_limit'] ) ) {
* Check if current module has a pagination
* @param unknown $i current section index
* @param unknown $j current module index
if ( !function_exists( 'herald_module_is_paginated' ) ):
function herald_module_is_paginated( $i, $j ) {
global $herald_module_pag_index;
if ( !empty( $herald_module_pag_index ) && $herald_module_pag_index['s_ind'] == $i && $herald_module_pag_index['m_ind'] == $j ) {
* Set paginated module index
* Get last posts module index so we know to which module we should apply pagination
* and set indexes to $herald_module_pag_index global var
* @param array $sections Sections data array
if ( !function_exists( 'herald_set_paginated_module_index' ) ):
function herald_set_paginated_module_index( $sections, $paged = false ) {
global $herald_module_pag_index;
//If we are on paginated modules page it shows only one section and module so index is set to "0"
$herald_module_pag_index = array( 's_ind' => 0, 'm_ind' => 0 );
$last_section_index = false;
$last_module_index = false;
foreach ( $sections as $m => $section ) {
if ( !empty( $section['modules'] ) ) {
foreach ( $section['modules'] as $n => $module ) {
if ( $module['type'] == 'posts' ) {
$last_section_index = $m;
if ( $last_section_index !== false && $last_module_index !== false ) {
$herald_module_pag_index = array( 's_ind' => $last_section_index, 'm_ind' => $last_module_index );
* Module template is paged
* Check if we are on paginated modules page
if ( !function_exists( 'herald_module_template_is_paged' ) ):
function herald_module_template_is_paged() {
$curr_page = is_front_page() ? absint( get_query_var( 'page' ) ) : absint( get_query_var( 'paged' ) );
return $curr_page > 1 ? $curr_page : false;
* Parse paged module template
* When we are on paginated module page
* pull only the last posts module and its section
* but check queries for other modules in other sections
* @param array $sections existing sections data
* @return array parsed new section data
if ( !function_exists( 'herald_parse_paged_module_template' ) ):
function herald_parse_paged_module_template( $sections ) {
foreach ( $sections as $s_ind => $section ) {
if ( !empty( $section['modules'] ) ) {
foreach ( $section['modules'] as $m_ind => $module ) {
$module = herald_parse_args( $module, herald_get_module_defaults( $module['type'] ) );
if ( $module['type'] == 'posts' ) {
if ( herald_module_is_paginated( $s_ind, $m_ind ) ) {
$new_sections = array( 0 => $section );
$module['starter_layout'] = 'none';
$new_sections[0]['modules'] = array( 0 => $module );
if ( $module['unique'] && $module['active']) {
herald_get_module_query( $module );
} else if ( $module['type'] == 'featured' ) {
if ( $module['unique'] && $module['active'] ) {
herald_get_featured_module_query( $module );