当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_is_stream函数代码示例

本文整理汇总了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;
 }
开发者ID:Softcatala,项目名称:sc-normalize-upload-dir,代码行数:16,代码来源:sc-normalize-upload-dir.php

示例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;
}
开发者ID:hpilevar,项目名称:WordPress,代码行数:60,代码来源:functions.php

示例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;
 }
开发者ID:justatechnology,项目名称:Security,代码行数:34,代码来源:class-wp-image-editor.php

示例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;
}
开发者ID:liangwei1988,项目名称:wordpress,代码行数:48,代码来源:functions.php

示例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);
 }
开发者ID:Didox,项目名称:beminfinito,代码行数:18,代码来源:class-wp-image-editor-gd.php

示例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;
 }
开发者ID:rkglug,项目名称:WordPress,代码行数:33,代码来源:class-wp-image-editor.php

示例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;
}
开发者ID:palimadra,项目名称:bubblegraphics-wpsite,代码行数:49,代码来源:functions.php


注:本文中的wp_is_stream函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。