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
h. After the final extraction of the css and js scripts, I change the composer entries. And we change to the /assets folder
{
"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
- Sorting and installing css and js: wordpress-pachet/ ├── composer.json # Composer configuration for the project ├── composer.lock # File automatically generated by Composer ├── copy-assets.php # PHP script for copying CSS/JS files ├── post-install-cmd.php # (Optional) Other post-install commands ├── assets/ # Folder for CSS/JS (automatically generated) ├── vendor/ # Dependencies installed automatically by Composer └── wordpress/ # WordPress core, manually included ├── wp-admin/ ├── wp-content/ │ ├── plugins/ │ ├── themes/ ├── wp-includes/ ├── wp-config.php └── alte fișiere WP...
- After installing and extracting js and css main core wordpress will be removed for security: wordpress-scripts/ ├── composer.json # Composer configuration without wordpress core ├── assets/ # Required CSS/JS files │ ├── custom.js │ ├── style.css └── README.md # Documentation (opțional)