[wp-trac] [WordPress Trac] #20716: Control how and when request_filesystem_credentials outputs creds form
WordPress Trac
wp-trac at lists.automattic.com
Mon May 21 02:02:09 UTC 2012
#20716: Control how and when request_filesystem_credentials outputs creds form
-------------------------+-------------------------------
Reporter: griffinjt | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Filesystem | Version: 3.4
Severity: normal | Keywords: reporter-feedback
-------------------------+-------------------------------
When using WP_Filesystem in a plugin or other external app, you can
initialize it this way:
{{{
if ( false == ( $creds = request_filesystem_credentials( $url, $method,
false, false, $form_fields ) ) ) {
return true;
}
}}}
Makes sense. If the method isn't direct or we don't have the credentials
we need, `request_filesystem_credentials` outputs a form and returns
false. Then we check again to make sure the credentials can be verified,
and it not, we continue to output the form until the credentials are good.
{{{
if ( ! WP_Filesystem( $creds ) ) {
request_filesystem_credentials( $url, $method, true, false,
$form_fields );
return true;
}
}}}
`request_filesystem_credentials` arbitrarily outputs the form whether you
want it to or not, unless you explicitly filter the
`request_filesystem_credentials` function itself. Using this in
conjunction with Ajax, you have to use output buffering to catch the
output and return it to the Ajax script for processing or else you get
errors. This definitely isn't ideal.
I'd suggest storing the form in a variable and possibly pass a parameter
that determines whether or not we want to actually output the form or not.
Or, if there is another (better) way, that's cool too. Just some way to
help `request_filesystem_credentials` determine how we want to interact
with credentials should we need them.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20716>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list