HEX
Server: LiteSpeed
System: Linux server302.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
User: synqowzz (1256)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //proc/self/cwd/wp-content/plugins/pro-elements/modules/custom-code/import-export/revert-runner.php
<?php

namespace ElementorPro\Modules\CustomCode\ImportExport;

use Elementor\App\Modules\ImportExport\Runners\Revert\Revert_Runner_Base;
use ElementorPro\Modules\CustomCode\Module as Custom_Code_Module;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class Revert_Runner extends Revert_Runner_Base {

	public static function get_name(): string {
		return 'custom-code';
	}

	public function should_revert( array $data ): bool {
		return (
			isset( $data['runners'] ) &&
			array_key_exists( static::get_name(), $data['runners'] )
		);
	}

	public function revert( array $data ) {
		$metadata = $data['runners'][ static::get_name() ] ?? [];

		$this->revert_imported_snippets( $metadata );
	}

	private function revert_imported_snippets( $metadata ) {
		$imported_snippets = $metadata['imported_snippets'] ?? [];

		foreach ( $imported_snippets as $snippet ) {
			wp_delete_post( $snippet['id'], true );
		}
	}
}