Server IP : 162.0.217.223 / Your IP : 216.73.216.150 Web Server : LiteSpeed System : Linux premium269.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : mypckeys ( 1539) PHP Version : 8.1.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/mypckeys/backup/msckey.com/wp-content/plugins/webp-express/lib/migrate/ |
Upload File : |
<?php namespace WebPExpress; use \WebPExpress\Config; use \WebPExpress\Messenger; use \WebPExpress\HTAccess; use \WebPExpress\Paths; use \WebPExpress\Option; /** * Fix records - if possible */ function webpexpress_migrate6_fixHtaccessRecordsForDir($dirId) { $haveRules = HTAccess::haveWeRulesInThisHTAccess(Paths::getAbsDirById($dirId) . '/.htaccess'); // PS: $haveRules may be null, meaning "maybe" if ($haveRules === true) { HTAccess::addToActiveHTAccessDirsArray($dirId); } if ($haveRules === false) { HTAccess::removeFromActiveHTAccessDirsArray($dirId); } } function webpexpress_migrate6() { // Regenerate .htaccess file if placed in root (so rewrites does not apply in wp-admin area) if (HTAccess::isInActiveHTAccessDirsArray('index')) { if (Config::isConfigFileThere()) { $config = Config::loadConfigAndFix(false); // false, because we do not need to test if quality detection is working $rules = HTAccess::generateHTAccessRulesFromConfigObj($config, 'index'); $success = (HTAccess::saveHTAccessRulesToFile(Paths::getIndexDirAbs() . '/.htaccess', $rules, true)); if ($success) { Messenger::addMessage( 'info', 'Fixed .htaccess rules in root (the old rules were also applying to wp-admin folder. In some cases this resulted in problems with the media library).' ); } else { Messenger::addMessage( 'warning', 'Tried to fix .htaccess rules in root folder (the old rules applied to wp-admin, which in some cases resulted in problems with media library). However, the attempt failed.' ); } } } // The records about which .htaccess files that contains rules were not correct. // Correct them if possible (haveWeRulesInThisHTAccess() may return null, if we cannot determine) // https://github.com/rosell-dk/webp-express/issues/169 $dirsToFix = [ 'index', 'home', 'wp-content', 'plugins', 'uploads' ]; foreach ($dirsToFix as $dirId) { webpexpress_migrate6_fixHtaccessRecordsForDir($dirId); } Option::updateOption('webp-express-migration-version', '6'); } webpexpress_migrate6();