| Server IP : 103.191.208.88 / Your IP : 216.73.216.44 Web Server : Microsoft-IIS/10.0 System : Windows NT COSMIC 10.0 build 20348 (Windows Server 2022) AMD64 User : IWPD_1831(willswel_) ( 0) PHP Version : 8.2.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/Inetpub/vhosts/willswell.com/httpdocs/wp-content/plugins/fluentform/app/ |
Upload File : |
<?php
namespace FluentForm\App;
use Composer\Script\Event;
use InvalidArgumentException;
use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;
class ComposerScript
{
public static function postInstall(Event $event)
{
static::postUpdate($event);
}
public static function postUpdate(Event $event)
{
$vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
$composerJson = json_decode(file_get_contents($vendorDir . '/../composer.json'), true);
$namespace = $composerJson['extra']['wpfluent']['namespace']['current'];
if (!$namespace) {
throw new InvalidArgumentException("Namespace not set in composer.json file.");
}
$itr = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(
$vendorDir.'/wpfluent/framework/src/', RecursiveDirectoryIterator::SKIP_DOTS
), RecursiveIteratorIterator::SELF_FIRST);
foreach ($itr as $file) {
if ($file->isDir()) {
continue;
}
$fileName = $file->getPathname();
$content = file_get_contents($fileName);
if (strpos($content, 'WPFluent\\') === false) {
continue;
}
$content = str_replace(
'WPFluent\\',
$namespace . '\\Framework\\',
$content
);
file_put_contents($fileName, $content);
}
}
}