| 1 |
<?php namespace Datafeedr\Api\Templates; |
| 2 |
|
| 3 |
use Datafeedr\Api\Wuwei\Templates\Template as Template_Abstract; |
| 4 |
|
| 5 |
/** |
| 6 |
* Template class. |
| 7 |
* |
| 8 |
* Extends the Wuwei Template_Abstract class. |
| 9 |
* |
| 10 |
* @since 2.0.0 |
| 11 |
*/ |
| 12 |
class Template extends Template_Abstract { |
| 13 |
|
| 14 |
/** |
| 15 |
* {@inheritdoc} |
| 16 |
*/ |
| 17 |
public function get_file() { |
| 18 |
|
| 19 |
$path = trailingslashit( realpath( __DIR__ . '/..' ) ); |
| 20 |
$path = trailingslashit( $path . 'Views' ); |
| 21 |
$file = $path . $this->name; |
| 22 |
|
| 23 |
/** |
| 24 |
* Filter the full path to our template file. Examples of a full path might be: |
| 25 |
* |
| 26 |
* - /home/user/public_html/wp-content/plugins/plugin-name/src/Template/price.php |
| 27 |
* |
| 28 |
* This filter allows you to modify the file name used when rendering the template. |
| 29 |
* |
| 30 |
* @since 2.0.0 |
| 31 |
* |
| 32 |
* @param string $file The full path to our template file. |
| 33 |
* @param object $this The Template object. |
| 34 |
*/ |
| 35 |
return apply_filters( 'datafeedr/api/template/get_file/file', $file, $this ); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* {@inheritdoc} |
| 40 |
*/ |
| 41 |
public function get_data() { |
| 42 |
|
| 43 |
$data = $this->data; |
| 44 |
|
| 45 |
/** |
| 46 |
* Filter the data we will have access to when rendering the template. The $data array is passed |
| 47 |
* through the extract() function which sets its array keys as variables and are made available |
| 48 |
* in the template files. |
| 49 |
* |
| 50 |
* @since 2.0.0 |
| 51 |
* |
| 52 |
* @param array $data An array of data to populate the template. |
| 53 |
* @param object $this The Template object. |
| 54 |
*/ |
| 55 |
return apply_filters( 'datafeedr/api/template/get_data/data', $data, $this ); |
| 56 |
} |
| 57 |
} |