@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | { |
9 | 9 | public $utility; |
10 | 10 | |
11 | - public function __construct( Utility $utility ) |
|
11 | + public function __construct(Utility $utility) |
|
12 | 12 | { |
13 | 13 | $this->utility = $utility; |
14 | 14 | } |
@@ -18,23 +18,23 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return null|object |
20 | 20 | */ |
21 | - public function get( $attachmentId ) |
|
21 | + public function get($attachmentId) |
|
22 | 22 | { |
23 | - $thumbnail = wp_get_attachment_image_src( $attachmentId, 'thumbnail' ); |
|
23 | + $thumbnail = wp_get_attachment_image_src($attachmentId, 'thumbnail'); |
|
24 | 24 | |
25 | - if( !$thumbnail )return; |
|
25 | + if (!$thumbnail)return; |
|
26 | 26 | |
27 | - $medium = $this->normalizeSrc( wp_get_attachment_image_src( $attachmentId, 'medium' ), $thumbnail ); |
|
28 | - $large = $this->normalizeSrc( wp_get_attachment_image_src( $attachmentId, 'large' ), $medium ); |
|
27 | + $medium = $this->normalizeSrc(wp_get_attachment_image_src($attachmentId, 'medium'), $thumbnail); |
|
28 | + $large = $this->normalizeSrc(wp_get_attachment_image_src($attachmentId, 'large'), $medium); |
|
29 | 29 | |
30 | 30 | return (object) [ |
31 | - 'alt' => wp_strip_all_tags( get_post_meta( $attachmentId, '_wp_attachment_image_alt', true ), true ), |
|
32 | - 'caption' => wp_get_attachment_caption( $attachmentId ), |
|
33 | - 'copyright' => wp_strip_all_tags( get_post_meta( $attachmentId, '_copyright', true ), true ), |
|
31 | + 'alt' => wp_strip_all_tags(get_post_meta($attachmentId, '_wp_attachment_image_alt', true), true), |
|
32 | + 'caption' => wp_get_attachment_caption($attachmentId), |
|
33 | + 'copyright' => wp_strip_all_tags(get_post_meta($attachmentId, '_copyright', true), true), |
|
34 | 34 | 'large' => $large, |
35 | 35 | 'medium' => $medium, |
36 | - 'permalink' => get_attachment_link( $attachmentId ), |
|
37 | - 'thumbnail' => $this->normalizeSrc( $thumbnail ), |
|
36 | + 'permalink' => get_attachment_link($attachmentId), |
|
37 | + 'thumbnail' => $this->normalizeSrc($thumbnail), |
|
38 | 38 | ]; |
39 | 39 | } |
40 | 40 | |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return array |
45 | 45 | */ |
46 | - protected function normalizeSrc( array $image, $fallback = false ) |
|
46 | + protected function normalizeSrc(array $image, $fallback = false) |
|
47 | 47 | { |
48 | - if( is_array( $fallback ) && count( array_diff( $image, $fallback )) < 2 ) { |
|
48 | + if (is_array($fallback) && count(array_diff($image, $fallback)) < 2) { |
|
49 | 49 | $image = $fallback; |
50 | 50 | } |
51 | 51 | return [ |
@@ -7,22 +7,22 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @return string |
9 | 9 | */ |
10 | - public function buildAttributes( array $atts = [] ) |
|
10 | + public function buildAttributes(array $atts = []) |
|
11 | 11 | { |
12 | 12 | $attributes = []; |
13 | - foreach( $atts as $key => $value ) { |
|
14 | - $attributes[] = sprintf( '%s="%s"', $key, $value ); |
|
13 | + foreach ($atts as $key => $value) { |
|
14 | + $attributes[] = sprintf('%s="%s"', $key, $value); |
|
15 | 15 | } |
16 | - return implode( ' ', $attributes ); |
|
16 | + return implode(' ', $attributes); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @return string |
21 | 21 | */ |
22 | - public function buildAttributesFor( $tag, array $atts = [] ) |
|
22 | + public function buildAttributesFor($tag, array $atts = []) |
|
23 | 23 | { |
24 | 24 | return $this->buildAttributes( |
25 | - wp_parse_args( $atts, apply_filters( "castor/render/$tag/attributes", [] )) |
|
25 | + wp_parse_args($atts, apply_filters("castor/render/$tag/attributes", [])) |
|
26 | 26 | ); |
27 | 27 | } |
28 | 28 | |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return string |
34 | 34 | */ |
35 | - public function buildClassName( $name, $path = '' ) |
|
35 | + public function buildClassName($name, $path = '') |
|
36 | 36 | { |
37 | - $className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ))); |
|
38 | - $className = implode( '', $className ); |
|
37 | + $className = array_map('ucfirst', array_map('strtolower', preg_split('/[-_]/', $name))); |
|
38 | + $className = implode('', $className); |
|
39 | 39 | |
40 | - return !empty( $path ) |
|
41 | - ? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className )) |
|
40 | + return !empty($path) |
|
41 | + ? str_replace('\\\\', '\\', sprintf('%s\%s', $path, $className)) |
|
42 | 42 | : $className; |
43 | 43 | } |
44 | 44 | |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - public function buildMethodName( $name, $prefix = 'get' ) |
|
51 | + public function buildMethodName($name, $prefix = 'get') |
|
52 | 52 | { |
53 | - return lcfirst( $this->buildClassName( $prefix . '-' . $name )); |
|
53 | + return lcfirst($this->buildClassName($prefix . '-' . $name)); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return string |
62 | 62 | */ |
63 | - public function endWith( $suffix, $string, $unique = true ) |
|
63 | + public function endWith($suffix, $string, $unique = true) |
|
64 | 64 | { |
65 | - return $unique && $this->endsWith( $suffix, $string ) |
|
65 | + return $unique && $this->endsWith($suffix, $string) |
|
66 | 66 | ? $string |
67 | 67 | : $string . $suffix; |
68 | 68 | } |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string |
75 | 75 | */ |
76 | - public function endsWith( $needle, $haystack ) |
|
76 | + public function endsWith($needle, $haystack) |
|
77 | 77 | { |
78 | - $length = strlen( $needle ); |
|
78 | + $length = strlen($needle); |
|
79 | 79 | return $length != 0 |
80 | - ? substr( $haystack, -$length ) === $needle |
|
80 | + ? substr($haystack, -$length) === $needle |
|
81 | 81 | : true; |
82 | 82 | } |
83 | 83 | |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return void |
89 | 89 | */ |
90 | - public function printTag( $tag, $value, array $attributes = [] ) |
|
90 | + public function printTag($tag, $value, array $attributes = []) |
|
91 | 91 | { |
92 | - $attributes = $this->buildAttributesFor( $tag, $attributes ); |
|
92 | + $attributes = $this->buildAttributesFor($tag, $attributes); |
|
93 | 93 | |
94 | - printf( '<%s>%s</%s>', |
|
95 | - rtrim( sprintf( '%s %s', $tag, $attributes )), |
|
94 | + printf('<%s>%s</%s>', |
|
95 | + rtrim(sprintf('%s %s', $tag, $attributes)), |
|
96 | 96 | $value, |
97 | 97 | $tag |
98 | 98 | ); |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return string |
107 | 107 | */ |
108 | - public function startWith( $prefix, $string, $unique = true ) |
|
108 | + public function startWith($prefix, $string, $unique = true) |
|
109 | 109 | { |
110 | - return $unique && $this->startsWith( $prefix, $string ) |
|
110 | + return $unique && $this->startsWith($prefix, $string) |
|
111 | 111 | ? $string |
112 | 112 | : $prefix . $string; |
113 | 113 | } |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return string |
120 | 120 | */ |
121 | - public function startsWith( $needle, $haystack ) |
|
121 | + public function startsWith($needle, $haystack) |
|
122 | 122 | { |
123 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
123 | + return substr($haystack, 0, strlen($needle)) === $needle; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @return string |
132 | 132 | */ |
133 | - public function trimLeft( $string, $needle, $caseSensitive = true ) |
|
133 | + public function trimLeft($string, $needle, $caseSensitive = true) |
|
134 | 134 | { |
135 | 135 | $strPos = $caseSensitive ? "strpos" : "stripos"; |
136 | - if( $strPos( $string, $needle ) === 0 ) { |
|
137 | - $string = substr( $string, strlen( $needle )); |
|
136 | + if ($strPos($string, $needle) === 0) { |
|
137 | + $string = substr($string, strlen($needle)); |
|
138 | 138 | } |
139 | 139 | return $string; |
140 | 140 | } |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - public function trimRight( $string, $needle, $caseSensitive = true ) |
|
149 | + public function trimRight($string, $needle, $caseSensitive = true) |
|
150 | 150 | { |
151 | 151 | $strPos = $caseSensitive ? "strpos" : "stripos"; |
152 | - if( $strPos( $string, $needle, strlen( $string ) - strlen( $needle )) !== false ) { |
|
153 | - $string = substr( $string, 0, -strlen( $needle )); |
|
152 | + if ($strPos($string, $needle, strlen($string) - strlen($needle)) !== false) { |
|
153 | + $string = substr($string, 0, -strlen($needle)); |
|
154 | 154 | } |
155 | 155 | return $string; |
156 | 156 | } |
@@ -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,64 +22,64 @@ 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( !$post )return; |
|
37 | - if( !$title ) { |
|
36 | + if (!$post)return; |
|
37 | + if (!$title) { |
|
38 | 38 | $title = $post->post_title; |
39 | 39 | } |
40 | 40 | |
41 | - printf( '<a href="%s" class="button"><span>%s</span></a>', |
|
42 | - get_permalink( $post->ID ), |
|
41 | + printf('<a href="%s" class="button"><span>%s</span></a>', |
|
42 | + get_permalink($post->ID), |
|
43 | 43 | $title |
44 | 44 | ); |
45 | 45 | } |
46 | 46 | |
47 | - public function buttons( array $postIds = [] ) |
|
47 | + public function buttons(array $postIds = []) |
|
48 | 48 | { |
49 | - foreach( $postIds as $postId ) { |
|
50 | - $this->button( $postId ); |
|
49 | + foreach ($postIds as $postId) { |
|
50 | + $this->button($postId); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - public function content( $metaKey = false ) |
|
54 | + public function content($metaKey = false) |
|
55 | 55 | { |
56 | 56 | $content = $metaKey |
57 | - ? $this->postmeta->get( $metaKey ) |
|
57 | + ? $this->postmeta->get($metaKey) |
|
58 | 58 | : get_the_content(); |
59 | 59 | |
60 | - $content = apply_filters( 'the_content', $content ); |
|
60 | + $content = apply_filters('the_content', $content); |
|
61 | 61 | |
62 | - print str_replace( ']]>', ']]>', $content ); |
|
62 | + print str_replace(']]>', ']]>', $content); |
|
63 | 63 | } |
64 | 64 | |
65 | - public function gallery( array $args = [] ) |
|
65 | + public function gallery(array $args = []) |
|
66 | 66 | { |
67 | - print $this->media->gallery( $args ); |
|
67 | + print $this->media->gallery($args); |
|
68 | 68 | } |
69 | 69 | |
70 | - public function title( $metaKey = false, array $attributes = [] ) |
|
70 | + public function title($metaKey = false, array $attributes = []) |
|
71 | 71 | { |
72 | - $tag = apply_filters( 'castor/render/title/tag', 'h2' ); |
|
72 | + $tag = apply_filters('castor/render/title/tag', 'h2'); |
|
73 | 73 | $value = $metaKey |
74 | - ? $this->postmeta->get( $metaKey ) |
|
74 | + ? $this->postmeta->get($metaKey) |
|
75 | 75 | : $this->theme->pageTitle(); |
76 | 76 | |
77 | - if( !$value )return; |
|
77 | + if (!$value)return; |
|
78 | 78 | |
79 | - $this->utility->printTag( $tag, wp_strip_all_tags( $value ), $attributes ); |
|
79 | + $this->utility->printTag($tag, wp_strip_all_tags($value), $attributes); |
|
80 | 80 | } |
81 | 81 | |
82 | - public function video( $metaKey = 'video', $screenshotMetaKey = false ) |
|
82 | + public function video($metaKey = 'video', $screenshotMetaKey = false) |
|
83 | 83 | { |
84 | 84 | } |
85 | 85 | } |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | { |
34 | 34 | $post = get_post( $postId ); |
35 | 35 | |
36 | - if( !$post )return; |
|
36 | + if( !$post ) { |
|
37 | + return; |
|
38 | + } |
|
37 | 39 | if( !$title ) { |
38 | 40 | $title = $post->post_title; |
39 | 41 | } |
@@ -74,7 +76,9 @@ discard block |
||
74 | 76 | ? $this->postmeta->get( $metaKey ) |
75 | 77 | : $this->theme->pageTitle(); |
76 | 78 | |
77 | - if( !$value )return; |
|
79 | + if( !$value ) { |
|
80 | + return; |
|
81 | + } |
|
78 | 82 | |
79 | 83 | $this->utility->printTag( $tag, wp_strip_all_tags( $value ), $attributes ); |
80 | 84 | } |