@@ -6,13 +6,13 @@ |
||
6 | 6 | |
7 | 7 | class Media extends Facade |
8 | 8 | { |
9 | - /** |
|
10 | - * Get the fully qualified class name of the component. |
|
11 | - * |
|
12 | - * @return string |
|
13 | - */ |
|
14 | - protected static function getFacadeAccessor() |
|
15 | - { |
|
16 | - return \GeminiLabs\Castor\Helpers\Media::class; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Get the fully qualified class name of the component. |
|
11 | + * |
|
12 | + * @return string |
|
13 | + */ |
|
14 | + protected static function getFacadeAccessor() |
|
15 | + { |
|
16 | + return \GeminiLabs\Castor\Helpers\Media::class; |
|
17 | + } |
|
18 | 18 | } |
@@ -11,29 +11,29 @@ discard block |
||
11 | 11 | public function __construct() |
12 | 12 | { |
13 | 13 | Facade::clearResolvedInstances(); |
14 | - Facade::setFacadeApplication( $this ); |
|
14 | + Facade::setFacadeApplication($this); |
|
15 | 15 | $this->registerAliases(); |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function init() |
19 | 19 | { |
20 | - $controller = $this->make( 'Controller' ); |
|
20 | + $controller = $this->make('Controller'); |
|
21 | 21 | |
22 | 22 | // Action hooks |
23 | - add_action( 'after_setup_theme', [$controller, 'afterSetupTheme'], 20 ); |
|
24 | - add_action( 'login_head', [$controller, 'login'] ); |
|
25 | - add_action( 'wp_enqueue_scripts', [$controller, 'registerAssets'] ); |
|
26 | - add_action( 'customize_register', [$controller, 'registerCustomizer'] ); |
|
27 | - add_action( 'customize_preview_init', [$controller, 'registerCustomizerAssets'] ); |
|
28 | - add_action( 'widgets_init', [$controller, 'registerSidebars'] ); |
|
23 | + add_action('after_setup_theme', [$controller, 'afterSetupTheme'], 20); |
|
24 | + add_action('login_head', [$controller, 'login']); |
|
25 | + add_action('wp_enqueue_scripts', [$controller, 'registerAssets']); |
|
26 | + add_action('customize_register', [$controller, 'registerCustomizer']); |
|
27 | + add_action('customize_preview_init', [$controller, 'registerCustomizerAssets']); |
|
28 | + add_action('widgets_init', [$controller, 'registerSidebars']); |
|
29 | 29 | |
30 | 30 | // Filter hooks |
31 | - add_filter( 'template_include', [$controller, 'filterTemplate'] ); |
|
32 | - add_filter( 'login_headertitle', [$controller, 'filterLoginTitle'] ); |
|
33 | - add_filter( 'login_headerurl', [$controller, 'filterLoginUrl'] ); |
|
31 | + add_filter('template_include', [$controller, 'filterTemplate']); |
|
32 | + add_filter('login_headertitle', [$controller, 'filterLoginTitle']); |
|
33 | + add_filter('login_headerurl', [$controller, 'filterLoginUrl']); |
|
34 | 34 | |
35 | - foreach( $this->getTemplateTypes() as $type ) { |
|
36 | - add_filter( "{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy'] ); |
|
35 | + foreach ($this->getTemplateTypes() as $type) { |
|
36 | + add_filter("{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy']); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | 'Utility' => Facades\Utility::class, |
52 | 52 | ]; |
53 | 53 | |
54 | - $aliases = apply_filters( 'castor/register/aliases', $aliases ); |
|
54 | + $aliases = apply_filters('castor/register/aliases', $aliases); |
|
55 | 55 | |
56 | - AliasLoader::getInstance( $aliases )->register(); |
|
56 | + AliasLoader::getInstance($aliases)->register(); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | public function capture() |
10 | 10 | { |
11 | 11 | ob_start(); |
12 | - call_user_func_array( [$this, 'print'], func_get_args() ); |
|
12 | + call_user_func_array([$this, 'print'], func_get_args()); |
|
13 | 13 | return ob_get_clean(); |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function className() |
17 | 17 | { |
18 | - return $this->isDev() && in_array( DEV, ['css', true] ) |
|
18 | + return $this->isDev() && in_array(DEV, ['css', true]) |
|
19 | 19 | ? 'dev' |
20 | 20 | : ''; |
21 | 21 | } |
22 | 22 | |
23 | 23 | public function debug() |
24 | 24 | { |
25 | - call_user_func_array( [$this, 'print'], func_get_args() ); |
|
25 | + call_user_func_array([$this, 'print'], func_get_args()); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function isDev() |
29 | 29 | { |
30 | - return defined( 'DEV' ) && !!DEV && WP_ENV == 'development'; |
|
30 | + return defined('DEV') && !!DEV && WP_ENV == 'development'; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function isProduction() |
@@ -39,44 +39,44 @@ discard block |
||
39 | 39 | { |
40 | 40 | $args = func_num_args(); |
41 | 41 | |
42 | - if( $args == 1 ) { |
|
43 | - printf( '<div class="print__r"><pre>%s</pre></div>', |
|
44 | - htmlspecialchars( print_r( func_get_arg(0), true ), ENT_QUOTES, 'UTF-8' ) |
|
42 | + if ($args == 1) { |
|
43 | + printf('<div class="print__r"><pre>%s</pre></div>', |
|
44 | + htmlspecialchars(print_r(func_get_arg(0), true), ENT_QUOTES, 'UTF-8') |
|
45 | 45 | ); |
46 | 46 | } |
47 | - else if( $args > 1 ) { |
|
47 | + else if ($args > 1) { |
|
48 | 48 | echo '<div class="print__r_group">'; |
49 | - foreach( func_get_args() as $value ) { |
|
50 | - $this->print( $value ); |
|
49 | + foreach (func_get_args() as $value) { |
|
50 | + $this->print($value); |
|
51 | 51 | } |
52 | 52 | echo '</div>'; |
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | - public function printFiltersFor( $hook = '' ) |
|
56 | + public function printFiltersFor($hook = '') |
|
57 | 57 | { |
58 | 58 | global $wp_filter; |
59 | - if( empty( $hook ) || !isset( $wp_filter[$hook] ))return; |
|
60 | - $this->print( $wp_filter[ $hook ] ); |
|
59 | + if (empty($hook) || !isset($wp_filter[$hook]))return; |
|
60 | + $this->print($wp_filter[$hook]); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | public function printTemplatePaths() |
64 | 64 | { |
65 | - if( $this->isDev() && ( DEV == 'templates' || DEV === true )) { |
|
66 | - $templates = array_keys( array_flip( $this->templatePaths )); |
|
67 | - $templates = array_map( function( $key, $value ) { |
|
68 | - return sprintf( '[%s] => %s', $key, $value ); |
|
69 | - }, array_keys( $templates ), $templates ); |
|
65 | + if ($this->isDev() && (DEV == 'templates' || DEV === true)) { |
|
66 | + $templates = array_keys(array_flip($this->templatePaths)); |
|
67 | + $templates = array_map(function($key, $value) { |
|
68 | + return sprintf('[%s] => %s', $key, $value); |
|
69 | + }, array_keys($templates), $templates); |
|
70 | 70 | |
71 | - $this->print( implode( "\n", $templates )); |
|
71 | + $this->print(implode("\n", $templates)); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - public function storeTemplatePath( $template ) |
|
75 | + public function storeTemplatePath($template) |
|
76 | 76 | { |
77 | - if( is_string( $template )) { |
|
78 | - $themeName = basename( strstr( $template, '/templates/', true )); |
|
79 | - $this->templatePaths[] = $themeName . strstr( $template, '/templates/' ); |
|
77 | + if (is_string($template)) { |
|
78 | + $themeName = basename(strstr($template, '/templates/', true)); |
|
79 | + $this->templatePaths[] = $themeName . strstr($template, '/templates/'); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
@@ -43,8 +43,7 @@ discard block |
||
43 | 43 | printf( '<div class="print__r"><pre>%s</pre></div>', |
44 | 44 | htmlspecialchars( print_r( func_get_arg(0), true ), ENT_QUOTES, 'UTF-8' ) |
45 | 45 | ); |
46 | - } |
|
47 | - else if( $args > 1 ) { |
|
46 | + } else if( $args > 1 ) { |
|
48 | 47 | echo '<div class="print__r_group">'; |
49 | 48 | foreach( func_get_args() as $value ) { |
50 | 49 | $this->print( $value ); |
@@ -56,7 +55,9 @@ discard block |
||
56 | 55 | public function printFiltersFor( $hook = '' ) |
57 | 56 | { |
58 | 57 | global $wp_filter; |
59 | - if( empty( $hook ) || !isset( $wp_filter[$hook] ))return; |
|
58 | + if( empty( $hook ) || !isset( $wp_filter[$hook] )) { |
|
59 | + return; |
|
60 | + } |
|
60 | 61 | $this->print( $wp_filter[ $hook ] ); |
61 | 62 | } |
62 | 63 |
@@ -6,13 +6,13 @@ |
||
6 | 6 | |
7 | 7 | class Render extends Facade |
8 | 8 | { |
9 | - /** |
|
10 | - * Get the fully qualified class name of the component. |
|
11 | - * |
|
12 | - * @return string |
|
13 | - */ |
|
14 | - protected static function getFacadeAccessor() |
|
15 | - { |
|
16 | - return \GeminiLabs\Castor\Helpers\Render::class; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Get the fully qualified class name of the component. |
|
11 | + * |
|
12 | + * @return string |
|
13 | + */ |
|
14 | + protected static function getFacadeAccessor() |
|
15 | + { |
|
16 | + return \GeminiLabs\Castor\Helpers\Render::class; |
|
17 | + } |
|
18 | 18 | } |
@@ -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,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 | } |
@@ -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(); |
@@ -37,7 +37,9 @@ discard block |
||
37 | 37 | |
38 | 38 | public function render() |
39 | 39 | { |
40 | - if( !isset( $this->video->html ))return; |
|
40 | + if( !isset( $this->video->html )) { |
|
41 | + return; |
|
42 | + } |
|
41 | 43 | return sprintf( |
42 | 44 | '<div class="video embed">%s%s</div>', |
43 | 45 | $this->renderScreenshot(), |
@@ -61,7 +63,9 @@ discard block |
||
61 | 63 | |
62 | 64 | public function renderScreenshot() |
63 | 65 | { |
64 | - if( !$this->args['image'] )return; |
|
66 | + if( !$this->args['image'] ) { |
|
67 | + return; |
|
68 | + } |
|
65 | 69 | return sprintf( '<div class="video-screenshot" style="background-image: url(%s)">%s</div>', |
66 | 70 | $this->args['image'], |
67 | 71 | $this->renderPlayButton() |
@@ -99,7 +103,9 @@ discard block |
||
99 | 103 | |
100 | 104 | foreach( $this->args as $key => $value ) { |
101 | 105 | $method = $this->utility->buildMethodName( $key, 'set' ); |
102 | - if( !method_exists( $this, $method ))continue; |
|
106 | + if( !method_exists( $this, $method )) { |
|
107 | + continue; |
|
108 | + } |
|
103 | 109 | call_user_func([ $this, $method ], $value ); |
104 | 110 | } |
105 | 111 | return $this->args; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | protected $theme; |
20 | 20 | protected $utility; |
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,16 +28,16 @@ discard block |
||
28 | 28 | $this->utility = $utility; |
29 | 29 | } |
30 | 30 | |
31 | - public function get( $args = [] ) |
|
31 | + public function get($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 | |
38 | 38 | public function render() |
39 | 39 | { |
40 | - if( !isset( $this->video->html ))return; |
|
40 | + if (!isset($this->video->html))return; |
|
41 | 41 | return sprintf( |
42 | 42 | '<div class="video embed">%s%s</div>', |
43 | 43 | $this->renderScreenshot(), |
@@ -55,37 +55,37 @@ discard block |
||
55 | 55 | '<a href="%s" class="video-play-btn">%s</a>' . |
56 | 56 | '</div>', |
57 | 57 | $this->args['url'], |
58 | - $this->theme->svg( 'play.svg' ) |
|
58 | + $this->theme->svg('play.svg') |
|
59 | 59 | ); |
60 | 60 | } |
61 | 61 | |
62 | 62 | public function renderScreenshot() |
63 | 63 | { |
64 | - if( !$this->args['image'] )return; |
|
65 | - return sprintf( '<div class="video-screenshot" style="background-image: url(%s)">%s</div>', |
|
64 | + if (!$this->args['image'])return; |
|
65 | + return sprintf('<div class="video-screenshot" style="background-image: url(%s)">%s</div>', |
|
66 | 66 | $this->args['image'], |
67 | 67 | $this->renderPlayButton() |
68 | 68 | ); |
69 | 69 | } |
70 | 70 | |
71 | - protected function setImage( $image ) |
|
71 | + protected function setImage($image) |
|
72 | 72 | { |
73 | - $image = $this->image->get( $image )->image; |
|
74 | - $this->args['image'] = isset( $image->large ) |
|
73 | + $image = $this->image->get($image)->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( $args ) |
|
86 | + protected function normalize($args) |
|
87 | 87 | { |
88 | - if( is_string( $args )) { |
|
88 | + if (is_string($args)) { |
|
89 | 89 | $args = ['url' => $args]; |
90 | 90 | } |
91 | 91 | |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | 'image' => '', // string || int |
94 | 94 | 'player' => '', // string || array |
95 | 95 | 'url' => '', // string |
96 | - ], $args ); |
|
96 | + ], $args); |
|
97 | 97 | |
98 | - foreach( $this->args as $key => $value ) { |
|
99 | - $method = $this->utility->buildMethodName( $key, 'set' ); |
|
100 | - if( !method_exists( $this, $method ))continue; |
|
101 | - call_user_func([ $this, $method ], $value ); |
|
98 | + foreach ($this->args as $key => $value) { |
|
99 | + $method = $this->utility->buildMethodName($key, 'set'); |
|
100 | + if (!method_exists($this, $method))continue; |
|
101 | + call_user_func([$this, $method], $value); |
|
102 | 102 | } |
103 | 103 | return $this->args; |
104 | 104 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | class PostMeta |
6 | 6 | { |
7 | - public function get( $value, array $args = [] ) |
|
7 | + public function get($value, array $args = []) |
|
8 | 8 | { |
9 | 9 | $defaults = [ |
10 | 10 | 'ID' => get_the_ID(), |
@@ -13,15 +13,15 @@ discard block |
||
13 | 13 | 'prefix' => 'pollux_', |
14 | 14 | ]; |
15 | 15 | |
16 | - $args = shortcode_atts( $defaults, $args ); |
|
16 | + $args = shortcode_atts($defaults, $args); |
|
17 | 17 | |
18 | - if( !empty( $value ) && $value[0] == '_' && !empty( $args['prefix'] )) { |
|
19 | - $args['prefix'] = sprintf( '_%s', rtrim( $args['prefix'], '_' )); |
|
18 | + if (!empty($value) && $value[0] == '_' && !empty($args['prefix'])) { |
|
19 | + $args['prefix'] = sprintf('_%s', rtrim($args['prefix'], '_')); |
|
20 | 20 | } |
21 | 21 | |
22 | - $metaValue = get_post_meta( $args['ID'], $args['prefix'] . $value, $args['single'] ); |
|
22 | + $metaValue = get_post_meta($args['ID'], $args['prefix'] . $value, $args['single']); |
|
23 | 23 | |
24 | - return empty( $metaValue ) |
|
24 | + return empty($metaValue) |
|
25 | 25 | ? $args['fallback'] |
26 | 26 | : $metaValue; |
27 | 27 | } |