@@ -4,161 +4,161 @@ |
||
4 | 4 | |
5 | 5 | class Theme |
6 | 6 | { |
7 | - public $archiveMeta; |
|
8 | - public $postMeta; |
|
9 | - |
|
10 | - public function __construct(ArchiveMeta $archiveMeta, PostMeta $postMeta) |
|
11 | - { |
|
12 | - $this->archiveMeta = $archiveMeta; |
|
13 | - $this->postMeta = $postMeta; |
|
14 | - } |
|
15 | - |
|
16 | - /** |
|
17 | - * @param string $asset |
|
18 | - * |
|
19 | - * @return string |
|
20 | - */ |
|
21 | - public function assetPath($asset) |
|
22 | - { |
|
23 | - return $this->paths('dir.stylesheet').'assets/'.$asset; |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * @param string $asset |
|
28 | - * |
|
29 | - * @return string |
|
30 | - */ |
|
31 | - public function assetUri($asset) |
|
32 | - { |
|
33 | - return $this->paths('uri.stylesheet').'assets/'.$asset; |
|
34 | - } |
|
35 | - |
|
36 | - /** |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function copyright() |
|
40 | - { |
|
41 | - return __('Copyright', 'castor').' © '.date('Y').', '.get_bloginfo('name'); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * @return bool |
|
46 | - */ |
|
47 | - public function displaySidebar() |
|
48 | - { |
|
49 | - $conditions = [ |
|
50 | - is_archive(), |
|
51 | - is_home(), |
|
52 | - is_single(), |
|
53 | - ]; |
|
54 | - |
|
55 | - $display = in_array(true, $conditions); |
|
56 | - |
|
57 | - return apply_filters('castor/display/sidebar', $display); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * @param string $asset |
|
62 | - * |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - public function imagePath($asset) |
|
66 | - { |
|
67 | - return $this->assetPath(castor_app()->imgDir.$asset); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * @param string $asset |
|
72 | - * |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public function imageUri($asset) |
|
76 | - { |
|
77 | - return $this->assetUri(castor_app()->imgDir.$asset); |
|
78 | - } |
|
79 | - |
|
80 | - public function pageTitle() |
|
81 | - { |
|
82 | - foreach (['is_404', 'is_archive', 'is_home', 'is_page', 'is_search'] as $bool) { |
|
83 | - if (!$bool()) { |
|
84 | - continue; |
|
85 | - } |
|
86 | - $method = sprintf('get%sTitle', ucfirst(str_replace('is_', '', $bool))); |
|
87 | - return $this->$method(); |
|
88 | - } |
|
89 | - |
|
90 | - return get_the_title(); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param string|null $path |
|
95 | - * |
|
96 | - * @return array|string |
|
97 | - */ |
|
98 | - public function paths($path = null) |
|
99 | - { |
|
100 | - $paths = [ |
|
101 | - 'dir.stylesheet' => get_stylesheet_directory(), |
|
102 | - 'dir.template' => get_template_directory(), |
|
103 | - 'dir.upload' => wp_upload_dir()['basedir'], |
|
104 | - 'uri.stylesheet' => get_stylesheet_directory_uri(), |
|
105 | - 'uri.template' => get_template_directory_uri(), |
|
106 | - ]; |
|
107 | - |
|
108 | - if (is_null($path)) { |
|
109 | - return $paths; |
|
110 | - } |
|
111 | - |
|
112 | - return array_key_exists($path, $paths) |
|
113 | - ? trailingslashit($paths[$path]) |
|
114 | - : ''; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @param string|null $path |
|
119 | - * @param string $class |
|
120 | - * @return string|null |
|
121 | - */ |
|
122 | - public function svg($path = null, $class = '') |
|
123 | - { |
|
124 | - if (!file_exists($this->imagePath($path))) { |
|
125 | - return; |
|
126 | - } |
|
127 | - $svg = file_get_contents($this->imagePath($path)); |
|
128 | - $pattern = '/(<svg.+)( class=[\'\"](|[^\'\"]+)[\'\"])(>.+)/i'; |
|
129 | - if (1 === preg_match($pattern, $svg, $matches)) { |
|
130 | - $class .= ' '.$matches[3]; |
|
131 | - $svg = preg_filter($pattern, '$1$4', $svg); |
|
132 | - } |
|
133 | - return str_replace('<svg', '<svg class="'.trim($class).'"', $svg); |
|
134 | - } |
|
135 | - |
|
136 | - protected function get404Title() |
|
137 | - { |
|
138 | - return __('Not Found', 'castor'); |
|
139 | - } |
|
140 | - |
|
141 | - protected function getArchiveTitle() |
|
142 | - { |
|
143 | - return $this->archiveMeta->get('title', get_the_archive_title(), get_query_var('post_type')); |
|
144 | - } |
|
145 | - |
|
146 | - protected function getHomeTitle() |
|
147 | - { |
|
148 | - return ($home = (string) get_option('page_for_posts')) |
|
149 | - ? get_the_title($home) |
|
150 | - : get_the_archive_title(); |
|
151 | - } |
|
152 | - |
|
153 | - protected function getPageTitle() |
|
154 | - { |
|
155 | - return $this->postMeta->get('title', [ |
|
156 | - 'fallback' => get_the_title(), |
|
157 | - ]); |
|
158 | - } |
|
159 | - |
|
160 | - protected function getSearchTitle() |
|
161 | - { |
|
162 | - return sprintf(__('Search Results for %s', 'castor'), get_search_query()); |
|
163 | - } |
|
7 | + public $archiveMeta; |
|
8 | + public $postMeta; |
|
9 | + |
|
10 | + public function __construct(ArchiveMeta $archiveMeta, PostMeta $postMeta) |
|
11 | + { |
|
12 | + $this->archiveMeta = $archiveMeta; |
|
13 | + $this->postMeta = $postMeta; |
|
14 | + } |
|
15 | + |
|
16 | + /** |
|
17 | + * @param string $asset |
|
18 | + * |
|
19 | + * @return string |
|
20 | + */ |
|
21 | + public function assetPath($asset) |
|
22 | + { |
|
23 | + return $this->paths('dir.stylesheet').'assets/'.$asset; |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * @param string $asset |
|
28 | + * |
|
29 | + * @return string |
|
30 | + */ |
|
31 | + public function assetUri($asset) |
|
32 | + { |
|
33 | + return $this->paths('uri.stylesheet').'assets/'.$asset; |
|
34 | + } |
|
35 | + |
|
36 | + /** |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function copyright() |
|
40 | + { |
|
41 | + return __('Copyright', 'castor').' © '.date('Y').', '.get_bloginfo('name'); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * @return bool |
|
46 | + */ |
|
47 | + public function displaySidebar() |
|
48 | + { |
|
49 | + $conditions = [ |
|
50 | + is_archive(), |
|
51 | + is_home(), |
|
52 | + is_single(), |
|
53 | + ]; |
|
54 | + |
|
55 | + $display = in_array(true, $conditions); |
|
56 | + |
|
57 | + return apply_filters('castor/display/sidebar', $display); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * @param string $asset |
|
62 | + * |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + public function imagePath($asset) |
|
66 | + { |
|
67 | + return $this->assetPath(castor_app()->imgDir.$asset); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * @param string $asset |
|
72 | + * |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public function imageUri($asset) |
|
76 | + { |
|
77 | + return $this->assetUri(castor_app()->imgDir.$asset); |
|
78 | + } |
|
79 | + |
|
80 | + public function pageTitle() |
|
81 | + { |
|
82 | + foreach (['is_404', 'is_archive', 'is_home', 'is_page', 'is_search'] as $bool) { |
|
83 | + if (!$bool()) { |
|
84 | + continue; |
|
85 | + } |
|
86 | + $method = sprintf('get%sTitle', ucfirst(str_replace('is_', '', $bool))); |
|
87 | + return $this->$method(); |
|
88 | + } |
|
89 | + |
|
90 | + return get_the_title(); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param string|null $path |
|
95 | + * |
|
96 | + * @return array|string |
|
97 | + */ |
|
98 | + public function paths($path = null) |
|
99 | + { |
|
100 | + $paths = [ |
|
101 | + 'dir.stylesheet' => get_stylesheet_directory(), |
|
102 | + 'dir.template' => get_template_directory(), |
|
103 | + 'dir.upload' => wp_upload_dir()['basedir'], |
|
104 | + 'uri.stylesheet' => get_stylesheet_directory_uri(), |
|
105 | + 'uri.template' => get_template_directory_uri(), |
|
106 | + ]; |
|
107 | + |
|
108 | + if (is_null($path)) { |
|
109 | + return $paths; |
|
110 | + } |
|
111 | + |
|
112 | + return array_key_exists($path, $paths) |
|
113 | + ? trailingslashit($paths[$path]) |
|
114 | + : ''; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @param string|null $path |
|
119 | + * @param string $class |
|
120 | + * @return string|null |
|
121 | + */ |
|
122 | + public function svg($path = null, $class = '') |
|
123 | + { |
|
124 | + if (!file_exists($this->imagePath($path))) { |
|
125 | + return; |
|
126 | + } |
|
127 | + $svg = file_get_contents($this->imagePath($path)); |
|
128 | + $pattern = '/(<svg.+)( class=[\'\"](|[^\'\"]+)[\'\"])(>.+)/i'; |
|
129 | + if (1 === preg_match($pattern, $svg, $matches)) { |
|
130 | + $class .= ' '.$matches[3]; |
|
131 | + $svg = preg_filter($pattern, '$1$4', $svg); |
|
132 | + } |
|
133 | + return str_replace('<svg', '<svg class="'.trim($class).'"', $svg); |
|
134 | + } |
|
135 | + |
|
136 | + protected function get404Title() |
|
137 | + { |
|
138 | + return __('Not Found', 'castor'); |
|
139 | + } |
|
140 | + |
|
141 | + protected function getArchiveTitle() |
|
142 | + { |
|
143 | + return $this->archiveMeta->get('title', get_the_archive_title(), get_query_var('post_type')); |
|
144 | + } |
|
145 | + |
|
146 | + protected function getHomeTitle() |
|
147 | + { |
|
148 | + return ($home = (string) get_option('page_for_posts')) |
|
149 | + ? get_the_title($home) |
|
150 | + : get_the_archive_title(); |
|
151 | + } |
|
152 | + |
|
153 | + protected function getPageTitle() |
|
154 | + { |
|
155 | + return $this->postMeta->get('title', [ |
|
156 | + 'fallback' => get_the_title(), |
|
157 | + ]); |
|
158 | + } |
|
159 | + |
|
160 | + protected function getSearchTitle() |
|
161 | + { |
|
162 | + return sprintf(__('Search Results for %s', 'castor'), get_search_query()); |
|
163 | + } |
|
164 | 164 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | public $archiveMeta; |
8 | 8 | public $postMeta; |
9 | 9 | |
10 | - public function __construct(ArchiveMeta $archiveMeta, PostMeta $postMeta) |
|
10 | + public function __construct( ArchiveMeta $archiveMeta, PostMeta $postMeta ) |
|
11 | 11 | { |
12 | 12 | $this->archiveMeta = $archiveMeta; |
13 | 13 | $this->postMeta = $postMeta; |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return string |
20 | 20 | */ |
21 | - public function assetPath($asset) |
|
21 | + public function assetPath( $asset ) |
|
22 | 22 | { |
23 | - return $this->paths('dir.stylesheet').'assets/'.$asset; |
|
23 | + return $this->paths( 'dir.stylesheet' ).'assets/'.$asset; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return string |
30 | 30 | */ |
31 | - public function assetUri($asset) |
|
31 | + public function assetUri( $asset ) |
|
32 | 32 | { |
33 | - return $this->paths('uri.stylesheet').'assets/'.$asset; |
|
33 | + return $this->paths( 'uri.stylesheet' ).'assets/'.$asset; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function copyright() |
40 | 40 | { |
41 | - return __('Copyright', 'castor').' © '.date('Y').', '.get_bloginfo('name'); |
|
41 | + return __( 'Copyright', 'castor' ).' © '.date( 'Y' ).', '.get_bloginfo( 'name' ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | is_single(), |
53 | 53 | ]; |
54 | 54 | |
55 | - $display = in_array(true, $conditions); |
|
55 | + $display = in_array( true, $conditions ); |
|
56 | 56 | |
57 | - return apply_filters('castor/display/sidebar', $display); |
|
57 | + return apply_filters( 'castor/display/sidebar', $display ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - public function imagePath($asset) |
|
65 | + public function imagePath( $asset ) |
|
66 | 66 | { |
67 | - return $this->assetPath(castor_app()->imgDir.$asset); |
|
67 | + return $this->assetPath( castor_app()->imgDir.$asset ); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return string |
74 | 74 | */ |
75 | - public function imageUri($asset) |
|
75 | + public function imageUri( $asset ) |
|
76 | 76 | { |
77 | - return $this->assetUri(castor_app()->imgDir.$asset); |
|
77 | + return $this->assetUri( castor_app()->imgDir.$asset ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | public function pageTitle() |
81 | 81 | { |
82 | - foreach (['is_404', 'is_archive', 'is_home', 'is_page', 'is_search'] as $bool) { |
|
83 | - if (!$bool()) { |
|
82 | + foreach( ['is_404', 'is_archive', 'is_home', 'is_page', 'is_search'] as $bool ) { |
|
83 | + if( !$bool() ) { |
|
84 | 84 | continue; |
85 | 85 | } |
86 | - $method = sprintf('get%sTitle', ucfirst(str_replace('is_', '', $bool))); |
|
86 | + $method = sprintf( 'get%sTitle', ucfirst( str_replace( 'is_', '', $bool ) ) ); |
|
87 | 87 | return $this->$method(); |
88 | 88 | } |
89 | 89 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return array|string |
97 | 97 | */ |
98 | - public function paths($path = null) |
|
98 | + public function paths( $path = null ) |
|
99 | 99 | { |
100 | 100 | $paths = [ |
101 | 101 | 'dir.stylesheet' => get_stylesheet_directory(), |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | 'uri.template' => get_template_directory_uri(), |
106 | 106 | ]; |
107 | 107 | |
108 | - if (is_null($path)) { |
|
108 | + if( is_null( $path ) ) { |
|
109 | 109 | return $paths; |
110 | 110 | } |
111 | 111 | |
112 | - return array_key_exists($path, $paths) |
|
113 | - ? trailingslashit($paths[$path]) |
|
112 | + return array_key_exists( $path, $paths ) |
|
113 | + ? trailingslashit( $paths[$path] ) |
|
114 | 114 | : ''; |
115 | 115 | } |
116 | 116 | |
@@ -119,46 +119,46 @@ discard block |
||
119 | 119 | * @param string $class |
120 | 120 | * @return string|null |
121 | 121 | */ |
122 | - public function svg($path = null, $class = '') |
|
122 | + public function svg( $path = null, $class = '' ) |
|
123 | 123 | { |
124 | - if (!file_exists($this->imagePath($path))) { |
|
124 | + if( !file_exists( $this->imagePath( $path ) ) ) { |
|
125 | 125 | return; |
126 | 126 | } |
127 | - $svg = file_get_contents($this->imagePath($path)); |
|
127 | + $svg = file_get_contents( $this->imagePath( $path ) ); |
|
128 | 128 | $pattern = '/(<svg.+)( class=[\'\"](|[^\'\"]+)[\'\"])(>.+)/i'; |
129 | - if (1 === preg_match($pattern, $svg, $matches)) { |
|
129 | + if( 1 === preg_match( $pattern, $svg, $matches ) ) { |
|
130 | 130 | $class .= ' '.$matches[3]; |
131 | - $svg = preg_filter($pattern, '$1$4', $svg); |
|
131 | + $svg = preg_filter( $pattern, '$1$4', $svg ); |
|
132 | 132 | } |
133 | - return str_replace('<svg', '<svg class="'.trim($class).'"', $svg); |
|
133 | + return str_replace( '<svg', '<svg class="'.trim( $class ).'"', $svg ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | protected function get404Title() |
137 | 137 | { |
138 | - return __('Not Found', 'castor'); |
|
138 | + return __( 'Not Found', 'castor' ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | protected function getArchiveTitle() |
142 | 142 | { |
143 | - return $this->archiveMeta->get('title', get_the_archive_title(), get_query_var('post_type')); |
|
143 | + return $this->archiveMeta->get( 'title', get_the_archive_title(), get_query_var( 'post_type' ) ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | protected function getHomeTitle() |
147 | 147 | { |
148 | - return ($home = (string) get_option('page_for_posts')) |
|
149 | - ? get_the_title($home) |
|
148 | + return ( $home = (string) get_option( 'page_for_posts' ) ) |
|
149 | + ? get_the_title( $home ) |
|
150 | 150 | : get_the_archive_title(); |
151 | 151 | } |
152 | 152 | |
153 | 153 | protected function getPageTitle() |
154 | 154 | { |
155 | - return $this->postMeta->get('title', [ |
|
155 | + return $this->postMeta->get( 'title', [ |
|
156 | 156 | 'fallback' => get_the_title(), |
157 | - ]); |
|
157 | + ] ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | protected function getSearchTitle() |
161 | 161 | { |
162 | - return sprintf(__('Search Results for %s', 'castor'), get_search_query()); |
|
162 | + return sprintf( __( 'Search Results for %s', 'castor' ), get_search_query() ); |
|
163 | 163 | } |
164 | 164 | } |
@@ -2,8 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace GeminiLabs\Castor\Helpers; |
4 | 4 | |
5 | -class Theme |
|
6 | -{ |
|
5 | +class Theme { |
|
7 | 6 | public $archiveMeta; |
8 | 7 | public $postMeta; |
9 | 8 |
@@ -4,80 +4,80 @@ |
||
4 | 4 | |
5 | 5 | class Development |
6 | 6 | { |
7 | - public $templatePaths = []; |
|
7 | + public $templatePaths = []; |
|
8 | 8 | |
9 | - protected $utility; |
|
9 | + protected $utility; |
|
10 | 10 | |
11 | - public function __construct(Utility $utility) |
|
12 | - { |
|
13 | - $this->utility = $utility; |
|
14 | - } |
|
11 | + public function __construct(Utility $utility) |
|
12 | + { |
|
13 | + $this->utility = $utility; |
|
14 | + } |
|
15 | 15 | |
16 | - public function capture() |
|
17 | - { |
|
18 | - ob_start(); |
|
19 | - call_user_func_array([$this, 'printF'], func_get_args()); |
|
20 | - return ob_get_clean(); |
|
21 | - } |
|
16 | + public function capture() |
|
17 | + { |
|
18 | + ob_start(); |
|
19 | + call_user_func_array([$this, 'printF'], func_get_args()); |
|
20 | + return ob_get_clean(); |
|
21 | + } |
|
22 | 22 | |
23 | - public function className($override = 'dev') |
|
24 | - { |
|
25 | - return $this->isDev() ? $override : ''; |
|
26 | - } |
|
23 | + public function className($override = 'dev') |
|
24 | + { |
|
25 | + return $this->isDev() ? $override : ''; |
|
26 | + } |
|
27 | 27 | |
28 | - public function debug() |
|
29 | - { |
|
30 | - call_user_func_array([$this, 'printF'], func_get_args()); |
|
31 | - } |
|
28 | + public function debug() |
|
29 | + { |
|
30 | + call_user_func_array([$this, 'printF'], func_get_args()); |
|
31 | + } |
|
32 | 32 | |
33 | - public function isDev() |
|
34 | - { |
|
35 | - return defined('DEV') && (bool) DEV && WP_ENV == 'development'; |
|
36 | - } |
|
33 | + public function isDev() |
|
34 | + { |
|
35 | + return defined('DEV') && (bool) DEV && WP_ENV == 'development'; |
|
36 | + } |
|
37 | 37 | |
38 | - public function isProduction() |
|
39 | - { |
|
40 | - return WP_ENV == 'production'; |
|
41 | - } |
|
38 | + public function isProduction() |
|
39 | + { |
|
40 | + return WP_ENV == 'production'; |
|
41 | + } |
|
42 | 42 | |
43 | - public function printFiltersFor($hook = '') |
|
44 | - { |
|
45 | - global $wp_filter; |
|
46 | - if (empty($hook) || !isset($wp_filter[$hook])) { |
|
47 | - return; |
|
48 | - } |
|
49 | - $this->printF($wp_filter[$hook]); |
|
50 | - } |
|
43 | + public function printFiltersFor($hook = '') |
|
44 | + { |
|
45 | + global $wp_filter; |
|
46 | + if (empty($hook) || !isset($wp_filter[$hook])) { |
|
47 | + return; |
|
48 | + } |
|
49 | + $this->printF($wp_filter[$hook]); |
|
50 | + } |
|
51 | 51 | |
52 | - public function printTemplatePaths() |
|
53 | - { |
|
54 | - $templates = array_map(function ($key, $value) { |
|
55 | - return sprintf('[%s] => %s', $key, $value); |
|
56 | - }, array_keys($this->templatePaths), $this->templatePaths); |
|
57 | - $this->printF(implode("\n", $templates)); |
|
58 | - } |
|
52 | + public function printTemplatePaths() |
|
53 | + { |
|
54 | + $templates = array_map(function ($key, $value) { |
|
55 | + return sprintf('[%s] => %s', $key, $value); |
|
56 | + }, array_keys($this->templatePaths), $this->templatePaths); |
|
57 | + $this->printF(implode("\n", $templates)); |
|
58 | + } |
|
59 | 59 | |
60 | - public function storeTemplatePath($template) |
|
61 | - { |
|
62 | - if (is_string($template)) { |
|
63 | - $this->templatePaths[] = $this->utility->trimLeft($template, trailingslashit(WP_CONTENT_DIR)); |
|
64 | - } |
|
65 | - } |
|
60 | + public function storeTemplatePath($template) |
|
61 | + { |
|
62 | + if (is_string($template)) { |
|
63 | + $this->templatePaths[] = $this->utility->trimLeft($template, trailingslashit(WP_CONTENT_DIR)); |
|
64 | + } |
|
65 | + } |
|
66 | 66 | |
67 | - protected function printF() |
|
68 | - { |
|
69 | - $args = func_num_args(); |
|
67 | + protected function printF() |
|
68 | + { |
|
69 | + $args = func_num_args(); |
|
70 | 70 | |
71 | - if (1 == $args) { |
|
72 | - printf('<div class="print__r"><pre>%s</pre></div>', |
|
73 | - htmlspecialchars(print_r(func_get_arg(0), true), ENT_QUOTES, 'UTF-8') |
|
74 | - ); |
|
75 | - } elseif ($args > 1) { |
|
76 | - echo '<div class="print__r_group">'; |
|
77 | - foreach (func_get_args() as $value) { |
|
78 | - $this->printF($value); |
|
79 | - } |
|
80 | - echo '</div>'; |
|
81 | - } |
|
82 | - } |
|
71 | + if (1 == $args) { |
|
72 | + printf('<div class="print__r"><pre>%s</pre></div>', |
|
73 | + htmlspecialchars(print_r(func_get_arg(0), true), ENT_QUOTES, 'UTF-8') |
|
74 | + ); |
|
75 | + } elseif ($args > 1) { |
|
76 | + echo '<div class="print__r_group">'; |
|
77 | + foreach (func_get_args() as $value) { |
|
78 | + $this->printF($value); |
|
79 | + } |
|
80 | + echo '</div>'; |
|
81 | + } |
|
82 | + } |
|
83 | 83 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | protected $utility; |
10 | 10 | |
11 | - public function __construct(Utility $utility) |
|
11 | + public function __construct( Utility $utility ) |
|
12 | 12 | { |
13 | 13 | $this->utility = $utility; |
14 | 14 | } |
@@ -16,23 +16,23 @@ discard block |
||
16 | 16 | public function capture() |
17 | 17 | { |
18 | 18 | ob_start(); |
19 | - call_user_func_array([$this, 'printF'], func_get_args()); |
|
19 | + call_user_func_array( [$this, 'printF'], func_get_args() ); |
|
20 | 20 | return ob_get_clean(); |
21 | 21 | } |
22 | 22 | |
23 | - public function className($override = 'dev') |
|
23 | + public function className( $override = 'dev' ) |
|
24 | 24 | { |
25 | 25 | return $this->isDev() ? $override : ''; |
26 | 26 | } |
27 | 27 | |
28 | 28 | public function debug() |
29 | 29 | { |
30 | - call_user_func_array([$this, 'printF'], func_get_args()); |
|
30 | + call_user_func_array( [$this, 'printF'], func_get_args() ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function isDev() |
34 | 34 | { |
35 | - return defined('DEV') && (bool) DEV && WP_ENV == 'development'; |
|
35 | + return defined( 'DEV' ) && (bool) DEV && WP_ENV == 'development'; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function isProduction() |
@@ -40,27 +40,27 @@ discard block |
||
40 | 40 | return WP_ENV == 'production'; |
41 | 41 | } |
42 | 42 | |
43 | - public function printFiltersFor($hook = '') |
|
43 | + public function printFiltersFor( $hook = '' ) |
|
44 | 44 | { |
45 | 45 | global $wp_filter; |
46 | - if (empty($hook) || !isset($wp_filter[$hook])) { |
|
46 | + if( empty( $hook ) || !isset( $wp_filter[$hook] ) ) { |
|
47 | 47 | return; |
48 | 48 | } |
49 | - $this->printF($wp_filter[$hook]); |
|
49 | + $this->printF( $wp_filter[$hook] ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public function printTemplatePaths() |
53 | 53 | { |
54 | - $templates = array_map(function ($key, $value) { |
|
55 | - return sprintf('[%s] => %s', $key, $value); |
|
56 | - }, array_keys($this->templatePaths), $this->templatePaths); |
|
57 | - $this->printF(implode("\n", $templates)); |
|
54 | + $templates = array_map( function( $key, $value ) { |
|
55 | + return sprintf( '[%s] => %s', $key, $value ); |
|
56 | + }, array_keys( $this->templatePaths ), $this->templatePaths ); |
|
57 | + $this->printF( implode( "\n", $templates ) ); |
|
58 | 58 | } |
59 | 59 | |
60 | - public function storeTemplatePath($template) |
|
60 | + public function storeTemplatePath( $template ) |
|
61 | 61 | { |
62 | - if (is_string($template)) { |
|
63 | - $this->templatePaths[] = $this->utility->trimLeft($template, trailingslashit(WP_CONTENT_DIR)); |
|
62 | + if( is_string( $template ) ) { |
|
63 | + $this->templatePaths[] = $this->utility->trimLeft( $template, trailingslashit( WP_CONTENT_DIR ) ); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | { |
69 | 69 | $args = func_num_args(); |
70 | 70 | |
71 | - if (1 == $args) { |
|
72 | - printf('<div class="print__r"><pre>%s</pre></div>', |
|
73 | - htmlspecialchars(print_r(func_get_arg(0), true), ENT_QUOTES, 'UTF-8') |
|
71 | + if( 1 == $args ) { |
|
72 | + printf( '<div class="print__r"><pre>%s</pre></div>', |
|
73 | + htmlspecialchars( print_r( func_get_arg( 0 ), true ), ENT_QUOTES, 'UTF-8' ) |
|
74 | 74 | ); |
75 | - } elseif ($args > 1) { |
|
75 | + } elseif( $args > 1 ) { |
|
76 | 76 | echo '<div class="print__r_group">'; |
77 | - foreach (func_get_args() as $value) { |
|
78 | - $this->printF($value); |
|
77 | + foreach( func_get_args() as $value ) { |
|
78 | + $this->printF( $value ); |
|
79 | 79 | } |
80 | 80 | echo '</div>'; |
81 | 81 | } |
@@ -2,8 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace GeminiLabs\Castor\Helpers; |
4 | 4 | |
5 | -class Development |
|
6 | -{ |
|
5 | +class Development { |
|
7 | 6 | public $templatePaths = []; |
8 | 7 | |
9 | 8 | protected $utility; |
@@ -72,7 +71,8 @@ discard block |
||
72 | 71 | printf('<div class="print__r"><pre>%s</pre></div>', |
73 | 72 | htmlspecialchars(print_r(func_get_arg(0), true), ENT_QUOTES, 'UTF-8') |
74 | 73 | ); |
75 | - } elseif ($args > 1) { |
|
74 | + } |
|
75 | + elseif ($args > 1) { |
|
76 | 76 | echo '<div class="print__r_group">'; |
77 | 77 | foreach (func_get_args() as $value) { |
78 | 78 | $this->printF($value); |