@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | public static $current; |
18 | 18 | |
19 | - public $hooks = []; |
|
19 | + public $hooks = [ ]; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * {@inheritdoc} |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | { |
26 | 26 | parent::init(); |
27 | 27 | |
28 | - add_action( 'wp_ajax_pollux/archives/featured/html', [$this, 'getFeaturedImageHtml'] ); |
|
29 | - add_action( 'pollux/archives/init', [$this, 'registerFeaturedImageMetaBox'] ); |
|
30 | - add_action( 'pollux/archives/editor', [$this, 'renderEditor'], 10, 2 ); |
|
31 | - add_action( 'wp_ajax_pollux/archives/featured', [$this, 'setFeaturedImage'] ); |
|
32 | - add_filter( 'pollux/archives/metabox/submit', [$this, 'filterSubmitMetaBox'] ); |
|
33 | - add_filter( 'pollux/archives/show/instructions', '__return_true' ); |
|
28 | + add_action( 'wp_ajax_pollux/archives/featured/html', [ $this, 'getFeaturedImageHtml' ] ); |
|
29 | + add_action( 'pollux/archives/init', [ $this, 'registerFeaturedImageMetaBox' ] ); |
|
30 | + add_action( 'pollux/archives/editor', [ $this, 'renderEditor' ], 10, 2 ); |
|
31 | + add_action( 'wp_ajax_pollux/archives/featured', [ $this, 'setFeaturedImage' ] ); |
|
32 | + add_filter( 'pollux/archives/metabox/submit', [ $this, 'filterSubmitMetaBox' ] ); |
|
33 | + add_filter( 'pollux/archives/show/instructions', '__return_true' ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | public function filterBeforeInstructions() |
41 | 41 | { |
42 | 42 | return sprintf( '<pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
43 | - array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) { |
|
44 | - return $instructions . $this->filterInstruction( null, ['slug' => $id], ['slug' => $this->getPostType()] ) . PHP_EOL; |
|
43 | + array_reduce( [ 'title', 'content', 'featured' ], function( $instructions, $id ) { |
|
44 | + return $instructions . $this->filterInstruction( null, [ 'slug' => $id ], [ 'slug' => $this->getPostType() ] ) . PHP_EOL; |
|
45 | 45 | }) |
46 | 46 | ); |
47 | 47 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function filterInstruction( $instruction, array $field, array $metabox ) |
55 | 55 | { |
56 | - return sprintf( "ArchiveMeta::%s('%s');", $metabox['slug'], $field['slug'] ); |
|
56 | + return sprintf( "ArchiveMeta::%s('%s');", $metabox[ 'slug' ], $field[ 'slug' ] ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function filterSubmitMetaBox( array $args ) |
64 | 64 | { |
65 | - $args[1] = __( 'Save Archive', 'pollux' ); |
|
65 | + $args[ 1 ] = __( 'Save Archive', 'pollux' ); |
|
66 | 66 | return $args; |
67 | 67 | } |
68 | 68 | |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function getFeaturedImageHtml() |
75 | 75 | { |
76 | - check_ajax_referer( sprintf( '%s-options', static::id() )); |
|
76 | + check_ajax_referer( sprintf( '%s-options', static::id() ) ); |
|
77 | 77 | static::$current = filter_input( INPUT_POST, 'post_type' ); |
78 | 78 | ob_start(); |
79 | - $this->renderFeaturedImageMetaBox( intval( filter_input( INPUT_POST, 'thumbnail_id' ))); |
|
79 | + $this->renderFeaturedImageMetaBox( intval( filter_input( INPUT_POST, 'thumbnail_id' ) ) ); |
|
80 | 80 | wp_send_json_success( ob_get_clean() ); |
81 | 81 | } |
82 | 82 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | public function register() |
99 | 99 | { |
100 | 100 | $screenId = ( new Helper )->getCurrentScreen()->id; |
101 | - if( in_array( $screenId, $this->hooks )) { |
|
101 | + if( in_array( $screenId, $this->hooks ) ) { |
|
102 | 102 | $this->hook = $screenId; |
103 | 103 | } |
104 | 104 | parent::register(); |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function registerFeaturedImageMetaBox() |
112 | 112 | { |
113 | - if( !current_user_can( 'upload_files' ))return; |
|
114 | - add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [$this, 'renderFeaturedImageMetaBox'], null, 'side', 'low' ); |
|
113 | + if( !current_user_can( 'upload_files' ) )return; |
|
114 | + add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [ $this, 'renderFeaturedImageMetaBox' ], null, 'side', 'low' ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | public function registerPage() |
122 | 122 | { |
123 | 123 | foreach( $this->getPostTypesWithArchive() as $type => $page ) { |
124 | - $labels = get_post_type_labels( get_post_type_object( $type )); |
|
125 | - $this->hooks[$type] = call_user_func_array( 'add_submenu_page', $this->filter( 'page', [ |
|
124 | + $labels = get_post_type_labels( get_post_type_object( $type ) ); |
|
125 | + $this->hooks[ $type ] = call_user_func_array( 'add_submenu_page', $this->filter( 'page', [ |
|
126 | 126 | $page, |
127 | 127 | sprintf( _x( '%s Archive', 'post archive', 'pollux' ), $labels->singular_name ), |
128 | 128 | sprintf( _x( '%s Archive', 'post archive', 'pollux' ), $labels->singular_name ), |
129 | 129 | 'edit_theme_options', |
130 | 130 | sprintf( '%s_archive', $type ), |
131 | - [$this, 'renderPage'], |
|
132 | - ])); |
|
131 | + [ $this, 'renderPage' ], |
|
132 | + ] ) ); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | 'resize' => false, |
151 | 151 | 'wp_autoresize_on' => true, |
152 | 152 | ], |
153 | - ]); |
|
153 | + ] ); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function renderFeaturedImageMetaBox( $imageId = null ) |
161 | 161 | { |
162 | - if( !is_numeric( $imageId )) { |
|
162 | + if( !is_numeric( $imageId ) ) { |
|
163 | 163 | $imageId = ArchiveMeta::get( 'featured', -1, $this->getPostType() ); |
164 | 164 | } |
165 | - $imageSize = isset( wp_get_additional_image_sizes()['post-thumbnail'] ) |
|
165 | + $imageSize = isset( wp_get_additional_image_sizes()[ 'post-thumbnail' ] ) |
|
166 | 166 | ? 'post-thumbnail' |
167 | - : [266, 266]; |
|
167 | + : [ 266, 266 ]; |
|
168 | 168 | $thumbnail = get_post( $imageId ) |
169 | 169 | ? wp_get_attachment_image( $imageId, $imageSize ) |
170 | 170 | : __( 'Set Featured Image', 'pollux' ); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | 'post_type' => $this->getPostType(), |
177 | 177 | 'remove_image' => __( 'Remove featured image', 'pollux' ), |
178 | 178 | 'thumbnail' => $thumbnail, |
179 | - ]); |
|
179 | + ] ); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | public function renderPage() |
187 | 187 | { |
188 | 188 | $type = $this->getPostType(); |
189 | - if( empty( $type ))return; |
|
190 | - $labels = get_post_type_labels( get_post_type_object( $type )); |
|
189 | + if( empty( $type ) )return; |
|
190 | + $labels = get_post_type_labels( get_post_type_object( $type ) ); |
|
191 | 191 | $this->app->render( 'archive/index', [ |
192 | 192 | 'columns' => get_current_screen()->get_columns(), |
193 | 193 | 'content' => ArchiveMeta::get( 'content', '', $type ), |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | 'id' => static::id(), |
196 | 196 | 'post_type' => $type, |
197 | 197 | 'title' => ArchiveMeta::get( 'title', '', $type ), |
198 | - ]); |
|
198 | + ] ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | protected function getDefaults() |
205 | 205 | { |
206 | - return []; |
|
206 | + return [ ]; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | protected function getPostType() |
213 | 213 | { |
214 | 214 | $type = array_search( $this->hook, $this->hooks ); |
215 | - if( !empty( $type ) && is_string( $type )) { |
|
215 | + if( !empty( $type ) && is_string( $type ) ) { |
|
216 | 216 | static::$current = $type; |
217 | 217 | } |
218 | 218 | return static::$current; |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | { |
226 | 226 | $types = array_map( function( $value ) { |
227 | 227 | return sprintf( 'edit.php?post_type=%s', $value ); |
228 | - }, get_post_types( ['has_archive' => 1] )); |
|
229 | - return array_merge( $types, ['post' => 'edit.php'] ); |
|
228 | + }, get_post_types( [ 'has_archive' => 1 ] ) ); |
|
229 | + return array_merge( $types, [ 'post' => 'edit.php' ] ); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -40,7 +40,8 @@ discard block |
||
40 | 40 | public function filterBeforeInstructions() |
41 | 41 | { |
42 | 42 | return sprintf( '<pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
43 | - array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) { |
|
43 | + array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) |
|
44 | + { |
|
44 | 45 | return $instructions . $this->filterInstruction( null, ['slug' => $id], ['slug' => $this->getPostType()] ) . PHP_EOL; |
45 | 46 | }) |
46 | 47 | ); |
@@ -110,7 +111,9 @@ discard block |
||
110 | 111 | */ |
111 | 112 | public function registerFeaturedImageMetaBox() |
112 | 113 | { |
113 | - if( !current_user_can( 'upload_files' ))return; |
|
114 | + if( !current_user_can( 'upload_files' )) { |
|
115 | + return; |
|
116 | + } |
|
114 | 117 | add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [$this, 'renderFeaturedImageMetaBox'], null, 'side', 'low' ); |
115 | 118 | } |
116 | 119 | |
@@ -186,7 +189,9 @@ discard block |
||
186 | 189 | public function renderPage() |
187 | 190 | { |
188 | 191 | $type = $this->getPostType(); |
189 | - if( empty( $type ))return; |
|
192 | + if( empty( $type )) { |
|
193 | + return; |
|
194 | + } |
|
190 | 195 | $labels = get_post_type_labels( get_post_type_object( $type )); |
191 | 196 | $this->app->render( 'archive/index', [ |
192 | 197 | 'columns' => get_current_screen()->get_columns(), |
@@ -223,7 +228,8 @@ discard block |
||
223 | 228 | */ |
224 | 229 | protected function getPostTypesWithArchive() |
225 | 230 | { |
226 | - $types = array_map( function( $value ) { |
|
231 | + $types = array_map( function( $value ) |
|
232 | + { |
|
227 | 233 | return sprintf( 'edit.php?post_type=%s', $value ); |
228 | 234 | }, get_post_types( ['has_archive' => 1] )); |
229 | 235 | return array_merge( $types, ['post' => 'edit.php'] ); |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function filterPluginLinks( array $links ) |
33 | 33 | { |
34 | - $settings_url = admin_url( sprintf( 'options-general.php?page=%s', $this->app->id )); |
|
35 | - $links[] = sprintf( '<a href="%s">%s</a>', $settings_url, __( 'Settings', 'pollux' )); |
|
34 | + $settings_url = admin_url( sprintf( 'options-general.php?page=%s', $this->app->id ) ); |
|
35 | + $links[ ] = sprintf( '<a href="%s">%s</a>', $settings_url, __( 'Settings', 'pollux' ) ); |
|
36 | 36 | return $links; |
37 | 37 | } |
38 | 38 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function filterWordPressFooter( $text ) |
44 | 44 | { |
45 | - if( $this->app->config['remove_wordpress_footer'] )return; |
|
45 | + if( $this->app->config[ 'remove_wordpress_footer' ] )return; |
|
46 | 46 | return $text; |
47 | 47 | } |
48 | 48 | |
@@ -60,17 +60,17 @@ discard block |
||
60 | 60 | |
61 | 61 | wp_enqueue_style( 'pollux/main.css', |
62 | 62 | $this->app->url( 'assets/main.css' ), |
63 | - apply_filters( 'pollux/enqueue/css/deps', [] ), |
|
63 | + apply_filters( 'pollux/enqueue/css/deps', [ ] ), |
|
64 | 64 | $this->app->version |
65 | 65 | ); |
66 | 66 | wp_enqueue_script( 'pollux/main.js', |
67 | 67 | $this->app->url( 'assets/main.js' ), |
68 | - apply_filters( 'pollux/enqueue/js/deps', [] ), |
|
68 | + apply_filters( 'pollux/enqueue/js/deps', [ ] ), |
|
69 | 69 | $this->app->version |
70 | 70 | ); |
71 | 71 | wp_localize_script( 'pollux/main.js', |
72 | 72 | apply_filters( 'pollux/enqueue/js/localize/name', $this->app->id ), |
73 | - apply_filters( 'pollux/enqueue/js/localize/variables', [] ) |
|
73 | + apply_filters( 'pollux/enqueue/js/localize/variables', [ ] ) |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | __( 'Pollux', 'pollux' ), |
87 | 87 | 'manage_options', |
88 | 88 | $this->app->id, |
89 | - [$this, 'renderPage'] |
|
89 | + [ $this, 'renderPage' ] |
|
90 | 90 | ); |
91 | 91 | } |
92 | 92 | |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function removeDashboardWidgets() |
98 | 98 | { |
99 | - if( !$this->app->config['remove_dashboard_widgets'] )return; |
|
99 | + if( !$this->app->config[ 'remove_dashboard_widgets' ] )return; |
|
100 | 100 | $widgets = apply_filters( 'pollux/dashoard/widgets', [ |
101 | 101 | 'dashboard_quick_press', |
102 | - ]); |
|
102 | + ] ); |
|
103 | 103 | foreach( $widgets as $widget ) { |
104 | 104 | remove_meta_box( $widget, 'dashboard', 'normal' ); |
105 | 105 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function removeWordPressMenu() |
113 | 113 | { |
114 | - if( !$this->app->config['remove_wordpress_menu'] )return; |
|
114 | + if( !$this->app->config[ 'remove_wordpress_menu' ] )return; |
|
115 | 115 | global $wp_admin_bar; |
116 | 116 | $wp_admin_bar->remove_menu( 'wp-logo' ); |
117 | 117 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $this->app->render( 'index', [ |
126 | 126 | 'heading' => __( 'Pollux Settings', 'pollux' ), |
127 | 127 | 'id' => $this->hook, |
128 | - ]); |
|
128 | + ] ); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function registerArchiveAssets( WP_Screen $screen ) |
135 | 135 | { |
136 | - if(( new Helper )->endsWith( '_archive', $screen->id ) && $screen->pagenow == 'edit.php' ) { |
|
136 | + if( ( new Helper )->endsWith( '_archive', $screen->id ) && $screen->pagenow == 'edit.php' ) { |
|
137 | 137 | wp_enqueue_script( 'common' ); |
138 | 138 | wp_enqueue_script( 'editor-expand' ); |
139 | 139 | wp_enqueue_script( 'post' ); |
@@ -153,12 +153,12 @@ discard block |
||
153 | 153 | if( $screen->id == 'settings_page_pollux' && $screen->pagenow == 'options-general.php' ) { |
154 | 154 | wp_enqueue_style( 'pollux/codemirror.css', |
155 | 155 | $this->app->url( 'assets/codemirror.css' ), |
156 | - [], |
|
156 | + [ ], |
|
157 | 157 | $this->app->version |
158 | 158 | ); |
159 | 159 | wp_enqueue_script( 'pollux/codemirror.js', |
160 | 160 | $this->app->url( 'assets/codemirror.js' ), |
161 | - ['pollux/main.js'], |
|
161 | + [ 'pollux/main.js' ], |
|
162 | 162 | $this->app->version |
163 | 163 | ); |
164 | 164 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | protected function registerSettingsAssets( WP_Screen $screen ) |
171 | 171 | { |
172 | - if( $screen->id == sprintf( 'toplevel_page_%s', Settings::id() )) { |
|
172 | + if( $screen->id == sprintf( 'toplevel_page_%s', Settings::id() ) ) { |
|
173 | 173 | wp_enqueue_script( 'common' ); |
174 | 174 | wp_enqueue_script( 'postbox' ); |
175 | 175 | wp_enqueue_script( 'wp-lists' ); |
@@ -41,24 +41,24 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function init() |
43 | 43 | { |
44 | - if( empty( $this->app->config[static::ID] ))return; |
|
45 | - if( is_bool( $this->app->config[static::ID] )) { |
|
46 | - $this->app->config[static::ID] = []; |
|
44 | + if( empty( $this->app->config[ static::ID ] ) )return; |
|
45 | + if( is_bool( $this->app->config[ static::ID ] ) ) { |
|
46 | + $this->app->config[ static::ID ] = [ ]; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | // @todo: run GateKeeper to check dependencies and capability (make sure it it run on the correct hook!) |
50 | 50 | // if( !is_plugin_active( 'meta-box/meta-box.php' ))return; |
51 | 51 | |
52 | - $this->normalize( $this->app->config[static::ID] ); |
|
52 | + $this->normalize( $this->app->config[ static::ID ] ); |
|
53 | 53 | |
54 | - add_action( 'pollux/'.static::ID.'/init', [$this, 'addSubmitMetaBox'] ); |
|
55 | - add_action( 'current_screen', [$this, 'register'] ); |
|
56 | - add_action( 'admin_menu', [$this, 'registerPage'] ); |
|
57 | - add_action( 'admin_menu', [$this, 'registerSetting'] ); |
|
58 | - add_action( 'pollux/'.static::ID.'/init', [$this, 'reset'] ); |
|
59 | - add_action( 'admin_print_footer_scripts', [$this, 'renderFooterScript'] ); |
|
60 | - add_filter( 'pollux/'.static::ID.'/instruction', [$this, 'filterInstruction'], 10, 3 ); |
|
61 | - add_filter( 'pollux/'.static::ID.'/before/instructions', [$this, 'filterBeforeInstructions'] ); |
|
54 | + add_action( 'pollux/' . static::ID . '/init', [ $this, 'addSubmitMetaBox' ] ); |
|
55 | + add_action( 'current_screen', [ $this, 'register' ] ); |
|
56 | + add_action( 'admin_menu', [ $this, 'registerPage' ] ); |
|
57 | + add_action( 'admin_menu', [ $this, 'registerSetting' ] ); |
|
58 | + add_action( 'pollux/' . static::ID . '/init', [ $this, 'reset' ] ); |
|
59 | + add_action( 'admin_print_footer_scripts', [ $this, 'renderFooterScript' ] ); |
|
60 | + add_filter( 'pollux/' . static::ID . '/instruction', [ $this, 'filterInstruction' ], 10, 3 ); |
|
61 | + add_filter( 'pollux/' . static::ID . '/before/instructions', [ $this, 'filterBeforeInstructions' ] ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | call_user_func_array( 'add_meta_box', $this->filter( 'metabox/submit', [ |
71 | 71 | 'submitdiv', |
72 | 72 | __( 'Save Settings', 'pollux' ), |
73 | - [$this, 'renderSubmitMetaBox'], |
|
73 | + [ $this, 'renderSubmitMetaBox' ], |
|
74 | 74 | $this->hook, |
75 | 75 | 'side', |
76 | 76 | 'high', |
77 | - ])); |
|
77 | + ] ) ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function filterInstruction( $instruction, array $field, array $metabox ) |
95 | 95 | { |
96 | - return sprintf( "SiteMeta::%s('%s');", $metabox['slug'], $field['slug'] ); |
|
96 | + return sprintf( "SiteMeta::%s('%s');", $metabox[ 'slug' ], $field[ 'slug' ] ); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function filterSavedSettings( $settings ) |
105 | 105 | { |
106 | - if( is_null( $settings )) { |
|
107 | - $settings = []; |
|
106 | + if( is_null( $settings ) ) { |
|
107 | + $settings = [ ]; |
|
108 | 108 | } |
109 | - return $this->filter( 'save', array_merge( $this->getSettings(), $settings )); |
|
109 | + return $this->filter( 'save', array_merge( $this->getSettings(), $settings ) ); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -126,14 +126,14 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function register() |
128 | 128 | { |
129 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
129 | + if( ( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
130 | 130 | foreach( parent::register() as $metabox ) { |
131 | 131 | new RWMetaBox( $metabox, static::ID, $this ); |
132 | 132 | } |
133 | 133 | add_screen_option( 'layout_columns', [ |
134 | 134 | 'max' => 2, |
135 | 135 | 'default' => 2, |
136 | - ]); |
|
136 | + ] ); |
|
137 | 137 | $this->action( 'init' ); |
138 | 138 | } |
139 | 139 | |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | __( 'Site Settings', 'pollux' ), |
149 | 149 | 'edit_theme_options', |
150 | 150 | static::id(), |
151 | - [$this, 'renderPage'], |
|
151 | + [ $this, 'renderPage' ], |
|
152 | 152 | 'dashicons-screenoptions', |
153 | 153 | 1313 |
154 | - ])); |
|
154 | + ] ) ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function registerSetting() |
162 | 162 | { |
163 | - register_setting( static::id(), static::id(), [$this, 'filterSavedSettings'] ); |
|
163 | + register_setting( static::id(), static::id(), [ $this, 'filterSavedSettings' ] ); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | */ |
170 | 170 | public function renderFooterScript() |
171 | 171 | { |
172 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
172 | + if( ( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
173 | 173 | $this->app->render( 'settings/script', [ |
174 | 174 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
175 | 175 | 'hook' => $this->hook, |
176 | 176 | 'id' => static::id(), |
177 | - ]); |
|
177 | + ] ); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | 'columns' => get_current_screen()->get_columns(), |
188 | 188 | 'heading' => __( 'Site Settings', 'pollux' ), |
189 | 189 | 'id' => static::id(), |
190 | - ]); |
|
190 | + ] ); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | ]; |
205 | 205 | $this->app->render( 'settings/submit', [ |
206 | 206 | 'reset' => __( 'Reset all', 'pollux' ), |
207 | - 'reset_url' => esc_url( add_query_arg( $query, admin_url( $pagenow ))), |
|
207 | + 'reset_url' => esc_url( add_query_arg( $query, admin_url( $pagenow ) ) ), |
|
208 | 208 | 'submit' => get_submit_button( __( 'Save', 'pollux' ), 'primary', 'submit', false ), |
209 | - ]); |
|
209 | + ] ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -218,15 +218,15 @@ discard block |
||
218 | 218 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
219 | 219 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
220 | 220 | )return; |
221 | - if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
|
221 | + if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook ) ) { |
|
222 | 222 | update_option( static::id(), $this->getDefaults() ); |
223 | 223 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
224 | 224 | } |
225 | 225 | else { |
226 | - add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' )); |
|
226 | + add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' ) ); |
|
227 | 227 | } |
228 | 228 | set_transient( 'settings_errors', get_settings_errors(), 30 ); |
229 | - wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() )); |
|
229 | + wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() ) ); |
|
230 | 230 | exit; |
231 | 231 | } |
232 | 232 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | protected function filterArrayByKey( array $array, $key ) |
238 | 238 | { |
239 | 239 | return array_filter( $array, function( $value ) use( $key ) { |
240 | - return !empty( $value[$key] ); |
|
240 | + return !empty( $value[ $key ] ); |
|
241 | 241 | }); |
242 | 242 | } |
243 | 243 | |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | |
251 | 251 | array_walk( $metaboxes, function( &$metabox ) { |
252 | 252 | $fields = array_map( function( $field ) { |
253 | - $field = wp_parse_args( $field, ['std' => ''] ); |
|
254 | - return [$field['slug'] => $field['std']]; |
|
255 | - }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |
|
253 | + $field = wp_parse_args( $field, [ 'std' => '' ] ); |
|
254 | + return [ $field[ 'slug' ] => $field[ 'std' ] ]; |
|
255 | + }, $this->filterArrayByKey( $metabox[ 'fields' ], 'slug' ) ); |
|
256 | 256 | $metabox = [ |
257 | - $metabox['slug'] => call_user_func_array( 'array_merge', $fields ), |
|
257 | + $metabox[ 'slug' ] => call_user_func_array( 'array_merge', $fields ), |
|
258 | 258 | ]; |
259 | 259 | }); |
260 | 260 | return call_user_func_array( 'array_merge', $metaboxes ); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | protected function normalizeFieldName( $name, array $data, $parentId ) |
274 | 274 | { |
275 | - return sprintf( '%s[%s][%s]', static::id(), $parentId, $data['slug'] ); |
|
275 | + return sprintf( '%s[%s][%s]', static::id(), $parentId, $data[ 'slug' ] ); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -41,7 +41,9 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function init() |
43 | 43 | { |
44 | - if( empty( $this->app->config[static::ID] ))return; |
|
44 | + if( empty( $this->app->config[static::ID] )) { |
|
45 | + return; |
|
46 | + } |
|
45 | 47 | if( is_bool( $this->app->config[static::ID] )) { |
46 | 48 | $this->app->config[static::ID] = []; |
47 | 49 | } |
@@ -126,7 +128,9 @@ discard block |
||
126 | 128 | */ |
127 | 129 | public function register() |
128 | 130 | { |
129 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
131 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
132 | + return; |
|
133 | + } |
|
130 | 134 | foreach( parent::register() as $metabox ) { |
131 | 135 | new RWMetaBox( $metabox, static::ID, $this ); |
132 | 136 | } |
@@ -169,7 +173,9 @@ discard block |
||
169 | 173 | */ |
170 | 174 | public function renderFooterScript() |
171 | 175 | { |
172 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
176 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
177 | + return; |
|
178 | + } |
|
173 | 179 | $this->app->render( 'settings/script', [ |
174 | 180 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
175 | 181 | 'hook' => $this->hook, |
@@ -217,7 +223,9 @@ discard block |
||
217 | 223 | { |
218 | 224 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
219 | 225 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
220 | - )return; |
|
226 | + ) { |
|
227 | + return; |
|
228 | + } |
|
221 | 229 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
222 | 230 | update_option( static::id(), $this->getDefaults() ); |
223 | 231 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
@@ -236,7 +244,8 @@ discard block |
||
236 | 244 | */ |
237 | 245 | protected function filterArrayByKey( array $array, $key ) |
238 | 246 | { |
239 | - return array_filter( $array, function( $value ) use( $key ) { |
|
247 | + return array_filter( $array, function( $value ) use( $key ) |
|
248 | + { |
|
240 | 249 | return !empty( $value[$key] ); |
241 | 250 | }); |
242 | 251 | } |
@@ -248,8 +257,10 @@ discard block |
||
248 | 257 | { |
249 | 258 | $metaboxes = $this->filterArrayByKey( $this->metaboxes, 'slug' ); |
250 | 259 | |
251 | - array_walk( $metaboxes, function( &$metabox ) { |
|
252 | - $fields = array_map( function( $field ) { |
|
260 | + array_walk( $metaboxes, function( &$metabox ) |
|
261 | + { |
|
262 | + $fields = array_map( function( $field ) |
|
263 | + { |
|
253 | 264 | $field = wp_parse_args( $field, ['std' => ''] ); |
254 | 265 | return [$field['slug'] => $field['std']]; |
255 | 266 | }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | |
31 | 31 | public function __construct() |
32 | 32 | { |
33 | - $this->file = realpath( dirname( dirname( __FILE__ )) . '/pollux.php' ); |
|
34 | - $this->gatekeeper = new GateKeeper( plugin_basename( $this->file )); |
|
33 | + $this->file = realpath( dirname( dirname( __FILE__ ) ) . '/pollux.php' ); |
|
34 | + $this->gatekeeper = new GateKeeper( plugin_basename( $this->file ) ); |
|
35 | 35 | |
36 | 36 | $data = get_file_data( $this->file, array( |
37 | 37 | 'id' => 'Text Domain', |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | $basename = plugin_basename( $this->file ); |
56 | 56 | $controller = $this->make( 'Controller' ); |
57 | 57 | |
58 | - add_action( 'admin_enqueue_scripts', array( $controller, 'registerAssets' )); |
|
59 | - add_action( 'admin_menu', array( $controller, 'registerPage' )); |
|
60 | - add_action( 'admin_init', array( $controller, 'removeDashboardWidgets' )); |
|
61 | - add_action( 'wp_before_admin_bar_render', array( $controller, 'removeWordPressMenu' )); |
|
62 | - add_filter( "plugin_action_links_{$basename}", array( $controller, 'filterPluginLinks' )); |
|
63 | - add_filter( 'admin_footer_text', array( $controller, 'filterWordPressFooter' )); |
|
58 | + add_action( 'admin_enqueue_scripts', array( $controller, 'registerAssets' ) ); |
|
59 | + add_action( 'admin_menu', array( $controller, 'registerPage' ) ); |
|
60 | + add_action( 'admin_init', array( $controller, 'removeDashboardWidgets' ) ); |
|
61 | + add_action( 'wp_before_admin_bar_render', array( $controller, 'removeWordPressMenu' ) ); |
|
62 | + add_filter( "plugin_action_links_{$basename}", array( $controller, 'filterPluginLinks' ) ); |
|
63 | + add_filter( 'admin_footer_text', array( $controller, 'filterWordPressFooter' ) ); |
|
64 | 64 | |
65 | 65 | // Disallow indexing of the site on non-production environments |
66 | 66 | if( !$this->environment( 'production' ) && !is_admin() ) { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | public function environment( $checkFor = '' ) |
76 | 76 | { |
77 | 77 | $environment = defined( 'WP_ENV' ) ? WP_ENV : 'production'; |
78 | - if( !empty( $checkFor )) { |
|
78 | + if( !empty( $checkFor ) ) { |
|
79 | 79 | return $environment == $checkFor; |
80 | 80 | } |
81 | 81 | return $environment; |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function onActivation() |
88 | 88 | { |
89 | - if( !get_option( Settings::id() )) { |
|
90 | - update_option( Settings::id(), [] ); |
|
89 | + if( !get_option( Settings::id() ) ) { |
|
90 | + update_option( Settings::id(), [ ] ); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | * @param string $view |
112 | 112 | * @return bool |
113 | 113 | */ |
114 | - public function render( $view, array $data = [] ) |
|
114 | + public function render( $view, array $data = [ ] ) |
|
115 | 115 | { |
116 | 116 | $file = apply_filters( 'pollux/views/file', |
117 | - $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ))), |
|
117 | + $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ) ) ), |
|
118 | 118 | $view, |
119 | 119 | $data |
120 | 120 | ); |
121 | - if( file_exists( $file )) { |
|
121 | + if( file_exists( $file ) ) { |
|
122 | 122 | extract( $data ); |
123 | 123 | return include $file; |
124 | 124 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function url( $path = '' ) |
133 | 133 | { |
134 | - return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' )); |
|
134 | + return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' ) ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | { |
142 | 142 | Facade::clearResolvedInstances(); |
143 | 143 | Facade::setFacadeApplication( $this ); |
144 | - $this->config = ( new Config( $this ))->get(); |
|
144 | + $this->config = ( new Config( $this ) )->get(); |
|
145 | 145 | $this->registerAliases(); |
146 | 146 | $classNames = array( |
147 | 147 | 'MetaBox\MetaBox', |
@@ -36,8 +36,8 @@ |
||
36 | 36 | $data = wp_parse_args( $data, $defaults ); |
37 | 37 | foreach( $defaults as $key => $value ) { |
38 | 38 | $method = ( new Helper )->buildMethodName( $key, 'normalize' ); |
39 | - if( method_exists( $this, $method )) { |
|
40 | - $data[$key] = $this->$method( $data[$key], $data, $id ); |
|
39 | + if( method_exists( $this, $method ) ) { |
|
40 | + $data[ $key ] = $this->$method( $data[ $key ], $data, $id ); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | return $data; |