-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathView.php
More file actions
37 lines (29 loc) · 921 Bytes
/
View.php
File metadata and controls
37 lines (29 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?
namespace cw\wp;
class View{
use \cw\php\view\html\traits\Html{
image as protected _original_image;
}
public $viewPath;
public $imagePath;
public function __construct($viewPath ='template-parts',
$imagePath ='assets/images'){
$this->viewPath = $viewPath;
$this->imagePath = $imagePath;
}
public function render($template, $variation=null){
get_template_part("$this->viewPath/$template", $variation);
}
// affects also public function img
public function image($src, $options){
if(strpos($src, '://') !== false
|| strpos($src, '//') === 0)
return $this->_original_image($src, $options);
$src = implode('/',[
get_stylesheet_directory_uri(),
$this->imagePath,
$src
]);
return $this->_original_image($src, $options);
}
}