@@ -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 | /** |
@@ -128,12 +128,12 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return array |
130 | 130 | */ |
131 | - public function toArray( $value ) |
|
131 | + public function toArray($value) |
|
132 | 132 | { |
133 | - if( is_string( $value )) { |
|
134 | - $value = trim( $value ); |
|
133 | + if (is_string($value)) { |
|
134 | + $value = trim($value); |
|
135 | 135 | } |
136 | - return array_filter((array) $value ); |
|
136 | + return array_filter((array) $value); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return string |
145 | 145 | */ |
146 | - public function trimLeft( $string, $needle, $caseSensitive = true ) |
|
146 | + public function trimLeft($string, $needle, $caseSensitive = true) |
|
147 | 147 | { |
148 | 148 | $strPos = $caseSensitive ? "strpos" : "stripos"; |
149 | - if( $strPos( $string, $needle ) === 0 ) { |
|
150 | - $string = substr( $string, strlen( $needle )); |
|
149 | + if ($strPos($string, $needle) === 0) { |
|
150 | + $string = substr($string, strlen($needle)); |
|
151 | 151 | } |
152 | 152 | return $string; |
153 | 153 | } |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @return string |
161 | 161 | */ |
162 | - public function trimRight( $string, $needle, $caseSensitive = true ) |
|
162 | + public function trimRight($string, $needle, $caseSensitive = true) |
|
163 | 163 | { |
164 | 164 | $strPos = $caseSensitive ? "strpos" : "stripos"; |
165 | - if( $strPos( $string, $needle, strlen( $string ) - strlen( $needle )) !== false ) { |
|
166 | - $string = substr( $string, 0, -strlen( $needle )); |
|
165 | + if ($strPos($string, $needle, strlen($string) - strlen($needle)) !== false) { |
|
166 | + $string = substr($string, 0, -strlen($needle)); |
|
167 | 167 | } |
168 | 168 | return $string; |
169 | 169 | } |
@@ -30,15 +30,15 @@ discard block |
||
30 | 30 | * @return mixed |
31 | 31 | * @throws \RuntimeException |
32 | 32 | */ |
33 | - public static function __callStatic( $method, $args ) |
|
33 | + public static function __callStatic($method, $args) |
|
34 | 34 | { |
35 | 35 | $instance = static::getFacadeRoot(); |
36 | 36 | |
37 | - if( !$instance ) { |
|
38 | - throw new RuntimeException( 'A facade root has not been set.' ); |
|
37 | + if (!$instance) { |
|
38 | + throw new RuntimeException('A facade root has not been set.'); |
|
39 | 39 | } |
40 | 40 | |
41 | - return $instance->$method( ...$args ); |
|
41 | + return $instance->$method(...$args); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public static function getFacadeRoot() |
70 | 70 | { |
71 | - return static::resolveFacadeInstance( static::getFacadeAccessor() ); |
|
71 | + return static::resolveFacadeInstance(static::getFacadeAccessor()); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return void |
78 | 78 | */ |
79 | - public static function setFacadeApplication( Application $app ) |
|
79 | + public static function setFacadeApplication(Application $app) |
|
80 | 80 | { |
81 | 81 | static::$app = $app; |
82 | 82 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected static function getFacadeAccessor() |
92 | 92 | { |
93 | - throw new RuntimeException( 'Facade does not implement getFacadeAccessor method.' ); |
|
93 | + throw new RuntimeException('Facade does not implement getFacadeAccessor method.'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return mixed |
102 | 102 | */ |
103 | - protected static function resolveFacadeInstance( $name ) |
|
103 | + protected static function resolveFacadeInstance($name) |
|
104 | 104 | { |
105 | - if( is_object( $name )) { |
|
105 | + if (is_object($name)) { |
|
106 | 106 | return $name; |
107 | 107 | } |
108 | 108 | |
109 | - if( isset( static::$resolvedInstance[$name] )) { |
|
109 | + if (isset(static::$resolvedInstance[$name])) { |
|
110 | 110 | return static::$resolvedInstance[$name]; |
111 | 111 | } |
112 | 112 | |
113 | - return static::$resolvedInstance[$name] = static::$app->make( $name ); |
|
113 | + return static::$resolvedInstance[$name] = static::$app->make($name); |
|
114 | 114 | } |
115 | 115 | } |
@@ -16,24 +16,24 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function afterSetupTheme() |
18 | 18 | { |
19 | - add_editor_style( Theme::assetUri( 'css/editor.css' )); |
|
20 | - add_theme_support( 'customize-selective-refresh-widgets' ); |
|
21 | - add_theme_support( 'html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form'] ); |
|
22 | - add_theme_support( 'post-thumbnails' ); |
|
23 | - add_theme_support( 'soil-clean-up' ); |
|
24 | - add_theme_support( 'soil-jquery-cdn' ); |
|
25 | - add_theme_support( 'soil-nav-walker' ); |
|
26 | - add_theme_support( 'soil-nice-search' ); |
|
27 | - add_theme_support( 'soil-relative-urls' ); |
|
28 | - add_theme_support( 'title-tag' ); |
|
29 | - load_theme_textdomain( 'castor', Theme::paths( 'dir.template' ) . '/languages' ); |
|
30 | - |
|
31 | - $menus = apply_filters( 'castor/register/nav_menus', [ |
|
32 | - 'main_menu' => __( 'Main Menu', 'castor' ), |
|
19 | + add_editor_style(Theme::assetUri('css/editor.css')); |
|
20 | + add_theme_support('customize-selective-refresh-widgets'); |
|
21 | + add_theme_support('html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form']); |
|
22 | + add_theme_support('post-thumbnails'); |
|
23 | + add_theme_support('soil-clean-up'); |
|
24 | + add_theme_support('soil-jquery-cdn'); |
|
25 | + add_theme_support('soil-nav-walker'); |
|
26 | + add_theme_support('soil-nice-search'); |
|
27 | + add_theme_support('soil-relative-urls'); |
|
28 | + add_theme_support('title-tag'); |
|
29 | + load_theme_textdomain('castor', Theme::paths('dir.template') . '/languages'); |
|
30 | + |
|
31 | + $menus = apply_filters('castor/register/nav_menus', [ |
|
32 | + 'main_menu' => __('Main Menu', 'castor'), |
|
33 | 33 | ]); |
34 | 34 | |
35 | - foreach( $menus as $location => $description ) { |
|
36 | - register_nav_menu( $location, $description ); |
|
35 | + foreach ($menus as $location => $description) { |
|
36 | + register_nav_menu($location, $description); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function filterLoginTitle() |
45 | 45 | { |
46 | - return get_bloginfo( 'name' ); |
|
46 | + return get_bloginfo('name'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -52,18 +52,18 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function filterLoginUrl() |
54 | 54 | { |
55 | - return get_bloginfo( 'url' ); |
|
55 | + return get_bloginfo('url'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @return string |
60 | 60 | * @filter template_include |
61 | 61 | */ |
62 | - public function filterTemplate( $template ) |
|
62 | + public function filterTemplate($template) |
|
63 | 63 | { |
64 | - if( is_string( $template )) { |
|
65 | - $template = Template::setLayout( $template ); |
|
66 | - Development::storeTemplatePath( $template ); |
|
64 | + if (is_string($template)) { |
|
65 | + $template = Template::setLayout($template); |
|
66 | + Development::storeTemplatePath($template); |
|
67 | 67 | } |
68 | 68 | return $template; |
69 | 69 | } |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | * @return array |
73 | 73 | * @filter {$type}_template_hierarchy |
74 | 74 | */ |
75 | - public function filterTemplateHierarchy( array $templates ) |
|
75 | + public function filterTemplateHierarchy(array $templates) |
|
76 | 76 | { |
77 | - return array_map( function( $template ) { |
|
78 | - return Utility::startWith( 'templates/', $template ); |
|
79 | - }, $templates ); |
|
77 | + return array_map(function($template) { |
|
78 | + return Utility::startWith('templates/', $template); |
|
79 | + }, $templates); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function login() |
87 | 87 | { |
88 | - if( file_exists( Theme::assetPath( 'css/login.css' ))) { |
|
89 | - printf( '<link rel="stylesheet" href="%s">', Theme::assetUri( 'css/login.css' )); |
|
88 | + if (file_exists(Theme::assetPath('css/login.css'))) { |
|
89 | + printf('<link rel="stylesheet" href="%s">', Theme::assetUri('css/login.css')); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -96,20 +96,20 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function registerAssets() |
98 | 98 | { |
99 | - wp_enqueue_style( 'castor/main.css', |
|
100 | - Theme::assetUri( 'css/main.css' ), |
|
101 | - apply_filters( 'castor/enqueue/css/deps', [] ), |
|
99 | + wp_enqueue_style('castor/main.css', |
|
100 | + Theme::assetUri('css/main.css'), |
|
101 | + apply_filters('castor/enqueue/css/deps', []), |
|
102 | 102 | null |
103 | 103 | ); |
104 | - wp_enqueue_script( 'castor/main.js', |
|
105 | - Theme::assetUri( 'js/main.js' ), |
|
106 | - apply_filters( 'castor/enqueue/js/deps', [] ), |
|
104 | + wp_enqueue_script('castor/main.js', |
|
105 | + Theme::assetUri('js/main.js'), |
|
106 | + apply_filters('castor/enqueue/js/deps', []), |
|
107 | 107 | null, |
108 | 108 | true |
109 | 109 | ); |
110 | - wp_localize_script( 'castor/main.js', apply_filters( 'castor/enqueue/js/localize/variable', 'globals' ), |
|
111 | - apply_filters( 'castor/enqueue/js/localize/variables', [ |
|
112 | - 'ajax' => admin_url( 'admin-ajax.php' ), |
|
110 | + wp_localize_script('castor/main.js', apply_filters('castor/enqueue/js/localize/variable', 'globals'), |
|
111 | + apply_filters('castor/enqueue/js/localize/variables', [ |
|
112 | + 'ajax' => admin_url('admin-ajax.php'), |
|
113 | 113 | ]) |
114 | 114 | ); |
115 | 115 | } |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * @return void |
119 | 119 | * @action customize_register |
120 | 120 | */ |
121 | - public function registerCustomizer( WP_Customize_Manager $manager ) |
|
121 | + public function registerCustomizer(WP_Customize_Manager $manager) |
|
122 | 122 | { |
123 | - $manager->get_setting( 'blogname' )->transport = 'postMessage'; |
|
124 | - $manager->selective_refresh->add_partial( 'blogname', [ |
|
123 | + $manager->get_setting('blogname')->transport = 'postMessage'; |
|
124 | + $manager->selective_refresh->add_partial('blogname', [ |
|
125 | 125 | 'selector' => '.brand', |
126 | 126 | 'render_callback' => function() { |
127 | - bloginfo( 'name' ); |
|
127 | + bloginfo('name'); |
|
128 | 128 | }, |
129 | 129 | ]); |
130 | 130 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function registerCustomizerAssets() |
137 | 137 | { |
138 | - wp_enqueue_script( 'castor/customizer.js', Theme::assetUri( 'js/customizer.js' ), ['customize-preview'], null, true ); |
|
138 | + wp_enqueue_script('castor/customizer.js', Theme::assetUri('js/customizer.js'), ['customize-preview'], null, true); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,23 +144,23 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function registerSidebars() |
146 | 146 | { |
147 | - $defaults = apply_filters( 'castor/register/sidebars/defaults', [ |
|
147 | + $defaults = apply_filters('castor/register/sidebars/defaults', [ |
|
148 | 148 | 'before_widget' => '<div class="widget %1$s %2$s">', |
149 | 149 | 'after_widget' => '</div>', |
150 | 150 | 'before_title' => '<h4>', |
151 | 151 | 'after_title' => '</h4>', |
152 | 152 | ]); |
153 | 153 | |
154 | - $sidebars = apply_filters( 'castor/register/sidebars', [ |
|
155 | - 'sidebar-primary' => __( 'Primary Sidebar', 'castor' ), |
|
156 | - 'sidebar-footer' => __( 'Footer Sidebar', 'castor' ), |
|
154 | + $sidebars = apply_filters('castor/register/sidebars', [ |
|
155 | + 'sidebar-primary' => __('Primary Sidebar', 'castor'), |
|
156 | + 'sidebar-footer' => __('Footer Sidebar', 'castor'), |
|
157 | 157 | ]); |
158 | 158 | |
159 | - foreach( $sidebars as $id => $name ) { |
|
159 | + foreach ($sidebars as $id => $name) { |
|
160 | 160 | register_sidebar([ |
161 | 161 | 'id' => $id, |
162 | 162 | 'name' => $name, |
163 | - ] + $defaults ); |
|
163 | + ] + $defaults); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | } |
@@ -6,13 +6,13 @@ |
||
6 | 6 | |
7 | 7 | class SiteMeta 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\SiteMeta::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\SiteMeta::class; |
|
17 | + } |
|
18 | 18 | } |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | public function capture() |
10 | 10 | { |
11 | 11 | ob_start(); |
12 | - call_user_func_array( [$this, 'printF'], func_get_args() ); |
|
12 | + call_user_func_array([$this, 'printF'], 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, 'printF'], func_get_args() ); |
|
25 | + call_user_func_array([$this, 'printF'], 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() |
@@ -35,30 +35,30 @@ discard block |
||
35 | 35 | return WP_ENV == 'production'; |
36 | 36 | } |
37 | 37 | |
38 | - public function printFiltersFor( $hook = '' ) |
|
38 | + public function printFiltersFor($hook = '') |
|
39 | 39 | { |
40 | 40 | global $wp_filter; |
41 | - if( empty( $hook ) || !isset( $wp_filter[$hook] ))return; |
|
42 | - $this->printF( $wp_filter[ $hook ] ); |
|
41 | + if (empty($hook) || !isset($wp_filter[$hook]))return; |
|
42 | + $this->printF($wp_filter[$hook]); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function printTemplatePaths() |
46 | 46 | { |
47 | - if( $this->isDev() && ( DEV == 'templates' || DEV === true )) { |
|
48 | - $templates = array_keys( array_flip( $this->templatePaths )); |
|
49 | - $templates = array_map( function( $key, $value ) { |
|
50 | - return sprintf( '[%s] => %s', $key, $value ); |
|
51 | - }, array_keys( $templates ), $templates ); |
|
47 | + if ($this->isDev() && (DEV == 'templates' || DEV === true)) { |
|
48 | + $templates = array_keys(array_flip($this->templatePaths)); |
|
49 | + $templates = array_map(function($key, $value) { |
|
50 | + return sprintf('[%s] => %s', $key, $value); |
|
51 | + }, array_keys($templates), $templates); |
|
52 | 52 | |
53 | - $this->printF( implode( "\n", $templates )); |
|
53 | + $this->printF(implode("\n", $templates)); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | - public function storeTemplatePath( $template ) |
|
57 | + public function storeTemplatePath($template) |
|
58 | 58 | { |
59 | - if( is_string( $template )) { |
|
60 | - $themeName = basename( strstr( $template, '/templates/', true )); |
|
61 | - $this->templatePaths[] = $themeName . strstr( $template, '/templates/' ); |
|
59 | + if (is_string($template)) { |
|
60 | + $themeName = basename(strstr($template, '/templates/', true)); |
|
61 | + $this->templatePaths[] = $themeName . strstr($template, '/templates/'); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -66,15 +66,15 @@ discard block |
||
66 | 66 | { |
67 | 67 | $args = func_num_args(); |
68 | 68 | |
69 | - if( $args == 1 ) { |
|
70 | - printf( '<div class="print__r"><pre>%s</pre></div>', |
|
71 | - htmlspecialchars( print_r( func_get_arg(0), true ), ENT_QUOTES, 'UTF-8' ) |
|
69 | + if ($args == 1) { |
|
70 | + printf('<div class="print__r"><pre>%s</pre></div>', |
|
71 | + htmlspecialchars(print_r(func_get_arg(0), true), ENT_QUOTES, 'UTF-8') |
|
72 | 72 | ); |
73 | 73 | } |
74 | - else if( $args > 1 ) { |
|
74 | + else if ($args > 1) { |
|
75 | 75 | echo '<div class="print__r_group">'; |
76 | - foreach( func_get_args() as $value ) { |
|
77 | - $this->printF( $value ); |
|
76 | + foreach (func_get_args() as $value) { |
|
77 | + $this->printF($value); |
|
78 | 78 | } |
79 | 79 | echo '</div>'; |
80 | 80 | } |
@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | public function printFiltersFor( $hook = '' ) |
39 | 39 | { |
40 | 40 | global $wp_filter; |
41 | - if( empty( $hook ) || !isset( $wp_filter[$hook] ))return; |
|
41 | + if( empty( $hook ) || !isset( $wp_filter[$hook] )) { |
|
42 | + return; |
|
43 | + } |
|
42 | 44 | $this->printF( $wp_filter[ $hook ] ); |
43 | 45 | } |
44 | 46 | |
@@ -70,8 +72,7 @@ discard block |
||
70 | 72 | printf( '<div class="print__r"><pre>%s</pre></div>', |
71 | 73 | htmlspecialchars( print_r( func_get_arg(0), true ), ENT_QUOTES, 'UTF-8' ) |
72 | 74 | ); |
73 | - } |
|
74 | - else if( $args > 1 ) { |
|
75 | + } else if( $args > 1 ) { |
|
75 | 76 | echo '<div class="print__r_group">'; |
76 | 77 | foreach( func_get_args() as $value ) { |
77 | 78 | $this->printF( $value ); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | protected $theme; |
20 | 20 | protected $utility; |
21 | 21 | |
22 | - public function __construct( Image $image, PostMeta $postmeta, Theme $theme, Utility $utility ) |
|
22 | + public function __construct(Image $image, PostMeta $postmeta, Theme $theme, Utility $utility) |
|
23 | 23 | { |
24 | 24 | $this->image = $image; |
25 | 25 | $this->postmeta = $postmeta; |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @return WP_Query |
32 | 32 | */ |
33 | - public function get( array $args = [] ) |
|
33 | + public function get(array $args = []) |
|
34 | 34 | { |
35 | - $this->normalizeArgs( $args ); |
|
35 | + $this->normalizeArgs($args); |
|
36 | 36 | |
37 | 37 | $this->gallery = new WP_Query([ |
38 | 38 | 'orderby' => 'post__in', |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function render() |
54 | 54 | { |
55 | - if( empty( $this->args['media'] ))return; |
|
56 | - $images = array_reduce( $this->gallery->posts, function( $images, $attachment ) { |
|
57 | - return $images . $this->renderImage( $attachment ); |
|
55 | + if (empty($this->args['media']))return; |
|
56 | + $images = array_reduce($this->gallery->posts, function($images, $attachment) { |
|
57 | + return $images . $this->renderImage($attachment); |
|
58 | 58 | }); |
59 | - return sprintf( '<div class="gallery-images" itemscope itemtype="http://schema.org/ImageGallery">%s</div>%s', |
|
59 | + return sprintf('<div class="gallery-images" itemscope itemtype="http://schema.org/ImageGallery">%s</div>%s', |
|
60 | 60 | $images, |
61 | 61 | $this->renderPagination() |
62 | 62 | ); |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * @return null|string |
67 | 67 | */ |
68 | - public function renderImage( WP_Post $attachment ) |
|
68 | + public function renderImage(WP_Post $attachment) |
|
69 | 69 | { |
70 | - $image = $this->image->get( $attachment->ID )->image; |
|
70 | + $image = $this->image->get($attachment->ID)->image; |
|
71 | 71 | |
72 | - if( !$image )return; |
|
72 | + if (!$image)return; |
|
73 | 73 | return sprintf( |
74 | 74 | '<figure class="gallery-image" data-w="%s" data-h="%s" data-ps=\'%s\' itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">' . |
75 | 75 | '%s<figcaption itemprop="caption description">' . |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | '</figure>', |
79 | 79 | $image->thumbnail['width'], |
80 | 80 | $image->thumbnail['height'], |
81 | - $this->getPhotoswipeData( $image ), |
|
82 | - $this->renderImageTag( $image ), |
|
81 | + $this->getPhotoswipeData($image), |
|
82 | + $this->renderImageTag($image), |
|
83 | 83 | $image->caption, |
84 | 84 | $image->copyright |
85 | 85 | ); |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function renderPagination() |
92 | 92 | { |
93 | - if( !$this->args['pagination'] )return; |
|
93 | + if (!$this->args['pagination'])return; |
|
94 | 94 | return paginate_links([ |
95 | - 'before_page_number' => '<span class="screen-reader-text">' . __( 'Page', 'castor' ) . ' </span>', |
|
95 | + 'before_page_number' => '<span class="screen-reader-text">' . __('Page', 'castor') . ' </span>', |
|
96 | 96 | 'current' => $this->gallery->query['paged'], |
97 | 97 | 'mid_size' => 1, |
98 | - 'next_text' => __( 'Next', 'castor' ), |
|
99 | - 'prev_text' => __( 'Previous', 'castor' ), |
|
98 | + 'next_text' => __('Next', 'castor'), |
|
99 | + 'prev_text' => __('Previous', 'castor'), |
|
100 | 100 | 'total' => $this->gallery->max_num_pages, |
101 | 101 | ]); |
102 | 102 | } |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return bool |
109 | 109 | */ |
110 | - protected function getBoolValue( $key, $value = null ) |
|
110 | + protected function getBoolValue($key, $value = null) |
|
111 | 111 | { |
112 | - $bool = $this->getValue( $key, $value ); |
|
112 | + $bool = $this->getValue($key, $value); |
|
113 | 113 | |
114 | - if( is_null( filter_var( $bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ))) { |
|
115 | - $bool = $this->postmeta->get( $bool ); |
|
114 | + if (is_null(filter_var($bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE))) { |
|
115 | + $bool = $this->postmeta->get($bool); |
|
116 | 116 | } |
117 | - return wp_validate_boolean( $bool ); |
|
117 | + return wp_validate_boolean($bool); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return int |
124 | 124 | */ |
125 | - protected function getGalleryArg( $value = null ) |
|
125 | + protected function getGalleryArg($value = null) |
|
126 | 126 | { |
127 | - $gallery = $this->getValue( 'gallery', $value ); |
|
127 | + $gallery = $this->getValue('gallery', $value); |
|
128 | 128 | |
129 | - if( !is_numeric( $gallery ) && is_string( $gallery )) { |
|
130 | - $gallery = intval( $this->postmeta->get( $gallery )); |
|
129 | + if (!is_numeric($gallery) && is_string($gallery)) { |
|
130 | + $gallery = intval($this->postmeta->get($gallery)); |
|
131 | 131 | } |
132 | - return !is_null( get_post( $gallery )) |
|
133 | - ? intval( $gallery ) |
|
132 | + return !is_null(get_post($gallery)) |
|
133 | + ? intval($gallery) |
|
134 | 134 | : 0; |
135 | 135 | } |
136 | 136 | |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return int |
141 | 141 | */ |
142 | - protected function getImagesPerPageArg( $value = null ) |
|
142 | + protected function getImagesPerPageArg($value = null) |
|
143 | 143 | { |
144 | - $perPage = $this->getValue( 'images_per_page', $value ); |
|
144 | + $perPage = $this->getValue('images_per_page', $value); |
|
145 | 145 | |
146 | - if( !is_numeric( $perPage ) && is_string( $perPage )) { |
|
147 | - $perPage = $this->postmeta->get( $perPage ); |
|
146 | + if (!is_numeric($perPage) && is_string($perPage)) { |
|
147 | + $perPage = $this->postmeta->get($perPage); |
|
148 | 148 | } |
149 | - return !!intval( $perPage ) |
|
149 | + return !!intval($perPage) |
|
150 | 150 | ? $perPage |
151 | 151 | : -1; |
152 | 152 | } |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return bool |
158 | 158 | */ |
159 | - protected function getLazyloadArg( $value = null ) |
|
159 | + protected function getLazyloadArg($value = null) |
|
160 | 160 | { |
161 | - return $this->getBoolValue( 'lazyload', $value ); |
|
161 | + return $this->getBoolValue('lazyload', $value); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return array |
168 | 168 | */ |
169 | - protected function getMediaArg( $value = null ) |
|
169 | + protected function getMediaArg($value = null) |
|
170 | 170 | { |
171 | - $media = $this->getValue( 'media', $value ); |
|
171 | + $media = $this->getValue('media', $value); |
|
172 | 172 | |
173 | - if( is_string( $media )) { |
|
174 | - $media = $this->postmeta->get( $media, [ |
|
173 | + if (is_string($media)) { |
|
174 | + $media = $this->postmeta->get($media, [ |
|
175 | 175 | 'ID' => $this->getGalleryArg(), |
176 | 176 | 'single' => false, |
177 | 177 | ]); |
178 | 178 | } |
179 | - return is_array( $media ) |
|
180 | - ? wp_parse_id_list( $media ) |
|
179 | + return is_array($media) |
|
180 | + ? wp_parse_id_list($media) |
|
181 | 181 | : []; |
182 | 182 | } |
183 | 183 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function getPaged() |
188 | 188 | { |
189 | - return intval( get_query_var(( is_front_page() ? 'page' : 'paged' ))) ?: 1; |
|
189 | + return intval(get_query_var((is_front_page() ? 'page' : 'paged'))) ?: 1; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @return bool |
196 | 196 | */ |
197 | - protected function getPaginationArg( $value = null ) |
|
197 | + protected function getPaginationArg($value = null) |
|
198 | 198 | { |
199 | - return $this->getBoolValue( 'pagination', $value ); |
|
199 | + return $this->getBoolValue('pagination', $value); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -204,17 +204,17 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return bool |
206 | 206 | */ |
207 | - protected function getPermalinksArg( $value = null ) |
|
207 | + protected function getPermalinksArg($value = null) |
|
208 | 208 | { |
209 | - return $this->getBoolValue( 'permalinks', $value ); |
|
209 | + return $this->getBoolValue('permalinks', $value); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
213 | 213 | * @return string |
214 | 214 | */ |
215 | - protected function getPhotoswipeData( $image ) |
|
215 | + protected function getPhotoswipeData($image) |
|
216 | 216 | { |
217 | - return sprintf( '{"l":{"src":"%s","w":%d,"h":%d},"m":{"src":"%s","w":%d,"h":%d}}', |
|
217 | + return sprintf('{"l":{"src":"%s","w":%d,"h":%d},"m":{"src":"%s","w":%d,"h":%d}}', |
|
218 | 218 | $image->large['url'], |
219 | 219 | $image->large['width'], |
220 | 220 | $image->large['height'], |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return mixed |
232 | 232 | */ |
233 | - protected function getValue( $key, $value = null ) |
|
233 | + protected function getValue($key, $value = null) |
|
234 | 234 | { |
235 | - if( is_null( $value ) && isset( $this->args[$key] )) { |
|
235 | + if (is_null($value) && isset($this->args[$key])) { |
|
236 | 236 | $value = $this->args[$key]; |
237 | 237 | } |
238 | 238 | return $value; |
@@ -241,23 +241,23 @@ discard block |
||
241 | 241 | /** |
242 | 242 | * @return array |
243 | 243 | */ |
244 | - protected function normalizeArgs( array $args = [] ) |
|
244 | + protected function normalizeArgs(array $args = []) |
|
245 | 245 | { |
246 | 246 | $defaults = [ |
247 | - 'gallery', // (string) meta_key | (int) post_id |
|
248 | - 'lazyload', // (string) meta_key | (bool) |
|
249 | - 'media', // (string) meta_key | (array) post_ids |
|
250 | - 'pagination', // (string) meta_key | (bool) |
|
247 | + 'gallery', // (string) meta_key | (int) post_id |
|
248 | + 'lazyload', // (string) meta_key | (bool) |
|
249 | + 'media', // (string) meta_key | (array) post_ids |
|
250 | + 'pagination', // (string) meta_key | (bool) |
|
251 | 251 | 'images_per_page', // (string) meta_key | (int) number |
252 | - 'permalinks', // (string) meta_key | (bool) |
|
252 | + 'permalinks', // (string) meta_key | (bool) |
|
253 | 253 | ]; |
254 | 254 | |
255 | - $this->args = shortcode_atts( array_combine( $defaults, $defaults ), $args ); |
|
255 | + $this->args = shortcode_atts(array_combine($defaults, $defaults), $args); |
|
256 | 256 | |
257 | - array_walk( $this->args, function( &$value, $key ) { |
|
258 | - $method = $this->utility->buildMethodName( $key . '_arg' ); |
|
259 | - if( method_exists( $this, $method )) { |
|
260 | - $value = call_user_func([ $this, $method ], $value ); |
|
257 | + array_walk($this->args, function(&$value, $key) { |
|
258 | + $method = $this->utility->buildMethodName($key . '_arg'); |
|
259 | + if (method_exists($this, $method)) { |
|
260 | + $value = call_user_func([$this, $method], $value); |
|
261 | 261 | } |
262 | 262 | }); |
263 | 263 | |
@@ -269,20 +269,20 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return null|string |
271 | 271 | */ |
272 | - protected function renderImageTag( $image ) |
|
272 | + protected function renderImageTag($image) |
|
273 | 273 | { |
274 | 274 | $imgSrc = $this->getLazyloadArg() |
275 | - ? $this->theme->imageUri( 'blank.gif' ) |
|
275 | + ? $this->theme->imageUri('blank.gif') |
|
276 | 276 | : $image->thumbnail['url']; |
277 | 277 | |
278 | - $imgTag = sprintf( '<img src="%s" data-src="%s" itemprop="thumbnail" alt="%s"/>', |
|
278 | + $imgTag = sprintf('<img src="%s" data-src="%s" itemprop="thumbnail" alt="%s"/>', |
|
279 | 279 | $imgSrc, |
280 | 280 | $image->thumbnail['url'], |
281 | 281 | $image->alt |
282 | 282 | ); |
283 | 283 | |
284 | 284 | return $this->getPermalinksArg() |
285 | - ? sprintf( '<a href="%s" itemprop="contentUrl">%s</a>', $image->permalink, $imgTag ) |
|
285 | + ? sprintf('<a href="%s" itemprop="contentUrl">%s</a>', $image->permalink, $imgTag) |
|
286 | 286 | : $imgTag; |
287 | 287 | } |
288 | 288 | } |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function render() |
54 | 54 | { |
55 | - if( empty( $this->args['media'] ))return; |
|
55 | + if( empty( $this->args['media'] )) { |
|
56 | + return; |
|
57 | + } |
|
56 | 58 | $images = array_reduce( $this->gallery->posts, function( $images, $attachment ) { |
57 | 59 | return $images . $this->renderImage( $attachment ); |
58 | 60 | }); |
@@ -69,7 +71,9 @@ discard block |
||
69 | 71 | { |
70 | 72 | $image = $this->image->get( $attachment->ID )->image; |
71 | 73 | |
72 | - if( !$image )return; |
|
74 | + if( !$image ) { |
|
75 | + return; |
|
76 | + } |
|
73 | 77 | return sprintf( |
74 | 78 | '<figure class="gallery-image" data-w="%s" data-h="%s" data-ps=\'%s\' itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">' . |
75 | 79 | '%s<figcaption itemprop="caption description">' . |
@@ -90,7 +94,9 @@ discard block |
||
90 | 94 | */ |
91 | 95 | public function renderPagination() |
92 | 96 | { |
93 | - if( !$this->args['pagination'] )return; |
|
97 | + if( !$this->args['pagination'] ) { |
|
98 | + return; |
|
99 | + } |
|
94 | 100 | return paginate_links([ |
95 | 101 | 'before_page_number' => '<span class="screen-reader-text">' . __( 'Page', 'castor' ) . ' </span>', |
96 | 102 | 'current' => $this->gallery->query['paged'], |
@@ -18,24 +18,24 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return string |
20 | 20 | */ |
21 | - public function get( $slug, $name = '' ) |
|
21 | + public function get($slug, $name = '') |
|
22 | 22 | { |
23 | - $template = Utility::startWith( 'templates/', $slug ); |
|
23 | + $template = Utility::startWith('templates/', $slug); |
|
24 | 24 | $templates = ["{$template}.php"]; |
25 | 25 | |
26 | - if( 'index' != basename( $this->template, '.php' )) { |
|
27 | - $filepath = dirname( $template ) != '.' |
|
28 | - ? sprintf( '%s/', dirname( $template )) |
|
26 | + if ('index' != basename($this->template, '.php')) { |
|
27 | + $filepath = dirname($template) != '.' |
|
28 | + ? sprintf('%s/', dirname($template)) |
|
29 | 29 | : ''; |
30 | 30 | array_unshift( |
31 | 31 | $templates, |
32 | - sprintf( '%s%s-%s.php', $filepath, $name, basename( $template )) |
|
32 | + sprintf('%s%s-%s.php', $filepath, $name, basename($template)) |
|
33 | 33 | ); |
34 | 34 | } |
35 | 35 | |
36 | - $templates = apply_filters( "castor/templates/{$slug}", $templates, $name ); |
|
36 | + $templates = apply_filters("castor/templates/{$slug}", $templates, $name); |
|
37 | 37 | |
38 | - return locate_template( $templates ); |
|
38 | + return locate_template($templates); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return void |
46 | 46 | */ |
47 | - public function load( $slug, $name = '' ) |
|
47 | + public function load($slug, $name = '') |
|
48 | 48 | { |
49 | - $template = $this->get( $slug, $name ); |
|
50 | - if( !empty( $template )) { |
|
51 | - Development::storeTemplatePath( $template ); |
|
52 | - load_template( $template, false ); |
|
49 | + $template = $this->get($slug, $name); |
|
50 | + if (!empty($template)) { |
|
51 | + Development::storeTemplatePath($template); |
|
52 | + load_template($template, false); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function main() |
60 | 60 | { |
61 | - $this->load( $this->template ); |
|
61 | + $this->load($this->template); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return string|void |
68 | 68 | */ |
69 | - public function setLayout( $template ) |
|
69 | + public function setLayout($template) |
|
70 | 70 | { |
71 | - $this->template = Utility::trimRight( strstr( $template, 'templates/' ), '.php' ); |
|
72 | - return $this->get( apply_filters( 'castor/templates/layout', 'layouts/default' )); |
|
71 | + $this->template = Utility::trimRight(strstr($template, 'templates/'), '.php'); |
|
72 | + return $this->get(apply_filters('castor/templates/layout', 'layouts/default')); |
|
73 | 73 | } |
74 | 74 | } |
@@ -6,13 +6,13 @@ |
||
6 | 6 | |
7 | 7 | class ArchiveMeta 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\ArchiveMeta::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\ArchiveMeta::class; |
|
17 | + } |
|
18 | 18 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | public function __construct() |
21 | 21 | { |
22 | - $this->options = get_option( apply_filters( 'pollux/archives/id', 'pollux_archives' ), [] ); |
|
22 | + $this->options = get_option(apply_filters('pollux/archives/id', 'pollux_archives'), []); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * @param string $group |
29 | 29 | * @return mixed |
30 | 30 | */ |
31 | - public function get( $key = '', $fallback = null, $group = '' ) |
|
31 | + public function get($key = '', $fallback = null, $group = '') |
|
32 | 32 | { |
33 | - return parent::get( $group, $key, $fallback ); |
|
33 | + return parent::get($group, $key, $fallback); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |