<?php

add_action('wp_enqueue_scripts', static function () {
    $deps = [];

    if (class_exists(\Elementor\Plugin::class)) {
        $deps[] = 'elementor-frontend';
    }

    wp_enqueue_style('vehica', get_template_directory_uri() . '/style.css', $deps, VEHICA_VERSION);
    wp_enqueue_style('vehica-child', get_stylesheet_directory_uri() . '/style.css', ['vehica']);
});

add_action('after_setup_theme', static function () {
    load_child_theme_textdomain('vehica', get_stylesheet_directory() . '/languages');
});

/* DESATIVA SELETOR DE IDIOMAS */
add_filter( 'login_display_language_dropdown', '__return_false' );

/* REMOVE WORDPRESS BARRA FERRAMENTAS */
function seisbrasil_scripts_wp_logo( $wp_admin_bar ) {
	$wp_admin_bar->remove_node('wp-logo');	
	$wp_admin_bar->remove_node('new-content');
	$wp_admin_bar->remove_node('view-site');	
	$wp_admin_bar->remove_node('woocommerce-site-visibility-badge');
}
add_action('admin_bar_menu', 'seisbrasil_scripts_wp_logo', 999);

/* ADCIONAR LINK PARA O SITE */
function seisbrasil_add_link_to_admin_bar($admin_bar) {
    $args = array(
        'id' => 'my-custom-link',
        'title' => 'Visitar Site', 
        'href' => '/',		
		'meta' => array(
        'target' => '_blank',
        )
    );
    $admin_bar->add_node($args);
}
add_action('admin_bar_menu', 'seisbrasil_add_link_to_admin_bar', 999);

/* PAGINA DE LOGIN */
function my_login_logo() { ?>
    <style type="text/css">
        #login h1 a, .login h1 a {
            background-image: url(/wp-content/uploads/logo_login.png);
		height:50px;
		width:280px;
		background-size: 280px 50px;
		background-repeat: no-repeat;
        	padding-bottom: 0px;
        }
		body.login.js.login-action-login.wp-core-ui.locale-pt-br {
			background: linear-gradient(rgb(0 0 0 / 60%), rgb(0 0 0 / 60%)), url(/wp-content/uploads/bg-login.webp) no-repeat center;
            background-size: cover;
		}
		/*Cor do Background da tela perdeu a senha*/
		body.login.js.login-action-lostpassword.wp-core-ui.locale-pt-br {
            background: #505050;
        }
		.login #backtoblog a, .login #nav a {    
            color: #dfdfdf!important
        }
		.login form {
            border-radius: 5px; 
			background: #000 !important;
			border: 1px solid #e52d27 !important;
			color: #ebebeb;
			padding: 26px 24px 34px !important;
		}		
		/*Cor e estilo do Botão*/
		.wp-core-ui .button.button-large {
            width: 100%;
            min-height: 36px !important;
            border-radius: 16px;
			background: #e52d27;
            border-color: #e52d27;
			text-align: center;
			color: #fff;
        }
		/*Cor do Botão :hover*/
		.wp-core-ui .button.button-large:hover {
            background: #bf241f;
            border-color: #bf241f;
        }		  
		/*Background Atualizar Email Admin*/
        body.login.js.login-action-confirm_admin_email.wp-core-ui.locale-pt-br {
             background: #505050;
        }
		/*Cor Texto Superior Formulário*/
		.login .admin-email__heading {    
             color: #ebebeb !important;  
        }
		/*Epaço Entre Botão Atualizar Email Admin*/
        .login .admin-email__actions .button-primary {    
             margin-left: 0 !important;    
             margin-top: 10px;
        }   
		#login {
            width: 350px !important;
        }
		#backtoblog {
            display: none;
        }     
		/*#nav {
            display: none;
        }*/
		.privacy-policy-link {
            display: none;
        }
    </style>
<?php }
add_action( 'login_enqueue_scripts', 'my_login_logo' );

/* LINK LOGO */
function my_login_logo_url() {
    return home_url(); // A url da logo --> home
}
add_filter( 'login_headerurl', 'my_login_logo_url' );

/* ALTERAR MENSAGEM DE ERRO TELA DE LOGIN */
function seisbrasil_no_wordpress_errors () {
   return 'Algo está errado!';
 }
 add_filter ('login_errors', 'seisbrasil_no_wordpress_errors');
