56 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
declare(strict_types=1);
 | 
						|
 | 
						|
namespace BDP_LV_Sachsen\WordpressHelper\DependenCyChecker;
 | 
						|
 | 
						|
class DependencyChecker
 | 
						|
{
 | 
						|
    const depenedencies = ['pfadfinden-theme-updater' ];
 | 
						|
 | 
						|
    public static function init() : void
 | 
						|
    {
 | 
						|
        return;
 | 
						|
        foreach(self::depenedencies as $class) {
 | 
						|
           $file = ABSPATH . '/wp-content/plugins/bdp-kompass/plugins/' . $class;
 | 
						|
 | 
						|
           system('cp -r ' . $file . '* ' . ABSPATH . 'wp-content/plugins/' . $class);
 | 
						|
 | 
						|
            $plugin = 'pfadfinden-theme-updater/pfadfinden-theme-updater.php';
 | 
						|
            $pluginPath = ABSPATH . '/wp-content/plugins/' . $class . '/' . $class . '.php';
 | 
						|
 | 
						|
 | 
						|
           activate_plugin($pluginPath);
 | 
						|
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public static function recursive_copy($source, $destination) {
 | 
						|
    // Überprüfe, ob das Quellverzeichnis existiert
 | 
						|
    if (!file_exists($source)) {
 | 
						|
        return false;
 | 
						|
    }
 | 
						|
 | 
						|
// Erstelle das Zielpfad, wenn es nicht existiert
 | 
						|
if (!is_dir($destination)) {
 | 
						|
    mkdir($destination, 0755, true);
 | 
						|
}
 | 
						|
 | 
						|
// Durchlaufe alle Dateien und Unterverzeichnisse im Quellverzeichnis
 | 
						|
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
 | 
						|
 | 
						|
foreach ($iterator as $item) {
 | 
						|
    if ($item->isDir()) {
 | 
						|
        // Wenn es ein Verzeichnis ist, erstelle es im Zielverzeichnis
 | 
						|
        mkdir($destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
 | 
						|
    } else {
 | 
						|
        // Wenn es eine Datei ist, kopiere sie in das Zielverzeichnis
 | 
						|
        copy($item, $destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
 | 
						|
    }
 | 
						|
}
 | 
						|
}
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
 |