| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: WPOrLogin - Personalizar login de WordPress |
| 4 |
* Plugin URI: https://oregoom.com/wporlogin/ |
| 5 |
* Description: Plugin para personalizar el login de WordPress. |
| 6 |
* Version: 2.0 |
| 7 |
* Author: Nivardo Ch |
| 8 |
* Author URI:https://nivardoch.com |
| 9 |
* License: GPL2 |
| 10 |
* Text Domain: wporlogin-text-domain |
| 11 |
* Domain Path: /languages |
| 12 |
*/ |
| 13 |
|
| 14 |
require_once plugin_dir_path(__FILE__) .'includes/wporloginpage.php'; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
function wporlogin_insert_script_upload(){ |
| 21 |
|
| 22 |
wp_enqueue_media();//PARA ABRIR LA BIBLIOTEMA MEDIOS |
| 23 |
|
| 24 |
//REGISTRAR EL SCRIPT JS |
| 25 |
wp_register_script('wporlogin_my_upload', plugin_dir_url( __FILE__ ).'js/img-fondo.js', array('jquery'), '1', true ); |
| 26 |
wp_enqueue_script('wporlogin_my_upload'); //MOSTRAR EL SCRIPT JS EN ADMIN |
| 27 |
} |
| 28 |
add_action("admin_enqueue_scripts", "wporlogin_insert_script_upload"); |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
//////////////////////////////////////////////////////////////////////////////// |
| 35 |
// WP LOGIN: AGREGAR NUEVO LOGO EN LUGAR DE WORDPRESS |
| 36 |
//////////////////////////////////////////////////////////////////////////////// |
| 37 |
|
| 38 |
function wporlogin_page_login() { |
| 39 |
|
| 40 |
//////////////////////////////////////////////////////////////////////////// |
| 41 |
// WP LOGIN: CONDICIÓN PARA APLICAR CSS A PAGE LOGIN |
| 42 |
//////////////////////////////////////////////////////////////////////////// |
| 43 |
|
| 44 |
$wporlogin_design = get_option('wporlogin_design', false); |
| 45 |
|
| 46 |
if( ($wporlogin_design != false) && ($wporlogin_design == 'wporlogin_design_standard') ){ |
| 47 |
|
| 48 |
//////////////////////////////////////////////////////////////////////////// |
| 49 |
// WP LOGIN: DISEÑO ESTANDAR |
| 50 |
// Version: 1.0 |
| 51 |
//////////////////////////////////////////////////////////////////////////// |
| 52 |
|
| 53 |
//COMPROBANDO SI LA VARIABLE ES NULO O VACIO |
| 54 |
if(get_option("wporlogin_url_img_fondo")){ |
| 55 |
$wporlogin_url_img_fondo_val = esc_html(get_option("wporlogin_url_img_fondo")); |
| 56 |
} else { |
| 57 |
//IMPRIMIR IMG DE FONDO POR DEFECTO DE LA CARPETA DE PLUGIN |
| 58 |
$wporlogin_url_img_fondo_val = esc_html(plugin_dir_url( __FILE__ ).'img/wporlogin-img-fondo-2.jpg'); |
| 59 |
} |
| 60 |
?> |
| 61 |
<style type="text/css" media="screen"> |
| 62 |
|
| 63 |
@media (min-width: 415px) { |
| 64 |
/* |
| 65 |
ESTILOS PARA IMAGEN DE FONDO DE LOGIN |
| 66 |
*/ |
| 67 |
body.login { |
| 68 |
background-image: url(<?php echo esc_url($wporlogin_url_img_fondo_val); ?>); |
| 69 |
background-position: center; |
| 70 |
background-size: cover; |
| 71 |
background-attachment: fixed; |
| 72 |
margin: 0; |
| 73 |
color: #444; |
| 74 |
font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',sans-serif; |
| 75 |
} |
| 76 |
|
| 77 |
body.login div#login { |
| 78 |
min-height: 100vh !important; |
| 79 |
background-color: #ffffff !important; |
| 80 |
width: 420px !important; |
| 81 |
/*max-width: 420px !important;*/ |
| 82 |
margin-left: 10% !important; |
| 83 |
display: flex !important; |
| 84 |
flex-direction: column !important; |
| 85 |
-moz-box-align: center !important; |
| 86 |
align-items: center !important; |
| 87 |
box-shadow: 0 0 15px rgba(0,0,0,.8) !important; |
| 88 |
|
| 89 |
padding: 0; /* CSS de Oregoom */ |
| 90 |
} |
| 91 |
|
| 92 |
body.login div#login form#loginform, form#registerform, form#lostpasswordform { |
| 93 |
margin-top: 20px; |
| 94 |
margin-left: 0; |
| 95 |
padding: 26px 50px 46px; |
| 96 |
font-weight: 400; |
| 97 |
overflow: hidden; |
| 98 |
box-shadow: 0 1px 3px rgba(0,0,0,.04); |
| 99 |
} |
| 100 |
|
| 101 |
} /*@media (min-width: 415px) */ |
| 102 |
|
| 103 |
body.login{ |
| 104 |
background-color: #ffffff !important; |
| 105 |
} |
| 106 |
|
| 107 |
body.login div#login h1 { |
| 108 |
text-align: center; |
| 109 |
margin: 0; |
| 110 |
padding: 15% 0 0 0; |
| 111 |
} |
| 112 |
|
| 113 |
body.login div#login h1 a { |
| 114 |
/* background-image: url(https://avesexoticas.org/wp-admin/images/wordpress-logo.svg?ver=20131107); |
| 115 |
background-size: 84px; |
| 116 |
background-position: center top; |
| 117 |
background-repeat: no-repeat; */ |
| 118 |
|
| 119 |
color: #444; |
| 120 |
|
| 121 |
/*height: 84px;*/ |
| 122 |
|
| 123 |
font-size: 20px; |
| 124 |
font-weight: 400; |
| 125 |
line-height: 1.3; |
| 126 |
margin: 0 auto 25px; |
| 127 |
padding: 0; |
| 128 |
text-decoration: none; |
| 129 |
|
| 130 |
/*width: 84px;*/ |
| 131 |
|
| 132 |
text-indent: -9999px; |
| 133 |
outline: 0; |
| 134 |
overflow: hidden; |
| 135 |
display: block; |
| 136 |
|
| 137 |
<?php |
| 138 |
|
| 139 |
if(get_option("wporlogin_url_logotipo")){?> |
| 140 |
background-image: url(<?php echo esc_url(get_option('wporlogin_url_logotipo')); ?>) !important; |
| 141 |
background-size: 200px; |
| 142 |
background-position: center top; |
| 143 |
background-repeat: no-repeat; |
| 144 |
width: 200px; |
| 145 |
height: 84px; |
| 146 |
<?php |
| 147 |
} else { |
| 148 |
|
| 149 |
$custom_logo_id = get_theme_mod( 'custom_logo' ); |
| 150 |
$image = wp_get_attachment_image_src( $custom_logo_id , 'full' ); |
| 151 |
|
| 152 |
/* |
| 153 |
* CONDICIÓN PARA SABER SI EL TEMA YA LO TIENE |
| 154 |
* ASIGNADO UN LOGO |
| 155 |
* |
| 156 |
* SI ES VERDAD, ENTONCES MUESTRA EL LOGO ASIGNADO |
| 157 |
* SI ES FALSO, MUESTRA EL LOGO DE WORDPRESS |
| 158 |
*/ |
| 159 |
if($image[0]){ |
| 160 |
?> |
| 161 |
background-image: url(<?php echo esc_url($image[0]); ?>) !important; |
| 162 |
background-size: 200px; |
| 163 |
background-position: center top; |
| 164 |
background-repeat: no-repeat; |
| 165 |
width: 200px; |
| 166 |
<?php |
| 167 |
} |
| 168 |
}?> |
| 169 |
} |
| 170 |
|
| 171 |
body.login div#login form#loginform, form#registerform, form#lostpasswordform { |
| 172 |
margin-top: 20px; |
| 173 |
margin-left: 0; |
| 174 |
/*padding: 26px 50px 46px;*/ |
| 175 |
font-weight: 400; |
| 176 |
overflow: hidden; |
| 177 |
box-shadow: 0 1px 3px rgba(0,0,0,.04); |
| 178 |
|
| 179 |
border: none !important; |
| 180 |
padding-bottom: 10px; |
| 181 |
} |
| 182 |
|
| 183 |
body.login div#login form#loginform p { |
| 184 |
margin-bottom: 0; |
| 185 |
} |
| 186 |
|
| 187 |
/* body.login div#login form#loginform p label { |
| 188 |
display: none; |
| 189 |
visibility: hidden; |
| 190 |
}*/ |
| 191 |
|
| 192 |
body.login div#login form#loginform input#user_login, |
| 193 |
form#registerform input#user_login, |
| 194 |
form#registerform input#user_email, |
| 195 |
form#lostpasswordform input#user_login{ |
| 196 |
font-size: 15px !important; |
| 197 |
line-height: 1.33333333 !important; |
| 198 |
width: 100% !important; |
| 199 |
margin: 0 6px 16px 0 !important; |
| 200 |
min-height: 40px !important; |
| 201 |
max-height: none !important; |
| 202 |
border: none !important; |
| 203 |
border-radius: 0 !important; |
| 204 |
border-bottom: #a4a7b5 1px solid !important; |
| 205 |
padding: 0 !important; |
| 206 |
} |
| 207 |
body.login div#login form#loginform p input#user_login:focus, |
| 208 |
form#registerform input#user_login:focus, |
| 209 |
form#registerform input#user_email:focus, |
| 210 |
form#lostpasswordform input#user_login:focus { |
| 211 |
outline: 0 none !important; |
| 212 |
border-bottom: #006fff 1px solid !important; |
| 213 |
box-shadow: none; |
| 214 |
} |
| 215 |
|
| 216 |
body.login div#login form#loginform input#user_pass { |
| 217 |
font-size: 15px !important; |
| 218 |
line-height: 1.33333333 !important; |
| 219 |
width: 100% !important; |
| 220 |
margin: 0 6px 16px 0 !important; |
| 221 |
min-height: 40px !important; |
| 222 |
max-height: none !important; |
| 223 |
border: none !important; |
| 224 |
border-radius: 0 !important; |
| 225 |
border-bottom: #a4a7b5 1px solid !important; |
| 226 |
padding: 0 !important; |
| 227 |
} |
| 228 |
body.login div#login form#loginform input#user_pass:focus { |
| 229 |
outline: 0 none !important; |
| 230 |
border-bottom: #006fff 1px solid !important; |
| 231 |
box-shadow: none; |
| 232 |
} |
| 233 |
|
| 234 |
body.login div#login form#loginform button.button-secondary { |
| 235 |
color: #1a73e8; |
| 236 |
} |
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
body.login div#login form#loginform p.submit input#wp-submit, form#registerform p.submit input#wp-submit, form#lostpasswordform p.submit input#wp-submit { |
| 241 |
/*background-color: #0780F9 !important;*/ |
| 242 |
background-color: #1a73e8 !important; |
| 243 |
border: solid 1px #1a73e8 !important; |
| 244 |
float: none !important; |
| 245 |
width: 100%; |
| 246 |
height: 50px; |
| 247 |
font-size: 15px; |
| 248 |
margin-top: 10px; |
| 249 |
border-radius: 6px; |
| 250 |
font-family: Lato, sans-serif; |
| 251 |
} |
| 252 |
body.login div#login form#loginform p.submit input#wp-submit:hover, form#registerform p.submit input#wp-submit:hover, form#lostpasswordform p.submit input#wp-submit:hover { |
| 253 |
background-color: #287ae6 !important; |
| 254 |
} |
| 255 |
body.login div#login form#loginform p.submit input#wp-submit:focus, form#registerform p.submit input#wp-submit:focus, form#lostpasswordform p.submit input#wp-submit:focus { |
| 256 |
box-shadow: none; |
| 257 |
} |
| 258 |
|
| 259 |
body.login div#login p#nav { |
| 260 |
text-align: center; |
| 261 |
padding-bottom: 30px; |
| 262 |
} |
| 263 |
|
| 264 |
body.login div#login p#nav a:hover { |
| 265 |
color: #1a73e8 !important; |
| 266 |
} |
| 267 |
body.login div#login p#nav a:focus { |
| 268 |
box-shadow: none; |
| 269 |
} |
| 270 |
|
| 271 |
|
| 272 |
#login .message{ |
| 273 |
box-shadow: none !important; |
| 274 |
} |
| 275 |
|
| 276 |
#login #login_error{ |
| 277 |
box-shadow: none !important; |
| 278 |
} |
| 279 |
|
| 280 |
|
| 281 |
#login #backtoblog{ |
| 282 |
display: none; |
| 283 |
} |
| 284 |
|
| 285 |
</style> |
| 286 |
<script> |
| 287 |
|
| 288 |
$(document).ready(function(){ |
| 289 |
jQuery('form#loginform').append('<p><strong>texto de prueba</strong></p>'); |
| 290 |
}); |
| 291 |
|
| 292 |
|
| 293 |
</script> |
| 294 |
<?php |
| 295 |
|
| 296 |
} else { |
| 297 |
|
| 298 |
//////////////////////////////////////////////////////////////////////// |
| 299 |
// WP LOGIN: DESIGN BASIC |
| 300 |
//////////////////////////////////////////////////////////////////////// |
| 301 |
|
| 302 |
require_once plugin_dir_path(__FILE__) .'includes/design-basic.php'; |
| 303 |
|
| 304 |
} // END DESIGN BASIC |
| 305 |
|
| 306 |
} |
| 307 |
add_action('login_enqueue_scripts', 'wporlogin_page_login'); |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
// define the login_footer callback |
| 316 |
function wporlogin_add_menu_login_footer() { |
| 317 |
echo '<div><h1>hola como</h1></div>'; |
| 318 |
} |
| 319 |
//add_action( 'login_footer', 'wporlogin_add_menu_login_footer', 10, 2 ); |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
/////////////////////////////////////////////////////////////////////////////////////// |
| 329 |
// WP LOGIN: CAMBIAR LA URL POR DEFECTO DEL LOGO |
| 330 |
/////////////////////////////////////////////////////////////////////////////////////// |
| 331 |
|
| 332 |
function wporlogin_mostrar_ruta_url_logotipo() { |
| 333 |
if(get_option("wporlogin_ruta_url_logotipo")){ |
| 334 |
return esc_url(get_option('wporlogin_ruta_url_logotipo')); |
| 335 |
} else { |
| 336 |
return home_url(); |
| 337 |
} |
| 338 |
} |
| 339 |
add_filter('login_headerurl', 'wporlogin_mostrar_ruta_url_logotipo'); |
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
function wporlogin_mostrar_logotipo_title() { |
| 348 |
|
| 349 |
//////////////////////////////////////////////////////////////////////////// |
| 350 |
// WP LOGIN: CONDICIÓN PARA APLICAR CSS A PAGE LOGIN |
| 351 |
//////////////////////////////////////////////////////////////////////////// |
| 352 |
|
| 353 |
$wporlogin_design = get_option('wporlogin_design', false); |
| 354 |
|
| 355 |
if( ($wporlogin_design != false) && ($wporlogin_design == 'wporlogin_design_standard') ){ //Cuando existe diseño seleccionado |
| 356 |
|
| 357 |
if(get_option("wporlogin_titulo_logotipo")){ |
| 358 |
|
| 359 |
return esc_html(get_option('wporlogin_titulo_logotipo')); |
| 360 |
|
| 361 |
} |
| 362 |
|
| 363 |
} else { //cuando el diseño es Default |
| 364 |
|
| 365 |
if(isset($_GET['action'])){ |
| 366 |
|
| 367 |
$wporlogin_action = $_GET['action']; |
| 368 |
|
| 369 |
if($wporlogin_action == 'register'){ |
| 370 |
|
| 371 |
return __('Regístrate', 'wporlogin-text-domain'); |
| 372 |
|
| 373 |
} else { |
| 374 |
|
| 375 |
if($wporlogin_action == 'lostpassword'){ |
| 376 |
|
| 377 |
return __('Restablecer contraseña', 'wporlogin-text-domain'); |
| 378 |
|
| 379 |
} else { |
| 380 |
|
| 381 |
return __('Iniciar sesión', 'wporlogin-text-domain'); |
| 382 |
|
| 383 |
} |
| 384 |
|
| 385 |
} |
| 386 |
} else { |
| 387 |
|
| 388 |
return __('Iniciar sesión', 'wporlogin-text-domain'); |
| 389 |
|
| 390 |
} |
| 391 |
} |
| 392 |
|
| 393 |
} |
| 394 |
add_filter('login_headertext', 'wporlogin_mostrar_logotipo_title'); |