<?php
function my_child_theme_enqueue_styles() {
    wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
    wp_enqueue_style('child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array('parent-style')
    );
}


// Redirect users away from wp-login.php and wp-admin to a custom 404 page
function custom_login_redirect($redirect_to, $request, $user) {
    if (strpos($_SERVER['REQUEST_URI'], 'wp-login.php') !== false || strpos($_SERVER['REQUEST_URI'], 'wp-admin') !== false  || strpos($_SERVER['REQUEST_URI'], 'wp-login') !== false  ) {
        wp_redirect(home_url('/404-page'));
        exit;
    }
    return home_url('/wp-admin');
}
add_filter('login_redirect', 'custom_login_redirect', 10, 3);
// Redirect to a custom login page after logout
function custom_logout_redirect() {
    wp_redirect(home_url('/homecare-portal.php'));
    exit();
}
add_action('wp_logout', 'custom_logout_redirect');


function insert_elementor_template($atts) {
    $atts = shortcode_atts(array(
        'id' => ''
    ), $atts);

    if (!empty($atts['id'])) {
        return Elementor\Plugin::instance()->frontend->get_builder_content_for_display($atts['id']);
    }

    return ''; // Return nothing if ID is empty
}
add_shortcode('elementor_template', 'insert_elementor_template');


function cyberace_theme_setup() {
  register_nav_menus( array(
    'header' => 'Header menu',
    'footer' => 'Footer menu'
  ) );
 }
 
add_action( 'after_setup_theme', 'cyberace_theme_setup' );