本文整理汇总了PHP中WP_Upgrader_Skin::request_filesystem_credentials方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Upgrader_Skin::request_filesystem_credentials方法的具体用法?PHP WP_Upgrader_Skin::request_filesystem_credentials怎么用?PHP WP_Upgrader_Skin::request_filesystem_credentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Upgrader_Skin
的用法示例。
在下文中一共展示了WP_Upgrader_Skin::request_filesystem_credentials方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: request_filesystem_credentials
/**
* Determines whether the upgrader needs FTP/SSH details in order to connect
* to the filesystem.
*
* @since 3.7.0
* @since 4.6.0 The `$context` parameter default changed from `false` to an empty string.
*
* @see request_filesystem_credentials()
*
* @param bool $error Optional. Whether the current request has failed to connect.
* Default false.
* @param string $context Optional. Full path to the directory that is tested
* for being writable. Default empty.
* @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
* @return bool True on success, false on failure.
*/
public function request_filesystem_credentials($error = false, $context = '', $allow_relaxed_file_ownership = false)
{
if ($context) {
$this->options['context'] = $context;
}
// TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version
// This will output a credentials form in event of failure, We don't want that, so just hide with a buffer
ob_start();
$result = parent::request_filesystem_credentials($error, $context, $allow_relaxed_file_ownership);
ob_end_clean();
return $result;
}
示例2: fs_connect
/**
* Connect to the filesystem.
*
* @since 2.8.0
*
* @param array $directories Optional. A list of directories. If any of these do
* not exist, a {@see WP_Error} object will be returned.
* Default empty array.
* @param bool $allow_relaxed_file_ownership Whether to allow relaxed file ownership.
* Default false.
* @return bool|WP_Error True if able to connect, false or a {@see WP_Error} otherwise.
*/
public function fs_connect($directories = array(), $allow_relaxed_file_ownership = false)
{
global $wp_filesystem;
if (false === ($credentials = $this->skin->request_filesystem_credentials(false, $directories[0], $allow_relaxed_file_ownership))) {
return false;
}
if (!WP_Filesystem($credentials, $directories[0], $allow_relaxed_file_ownership)) {
$error = true;
if (is_object($wp_filesystem) && $wp_filesystem->errors->get_error_code()) {
$error = $wp_filesystem->errors;
}
// Failed to connect, Error and request again
$this->skin->request_filesystem_credentials($error, $directories[0], $allow_relaxed_file_ownership);
return false;
}
if (!is_object($wp_filesystem)) {
return new WP_Error('fs_unavailable', $this->strings['fs_unavailable']);
}
if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
return new WP_Error('fs_error', $this->strings['fs_error'], $wp_filesystem->errors);
}
foreach ((array) $directories as $dir) {
switch ($dir) {
case ABSPATH:
if (!$wp_filesystem->abspath()) {
return new WP_Error('fs_no_root_dir', $this->strings['fs_no_root_dir']);
}
break;
case WP_CONTENT_DIR:
if (!$wp_filesystem->wp_content_dir()) {
return new WP_Error('fs_no_content_dir', $this->strings['fs_no_content_dir']);
}
break;
case WP_PLUGIN_DIR:
if (!$wp_filesystem->wp_plugins_dir()) {
return new WP_Error('fs_no_plugins_dir', $this->strings['fs_no_plugins_dir']);
}
break;
case get_theme_root():
if (!$wp_filesystem->wp_themes_dir()) {
return new WP_Error('fs_no_themes_dir', $this->strings['fs_no_themes_dir']);
}
break;
default:
if (!$wp_filesystem->find_folder($dir)) {
return new WP_Error('fs_no_folder', sprintf($this->strings['fs_no_folder'], esc_html(basename($dir))));
}
break;
}
}
return true;
}
示例3:
function request_filesystem_credentials($error = false, $context = '')
{
if ($context) {
$this->options['context'] = $context;
}
// TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version
// This will output a credentials form in event of failure, We don't want that, so just hide with a buffer
ob_start();
set_current_screen('tools');
// Only here to avoid PHP Notices from screen_icon() which is used within that HTML
$result = parent::request_filesystem_credentials($error);
ob_end_clean();
return $result;
}