file = $file; $this->plgDir = dirname($file); $this->plgURL = plugin_dir_url($file); $this->siteUrl = network_site_url(); $this->wpRoot = parse_url($this->siteUrl, PHP_URL_PATH); if (empty($this->wpRoot) || $this->wpRoot == DIRECTORY_SEPARATOR) { $this->wpRoot = ""; } else { $this->wpRoot .= DIRECTORY_SEPARATOR; } $this->siteUrl = trailingslashit($this->siteUrl); $this->isPro = file_exists("{$this->plgDir}/admin/options-advanced.php"); $this->mkEndPoint(); } if ($this->isPro) { $this->strPro = 'Pro'; } else { $this->strPro = 'Lite'; } } function mkEndPoint() { $this->keyEp = $this->key . '-ep'; $siteUrl = $this->siteUrl; if (defined('SUBDOMAIN_INSTALL')) { if (SUBDOMAIN_INSTALL) { $siteUrl = site_url(); } } if (function_exists('get_sites')) { $info = get_sites(); if (!empty($info[1]) && $info[1]->path == "/") { $siteUrl = site_url(); } } else if (function_exists('wp_get_sites')) { $info = wp_get_sites(); if (!empty($info[1]) && $info[1]['path'] == "/") { $siteUrl = site_url(); } } $siteUrl = trailingslashit($siteUrl); $this->endPoint = $siteUrl . $this->keyEp; } static function isEmptyHtaccess($data) { if (empty($data)) { return true; } $lines = explode("\n", $data); foreach ($lines as $l) { $l = trim($l); if (empty($l)) { continue; } if ($l[0] == '#') { continue; } return false; } return true; } function getServerSoftware() { $server = "unknown"; if (!empty($_SERVER['SERVER_SOFTWARE'])) { $serverSoftware = strtolower($_SERVER['SERVER_SOFTWARE']); } else { $serverSoftware = ""; } if (strpos($serverSoftware, "apache") !== false) { $server = "apache"; } if (strpos($serverSoftware, "nginx") !== false) { $server = "nginx"; } if (strpos($serverSoftware, "microsoft") !== false) { $server = "microsoft"; } return $server; } function getNginxMsg() { $data = 'location / { try_files $uri $uri/ /index.php?q=$request_uri; }'; return "
You are running on nginx. You may have to edit your config file after enabling Permalinks. Please see Nginx instructions. In most cases, all you have to do is to add this to your location block:
$data"; } function getMSMsg() { return "
You are running on a Microsoft server. Please enable and configure Permalinks. Here is how to do it."; } function getApacheMsg() { return "
You are running on an Apache or a generic server. Please enable and configure Permalinks. Add the standard WordPress directives to your .htaccess file or equivalent.";
}
function checkPerma() {
$permaStructure = get_option('permalink_structure');
if (!empty($permaStructure)) {
return;
}
$server = $this->getServerSoftware();
$msg = "";
switch ($server) {
case "nginx":
return $this->getNginxMsg();
case "microsoft":
return $this->getMSMsg();
default:
$msg = "
Depending on your server, follow the steps below.
"; $msg .= $this->getNginxMsg(); $msg .= $this->getMSMsg(); $msg .= $this->getApacheMsg(); case "apache": $file = ABSPATH . ".htaccess"; if (empty($this->wpRoot)) { $wpRoot = "/"; } else { $wpRoot = $this->wpRoot; } $data = " # BEGIN WordPress: Inserted by $this->nameYou already have an .htaccess file ($file) with these contents:
$currentData
Please edit it and add the standard WordPress directives (pointing all missing files to index.php). Here is what you need to add:
$data"; } } // No htaccess or it is empty. Safe to create a default one. $url = wp_nonce_url('plugin-install.php', 'plugin-install'); $creds = request_filesystem_credentials($url, '', false, false, ABSPATH); if ($creds !== false) { WP_Filesystem($creds); global $wp_filesystem; if (!empty($wp_filesystem)) { $abspath = trailingslashit($wp_filesystem->abspath()); $file = "{$abspath}.htaccess"; if ($wp_filesystem->put_contents($file, "$currentData\n$data")) { return "$msg
A default .htaccess has been created for you.
You do not have an .htaccess file and it does not look like I can create one for you. Please create $file and add the standard WordPress directives (pointing all missing files to index.php). Here is what you need to add:
$data"; } break; } } static function install($dir, $mOptions) { $ezOptions = get_option($mOptions); if (empty($ezOptions)) { // create the necessary tables $GLOBALS['isInstallingWP'] = true; chdir($dir . '/admin'); require_once('dbSetup.php'); $ezOptions['isSetup'] = true; } update_option($mOptions, $ezOptions); } static function uninstall($mOptions) { delete_option($mOptions); } static function getDB() { if (empty(self::$db)) { require_once 'DbHelper.php'; self::$db = new DbHelper(); } return self::$db; } function printAdminPage() { ?>
Loading... Please wait!