本文整理汇总了PHP中wp_is_stream函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_is_stream函数的具体用法?PHP wp_is_stream怎么用?PHP wp_is_stream使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_is_stream函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sc_remove_double_slashes
private function sc_remove_double_slashes($path)
{
$wrapper = null;
// Strip the protocol.
if (wp_is_stream($path)) {
list($wrapper, $path) = explode('://', $path, 2);
}
// From php.net/mkdir user contributed notes.
$path = preg_replace('#\\\\{2,}#', '\\', trim($path, '\\'));
$path = preg_replace('#/{2,}#', '/', $path);
// Put the wrapper back on the target.
if ($wrapper !== null) {
$path = $wrapper . '://' . $path;
}
return $path;
}
示例2: wp_mkdir_p
/**
* Recursive directory creation based on full path.
*
* Will attempt to set permissions on folders.
*
* @since 2.0.1
*
* @param string $target Full path to attempt to create.
* @return bool Whether the path was created. True if path already exists.
*/
function wp_mkdir_p($target)
{
$wrapper = null;
// Strip the protocol.
if (wp_is_stream($target)) {
list($wrapper, $target) = explode('://', $target, 2);
}
// From php.net/mkdir user contributed notes.
$target = str_replace('//', '/', $target);
// Put the wrapper back on the target.
if ($wrapper !== null) {
$target = $wrapper . '://' . $target;
}
/*
* Safe mode fails with a trailing slash under certain PHP versions.
* Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
*/
$target = rtrim($target, '/');
if (empty($target)) {
$target = '/';
}
if (file_exists($target)) {
return @is_dir($target);
}
// We need to find the permissions of the parent folder that exists and inherit that.
$target_parent = dirname($target);
while ('.' != $target_parent && !is_dir($target_parent)) {
$target_parent = dirname($target_parent);
}
// Get the permission bits.
if ($stat = @stat($target_parent)) {
$dir_perms = $stat['mode'] & 07777;
} else {
$dir_perms = 0777;
}
if (@mkdir($target, $dir_perms, true)) {
/*
* If a umask is set that modifies $dir_perms, we'll have to re-set
* the $dir_perms correctly with chmod()
*/
if ($dir_perms != ($dir_perms & ~umask())) {
$folder_parts = explode('/', substr($target, strlen($target_parent) + 1));
for ($i = 1, $c = count($folder_parts); $i <= $c; $i++) {
@chmod($target_parent . '/' . implode('/', array_slice($folder_parts, 0, $i)), $dir_perms);
}
}
return true;
}
return false;
}
示例3: make_image
/**
* Either calls editor's save function or handles file as a stream.
*
* @since 3.5.0
* @access protected
*
* @param string|stream $filename
* @param callable $function
* @param array $arguments
* @return boolean
*/
protected function make_image($filename, $function, $arguments)
{
if ($stream = wp_is_stream($filename)) {
ob_start();
} else {
// The directory containing the original file may no longer exist when using a replication plugin.
wp_mkdir_p(dirname($filename));
}
$result = call_user_func_array($function, $arguments);
if ($result && $stream) {
$contents = ob_get_contents();
$fp = fopen($filename, 'w');
if (!$fp) {
return false;
}
fwrite($fp, $contents);
fclose($fp);
}
if ($stream) {
ob_end_clean();
}
return $result;
}
示例4: wp_mkdir_p
/**
* Recursive directory creation based on full path.
*
* Will attempt to set permissions on folders.
*
* @since 2.0.1
*
* @param string $target Full path to attempt to create.
* @return bool Whether the path was created. True if path already exists.
*/
function wp_mkdir_p($target)
{
$wrapper = null;
// strip the protocol
if (wp_is_stream($target)) {
list($wrapper, $target) = explode('://', $target, 2);
}
// from php.net/mkdir user contributed notes
$target = str_replace('//', '/', $target);
// put the wrapper back on the target
if ($wrapper !== null) {
$target = $wrapper . '://' . $target;
}
// safe mode fails with a trailing slash under certain PHP versions.
$target = rtrim($target, '/');
// Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
if (empty($target)) {
$target = '/';
}
if (file_exists($target)) {
return @is_dir($target);
}
// Attempting to create the directory may clutter up our display.
if (@mkdir($target)) {
$stat = @stat(dirname($target));
$dir_perms = $stat['mode'] & 07777;
// Get the permission bits.
@chmod($target, $dir_perms);
return true;
} elseif (is_dir(dirname($target))) {
return false;
}
// If the above failed, attempt to create the parent node, then try again.
if ($target != '/' && wp_mkdir_p(dirname($target))) {
return wp_mkdir_p($target);
}
return false;
}
示例5: make_image
/**
* Either calls editor's save function or handles file as a stream.
*
* @since 3.5.0
* @access protected
*
* @param string|stream $filename
* @param callable $function
* @param array $arguments
* @return boolean
*/
protected function make_image($filename, $function, $arguments)
{
if (wp_is_stream($filename)) {
$arguments[1] = null;
}
return parent::make_image($filename, $function, $arguments);
}
示例6: make_image
/**
* Either calls editor's save function or handles file as a stream.
*
* @since 3.5.0
* @access protected
*
* @param string|stream $filename
* @param callable $function
* @param array $arguments
* @return boolean
*/
protected function make_image($filename, $function, $arguments)
{
$dst_file = $filename;
if ($stream = wp_is_stream($filename)) {
$filename = null;
ob_start();
}
$result = call_user_func_array($function, $arguments);
if ($result && $stream) {
$contents = ob_get_contents();
$fp = fopen($dst_file, 'w');
if (!$fp) {
return false;
}
fwrite($fp, $contents);
fclose($fp);
}
if ($stream) {
ob_end_clean();
}
return $result;
}
示例7: wp_mkdir_p
/**
* Recursive directory creation based on full path.
*
* Will attempt to set permissions on folders.
*
* @since 2.0.1
*
* @param string $target Full path to attempt to create.
* @return bool Whether the path was created. True if path already exists.
*/
function wp_mkdir_p($target)
{
$wrapper = null;
// strip the protocol
if (wp_is_stream($target)) {
list($wrapper, $target) = explode('://', $target, 2);
}
// from php.net/mkdir user contributed notes
$target = str_replace('//', '/', $target);
// put the wrapper back on the target
if ($wrapper !== null) {
$target = $wrapper . '://' . $target;
}
// safe mode fails with a trailing slash under certain PHP versions.
$target = rtrim($target, '/');
// Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
if (empty($target)) {
$target = '/';
}
if (file_exists($target)) {
return @is_dir($target);
}
// We need to find the permissions of the parent folder that exists and inherit that.
$target_parent = dirname($target);
while ('.' != $target_parent && !is_dir($target_parent)) {
$target_parent = dirname($target_parent);
}
// Get the permission bits.
if ($target_parent && '.' != $target_parent) {
$stat = @stat($target_parent);
$dir_perms = $stat['mode'] & 07777;
} else {
$dir_perms = 0777;
}
if (@mkdir($target, $dir_perms, true)) {
return true;
}
return false;
}