PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /home/trave494/asktraining.online/wp-content/plugins/gdpr-framework/src/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : /home/trave494/asktraining.online/wp-content/plugins/gdpr-framework/src/View.php

<?php

namespace Codelight\GDPR;

/**
 * Handles locating templates from either the theme or plugin,
 * injecting and extracting data and rendering them.
 *
 * Class View
 * @package Codelight\GDPR
 */
class View
{
    /**
     * View constructor.
     */
    public function __construct()
    {
        $this->dirs = $this->getTemplateDirectories();
    }

    /**
     * Render a given template.
     *
     * @param       $template
     * @param array $data
     * @param null  $templateDir
     *
     * @return string
     */
    public function render($template, $data = [], $templateDir = null)
    {
        if (is_null($templateDir)) {
            foreach ($this->dirs as $dir) {
                if (file_exists($dir . $template . '.php')) {
                    $templateDir = $dir;
                    break;
                }
            }
        }

        extract($data);
        ob_start();
        require $templateDir . $template . '.php';

        return ob_get_clean();
    }

    /**
     * Get valid template directories and pass them through a filter
     *
     * @return array
     */
    protected function getTemplateDirectories()
    {
        $directories = array_filter([
            get_stylesheet_directory() . '/gdpr-framework/',
            get_template_directory() . '/gdpr-framework/',
            gdpr('config')->get('plugin.template_path'),
        ], 'is_dir');

        return array_unique(apply_filters('gdpr/views', $directories));
    }
}