Generate files end copy wordpress-all - wordpress-pachet/ ├── composer.json ├── wordpress/
{
"name": "ghepes/wordpress-pachet",
"description": "Pachet WordPress complet, inclusiv CSS/JS.",
"type": "project",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.4"
},
"autoload": {
"psr-4": {
"Namespace\\WordPress\\": "wordpress/"
}
},
"scripts": {
"post-install-cmd": [
"php copy-assets.php"
],
"post-update-cmd": [
"php copy-assets.php"
]
}
}
assets
copy-assets.php
post-install-cmd.php
<?php
$sourceDirs = [
'wordpress/wp-admin',
'wordpress/wp-includes',
'wordpress/wp-content/plugins',
'wordpress/wp-content/themes'
];
$targetDir = 'assets/';
foreach ($sourceDirs as $dir) {
if (!is_dir($dir)) {
continue;
}
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
foreach ($files as $file) {
if ($file->isFile() && preg_match('/\.(css|js)$/', $file->getFilename())) {
$relativePath = str_replace($dir . '/', '', $file->getPathname());
$dest = $targetDir . $relativePath;
if (!is_dir(dirname($dest))) {
mkdir(dirname($dest), 0777, true);
}
copy($file->getPathname(), $dest);
}
}
}
<?php
$sourceDirs = ['wp-content/themes', 'wp-content/plugins', 'wp-admin', 'wp-includes'];
$targetDir = 'assets/';
foreach ($sourceDirs as $dir) {
$files = glob($dir . '/**/*.{css,js}', GLOB_BRACE);
foreach ($files as $file) {
$relativePath = str_replace($dir . '/', '', $file);
$dest = $targetDir . $relativePath;
if (!is_dir(dirname($dest))) {
mkdir(dirname($dest), 0777, true);
}
copy($file, $dest);
}
}
composer install
/assets
{
"name": "ghepes/wordpress-scripts",
"description": "Private package for CSS and JS scripts used in WordPress.",
"type": "library",
"license": "proprietary",
"require": {
"php": ">=7.4"
},
"autoload": {
"psr-4": {
"Namespace\\WordPressScripts\\": "assets/"
}
}
}
{
"name": "ghepes/wordpress-scripts",
"description": "Private package for CSS and JS scripts used in WordPress.",
"type": "library",
"license": "proprietary",
"require": {
"php": ">=7.4"
},
"autoload": {
"psr-4": {
"Namespace\\WordPressScripts\\": "assets/"
}
},
"scripts": {
"test": "vendor/bin/phpunit"
}
}
"repositories": [
{
"type": "vcs",
"url": "https://github.com/numele-tau/wordpress-scripts"
}
]
composer requires your-name/wordpress-scripts