: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Callback function for page metaboxes load
if ( !function_exists( 'herald_load_page_metaboxes' ) ) :
function herald_load_page_metaboxes() {
esc_html__( 'Page Layout', 'herald' ),
'herald_page_layout_metabox',
esc_html__( 'Sidebar', 'herald' ),
'herald_sidebar_metabox',
/* Authors template metabox */
esc_html__('Authors', 'herald'),
'herald_author_options_metabox',
esc_html__( 'Modules', 'herald' ),
'herald_modules_metabox',
esc_html__( 'Pagination', 'herald' ),
'herald_pagination_metabox',
* Callback function to save page meta data
if ( !function_exists( 'herald_save_page_metaboxes' ) ) :
function herald_save_page_metaboxes( $post_id, $post ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
if ( isset( $_POST['herald_page_nonce'] ) ) {
if ( !wp_verify_nonce( $_POST['herald_page_nonce'], __FILE__ ) )
if ( $post->post_type == 'page' && isset( $_POST['herald'] ) ) {
$post_type = get_post_type_object( $post->post_type );
if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
if( isset( $_POST['herald']['use_sidebar'] ) && $_POST['herald']['use_sidebar'] != 'inherit' ){
$herald_meta['use_sidebar'] = $_POST['herald']['use_sidebar'];
if( isset( $_POST['herald']['sidebar'] ) && $_POST['herald']['sidebar'] != 'inherit' ){
$herald_meta['sidebar'] = $_POST['herald']['sidebar'];
if( isset( $_POST['herald']['sticky_sidebar'] ) && $_POST['herald']['sticky_sidebar'] != 'inherit' ){
$herald_meta['sticky_sidebar'] = $_POST['herald']['sticky_sidebar'];
if( isset( $_POST['herald']['layout'] ) && $_POST['herald']['layout'] != 'inherit' ){
$herald_meta['layout'] = $_POST['herald']['layout'];
if( isset( $_POST['herald']['pag'] ) && $_POST['herald']['pag'] != 'none' ){
$herald_meta['pag'] = $_POST['herald']['pag'];
if ( isset( $_POST['herald']['sections'] ) ) {
$herald_meta['sections'] = array_values( $_POST['herald']['sections'] );
foreach($herald_meta['sections'] as $i => $section ){
if(!empty($section['modules'])){
foreach( $section['modules'] as $j => $module ){
if ( isset( $module['manual'] ) && !empty( $module['manual'] ) ) {
$section['modules'][$j]['manual'] = array_map( 'absint', explode( ",", $module['manual'] ) );
if ( isset( $module['author'] ) && !empty( $module['author'] ) ) {
$section['modules'][$j]['author'] = herald_get_authors_id_by_username($module['author']);
if( !empty( $module['exclude_by_id'] ) ){
$section['modules'][$j]['exclude_by_id'] = array_map('absint', explode(',', $module['exclude_by_id']));
if ( isset( $module['tag'] ) && !empty( $module['tag'] ) ) {
$tax = $module['type'] == 'woocommerce' ? 'product_tag' : 'post_tag';
$section['modules'][$j]['tag'] = herald_get_tax_term_slug_by_name( $module['tag'], $tax);
if( !empty( $module['tax'] ) ) {
foreach( $module['tax'] as $k => $tax ){
$taxonomies[$k] = herald_get_tax_term_id_by_name( $tax, $k);
$section['modules'][$j]['tax'] = $taxonomies;
$herald_meta['sections'][$i]['modules'] = array_values($section['modules']);
if ( isset( $_POST['herald']['authors'] ) ) {
$herald_meta['authors']['orderby'] = !empty( $_POST['herald']['authors']['orderby'] ) ? $_POST['herald']['authors']['orderby'] : 0;
$herald_meta['authors']['order'] = !empty( $_POST['herald']['authors']['order'] ) ? $_POST['herald']['authors']['order'] : 'DESC';
$herald_meta['authors']['exclude'] = !empty( $_POST['herald']['authors']['exclude'] ) ? array_map('absint', explode(',', $_POST['herald']['authors']['exclude'])) : '';
$herald_meta['authors']['roles'] = !empty( $_POST['herald']['authors']['roles'] ) ? $_POST['herald']['authors']['roles'] : array();
if(!empty($herald_meta)){
update_post_meta( $post_id, '_herald_meta', $herald_meta );
delete_post_meta( $post_id, '_herald_meta');
* Callback function to create layout metabox
if ( !function_exists( 'herald_page_layout_metabox' ) ) :
function herald_page_layout_metabox( $object, $box ) {
$meta = herald_get_page_meta( $object->ID );
$layouts = herald_get_page_layouts( true );
<ul class="herald-img-select-wrap">
<?php foreach ( $layouts as $id => $layout ): ?>
<?php $selected_class = $id == $meta['layout'] ? ' selected': ''; ?>
<img src="<?php echo esc_url($layout['img']); ?>" title="<?php echo esc_attr($layout['title']); ?>" class="herald-img-select<?php echo esc_attr($selected_class); ?>">
<span><?php echo esc_html( $layout['title'] ); ?></span>
<input type="radio" class="herald-hidden" name="herald[layout]" value="<?php echo esc_attr($id); ?>" <?php checked( $id, $meta['layout'] );?>/> </label>
<p class="description"><?php esc_html_e( 'Choose a layout', 'herald' ); ?></p>
* Callback function to create pagination metabox
if ( !function_exists( 'herald_pagination_metabox' ) ) :
function herald_pagination_metabox( $object, $box ) {
$meta = herald_get_page_meta( $object->ID );
$layouts = herald_get_pagination_layouts( false, true );
<ul class="herald-img-select-wrap">
<?php foreach ( $layouts as $id => $layout ): ?>
<?php $selected_class = $id == $meta['pag'] ? ' selected': ''; ?>
<img src="<?php echo esc_url($layout['img']); ?>" title="<?php echo esc_attr($layout['title']); ?>" class="herald-img-select<?php echo esc_attr($selected_class); ?>">
<span><?php echo esc_html( $layout['title'] ); ?></span>
<input type="radio" class="herald-hidden" name="herald[pag]" value="<?php echo esc_attr($id); ?>" <?php checked( $id, $meta['pag'] );?>/> </label>
<p class="description"><?php esc_html_e( 'Note: Pagination will be applied to the last post module on the page', 'herald' ); ?></p>
* Module generator metabox
* Callback function to create modules metabox
if ( !function_exists( 'herald_modules_metabox' ) ) :
function herald_modules_metabox( $object, $box ) {
$meta = herald_get_page_meta( $object->ID );
'use_sidebar' => 'right',
'sidebar' => 'herald_default_sidebar',
'sticky_sidebar' => 'herald_default_sticky_sidebar',
$module_defaults = herald_get_module_defaults();
'use_sidebar' => herald_get_sidebar_layouts(),
'sidebars' => herald_get_sidebars_list(),
'module_options' => herald_get_module_options()
<div id="herald-sections">
<?php if(!empty($meta['sections'])) : ?>
<?php foreach($meta['sections'] as $i => $section) : $section = herald_parse_args( $section, $default ); ?>
<?php herald_generate_section( $section, $options, $i ); ?>
<p><a href="javascript:void(0);" class="herald-add-section button-primary"><?php esc_html_e( 'Create new section', 'herald' ); ?></a></p>
<div id="herald-section-clone">
<?php herald_generate_section( $default, $options ); ?>
<div id="herald-module-clone">
<?php foreach( $module_defaults as $type => $module ): ?>
<div class="<?php echo esc_attr($type); ?>">
<?php herald_generate_module( $module, $options['module_options'][$type]); ?>
<div id="herald-sections-count" data-count="<?php echo count($meta['sections']); ?>"></div>
* Generate section field inside modules generator
* @param $section Data array for current section
* @param $options An array of section options
* @param $i id of a current section, if false then create an empty section
if ( !function_exists( 'herald_generate_section' ) ) :
function herald_generate_section( $section, $options, $i = false ) {
$name_prefix = ( $i === false ) ? '' : 'herald[sections]['.$i.']';
$edit = ( $i === false ) ? '' : 'edit';
$section_class = ( $i === false ) ? '' : 'herald-section-'.$i;
$section_num = ( $i === false ) ? '' : $i ;
<div class="herald-section <?php echo esc_attr($section_class); ?>" data-section="<?php echo esc_attr($section_num); ?>">
<div class="herald-modules">
<?php if(!empty( $section['modules'] ) ): ?>
<?php foreach($section['modules'] as $j => $module ) : $module = herald_parse_args( $module, herald_get_module_defaults( $module['type'] ) ); ?>
<?php herald_generate_module( $module, $module_options[$module['type']], $i, $j ); ?>
<div class="herald-modules-count" data-count="<?php echo esc_attr(count($section['modules'])); ?>"></div>
<div class="section-bottom">
<?php $module_data = herald_get_module_defaults(); ?>
<?php foreach( $module_data as $key => $mod ) : ?>
<a href="javascript:void(0);" class="herald-add-module button-secondary" data-type="<?php echo esc_attr($mod['type']); ?>"><?php echo '+ '.$mod['type_name']. ' ' .esc_html__( 'Module', 'herald'); ?></a>
<span><?php esc_html_e( 'Sidebar', 'herald' ); ?> (<span class="herald-sidebar"><?php echo esc_html( $section['use_sidebar'] ); ?></span>)</span>
<a href="javascript:void(0);" class="herald-edit-section button-secondary"><?php esc_html_e( 'Edit', 'herald' ); ?></a>
<a href="javascript:void(0);" class="herald-remove-section button-secondary"><?php esc_html_e( 'Remove', 'herald' ); ?></a>
<div class="herald-section-form <?php echo esc_attr($edit); ?>">
<div class="herald-opt-title">
<?php esc_html_e( 'Display sidebar', 'herald' ); ?>:
<div class="herald-opt-content">
<ul class="herald-img-select-wrap">
<?php foreach ( $use_sidebar as $id => $layout ): ?>
<?php $selected_class = herald_compare( $id, $section['use_sidebar'] ) ? ' selected': ''; ?>
<img src="<?php echo esc_url($layout['img']); ?>" title="<?php echo esc_attr($layout['title']); ?>" class="herald-img-select<?php echo esc_attr($selected_class); ?>">
<br/><span><?php echo esc_html( $layout['title'] ); ?></span>
<input type="radio" class="herald-hidden herald-count-me sec-sidebar" name="<?php echo esc_attr($name_prefix); ?>[use_sidebar]" value="<?php echo esc_attr($id); ?>" <?php checked( $id, $section['use_sidebar'] );?>/>
<small class="howto"><?php esc_html_e( 'Choose a sidebar layout', 'herald' ); ?></small>
<div class="herald-opt-title">
<?php esc_html_e( 'Standard sidebar', 'herald' ); ?>:
<div class="herald-opt-content">
<select name="<?php echo esc_attr($name_prefix); ?>[sidebar]" class="herald-count-me herald-opt-select">
<?php foreach ( $sidebars as $id => $name ): ?>
<option class="herald-count-me" value="<?php echo esc_attr($id); ?>" <?php selected( $id, $section['sidebar'] );?>><?php echo esc_html( $name ); ?></option>
<small class="howto"><?php esc_html_e( 'Choose a standard sidebar', 'herald' ); ?></small>
<div class="herald-opt-title">
<?php esc_html_e( 'Sticky sidebar', 'herald' ); ?>:
<div class="herald-opt-content">
<select name="<?php echo esc_attr($name_prefix); ?>[sticky_sidebar]" class="herald-count-me herald-opt-select">
<?php foreach ( $sidebars as $id => $name ): ?>
<option class="herald-count-me" value="<?php echo esc_attr($id); ?>" <?php selected( $id, $section['sticky_sidebar'] );?>><?php echo esc_html( $name ); ?></option>
<small class="howto"><?php esc_html_e( 'Choose a sticky sidebar', 'herald' ); ?></small>
<div class="herald-opt-title">
<?php esc_html_e( 'Custom CSS class', 'herald' ); ?>:
<div class="herald-opt-content">
<input class="herald-count-me" type="text" name="<?php echo esc_attr($name_prefix); ?>[css_class]" value="<?php echo esc_attr($section['css_class']);?>"/><br/>
<small class="howto"><?php esc_html_e( 'Specify class name for a possibility to apply custom styling to this section using CSS (i.e. my-custom-section)', 'herald' ); ?></small>
* @param $module Data array for current module
* @param $options An array of module options
* @param $i id of a current section
* @param $j id of a current module
if ( !function_exists( 'herald_generate_module' ) ) :
function herald_generate_module( $module, $options, $i = false, $j = false ) {
//print_r($module['type']);
$name_prefix = ( $i === false ) ? '' : 'herald[sections]['.$i.'][modules]['.$j.']';
$edit = ( $j === false ) ? '' : 'edit';
$module_class = ( $j === false ) ? '' : 'herald-module-'.$j;
$module_num = ( $j === false ) ? '' : $j;
$activate_hidden = $module['active'] ? 'herald-hidden' : '';
$deactivate_hidden = $module['active'] ? '' : 'herald-hidden';
if( !$module['active'] ) {
$module_class .= ' herald-module-disabled';
<div class="herald-module <?php echo esc_attr($module_class); ?>" data-module="<?php echo esc_attr($module_num); ?>">
<span class="herald-module-type">
<?php echo esc_html( $module['type_name'] ); ?>
<?php if(isset($module['columns']) && !in_array( $module['type'], array('woocommerce', 'authors', 'cats') ) ){
$columns = herald_get_module_columns();
echo '(<span class="herald-module-columns">'.$columns[$module['columns']]['title'].'</span>)';
<span class="herald-module-title"><?php echo esc_html( $module['title'] ); ?></span>
<a href="javascript:void(0);" class="herald-edit-module"><?php esc_html_e( 'Edit', 'herald' ); ?></a> |
<a href="javascript:void(0);" class="herald-deactivate-module"><span class="<?php echo esc_attr($deactivate_hidden);?>"><?php esc_html_e( 'Deactivate', 'herald' ); ?></span><span class="<?php echo esc_attr($activate_hidden);?>"><?php esc_html_e( 'Activate', 'herald' ); ?></span></a> |
<a href="javascript:void(0);" class="herald-remove-module"><?php esc_html_e( 'Remove', 'herald' ); ?></a>
<div class="herald-module-form <?php echo esc_attr($edit); ?>">
<input class="herald-count-me" type="hidden" name="<?php echo esc_attr($name_prefix); ?>[type]" value="<?php echo esc_attr($module['type']); ?>"/>
<input class="herald-module-deactivate" type="hidden" name="<?php echo esc_attr($name_prefix); ?>[active]" value="<?php echo esc_attr($module['active']); ?>"/>
<?php $mod_type = isset($module['cpt']) ? 'cpt' : $module['type']; ?>
<?php call_user_func( 'herald_generate_module_'.$mod_type, $module, $options, $name_prefix ); ?>
* @param $module Data array for current module
* @param $options An array of module options
* @param $name_prefix id of a current module
if ( !function_exists( 'herald_generate_module_posts' ) ) :
function herald_generate_module_posts( $module, $options, $name_prefix ){
<div class="herald-opt-tabs">
<a href="javascript:void(0);" class="active"><?php esc_html_e( 'Appearance', 'herald' ); ?></a>
<a href="javascript:void(0);"><?php esc_html_e( 'Selection', 'herald' ); ?></a>