@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | protected $args; |
20 | 20 | |
21 | - public function __construct( Image $image, PostMeta $postmeta, Theme $theme, Utility $utility ) |
|
21 | + public function __construct(Image $image, PostMeta $postmeta, Theme $theme, Utility $utility) |
|
22 | 22 | { |
23 | 23 | $this->image = $image; |
24 | 24 | $this->postmeta = $postmeta; |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @return WP_Query |
31 | 31 | */ |
32 | - public function query( array $args = [] ) |
|
32 | + public function query(array $args = []) |
|
33 | 33 | { |
34 | - $this->normalizeArgs( $args ); |
|
34 | + $this->normalizeArgs($args); |
|
35 | 35 | |
36 | 36 | return new WP_Query([ |
37 | 37 | 'orderby' => 'post__in', |
@@ -47,21 +47,21 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * @return string |
49 | 49 | */ |
50 | - public function render( WP_Query $gallery ) |
|
50 | + public function render(WP_Query $gallery) |
|
51 | 51 | { |
52 | - $images = array_reduce( $gallery->posts, function( $images, $attachment ) { |
|
53 | - return $images . $this->renderImage( $attachment ); |
|
52 | + $images = array_reduce($gallery->posts, function($images, $attachment) { |
|
53 | + return $images . $this->renderImage($attachment); |
|
54 | 54 | }); |
55 | - return sprintf( '<div class="gallery-images" itemscope itemtype="http://schema.org/ImageGallery">%s</div>', $images ); |
|
55 | + return sprintf('<div class="gallery-images" itemscope itemtype="http://schema.org/ImageGallery">%s</div>', $images); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @return null|string |
60 | 60 | */ |
61 | - public function renderImage( WP_Post $attachment ) |
|
61 | + public function renderImage(WP_Post $attachment) |
|
62 | 62 | { |
63 | - $image = $this->image->get( $attachment->ID ); |
|
64 | - if( !$image )return; |
|
63 | + $image = $this->image->get($attachment->ID); |
|
64 | + if (!$image)return; |
|
65 | 65 | return sprintf( |
66 | 66 | '<figure class="gallery-image" data-w="%s" data-h="%s" data-ps=\'%s\' itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">' . |
67 | 67 | '%s<figcaption itemprop="caption description">' . |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | '</figure>', |
71 | 71 | $image->thumbnail['width'], |
72 | 72 | $image->thumbnail['height'], |
73 | - $this->getPhotoswipeData( $image ), |
|
74 | - $this->renderImageTag( $image ), |
|
73 | + $this->getPhotoswipeData($image), |
|
74 | + $this->renderImageTag($image), |
|
75 | 75 | $image->caption, |
76 | 76 | $image->copyright |
77 | 77 | ); |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * @return null|string |
82 | 82 | */ |
83 | - public function renderPagination( WP_Query $query ) |
|
83 | + public function renderPagination(WP_Query $query) |
|
84 | 84 | { |
85 | - if( !$this->args['pagination'] )return; |
|
85 | + if (!$this->args['pagination'])return; |
|
86 | 86 | return paginate_links([ |
87 | - 'before_page_number' => '<span class="screen-reader-text">' . __( 'Page', 'castor' ) . ' </span>', |
|
87 | + 'before_page_number' => '<span class="screen-reader-text">' . __('Page', 'castor') . ' </span>', |
|
88 | 88 | 'current' => $query->query['paged'], |
89 | 89 | 'mid_size' => 1, |
90 | - 'next_text' => __( 'Next', 'castor' ), |
|
91 | - 'prev_text' => __( 'Previous', 'castor' ), |
|
90 | + 'next_text' => __('Next', 'castor'), |
|
91 | + 'prev_text' => __('Previous', 'castor'), |
|
92 | 92 | 'total' => $query->max_num_pages, |
93 | 93 | ]); |
94 | 94 | } |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return bool |
101 | 101 | */ |
102 | - protected function getBoolValue( $key, $value = null ) |
|
102 | + protected function getBoolValue($key, $value = null) |
|
103 | 103 | { |
104 | - $bool = $this->getValue( $key, $value ); |
|
104 | + $bool = $this->getValue($key, $value); |
|
105 | 105 | |
106 | - if( is_null( filter_var( $bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ))) { |
|
107 | - $bool = $this->postmeta->get( $bool ); |
|
106 | + if (is_null(filter_var($bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE))) { |
|
107 | + $bool = $this->postmeta->get($bool); |
|
108 | 108 | } |
109 | - return wp_validate_boolean( $bool ); |
|
109 | + return wp_validate_boolean($bool); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return int |
116 | 116 | */ |
117 | - protected function getGalleryArg( $value = null ) |
|
117 | + protected function getGalleryArg($value = null) |
|
118 | 118 | { |
119 | - $gallery = $this->getValue( 'gallery', $value ); |
|
119 | + $gallery = $this->getValue('gallery', $value); |
|
120 | 120 | |
121 | - if( !is_numeric( $gallery ) && is_string( $gallery )) { |
|
122 | - $gallery = intval( $this->postmeta->get( $gallery )); |
|
121 | + if (!is_numeric($gallery) && is_string($gallery)) { |
|
122 | + $gallery = intval($this->postmeta->get($gallery)); |
|
123 | 123 | } |
124 | - return !is_null( get_post( $gallery )) |
|
125 | - ? intval( $gallery ) |
|
124 | + return !is_null(get_post($gallery)) |
|
125 | + ? intval($gallery) |
|
126 | 126 | : 0; |
127 | 127 | } |
128 | 128 | |
@@ -131,14 +131,14 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return int |
133 | 133 | */ |
134 | - protected function getImagesPerPageArg( $value = null ) |
|
134 | + protected function getImagesPerPageArg($value = null) |
|
135 | 135 | { |
136 | - $perPage = $this->getValue( 'images_per_page', $value ); |
|
136 | + $perPage = $this->getValue('images_per_page', $value); |
|
137 | 137 | |
138 | - if( !is_numeric( $perPage ) && is_string( $perPage )) { |
|
139 | - $perPage = $this->postmeta->get( $perPage ); |
|
138 | + if (!is_numeric($perPage) && is_string($perPage)) { |
|
139 | + $perPage = $this->postmeta->get($perPage); |
|
140 | 140 | } |
141 | - return !!intval( $perPage ) |
|
141 | + return !!intval($perPage) |
|
142 | 142 | ? $perPage |
143 | 143 | : -1; |
144 | 144 | } |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return bool |
150 | 150 | */ |
151 | - protected function getLazyloadArg( $value = null ) |
|
151 | + protected function getLazyloadArg($value = null) |
|
152 | 152 | { |
153 | - return $this->getBoolValue( 'lazyload', $value ); |
|
153 | + return $this->getBoolValue('lazyload', $value); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -158,18 +158,18 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @return array |
160 | 160 | */ |
161 | - protected function getMediaArg( $value = null ) |
|
161 | + protected function getMediaArg($value = null) |
|
162 | 162 | { |
163 | - $media = $this->getValue( 'media', $value ); |
|
163 | + $media = $this->getValue('media', $value); |
|
164 | 164 | |
165 | - if( is_string( $media )) { |
|
166 | - $media = $this->postmeta->get( $media, [ |
|
165 | + if (is_string($media)) { |
|
166 | + $media = $this->postmeta->get($media, [ |
|
167 | 167 | 'ID' => $this->getGalleryArg(), |
168 | 168 | 'single' => false, |
169 | 169 | ]); |
170 | 170 | } |
171 | - return is_array( $media ) |
|
172 | - ? wp_parse_id_list( $media ) |
|
171 | + return is_array($media) |
|
172 | + ? wp_parse_id_list($media) |
|
173 | 173 | : []; |
174 | 174 | } |
175 | 175 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | protected function getPaged() |
180 | 180 | { |
181 | - return intval( get_query_var(( is_front_page() ? 'page' : 'paged' ))) ?: 1; |
|
181 | + return intval(get_query_var((is_front_page() ? 'page' : 'paged'))) ?: 1; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return bool |
188 | 188 | */ |
189 | - protected function getPaginationArg( $value = null ) |
|
189 | + protected function getPaginationArg($value = null) |
|
190 | 190 | { |
191 | - return $this->getBoolValue( 'pagination', $value ); |
|
191 | + return $this->getBoolValue('pagination', $value); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -196,17 +196,17 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return bool |
198 | 198 | */ |
199 | - protected function getPermalinksArg( $value = null ) |
|
199 | + protected function getPermalinksArg($value = null) |
|
200 | 200 | { |
201 | - return $this->getBoolValue( 'permalinks', $value ); |
|
201 | + return $this->getBoolValue('permalinks', $value); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
205 | 205 | * @return string |
206 | 206 | */ |
207 | - protected function getPhotoswipeData( $image ) |
|
207 | + protected function getPhotoswipeData($image) |
|
208 | 208 | { |
209 | - return sprintf( '{"l":{"src":"%s","w":%d,"h":%d},"m":{"src":"%s","w":%d,"h":%d}}', |
|
209 | + return sprintf('{"l":{"src":"%s","w":%d,"h":%d},"m":{"src":"%s","w":%d,"h":%d}}', |
|
210 | 210 | $image->large['url'], |
211 | 211 | $image->large['width'], |
212 | 212 | $image->large['height'], |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return mixed |
224 | 224 | */ |
225 | - protected function getValue( $key, $value = null ) |
|
225 | + protected function getValue($key, $value = null) |
|
226 | 226 | { |
227 | - if( is_null( $value ) && isset( $this->args[$key] )) { |
|
227 | + if (is_null($value) && isset($this->args[$key])) { |
|
228 | 228 | $value = $this->args[$key]; |
229 | 229 | } |
230 | 230 | return $value; |
@@ -233,23 +233,23 @@ discard block |
||
233 | 233 | /** |
234 | 234 | * @return array |
235 | 235 | */ |
236 | - protected function normalizeArgs( array $args = [] ) |
|
236 | + protected function normalizeArgs(array $args = []) |
|
237 | 237 | { |
238 | 238 | $defaults = [ |
239 | - 'gallery', // (string) meta_key | (int) post_id |
|
240 | - 'lazyload', // (string) meta_key | (bool) |
|
241 | - 'media', // (string) meta_key | (array) post_ids |
|
242 | - 'pagination', // (string) meta_key | (bool) |
|
239 | + 'gallery', // (string) meta_key | (int) post_id |
|
240 | + 'lazyload', // (string) meta_key | (bool) |
|
241 | + 'media', // (string) meta_key | (array) post_ids |
|
242 | + 'pagination', // (string) meta_key | (bool) |
|
243 | 243 | 'images_per_page', // (string) meta_key | (int) number |
244 | - 'permalinks', // (string) meta_key | (bool) |
|
244 | + 'permalinks', // (string) meta_key | (bool) |
|
245 | 245 | ]; |
246 | 246 | |
247 | - $this->args = shortcode_atts( array_combine( $defaults, $defaults ), $args ); |
|
247 | + $this->args = shortcode_atts(array_combine($defaults, $defaults), $args); |
|
248 | 248 | |
249 | - array_walk( $this->args, function( &$value, $key ) { |
|
250 | - $method = $this->utility->buildMethodName( $key . '_arg' ); |
|
251 | - if( method_exists( $this, $method )) { |
|
252 | - $value = call_user_func([ $this, $method ], $value ); |
|
249 | + array_walk($this->args, function(&$value, $key) { |
|
250 | + $method = $this->utility->buildMethodName($key . '_arg'); |
|
251 | + if (method_exists($this, $method)) { |
|
252 | + $value = call_user_func([$this, $method], $value); |
|
253 | 253 | } |
254 | 254 | }); |
255 | 255 | |
@@ -261,20 +261,20 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return null|string |
263 | 263 | */ |
264 | - protected function renderImageTag( $image ) |
|
264 | + protected function renderImageTag($image) |
|
265 | 265 | { |
266 | 266 | $imgSrc = $this->getLazyloadArg() |
267 | - ? $this->theme->imageUri( 'blank.gif' ) |
|
267 | + ? $this->theme->imageUri('blank.gif') |
|
268 | 268 | : $image->thumbnail['url']; |
269 | 269 | |
270 | - $imgTag = sprintf( '<img src="%s" data-src="%s" itemprop="thumbnail" alt="%s"/>', |
|
270 | + $imgTag = sprintf('<img src="%s" data-src="%s" itemprop="thumbnail" alt="%s"/>', |
|
271 | 271 | $imgSrc, |
272 | 272 | $image->thumbnail['url'], |
273 | 273 | $image->alt |
274 | 274 | ); |
275 | 275 | |
276 | 276 | return $this->getPermalinksArg() |
277 | - ? sprintf( '<a href="%s" itemprop="contentUrl">%s</a>', $image->permalink, $imgTag ) |
|
277 | + ? sprintf('<a href="%s" itemprop="contentUrl">%s</a>', $image->permalink, $imgTag) |
|
278 | 278 | : $imgTag; |
279 | 279 | } |
280 | 280 | } |
@@ -22,65 +22,65 @@ |
||
22 | 22 | 'width', |
23 | 23 | ]; |
24 | 24 | |
25 | - public function __construct( Utility $utility ) |
|
25 | + public function __construct(Utility $utility) |
|
26 | 26 | { |
27 | 27 | $this->oembed = _wp_oembed_get_object(); |
28 | 28 | $this->utility = $utility; |
29 | 29 | } |
30 | 30 | |
31 | - public function request( $url, $args = '' ) |
|
31 | + public function request($url, $args = '') |
|
32 | 32 | { |
33 | - $request = $this->oembed->fetch( $this->oembed->get_provider( $url ), $url, [ |
|
33 | + $request = $this->oembed->fetch($this->oembed->get_provider($url), $url, [ |
|
34 | 34 | 'width' => 1280, |
35 | 35 | 'height' => 1280, |
36 | 36 | ]); |
37 | 37 | return $request |
38 | - ? $this->modifyRequest( $request, $args ) |
|
38 | + ? $this->modifyRequest($request, $args) |
|
39 | 39 | : $request; |
40 | 40 | } |
41 | 41 | |
42 | - protected function domLoad( $html ) |
|
42 | + protected function domLoad($html) |
|
43 | 43 | { |
44 | 44 | $dom = new DomDocument; |
45 | - $dom->loadHTML( $html ); |
|
45 | + $dom->loadHTML($html); |
|
46 | 46 | return $dom; |
47 | 47 | } |
48 | 48 | |
49 | - protected function modifyRequest( $request, $args ) |
|
49 | + protected function modifyRequest($request, $args) |
|
50 | 50 | { |
51 | - $providerName = strtolower( $request->provider_name ); |
|
52 | - $provider = property_exists( $this, $providerName ) |
|
51 | + $providerName = strtolower($request->provider_name); |
|
52 | + $provider = property_exists($this, $providerName) |
|
53 | 53 | ? $this->$providerName |
54 | 54 | : []; |
55 | 55 | |
56 | - $method = $this->utility->buildMethodName( $providerName . '_request', 'modify' ); |
|
56 | + $method = $this->utility->buildMethodName($providerName . '_request', 'modify'); |
|
57 | 57 | |
58 | - if( method_exists( $this, $method )) { |
|
59 | - return call_user_func( [$this, $method], $request, array_intersect_key( |
|
60 | - wp_parse_args( $args ), |
|
61 | - array_flip( $provider ) |
|
58 | + if (method_exists($this, $method)) { |
|
59 | + return call_user_func([$this, $method], $request, array_intersect_key( |
|
60 | + wp_parse_args($args), |
|
61 | + array_flip($provider) |
|
62 | 62 | )); |
63 | 63 | } |
64 | 64 | return $request; |
65 | 65 | } |
66 | 66 | |
67 | - protected function modifyYoutubeRequest( $request, array $args ) |
|
67 | + protected function modifyYoutubeRequest($request, array $args) |
|
68 | 68 | { |
69 | - $html = $this->domLoad( $request->html ); |
|
70 | - $node = $html->getElementsByTagName( 'iframe' )->item(0); |
|
71 | - $url = $node->getAttribute( 'src' ); |
|
69 | + $html = $this->domLoad($request->html); |
|
70 | + $node = $html->getElementsByTagName('iframe')->item(0); |
|
71 | + $url = $node->getAttribute('src'); |
|
72 | 72 | |
73 | - if( isset( $args['fs'] ) && $args['fs'] == 0 ) { |
|
74 | - $node->removeAttribute( 'allowfullscreen' ); |
|
73 | + if (isset($args['fs']) && $args['fs'] == 0) { |
|
74 | + $node->removeAttribute('allowfullscreen'); |
|
75 | 75 | } |
76 | 76 | |
77 | - $args['origin'] = urlencode( get_bloginfo( 'url' )); |
|
77 | + $args['origin'] = urlencode(get_bloginfo('url')); |
|
78 | 78 | |
79 | - $node->setAttribute( 'src', |
|
80 | - add_query_arg( $args, remove_query_arg( 'feature', $url )) |
|
79 | + $node->setAttribute('src', |
|
80 | + add_query_arg($args, remove_query_arg('feature', $url)) |
|
81 | 81 | ); |
82 | 82 | |
83 | - $request->html = $html->saveHTML( $node ); |
|
83 | + $request->html = $html->saveHTML($node); |
|
84 | 84 | |
85 | 85 | return $request; |
86 | 86 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | public $image; |
13 | 13 | public $video; |
14 | 14 | |
15 | - public function __construct( Gallery $gallery, Image $image, Video $video ) |
|
15 | + public function __construct(Gallery $gallery, Image $image, Video $video) |
|
16 | 16 | { |
17 | 17 | $this->gallery = $gallery; |
18 | 18 | $this->image = $image; |
@@ -22,31 +22,31 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @return void|string |
24 | 24 | */ |
25 | - public function gallery( array $args = [] ) |
|
25 | + public function gallery(array $args = []) |
|
26 | 26 | { |
27 | - $gallery = $this->gallery->query( $args ); |
|
27 | + $gallery = $this->gallery->query($args); |
|
28 | 28 | |
29 | - if( $gallery->have_posts() ) { |
|
30 | - return $this->gallery->render( $gallery ) . $this->gallery->renderPagination( $gallery ); |
|
29 | + if ($gallery->have_posts()) { |
|
30 | + return $this->gallery->render($gallery) . $this->gallery->renderPagination($gallery); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @return WP_Query |
36 | 36 | */ |
37 | - public function getGalleryQuery( array $args = [] ) |
|
37 | + public function getGalleryQuery(array $args = []) |
|
38 | 38 | { |
39 | - return $this->gallery->query( $args ); |
|
39 | + return $this->gallery->query($args); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @return void|string |
44 | 44 | */ |
45 | - public function video( $args = [] ) |
|
45 | + public function video($args = []) |
|
46 | 46 | { |
47 | - if( is_string( $args )) { |
|
47 | + if (is_string($args)) { |
|
48 | 48 | $args = ['url' => $args]; |
49 | 49 | } |
50 | - return $this->video->get( $args )->render(); |
|
50 | + return $this->video->get($args)->render(); |
|
51 | 51 | } |
52 | 52 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | { |
9 | 9 | public $postmeta; |
10 | 10 | |
11 | - public function __construct( PostMeta $postmeta ) |
|
11 | + public function __construct(PostMeta $postmeta) |
|
12 | 12 | { |
13 | 13 | $this->postmeta = $postmeta; |
14 | 14 | } |
@@ -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 | /** |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | is_single(), |
45 | 45 | ]; |
46 | 46 | |
47 | - $display = in_array( true, $conditions ); |
|
47 | + $display = in_array(true, $conditions); |
|
48 | 48 | |
49 | - return apply_filters( 'castor/display/sidebar', $display ); |
|
49 | + return apply_filters('castor/display/sidebar', $display); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return string |
56 | 56 | */ |
57 | - public function imagePath( $asset ) |
|
57 | + public function imagePath($asset) |
|
58 | 58 | { |
59 | - return $this->paths( 'dir.stylesheet' ) . 'assets/img/' . $asset; |
|
59 | + return $this->paths('dir.stylesheet') . 'assets/img/' . $asset; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -64,16 +64,16 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string |
66 | 66 | */ |
67 | - public function imageUri( $asset ) |
|
67 | + public function imageUri($asset) |
|
68 | 68 | { |
69 | - return $this->paths( 'uri.stylesheet' ) . 'assets/img/' . $asset; |
|
69 | + return $this->paths('uri.stylesheet') . 'assets/img/' . $asset; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | public function pageTitle() |
73 | 73 | { |
74 | - foreach( ['is_404', 'is_archive', 'is_home', 'is_page', 'is_search'] as $bool ) { |
|
75 | - if( !$bool() )continue; |
|
76 | - $method = sprintf( 'get%sTitle', ucfirst( str_replace( 'is_', '', $bool ))); |
|
74 | + foreach (['is_404', 'is_archive', 'is_home', 'is_page', 'is_search'] as $bool) { |
|
75 | + if (!$bool())continue; |
|
76 | + $method = sprintf('get%sTitle', ucfirst(str_replace('is_', '', $bool))); |
|
77 | 77 | return $this->$method(); |
78 | 78 | } |
79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return array|string |
87 | 87 | */ |
88 | - public function paths( $path = null ) |
|
88 | + public function paths($path = null) |
|
89 | 89 | { |
90 | 90 | $paths = [ |
91 | 91 | 'dir.stylesheet' => get_stylesheet_directory(), |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | 'uri.template' => get_template_directory_uri(), |
96 | 96 | ]; |
97 | 97 | |
98 | - if( is_null( $path )) { |
|
98 | + if (is_null($path)) { |
|
99 | 99 | return $paths; |
100 | 100 | } |
101 | 101 | |
102 | - return array_key_exists( $path, $paths ) |
|
103 | - ? trailingslashit( $paths[$path] ) |
|
102 | + return array_key_exists($path, $paths) |
|
103 | + ? trailingslashit($paths[$path]) |
|
104 | 104 | : ''; |
105 | 105 | } |
106 | 106 | |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return string|null |
111 | 111 | */ |
112 | - public function svg( $path = null ) |
|
112 | + public function svg($path = null) |
|
113 | 113 | { |
114 | - if( $svg = file_get_contents( $this->imageUri( $path ))) { |
|
114 | + if ($svg = file_get_contents($this->imageUri($path))) { |
|
115 | 115 | return $svg; |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | 119 | protected function get404Title() |
120 | 120 | { |
121 | - return __( 'Not Found', 'castor' ); |
|
121 | + return __('Not Found', 'castor'); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | protected function getArchiveTitle() |
@@ -128,20 +128,20 @@ discard block |
||
128 | 128 | |
129 | 129 | protected function getHomeTitle() |
130 | 130 | { |
131 | - return ( $home = get_option( 'page_for_posts', true )) |
|
132 | - ? get_the_title( $home ) |
|
133 | - : __( 'Latest Posts', 'castor' ); |
|
131 | + return ($home = get_option('page_for_posts', true)) |
|
132 | + ? get_the_title($home) |
|
133 | + : __('Latest Posts', 'castor'); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | protected function getPageTitle() |
137 | 137 | { |
138 | - return ($title = $this->postmeta->get( 'title' )) |
|
138 | + return ($title = $this->postmeta->get('title')) |
|
139 | 139 | ? $title |
140 | 140 | : get_the_title(); |
141 | 141 | } |
142 | 142 | |
143 | 143 | protected function getSearchTitle() |
144 | 144 | { |
145 | - return sprintf( __( 'Search Results for %s', 'castor' ), get_search_query() ); |
|
145 | + return sprintf(__('Search Results for %s', 'castor'), get_search_query()); |
|
146 | 146 | } |
147 | 147 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | public $theme; |
15 | 15 | public $utility; |
16 | 16 | |
17 | - public function __construct( Media $media, PostMeta $postmeta, Theme $theme, Utility $utility ) |
|
17 | + public function __construct(Media $media, PostMeta $postmeta, Theme $theme, Utility $utility) |
|
18 | 18 | { |
19 | 19 | $this->media = $media; |
20 | 20 | $this->postmeta = $postmeta; |
@@ -22,58 +22,58 @@ discard block |
||
22 | 22 | $this->utility = $utility; |
23 | 23 | } |
24 | 24 | |
25 | - public function blockquote( $metaKey = false, array $attributes = [] ) |
|
25 | + public function blockquote($metaKey = false, array $attributes = []) |
|
26 | 26 | { |
27 | - if( $value = $this->postmeta->get( $metaKey )) { |
|
28 | - $this->utility->printTag( 'blockquote', wp_strip_all_tags( $value ), $attributes ); |
|
27 | + if ($value = $this->postmeta->get($metaKey)) { |
|
28 | + $this->utility->printTag('blockquote', wp_strip_all_tags($value), $attributes); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | - public function button( $postId = 0, $title = false ) |
|
32 | + public function button($postId = 0, $title = false) |
|
33 | 33 | { |
34 | - $post = get_post( $postId ); |
|
34 | + $post = get_post($postId); |
|
35 | 35 | |
36 | - if( !$postId || !$post )return; |
|
37 | - if( !$title ) { |
|
36 | + if (!$postId || !$post)return; |
|
37 | + if (!$title) { |
|
38 | 38 | $title = $post->post_title; |
39 | 39 | } |
40 | - printf( '<a href="%s" class="button"><span>%s</span></a>', |
|
41 | - get_permalink( $post->ID ), |
|
40 | + printf('<a href="%s" class="button"><span>%s</span></a>', |
|
41 | + get_permalink($post->ID), |
|
42 | 42 | $title |
43 | 43 | ); |
44 | 44 | } |
45 | 45 | |
46 | - public function buttons( $postIds = [] ) |
|
46 | + public function buttons($postIds = []) |
|
47 | 47 | { |
48 | - foreach( (array) $postIds as $postId ) { |
|
49 | - $this->button( $postId ); |
|
48 | + foreach ((array) $postIds as $postId) { |
|
49 | + $this->button($postId); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | - public function content( $metaKey = false ) |
|
53 | + public function content($metaKey = false) |
|
54 | 54 | { |
55 | 55 | $content = $metaKey |
56 | - ? $this->postmeta->get( $metaKey ) |
|
56 | + ? $this->postmeta->get($metaKey) |
|
57 | 57 | : get_the_content(); |
58 | 58 | |
59 | - echo str_replace( ']]>', ']]>', apply_filters( 'the_content', $content )); |
|
59 | + echo str_replace(']]>', ']]>', apply_filters('the_content', $content)); |
|
60 | 60 | } |
61 | 61 | |
62 | - public function gallery( array $args = [] ) |
|
62 | + public function gallery(array $args = []) |
|
63 | 63 | { |
64 | - echo $this->media->gallery( $args ); |
|
64 | + echo $this->media->gallery($args); |
|
65 | 65 | } |
66 | 66 | |
67 | - public function title( $metaKey = false, array $attributes = [] ) |
|
67 | + public function title($metaKey = false, array $attributes = []) |
|
68 | 68 | { |
69 | - $tag = apply_filters( 'castor/render/title/tag', 'h2' ); |
|
69 | + $tag = apply_filters('castor/render/title/tag', 'h2'); |
|
70 | 70 | $value = $metaKey |
71 | - ? $this->postmeta->get( $metaKey ) |
|
71 | + ? $this->postmeta->get($metaKey) |
|
72 | 72 | : $this->theme->pageTitle(); |
73 | 73 | |
74 | - if( !$value )return; |
|
74 | + if (!$value)return; |
|
75 | 75 | |
76 | - $this->utility->printTag( $tag, wp_strip_all_tags( $value ), $attributes ); |
|
76 | + $this->utility->printTag($tag, wp_strip_all_tags($value), $attributes); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return string|null |
83 | 83 | */ |
84 | - public function video( $args ) |
|
84 | + public function video($args) |
|
85 | 85 | { |
86 | - echo $this->media->video( $args ); |
|
86 | + echo $this->media->video($args); |
|
87 | 87 | } |
88 | 88 | } |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | { |
34 | 34 | $post = get_post( $postId ); |
35 | 35 | |
36 | - if( !$postId || !$post )return; |
|
36 | + if( !$postId || !$post ) { |
|
37 | + return; |
|
38 | + } |
|
37 | 39 | if( !$title ) { |
38 | 40 | $title = $post->post_title; |
39 | 41 | } |
@@ -71,7 +73,9 @@ discard block |
||
71 | 73 | ? $this->postmeta->get( $metaKey ) |
72 | 74 | : $this->theme->pageTitle(); |
73 | 75 | |
74 | - if( !$value )return; |
|
76 | + if( !$value ) { |
|
77 | + return; |
|
78 | + } |
|
75 | 79 | |
76 | 80 | $this->utility->printTag( $tag, wp_strip_all_tags( $value ), $attributes ); |
77 | 81 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | protected $args; |
20 | 20 | protected $video; |
21 | 21 | |
22 | - public function __construct( Image $image, Oembed $oembed, PostMeta $postmeta, Theme $theme, Utility $utility ) |
|
22 | + public function __construct(Image $image, Oembed $oembed, PostMeta $postmeta, Theme $theme, Utility $utility) |
|
23 | 23 | { |
24 | 24 | $this->image = $image; |
25 | 25 | $this->oembed = $oembed; |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | $this->utility = $utility; |
29 | 29 | } |
30 | 30 | |
31 | - public function get( array $args = [] ) |
|
31 | + public function get(array $args = []) |
|
32 | 32 | { |
33 | - $args = $this->normalize( $args ); |
|
34 | - $this->video = $this->oembed->request( $args['url'], $args['player'] ); |
|
33 | + $args = $this->normalize($args); |
|
34 | + $this->video = $this->oembed->request($args['url'], $args['player']); |
|
35 | 35 | return $this; |
36 | 36 | } |
37 | 37 | |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | '<a href="%s" class="video-play-btn">%s</a>' . |
46 | 46 | '</div>', |
47 | 47 | $this->args['url'], |
48 | - $this->theme->svg( 'play.svg' ) |
|
48 | + $this->theme->svg('play.svg') |
|
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | 52 | public function renderScreenshot() |
53 | 53 | { |
54 | - if( !$this->args['image'] )return; |
|
55 | - return sprintf( '<div class="video-screenshot" style="background-image: url(%s)">%s</div>', |
|
54 | + if (!$this->args['image'])return; |
|
55 | + return sprintf('<div class="video-screenshot" style="background-image: url(%s)">%s</div>', |
|
56 | 56 | $this->args['image'], |
57 | 57 | $this->renderPlayButton() |
58 | 58 | ); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | public function render() |
62 | 62 | { |
63 | - if( !isset( $this->video->html ))return; |
|
63 | + if (!isset($this->video->html))return; |
|
64 | 64 | return sprintf( |
65 | 65 | '<div class="video embed">%s%s</div>', |
66 | 66 | $this->renderScreenshot(), |
@@ -68,33 +68,33 @@ discard block |
||
68 | 68 | ); |
69 | 69 | } |
70 | 70 | |
71 | - protected function setImage( $image ) |
|
71 | + protected function setImage($image) |
|
72 | 72 | { |
73 | - $image = $this->image->get( $image ); |
|
74 | - $this->args['image'] = isset( $image->large ) |
|
73 | + $image = $this->image->get($image); |
|
74 | + $this->args['image'] = isset($image->large) |
|
75 | 75 | ? $image->large['url'] |
76 | 76 | : null; |
77 | 77 | } |
78 | 78 | |
79 | - protected function setUrl( $url ) |
|
79 | + protected function setUrl($url) |
|
80 | 80 | { |
81 | - $this->args['url'] = !filter_var( $url, FILTER_VALIDATE_URL ) |
|
82 | - ? $this->postmeta->get( $url ) |
|
81 | + $this->args['url'] = !filter_var($url, FILTER_VALIDATE_URL) |
|
82 | + ? $this->postmeta->get($url) |
|
83 | 83 | : $url; |
84 | 84 | } |
85 | 85 | |
86 | - protected function normalize( array $args = [] ) |
|
86 | + protected function normalize(array $args = []) |
|
87 | 87 | { |
88 | 88 | $this->args = shortcode_atts([ |
89 | 89 | 'image' => '', // string || int |
90 | 90 | 'player' => '', // string || array |
91 | 91 | 'url' => '', // string |
92 | - ], $args ); |
|
92 | + ], $args); |
|
93 | 93 | |
94 | - foreach( $this->args as $key => $value ) { |
|
95 | - $method = $this->utility->buildMethodName( $key, 'set' ); |
|
96 | - if( !method_exists( $this, $method ))continue; |
|
97 | - call_user_func([ $this, $method ], $value ); |
|
94 | + foreach ($this->args as $key => $value) { |
|
95 | + $method = $this->utility->buildMethodName($key, 'set'); |
|
96 | + if (!method_exists($this, $method))continue; |
|
97 | + call_user_func([$this, $method], $value); |
|
98 | 98 | } |
99 | 99 | return $this->args; |
100 | 100 | } |
@@ -51,7 +51,9 @@ discard block |
||
51 | 51 | |
52 | 52 | public function renderScreenshot() |
53 | 53 | { |
54 | - if( !$this->args['image'] )return; |
|
54 | + if( !$this->args['image'] ) { |
|
55 | + return; |
|
56 | + } |
|
55 | 57 | return sprintf( '<div class="video-screenshot" style="background-image: url(%s)">%s</div>', |
56 | 58 | $this->args['image'], |
57 | 59 | $this->renderPlayButton() |
@@ -60,7 +62,9 @@ discard block |
||
60 | 62 | |
61 | 63 | public function render() |
62 | 64 | { |
63 | - if( !isset( $this->video->html ))return; |
|
65 | + if( !isset( $this->video->html )) { |
|
66 | + return; |
|
67 | + } |
|
64 | 68 | return sprintf( |
65 | 69 | '<div class="video embed">%s%s</div>', |
66 | 70 | $this->renderScreenshot(), |
@@ -93,7 +97,9 @@ discard block |
||
93 | 97 | |
94 | 98 | foreach( $this->args as $key => $value ) { |
95 | 99 | $method = $this->utility->buildMethodName( $key, 'set' ); |
96 | - if( !method_exists( $this, $method ))continue; |
|
100 | + if( !method_exists( $this, $method )) { |
|
101 | + continue; |
|
102 | + } |
|
97 | 103 | call_user_func([ $this, $method ], $value ); |
98 | 104 | } |
99 | 105 | return $this->args; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | public $postmeta; |
11 | 11 | public $utility; |
12 | 12 | |
13 | - public function __construct( PostMeta $postmeta, Utility $utility ) |
|
13 | + public function __construct(PostMeta $postmeta, Utility $utility) |
|
14 | 14 | { |
15 | 15 | $this->postmeta = $postmeta; |
16 | 16 | $this->utility = $utility; |
@@ -21,25 +21,25 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return null|object |
23 | 23 | */ |
24 | - public function get( $attachment ) |
|
24 | + public function get($attachment) |
|
25 | 25 | { |
26 | - if( !filter_var( $attachment, FILTER_VALIDATE_INT )) { |
|
27 | - $attachment = $this->postmeta->get( $attachment ); |
|
26 | + if (!filter_var($attachment, FILTER_VALIDATE_INT)) { |
|
27 | + $attachment = $this->postmeta->get($attachment); |
|
28 | 28 | } |
29 | - if( !$attachment )return; |
|
29 | + if (!$attachment)return; |
|
30 | 30 | |
31 | - if( $thumbnail = wp_get_attachment_image_src( $attachment, 'thumbnail' )) { |
|
32 | - $medium = $this->normalizeSrc( wp_get_attachment_image_src( $attachment, 'medium' ), $thumbnail ); |
|
33 | - $large = $this->normalizeSrc( wp_get_attachment_image_src( $attachment, 'large' ), $medium ); |
|
31 | + if ($thumbnail = wp_get_attachment_image_src($attachment, 'thumbnail')) { |
|
32 | + $medium = $this->normalizeSrc(wp_get_attachment_image_src($attachment, 'medium'), $thumbnail); |
|
33 | + $large = $this->normalizeSrc(wp_get_attachment_image_src($attachment, 'large'), $medium); |
|
34 | 34 | |
35 | 35 | return (object) [ |
36 | - 'alt' => wp_strip_all_tags( get_post_meta( $attachment, '_wp_attachment_image_alt', true ), true ), |
|
37 | - 'caption' => wp_get_attachment_caption( $attachment ), |
|
38 | - 'copyright' => wp_strip_all_tags( get_post_meta( $attachment, '_copyright', true ), true ), |
|
36 | + 'alt' => wp_strip_all_tags(get_post_meta($attachment, '_wp_attachment_image_alt', true), true), |
|
37 | + 'caption' => wp_get_attachment_caption($attachment), |
|
38 | + 'copyright' => wp_strip_all_tags(get_post_meta($attachment, '_copyright', true), true), |
|
39 | 39 | 'large' => $large, |
40 | 40 | 'medium' => $medium, |
41 | - 'permalink' => get_attachment_link( $attachment ), |
|
42 | - 'thumbnail' => $this->normalizeSrc( $thumbnail ), |
|
41 | + 'permalink' => get_attachment_link($attachment), |
|
42 | + 'thumbnail' => $this->normalizeSrc($thumbnail), |
|
43 | 43 | ]; |
44 | 44 | } |
45 | 45 | } |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return array |
51 | 51 | */ |
52 | - protected function normalizeSrc( array $image, $fallback = false ) |
|
52 | + protected function normalizeSrc(array $image, $fallback = false) |
|
53 | 53 | { |
54 | - if( is_array( $fallback ) && count( array_diff( $image, $fallback )) < 2 ) { |
|
54 | + if (is_array($fallback) && count(array_diff($image, $fallback)) < 2) { |
|
55 | 55 | $image = $fallback; |
56 | 56 | } |
57 | 57 | return [ |
@@ -26,7 +26,9 @@ |
||
26 | 26 | if( !filter_var( $attachment, FILTER_VALIDATE_INT )) { |
27 | 27 | $attachment = $this->postmeta->get( $attachment ); |
28 | 28 | } |
29 | - if( !$attachment )return; |
|
29 | + if( !$attachment ) { |
|
30 | + return; |
|
31 | + } |
|
30 | 32 | |
31 | 33 | if( $thumbnail = wp_get_attachment_image_src( $attachment, 'thumbnail' )) { |
32 | 34 | $medium = $this->normalizeSrc( wp_get_attachment_image_src( $attachment, 'medium' ), $thumbnail ); |
@@ -1,27 +1,27 @@ |
||
1 | -<?php defined( 'WPINC' ) || die; |
|
1 | +<?php defined('WPINC') || die; |
|
2 | 2 | |
3 | 3 | global $wp_version; |
4 | 4 | |
5 | -if( version_compare( '5.6.0', phpversion(), '>=' )) { |
|
5 | +if (version_compare('5.6.0', phpversion(), '>=')) { |
|
6 | 6 | wp_die( |
7 | - __( 'You must be using PHP 5.6.0 or greater.', 'castor' ), |
|
8 | - __( 'Unsupported PHP version', 'castor' ) |
|
7 | + __('You must be using PHP 5.6.0 or greater.', 'castor'), |
|
8 | + __('Unsupported PHP version', 'castor') |
|
9 | 9 | ); |
10 | 10 | } |
11 | 11 | |
12 | -if( version_compare( '4.7.0', $wp_version, '>=' )) { |
|
12 | +if (version_compare('4.7.0', $wp_version, '>=')) { |
|
13 | 13 | wp_die( |
14 | - __( 'You must be using WordPress 4.7.0 or greater.', 'castor' ), |
|
15 | - __( 'Unsupported WordPress version', 'castor' ) |
|
14 | + __('You must be using WordPress 4.7.0 or greater.', 'castor'), |
|
15 | + __('Unsupported WordPress version', 'castor') |
|
16 | 16 | ); |
17 | 17 | } |
18 | 18 | |
19 | -if( is_customize_preview() && filter_input( INPUT_GET, 'theme' )) { |
|
19 | +if (is_customize_preview() && filter_input(INPUT_GET, 'theme')) { |
|
20 | 20 | wp_die( |
21 | - __( 'Theme must be activated prior to using the customizer.', 'castor' ) |
|
21 | + __('Theme must be activated prior to using the customizer.', 'castor') |
|
22 | 22 | ); |
23 | 23 | } |
24 | 24 | |
25 | -require_once( ABSPATH . '/' . WPINC . '/class-oembed.php' ); |
|
25 | +require_once(ABSPATH . '/' . WPINC . '/class-oembed.php'); |
|
26 | 26 | |
27 | 27 | \GeminiLabs\Castor\Application::getInstance()->init(); |