HEX
Server: Apache
System: Linux cpanelx.inxs.ro 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: crowdandsafety (1041)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/proc/self/cwd/wp-content/plugins/cornerstone/includes/classes/Util/View.php
<?php

namespace Themeco\Cornerstone\Util;

use Themeco\Cornerstone\Plugin;

class View {

  protected $view = false;
  protected $plugin;
  protected $path;

  public function __construct(Plugin $plugin) {
    $this->plugin = $plugin;
    $this->path = $this->plugin->path;
  }

  public function name( $name ) {
    $file = $this->plugin->path . '/includes/views/' . $name . '.php';

    if ( file_exists( $file ) ) {
      $this->view = $file;
    }

    return $this;
  }

  public function file() {
    return $this->view;
  }

  /**
   * Include a view file, optionally outputting its contents.
   */
  public function render( $echo = true, $data = array(), $extract = false ) {

    if ( empty( $this->view ) ) {
      return '';
    }

    ob_start();

    if ( $extract ) {
      extract( $data );
    }

    include( $this->view );

    $contents = ob_get_clean();

    if ( $echo ) {
      echo $contents;
    }

    return $contents;

  }

  public function view( $name ) {
    return (new self($this->plugin))->name($name)->render();
  }

}