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/wp-content/themes/dreamsalon/functions.php
<?php
if ( ! defined('ABSPATH') ) {
    exit;
}

 if(defined('DREAMSALON_URL') 	== false) 	define('DREAMSALON_URL', get_template_directory());
 if(defined('DREAMSALON_URI') 	== false) 	define('DREAMSALON_URI', get_template_directory_uri());
  

  add_action('after_setup_theme', 'dreamsalon_load_textdomain');
function dreamsalon_load_textdomain() {
    load_theme_textdomain('dreamsalon', get_template_directory() . '/languages');
 } 

// Require metabox
if( is_admin() ){
    // Require TGM
    require_once ( DREAMSALON_URL.'/inc/active_plugins.php' );	
    require_once (DREAMSALON_URL . '/inc/class-tgm-plugin-activation.php');	
    require( DREAMSALON_URL.'/inc/dreamsalon-demo-content.php' );
}
// require libraries, function
require( DREAMSALON_URL.'/inc/init.php' );

// Add js, css
require( DREAMSALON_URL.'/inc/add_js_css.php' );
    // register menu, widget
require( DREAMSALON_URL.'/inc/register_widget.php' );

// require menu
require_once (DREAMSALON_URL.'/inc/dsr_walker_nav_menu.php');

// require menu
require_once (DREAMSALON_URL.'/inc/function-utilities.php');
 
// require content
require_once (DREAMSALON_URL.'/templates/blog/define_blocks_content.php');

 // require breadcrumbs
 require( DREAMSALON_URL.'/inc/breadcrumbs.php' );

//Redux Functions
if(in_array('redux-framework/redux-framework.php', apply_filters('active_plugins', get_option('active_plugins'))))
{
    add_action( 'after_setup_theme', 'dreamsalon_register_redux_sections', 20 );
    function dreamsalon_register_redux_sections() {
        require_once ( DREAMSALON_URL.'/inc/options-init.php' );
    }
}
          
function dreamsalon_remove_widget_editort() {
    remove_theme_support( 'widgets-block-editor' );
}
add_action( 'after_setup_theme', 'dreamsalon_remove_widget_editort' );

//get options from wp_options for redux
if( !function_exists('dreamsalon_fl_framework_getoptions') )
{
    function dreamsalon_fl_framework_getoptions($get_text)
    {
        global $dreamsalon_theme_options;
        if(isset($dreamsalon_theme_options[$get_text]) &&  $dreamsalon_theme_options[$get_text] !=""):
            return $dreamsalon_theme_options[$get_text];
        else:
            return false;
        endif;
    }
}
// Remove <p> and <br/> from Contact Form 7
add_filter('wpcf7_autop_or_not', '__return_false');

//added for password and confirm password
function enqueue_jquery() {
    wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'enqueue_jquery');

 
// Use custom checkout order review layout (sidebar card) instead of the default table + payment stack.
add_action( 'wp', function() {
    if ( function_exists( 'is_checkout' ) && is_checkout() && ! is_wc_endpoint_url() ) {
        // Remove core callbacks.
        remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
        remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );

        // Add our own wrapper which loads the overridden review-order.php.
        add_action( 'woocommerce_checkout_order_review', function() {
            $checkout = WC()->checkout();
            wc_get_template( 'checkout/review-order.php', array( 'checkout' => $checkout ) );
        }, 10 );
    }
} );
add_theme_support( 'woocommerce' );
/**
 * Theme setup for adding block editor support.
 */
function dreamsalon_theme_setup() {
     add_theme_support( 'custom-logo', array(
        'height'      => 40,    
        'width'       => 180,   
        'flex-height' => true,
        'flex-width'  => true,
        'header-text' => array( 'site-title', 'site-description' ),
    ) );
     add_theme_support( 'wp-block-styles' );
     add_theme_support( 'align-wide' );
     add_theme_support( 'responsive-embeds' );
     add_theme_support( 'editor-styles' );
     add_editor_style( 'editor-style.css' );
}
add_action( 'after_setup_theme', 'dreamsalon_theme_setup' );
 
//Register block Style
function my_theme_register_block_styles() {
    // Add custom styles for the Paragraph block
    register_block_style(
        'core/paragraph',
        array(
            'name'  => 'fancy-paragraph',
            'label' => __( 'Fancy Paragraph', 'dreamsalon' ),
            'inline_style' => '.wp-block-paragraph.is-style-fancy-paragraph { font-style: italic; color: #3498db; }',
        )
    );

    // Add custom styles for the Image block
    register_block_style(
        'core/image',
        array(
            'name'  => 'rounded-image',
            'label' => __( 'Rounded Image', 'dreamsalon' ),
            'inline_style' => '.wp-block-image.is-style-rounded-image img { border-radius: 50%; }',
        )
    );
}
add_action( 'init', 'my_theme_register_block_styles' );


function my_theme_register_block_patterns() {
    // Register a simple hero block pattern
    register_block_pattern(
        'my-theme/hero-section',
        array(
            'title'       => __( 'Hero Section', 'dreamsalon' ),
            'description' => __( 'A hero section with a heading, paragraph, and button.', 'dreamsalon' ),
            'content'     => '<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"top":"50px","bottom":"50px"}}},"backgroundColor":"primary","textColor":"white"} -->
                <div class="wp-block-group alignfull has-white-color has-primary-background-color has-text-color has-background" style="padding-top:50px;padding-bottom:50px;">
                    <!-- wp:heading {"textAlign":"center"} -->
                    <h2 style="text-align:center">Welcome to My Website</h2>
                    <!-- /wp:heading -->

                    <!-- wp:paragraph {"align":"center"} -->
                    <p style="text-align:center">This is a hero section to grab attention and provide important information.</p>
                    <!-- /wp:paragraph -->

                    <!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} -->
                    <div class="wp-block-buttons">
                        <!-- wp:button {"backgroundColor":"secondary","textColor":"white"} -->
                        <div class="wp-block-button"><a class="wp-block-button__link has-white-color has-secondary-background-color has-text-color has-background">Learn More</a></div>
                        <!-- /wp:button -->
                    </div>
                    <!-- /wp:buttons -->
                </div>
                <!-- /wp:group -->',
            'categories'  => array( 'featured' ),
        )
    );
}
add_action( 'init', 'my_theme_register_block_patterns' );

add_filter('woocommerce_checkout_fields', function($fields) {

    $fields['billing']['billing_first_name']['priority'] = 10;
    $fields['billing']['billing_last_name']['priority']  = 20;
    $fields['billing']['billing_phone']['priority']      = 30;
    $fields['billing']['billing_email']['priority']      = 40;
    $fields['billing']['billing_address_1']['priority']  = 50;
	$fields['billing']['billing_address_2']['priority']  = 55;
	$fields['billing']['billing_country']['priority']  = 85;
    $fields['billing']['billing_city']['priority']       = 65;

    return $fields;
});
add_filter('woocommerce_checkout_fields', function ($fields) {

    $pairs = [
        'billing_first_name' => 'first',
        'billing_last_name'  => 'last',
        'billing_phone'      => 'first',
        'billing_email'      => 'last',
    ];

    foreach ($pairs as $field => $pos) {
        $fields['billing'][$field]['class'] = [
            'form-row-' . $pos
        ];

        if ($pos === 'last') {
            $fields['billing'][$field]['clear'] = true;
        }
    }

    return $fields;
});

?>