@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if( !function_exists( 'pollux_app' )) { |
|
3 | +if( !function_exists( 'pollux_app' ) ) { |
|
4 | 4 | function pollux_app() { |
5 | 5 | return GeminiLabs\Pollux\Application::getInstance(); |
6 | 6 | } |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * @var array |
12 | 12 | */ |
13 | - public $columns = []; |
|
13 | + public $columns = [ ]; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * @var array |
17 | 17 | */ |
18 | - public $types = []; |
|
18 | + public $types = [ ]; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @var Application |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | public function initColumns() |
29 | 29 | { |
30 | 30 | foreach( $this->types as $type => $args ) { |
31 | - add_action( "manage_{$type}_posts_custom_column", [$this, 'printColumnValue'], 10, 2 ); |
|
31 | + add_action( "manage_{$type}_posts_custom_column", [ $this, 'printColumnValue' ], 10, 2 ); |
|
32 | 32 | add_filter( "manage_{$type}_posts_columns", function( $columns ) use( $args ) { |
33 | - return count( $args['columns'] ) > 1 |
|
34 | - ? $args['columns'] |
|
33 | + return count( $args[ 'columns' ] ) > 1 |
|
34 | + ? $args[ 'columns' ] |
|
35 | 35 | : $columns; |
36 | 36 | }); |
37 | 37 | } |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | protected function getColumnImage( $postId ) |
59 | 59 | { |
60 | 60 | if( has_post_thumbnail( $postId ) ) { |
61 | - list( $src, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), [96, 48] ); |
|
61 | + list( $src, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), [ 96, 48 ] ); |
|
62 | 62 | $image = sprintf( '<img src="%s" alt="%s" width="%s" height="%s">', |
63 | - esc_url( set_url_scheme( $src )), |
|
64 | - esc_attr( get_the_title( $postId )), |
|
63 | + esc_url( set_url_scheme( $src ) ), |
|
64 | + esc_attr( get_the_title( $postId ) ), |
|
65 | 65 | $width, |
66 | 66 | $height |
67 | 67 | ); |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | protected function getColumnMedia() |
78 | 78 | { |
79 | 79 | return count( PostMeta::get( 'media', [ |
80 | - 'fallback' => [], |
|
80 | + 'fallback' => [ ], |
|
81 | 81 | 'single' => false, |
82 | - ])); |
|
82 | + ] ) ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | protected function normalizeColumns( array $columns ) |
98 | 98 | { |
99 | 99 | $columns = array_flip( $columns ); |
100 | - $columns = array_merge( $columns, array_intersect_key( $this->columns, $columns )); |
|
101 | - return ['cb' => '<input type="checkbox">'] + $columns; |
|
100 | + $columns = array_merge( $columns, array_intersect_key( $this->columns, $columns ) ); |
|
101 | + return [ 'cb' => '<input type="checkbox">' ] + $columns; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $defaults = [ |
110 | 110 | 'author' => __( 'Author', 'pollux' ), |
111 | 111 | 'categories' => __( 'Categories', 'pollux' ), |
112 | - 'comments' => sprintf( '<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%1$s</span></span>', __( 'Comments', 'pollux' )), |
|
112 | + 'comments' => sprintf( '<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%1$s</span></span>', __( 'Comments', 'pollux' ) ), |
|
113 | 113 | 'date' => __( 'Date', 'pollux' ), |
114 | 114 | 'image' => __( 'Image', 'pollux' ), |
115 | 115 | 'media' => __( 'Media', 'pollux' ), |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | { |
47 | 47 | $yamlFile = $this->getYamlFile(); |
48 | 48 | $yaml = $this->normalize( |
49 | - $this->parseYaml( file_get_contents( $yamlFile )) |
|
49 | + $this->parseYaml( file_get_contents( $yamlFile ) ) |
|
50 | 50 | ); |
51 | - if( !$yaml['disable_config'] ) { |
|
51 | + if( !$yaml[ 'disable_config' ] ) { |
|
52 | 52 | $config = $this->normalizeArray( |
53 | - array_filter( (array) get_option( Config::id(), [] )) |
|
53 | + array_filter( (array) get_option( Config::id(), [ ] ) ) |
|
54 | 54 | ); |
55 | 55 | } |
56 | 56 | return empty( $config ) |
57 | - ? $this->setTimestamp( $yaml, filemtime( $yamlFile )) |
|
57 | + ? $this->setTimestamp( $yaml, filemtime( $yamlFile ) ) |
|
58 | 58 | : $this->normalize( $config ); |
59 | 59 | } |
60 | 60 | |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | public function compile() |
65 | 65 | { |
66 | 66 | $configFile = $this->getCompileDestination(); |
67 | - if( $this->shouldCompile( $configFile )) { |
|
67 | + if( $this->shouldCompile( $configFile ) ) { |
|
68 | 68 | file_put_contents( $configFile, sprintf( '<?php // DO NOT MODIFY THIS FILE DIRECTLY!%sreturn (object) %s;', |
69 | 69 | PHP_EOL, |
70 | - $this->parseRawStrings( var_export( $this->setTimestamp( $this->options ), true )) |
|
71 | - )); |
|
70 | + $this->parseRawStrings( var_export( $this->setTimestamp( $this->options ), true ) ) |
|
71 | + ) ); |
|
72 | 72 | } |
73 | 73 | return include $configFile; |
74 | 74 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function convertArrayToYaml( array $array ) |
80 | 80 | { |
81 | 81 | return !empty( $array ) |
82 | - ? trim( $this->parseRawStrings( $this->dumpYaml( $array ))) |
|
82 | + ? trim( $this->parseRawStrings( $this->dumpYaml( $array ) ) ) |
|
83 | 83 | : ''; |
84 | 84 | } |
85 | 85 | |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | trailingslashit( trailingslashit( $theme->theme_root ) . $theme->template ), |
107 | 107 | trailingslashit( WP_CONTENT_DIR ), |
108 | 108 | trailingslashit( ABSPATH ), |
109 | - trailingslashit( dirname( ABSPATH )), |
|
110 | - trailingslashit( dirname( dirname( ABSPATH ))), |
|
111 | - ]); |
|
109 | + trailingslashit( dirname( ABSPATH ) ), |
|
110 | + trailingslashit( dirname( dirname( ABSPATH ) ) ), |
|
111 | + ] ); |
|
112 | 112 | foreach( (array) $configLocations as $location ) { |
113 | - if( !file_exists( $location . $configYaml ))continue; |
|
113 | + if( !file_exists( $location . $configYaml ) )continue; |
|
114 | 114 | return $location . $configYaml; |
115 | 115 | } |
116 | 116 | return $this->app->path( 'defaults.yml' ); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | public function setTimestamp( array $config, $timestamp = null ) |
147 | 147 | { |
148 | 148 | $timestamp || $timestamp = time(); |
149 | - $config['updated'] = $timestamp; |
|
149 | + $config[ 'updated' ] = $timestamp; |
|
150 | 150 | return $config; |
151 | 151 | } |
152 | 152 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | return Yaml::dump( $array, 13, 2 ); |
168 | 168 | } |
169 | 169 | catch( DumpException $e ) { |
170 | - error_log( print_r( $e->getMessage(), 1 )); |
|
170 | + error_log( print_r( $e->getMessage(), 1 ) ); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | { |
179 | 179 | return wp_parse_args( |
180 | 180 | $config, |
181 | - $this->parseYaml( file_get_contents( $this->app->path( 'defaults.yml' ))) |
|
181 | + $this->parseYaml( file_get_contents( $this->app->path( 'defaults.yml' ) ) ) |
|
182 | 182 | ); |
183 | 183 | } |
184 | 184 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $pattern = '/(\')((' . implode( '|', $strings ) . ')\(?.+\))(\')/'; |
193 | 193 | return stripslashes( |
194 | 194 | preg_replace_callback( $pattern, function( $matches ) { |
195 | - return str_replace( "''", "'", $matches[2] ); |
|
195 | + return str_replace( "''", "'", $matches[ 2 ] ); |
|
196 | 196 | }, $configString ) |
197 | 197 | ); |
198 | 198 | } |
@@ -207,10 +207,10 @@ discard block |
||
207 | 207 | } |
208 | 208 | catch( ParseException $e ) { |
209 | 209 | // http://api.symfony.com/3.2/Symfony/Component/Yaml/Exception/ParseException.html |
210 | - error_log( print_r( sprintf( 'Unable to parse the YAML string: %s', $e->getMessage() ), 1 )); |
|
211 | - error_log( print_r( $e->getParsedFile(), 1 )); |
|
212 | - error_log( print_r( $e->getParsedLine(), 1 )); |
|
213 | - error_log( print_r( $e->getSnippet(), 1 )); |
|
210 | + error_log( print_r( sprintf( 'Unable to parse the YAML string: %s', $e->getMessage() ), 1 ) ); |
|
211 | + error_log( print_r( $e->getParsedFile(), 1 ) ); |
|
212 | + error_log( print_r( $e->getParsedLine(), 1 ) ); |
|
213 | + error_log( print_r( $e->getSnippet(), 1 ) ); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | protected function shouldCompile( $configFile ) |
222 | 222 | { |
223 | - if( !file_exists( $configFile )) { |
|
223 | + if( !file_exists( $configFile ) ) { |
|
224 | 224 | return true; |
225 | 225 | } |
226 | 226 | $config = include $configFile; |