function iwp_mmb_direct_to_any_copy_dir($from, $to, $skip_list = array()) { //FIX ME: directly call function in backup.class.php later global $wp_filesystem; $wp_temp_direct = new WP_Filesystem_Direct(''); $dirlist = $wp_temp_direct->dirlist($from); $from = trailingslashit($from); $to = trailingslashit($to); $skip_regex = ''; foreach ((array) $skip_list as $key => $skip_file) { $skip_regex .= preg_quote($skip_file, '!') . '|'; } if (!empty($skip_regex)) { $skip_regex = '!(' . rtrim($skip_regex, '|') . ')$!i'; } foreach ((array) $dirlist as $filename => $fileinfo) { if (!empty($skip_regex)) { if (preg_match($skip_regex, $from . $filename)) { continue; } } if ('f' == $fileinfo['type']) { if (!$this->iwp_mmb_direct_to_any_copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE)) { // If copy failed, chmod file to 0644 and try again. $wp_filesystem->chmod($to . $filename, 0644); if (!$this->iwp_mmb_direct_to_any_copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE)) { return new WP_Error('copy_failed', __('Could not copy file.'), $to . $filename); } } } elseif ('d' == $fileinfo['type']) { if (!$wp_filesystem->is_dir($to . $filename)) { if (!$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR)) { return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename); } } $result = $this->iwp_mmb_direct_to_any_copy_dir($from . $filename, $to . $filename, $skip_list); if (is_wp_error($result)) { return $result; } } } return true; }
<?php defined('DTPB_BASENAME') or die; $wp_filesystem = new WP_Filesystem_Direct(array()); if ($dirlist = $wp_filesystem->dirlist(DTPB_DIR . "lib/elements")) { foreach ($dirlist as $dirname => $dirattr) { if ($dirattr['type'] == 'f' && preg_match("/(\\.php)\$/", $dirname)) { @(require_once DTPB_DIR . "lib/elements/" . $dirname); } } }
static function MoveDir($from, $to) { require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php'; $wp_filesystem = new WP_Filesystem_Direct(null); $dirlist = $wp_filesystem->dirlist($from); $from = trailingslashit($from); $to = trailingslashit($to); foreach ((array) $dirlist as $filename => $fileinfo) { if ('f' == $fileinfo['type']) { if (!$wp_filesystem->move($from . $filename, $to . $filename, true)) { return false; } $wp_filesystem->chmod($to . $filename, octdec(WPFB_PERM_FILE)); } elseif ('d' == $fileinfo['type']) { if (!$wp_filesystem->mkdir($to . $filename, octdec(WPFB_PERM_DIR))) { return false; } if (!self::MoveDir($from . $filename, $to . $filename)) { return false; } } } // finally delete the from dir @rmdir($from); return true; }
/** * @access public * * @param string $path * @param bool $include_hidden * @param bool $recursive * @return bool|array */ public function dirlist($path, $include_hidden = true, $recursive = false) { if ($this->authorized()) { return parent::dirlist($path, $include_hidden, $recursive); } else { return false; } }
function get_font_lists($path) { $wp_filesystem = new WP_Filesystem_Direct(array()); $icons = array(); if ($dirlist = $wp_filesystem->dirlist($path)) { foreach ($dirlist as $dirname => $dirattr) { if ($dirattr['type'] == 'd') { if ($dirfont = $wp_filesystem->dirlist($path . $dirname)) { foreach ($dirfont as $filename => $fileattr) { if (preg_match("/(\\.css)\$/", $filename)) { if ($icon = dt_exctract_icon($path . $dirname . "/" . $filename)) { $icons = @array_merge($icon, $icons); } break; } } } } elseif ($dirattr['type'] == 'f' && preg_match("/(\\.css)\$/", $dirname)) { if ($icon = dt_exctract_icon($path . $dirname)) { $icons = @array_merge($icon, $icons); } } } } return $icons; }