HEX
Server: nginx/1.24.0
System: Linux DGT-WORDPRESS-VM-SERVER 6.14.0-1014-azure #14~24.04.1-Ubuntu SMP Fri Oct 3 20:52:11 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.4.12
Disabled: NONE
Upload Files
File: /mnt/data/dreamssalon-wp-market/wp-content/themes/dreamsalon/inc/register_widget.php
<?php
/* Register Menu */
add_action( 'init', 'dreamsalon_register_menus' );
function dreamsalon_register_menus() {
  register_nav_menus( array(
    'primary'   => esc_html__( 'Primary Menu','dreamsalon' )

  ) );
}
 

 
function dreamsalon_second_widgets_init() {

  $args_blog = array(
    'name'          => esc_html__( 'Blog Sidebar' ,'dreamsalon'),
    'id'            => 'blog-sidebar',
    'description'   => esc_html__( 'Main Sidebar','dreamsalon' ),
    'class'         => '',
    'before_widget' => '<div id="%1$s" class="widget card %2$s">',
    'after_widget'  => '</div></div>',
    'before_title'  => '<div class="card-header  mb-0"><h4 class="sidebar-widget-title mb-0">',
    'after_title'   => '</h4></div><div class="card-body">',
  );

  register_sidebar( $args_blog );
}
add_action( 'widgets_init', 'dreamsalon_second_widgets_init' );

/**
 * Fallback for widgets that have no title: add the .widget-inner wrapper
 */
add_filter( 'dynamic_sidebar_params', 'dreamsalon_widget_inner_fallback' );
function dreamsalon_widget_inner_fallback( $params ) {
    // target only our sidebar
    if ( isset( $params[0]['id'] ) && 'blog-sidebar' === $params[0]['id'] ) {

        // if the before_widget already contains widget-inner, do nothing
        if ( false === strpos( $params[0]['before_widget'], 'widget-inner' ) ) {

            /*
             * Widgets without titles won't print 'after_title' so our opening <div class="widget-inner">
             * never appears. Append it to before_widget as a fallback and ensure after_widget closes it.
             */
            $params[0]['before_widget'] .= '<div class="card-body">';
            // ensure we still close both inner + outer
            $params[0]['after_widget'] = '</div></div>';
        }
    }
    return $params;
}