| 1 |
<?php |
| 2 |
|
| 3 |
namespace Better_Payment\Lite\Traits; |
| 4 |
|
| 5 |
/** |
| 6 |
* Exit if accessed directly |
| 7 |
*/ |
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Helper trait |
| 14 |
* |
| 15 |
* @since 0.0.1 |
| 16 |
*/ |
| 17 |
trait Helper |
| 18 |
{ |
| 19 |
use Elements, ElementorHelper, WordPressHelper; |
| 20 |
|
| 21 |
public function bp_template_render($filePath, $variables = array(), $print = true) |
| 22 |
{ |
| 23 |
$output = NULL; |
| 24 |
if (file_exists($filePath)) { |
| 25 |
// Extract the variables to a local namespace |
| 26 |
extract($variables); |
| 27 |
|
| 28 |
// Start output buffering |
| 29 |
ob_start(); |
| 30 |
|
| 31 |
// Include the template file |
| 32 |
include $filePath; |
| 33 |
|
| 34 |
// End buffering and return its contents |
| 35 |
$output = ob_get_clean(); |
| 36 |
} |
| 37 |
if ($print) { |
| 38 |
print $output; |
| 39 |
} |
| 40 |
return $output; |
| 41 |
} |
| 42 |
} |
| 43 |
|