@@ -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(); |