[wp-trac] [WordPress Trac] #41190: I hope to include the function definition part in the output to be disabled using "enable_login_autofocus" filter.
WordPress Trac
noreply at wordpress.org
Wed Jun 28 03:25:54 UTC 2017
#41190: I hope to include the function definition part in the output to be disabled
using "enable_login_autofocus" filter.
-------------------------------------+-----------------------------
Reporter: ka2 | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Login and Registration | Version: trunk
Severity: normal | Keywords:
Focuses: javascript, performance |
-------------------------------------+-----------------------------
Currently, when autofocus at login is turned OFF as below, only the
function calling part of "wp_attempt_focus()" is not outputted.
{{{
Add_filter( 'enable_login_autofocus', function(){ return false; } );
}}}
However, for them who do not need autofocus, the definition part of the
"wp_attempt_focus()" function should also be unnecessary. So, please do
not output the function definition part.
{{{
<script type="text/javascript">
<?php
/**
* Filters whether to print the call to `wp_attempt_focus()` on the login
screen.
*
* @since 4.8.0
*
* @param bool $print Whether to print the function call. Default true.
*/
if ( apply_filters( 'enable_login_autofocus', true ) && ! $error ) { ?>
function wp_attempt_focus(){
setTimeout( function(){ try{
<?php if ( $user_login ) { ?>
d = document.getElementById('user_pass');
d.value = '';
<?php } else { ?>
d = document.getElementById('user_login');
<?php if ( 'invalid_username' == $errors->get_error_code() ) { ?>
if( d.value != '' )
d.value = '';
<?php
}
}?>
d.focus();
d.select();
} catch(e){}
}, 200);
}
wp_attempt_focus();
<?php } ?>
if(typeof wpOnload=='function')wpOnload();
<?php if ( $interim_login ) { ?>
(function(){
try {
var i, links = document.getElementsByTagName('a');
for ( i in links ) {
if ( links[i].href )
links[i].target = '_blank';
}
} catch(e){}
}());
<?php } ?>
</script>
}}}
I think that it is best to apply the filter as described above.
I hope you will consider this.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41190>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list