| Server IP : 121.121.20.254 / Your IP : 216.73.216.145 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/KnowledgeBase/wp-content/plugins/wpmu-dev-seo/includes/core/ |
Upload File : |
<?php
namespace SmartCrawl;
abstract class Renderable {
private $view_defaults = null;
/**
* Renders the view by calling `_load`
*
* @param string $view View file to load.
* @param array $args Optional array of arguments to pass to view.
*
* @return bool
*/
protected function render_view( $view, $args = array() ) {
$view = $this->load_view( $view, $args );
if ( ! empty( $view ) ) {
echo $view; // phpcs:ignore -- The template being rendered could contain anything
}
return ! empty( $view );
}
/**
* Loads the view file and returns the output as string
*
* @param string $view View file to load.
* @param array $args Optional array of arguments to pass to view.
*
* @return mixed (string)View output on success, (bool)false on failure.
*/
protected function load_view( $view, $args = array() ) {
$view = preg_replace( '/[^\-_a-z0-9\/]/i', '', $view );
if ( empty( $view ) ) {
return false;
}
$_path = wp_normalize_path( SMARTCRAWL_PLUGIN_DIR . 'core/admin/templates/' . $view . '.php' );
if ( ! file_exists( $_path ) || ! is_readable( $_path ) ) {
return false;
}
if ( empty( $args ) || ! is_array( $args ) ) {
$args = array();
}
if ( is_null( $this->view_defaults ) ) {
$this->view_defaults = $this->get_view_defaults();
}
$args = wp_parse_args( $args, $this->view_defaults );
if ( ! empty( $args ) ) {
extract( $args ); // phpcs:ignore -- extract method is necessary here for making variables available to template
}
ob_start();
include $_path;
return ob_get_clean();
}
abstract protected function get_view_defaults();
}