Inpsyde\MultilingualPress\SiteDuplication\WPDBAttachmentCopier::get_attachment_paths PHP Метод

get_attachment_paths() приватный Метод

Only files referenced in the database are trustworthy, and will therefore get copied.
private get_attachment_paths ( ) : string[]
Результат string[] The array with directories relative to uploads as keys, and arrays of file paths as values.
    private function get_attachment_paths()
    {
        $metadata = $this->db->get_results("SELECT meta_value FROM {$this->db->postmeta} WHERE meta_key = '_wp_attachment_metadata'");
        if (!$metadata) {
            return [];
        }
        $attachment_paths = array_reduce($metadata, function (array $attachment_paths, $metadata) {
            $meta_value = maybe_unserialize($metadata->meta_value);
            if (empty($meta_value['file'])) {
                return $attachment_paths;
            }
            $file = $meta_value['file'];
            $dir = dirname($file);
            $attachment_paths[$dir][] = basename($file);
            if (empty($meta_value['sizes'])) {
                return $attachment_paths;
            }
            $sizes = $meta_value['sizes'];
            $attachment_paths[$dir] = array_reduce($sizes, function (array $dirs, array $size) {
                $dirs[] = $size['file'];
                return $dirs;
            }, $attachment_paths[$dir]);
            return $attachment_paths;
        }, []);
        return $attachment_paths;
    }