$vars Data for the template, available as `$vars`. * @return string */ public static function render( string $template, array $vars = array() ): string { $template = ltrim( str_replace( array( '..', '\\' ), array( '', '/' ), $template ), '/' ); $file = locate_template( array( 'hostkhata/' . $template . '.php' ) ); if ( '' === $file ) { $file = HOSTKHATA_PATH . 'templates/' . $template . '.php'; } if ( ! is_readable( $file ) ) { return ''; } /** * Filters the template file that will be rendered. * * @since 0.1.0 * * @param string $file Absolute path. * @param string $template Template name. */ $file = apply_filters( 'hostkhata_template_file', $file, $template ); ob_start(); ( static function () use ( $file, $vars ) { include $file; } )(); return (string) ob_get_clean(); } }