A8C_Files::check_to_upload_file PHP Метод

check_to_upload_file() публичный Метод

public check_to_upload_file ( $data, $postarr )
    function check_to_upload_file($data, $postarr)
    {
        // Check if this is an import or a local image_editor->save
        if (0 < intval($postarr['import_id']) || !$this->attachment_file_exists($postarr['guid'])) {
            $url_parts = parse_url($postarr['guid']);
            $uploads = wp_upload_dir();
            if (false !== $uploads['error']) {
                return $data;
            }
            $dir_file_parts = explode('/', $url_parts['path']);
            if (3 > count($dir_file_parts)) {
                return $data;
            }
            $local_file_path = implode('/', array_splice($dir_file_parts, count($dir_file_parts) - 3));
            $filename = constant('LOCAL_UPLOADS') . '/' . $local_file_path;
            $file = array('file' => $filename, 'url' => $this->get_files_service_hostname() . $url_parts['path'], 'type' => $postarr['post_mime_type'], 'error' => 0);
            $file = $this->upload_file($file, 'attachment_import');
            // did the file get renamed due to a name clash, if so record the change
            if (basename($url_parts['path']) != basename($file['file'])) {
                $data['guid'] = str_replace(basename($url_parts['path']), basename($file['file']), $data['guid']);
            }
        }
        return $data;
    }