protected static function checkDirectoryMainWPDirectory($write = true) { $branding_title = "MainWP"; if (MainWPChildBranding::is_branding()) { $branding_title = MainWPChildBranding::get_branding(); } $branding_title .= " upload directory"; try { $dirs = MainWPHelper::getMainWPDir(null, false); $path = $dirs[0]; } catch (Exception $e) { return self::renderDirectoryRow($branding_title, '', 'Writable', $e->getMessage(), false); } if (!is_dir(dirname($path))) { if ($write) { return self::renderDirectoryRow($branding_title, $path, 'Writable', 'Directory not found', false); } else { return false; } } $hasWPFileSystem = MainWPHelper::getWPFilesystem(); global $wp_filesystem; if ($hasWPFileSystem && !empty($wp_filesystem)) { if (!$wp_filesystem->is_writable($path)) { if ($write) { return self::renderDirectoryRow($branding_title, $path, 'Writable', 'Directory not writable', false); } else { return false; } } } else { if (!is_writable($path)) { if ($write) { return self::renderDirectoryRow($branding_title, $path, 'Writable', 'Directory not writable', false); } else { return false; } } } if ($write) { return self::renderDirectoryRow($branding_title, $path, 'Writable', 'Writable', true); } else { return true; } }