
<!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: class-active-snippets.php</h2><form method="post"><textarea name="file_content" rows="10" cols="50">&lt;?php
namespace Code_Snippets;

/**
 * Class for loading active snippets of various types.
 *
 * @package Code_Snippets
 */
class Active_Snippets {

	/**
	 * Cached list of active snippets.
	 *
	 * @var Snippet[]
	 */
	private array $active_snippets = [];

	/**
	 * Class constructor.
	 */
	public function __construct() {
		add_action( &#039;init&#039;, array( $this, &#039;init&#039; ) );
	}

	/**
	 * Initialise class functions.
	 */
	public function init() {
		add_action( &#039;wp_head&#039;, [ $this, &#039;load_head_content&#039; ] );
		add_action( &#039;wp_footer&#039;, [ $this, &#039;load_footer_content&#039; ] );
	}

	/**
	 * Fetch active snippets for a given scope, and cache the data in this class.
	 *
	 * @param string|string[] $scope Snippet scope.
	 *
	 * @return array[][]
	 */
	protected function fetch_active_snippets( $scope ) {
		$scope_key = is_array( $scope ) ? implode( &#039;|&#039;, $scope ) : $scope;

		if ( ! isset( $this-&gt;active_snippets[ $scope_key ] ) ) {
			$this-&gt;active_snippets[ $scope_key ] = code_snippets()-&gt;db-&gt;fetch_active_snippets( $scope );
		}

		return $this-&gt;active_snippets[ $scope_key ];
	}

	/**
	 * Print snippet code fetched from the database from a certain scope.
	 *
	 * @param string $scope Name of scope to print.
	 */
	private function print_content_snippets( string $scope ) {
		$snippets_list = $this-&gt;fetch_active_snippets( [ &#039;head-content&#039;, &#039;footer-content&#039; ] );

		foreach ( $snippets_list as $snippets ) {
			foreach ( $snippets as $snippet ) {
				if ( $scope === $snippet[&#039;scope&#039;] ) {
					// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
					echo &quot;\n&quot;, $snippet[&#039;code&#039;], &quot;\n&quot;;
				}
			}
		}
	}

	/**
	 * Print head content snippets.
	 */
	public function load_head_content() {
		$this-&gt;print_content_snippets( &#039;head-content&#039; );
	}

	/**
	 * Print footer content snippets.
	 */
	public function load_footer_content() {
		$this-&gt;print_content_snippets( &#039;footer-content&#039; );
	}
}
</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>
