@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function init() |
40 | 40 | { |
41 | - if( !$this->canProceed() )return; |
|
41 | + if( !$this->canProceed() ) { |
|
42 | + return; |
|
43 | + } |
|
42 | 44 | |
43 | 45 | $this->normalize( $this->app->config->{static::ID} ); |
44 | 46 | |
@@ -123,7 +125,9 @@ discard block |
||
123 | 125 | */ |
124 | 126 | public function register() |
125 | 127 | { |
126 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
128 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
129 | + return; |
|
130 | + } |
|
127 | 131 | if( $this->app->gatekeeper->hasDependency( self::DEPENDENCY )) { |
128 | 132 | foreach( parent::register() as $metabox ) { |
129 | 133 | new RWMetaBox( $metabox, static::ID, $this ); |
@@ -168,7 +172,9 @@ discard block |
||
168 | 172 | */ |
169 | 173 | public function renderFooterScript() |
170 | 174 | { |
171 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
175 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
176 | + return; |
|
177 | + } |
|
172 | 178 | $this->app->render( 'settings/script', [ |
173 | 179 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
174 | 180 | 'hook' => $this->hook, |
@@ -216,7 +222,9 @@ discard block |
||
216 | 222 | { |
217 | 223 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
218 | 224 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
219 | - )return; |
|
225 | + ) { |
|
226 | + return; |
|
227 | + } |
|
220 | 228 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
221 | 229 | update_option( static::id(), $this->getDefaults() ); |
222 | 230 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
@@ -235,7 +243,8 @@ discard block |
||
235 | 243 | */ |
236 | 244 | protected function filterArrayByKey( array $array, $key ) |
237 | 245 | { |
238 | - return array_filter( $array, function( $value ) use( $key ) { |
|
246 | + return array_filter( $array, function( $value ) use( $key ) |
|
247 | + { |
|
239 | 248 | return !empty( $value[$key] ); |
240 | 249 | }); |
241 | 250 | } |
@@ -247,8 +256,10 @@ discard block |
||
247 | 256 | { |
248 | 257 | $metaboxes = $this->filterArrayByKey( $this->metaboxes, 'slug' ); |
249 | 258 | |
250 | - array_walk( $metaboxes, function( &$metabox ) { |
|
251 | - $fields = array_map( function( $field ) { |
|
259 | + array_walk( $metaboxes, function( &$metabox ) |
|
260 | + { |
|
261 | + $fields = array_map( function( $field ) |
|
262 | + { |
|
252 | 263 | $field = wp_parse_args( $field, ['std' => ''] ); |
253 | 264 | return [$field['slug'] => $field['std']]; |
254 | 265 | }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |
@@ -72,7 +72,8 @@ discard block |
||
72 | 72 | 'href' => '', |
73 | 73 | ]); |
74 | 74 | $atts['class'] = trim( $atts['class'] . ' button button-small' ); |
75 | - $attributes = array_reduce( array_keys( $atts ), function( $carry, $key ) use( $atts ) { |
|
75 | + $attributes = array_reduce( array_keys( $atts ), function( $carry, $key ) use( $atts ) |
|
76 | + { |
|
76 | 77 | return $carry . sprintf( ' %s="%s"', $key, $atts[$key] ); |
77 | 78 | }); |
78 | 79 | return sprintf( '<a%s>%s</a>', $attributes, $title ); |
@@ -151,7 +152,9 @@ discard block |
||
151 | 152 | protected function buildMessage( array $messages ) |
152 | 153 | { |
153 | 154 | foreach( $messages as $key => &$message ) { |
154 | - if( !is_wp_error( $message ))continue; |
|
155 | + if( !is_wp_error( $message )) { |
|
156 | + continue; |
|
157 | + } |
|
155 | 158 | $message = $message->get_error_message(); |
156 | 159 | } |
157 | 160 | return wpautop( implode( PHP_EOL . PHP_EOL, $messages )); |
@@ -65,7 +65,9 @@ discard block |
||
65 | 65 | { |
66 | 66 | if( get_current_screen()->id != sprintf( 'settings_page_%s', $this->app->id ) |
67 | 67 | || filter_input( INPUT_GET, 'action' ) != 'activate' |
68 | - )return; |
|
68 | + ) { |
|
69 | + return; |
|
70 | + } |
|
69 | 71 | $plugin = filter_input( INPUT_GET, 'plugin' ); |
70 | 72 | check_admin_referer( 'activate-plugin_' . $plugin ); |
71 | 73 | $result = activate_plugin( $plugin, null, is_network_admin(), true ); |
@@ -140,7 +142,9 @@ discard block |
||
140 | 142 | public function hasPendingDependencies() |
141 | 143 | { |
142 | 144 | foreach( static::DEPENDENCIES as $plugin => $data ) { |
143 | - if( !$this->isPluginDependency( $plugin ))continue; |
|
145 | + if( !$this->isPluginDependency( $plugin )) { |
|
146 | + continue; |
|
147 | + } |
|
144 | 148 | $this->isPluginActive( $plugin ); |
145 | 149 | $this->isPluginVersionValid( $plugin ); |
146 | 150 | } |
@@ -236,7 +240,9 @@ discard block |
||
236 | 240 | if( get_current_screen()->id != 'settings_page_pollux' |
237 | 241 | || $this->app->config->disable_config |
238 | 242 | || !$this->hasPendingDependencies() |
239 | - )return; |
|
243 | + ) { |
|
244 | + return; |
|
245 | + } |
|
240 | 246 | $message = sprintf( '<strong>%s:</strong> %s', |
241 | 247 | __( 'Pollux requires the latest version of the following plugins', 'pollux' ), |
242 | 248 | $this->getDependencyLinks() |
@@ -321,7 +327,8 @@ discard block |
||
321 | 327 | */ |
322 | 328 | protected function getDependencyLinks() |
323 | 329 | { |
324 | - return array_reduce( array_keys( $this->errors ), function( $carry, $plugin ) { |
|
330 | + return array_reduce( array_keys( $this->errors ), function( $carry, $plugin ) |
|
331 | + { |
|
325 | 332 | return $carry . $this->getPluginLink( $plugin ); |
326 | 333 | }); |
327 | 334 | } |
@@ -40,7 +40,9 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function filterWordPressFooter( $text ) |
42 | 42 | { |
43 | - if( $this->app->config->remove_wordpress_footer )return; |
|
43 | + if( $this->app->config->remove_wordpress_footer ) { |
|
44 | + return; |
|
45 | + } |
|
44 | 46 | return $text; |
45 | 47 | } |
46 | 48 | |
@@ -79,7 +81,9 @@ discard block |
||
79 | 81 | */ |
80 | 82 | public function removeDashboardWidgets() |
81 | 83 | { |
82 | - if( !$this->app->config->remove_dashboard_widgets )return; |
|
84 | + if( !$this->app->config->remove_dashboard_widgets ) { |
|
85 | + return; |
|
86 | + } |
|
83 | 87 | $widgets = apply_filters( 'pollux/dashoard/widgets', [ |
84 | 88 | 'dashboard_primary', |
85 | 89 | 'dashboard_quick_press', |
@@ -95,7 +99,9 @@ discard block |
||
95 | 99 | */ |
96 | 100 | public function removeWordPressMenu() |
97 | 101 | { |
98 | - if( !$this->app->config->remove_wordpress_menu )return; |
|
102 | + if( !$this->app->config->remove_wordpress_menu ) { |
|
103 | + return; |
|
104 | + } |
|
99 | 105 | global $wp_admin_bar; |
100 | 106 | $wp_admin_bar->remove_menu( 'wp-logo' ); |
101 | 107 | } |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function init() |
25 | 25 | { |
26 | - if( !$this->app->config->disable_posts )return; |
|
26 | + if( !$this->app->config->disable_posts ) { |
|
27 | + return; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | remove_action( 'welcome_panel', 'wp_welcome_panel' ); |
29 | 31 | |
@@ -46,7 +48,9 @@ discard block |
||
46 | 48 | { |
47 | 49 | if( !in_array(( new Helper )->getCurrentScreen()->pagenow, [ |
48 | 50 | 'edit.php', 'edit-tags.php', 'post-new.php', |
49 | - ]))return; |
|
51 | + ])) { |
|
52 | + return; |
|
53 | + } |
|
50 | 54 | |
51 | 55 | if( !filter_input_array( INPUT_GET, [ |
52 | 56 | 'post_type' => FILTER_DEFAULT, |
@@ -98,12 +102,17 @@ discard block |
||
98 | 102 | */ |
99 | 103 | public function modifyDashboardWidgets() |
100 | 104 | { |
101 | - if( !is_blog_admin() || !current_user_can( 'edit_posts' ))return; |
|
105 | + if( !is_blog_admin() || !current_user_can( 'edit_posts' )) { |
|
106 | + return; |
|
107 | + } |
|
102 | 108 | |
103 | 109 | global $wp_meta_boxes; |
104 | 110 | $widgets = &$wp_meta_boxes['dashboard']['normal']['core']; |
105 | - if( !isset( $widgets['dashboard_right_now']['callback'] ))return; |
|
106 | - $widgets['dashboard_right_now']['callback'] = function() { |
|
111 | + if( !isset( $widgets['dashboard_right_now']['callback'] )) { |
|
112 | + return; |
|
113 | + } |
|
114 | + $widgets['dashboard_right_now']['callback'] = function() |
|
115 | + { |
|
107 | 116 | ob_start(); |
108 | 117 | wp_dashboard_right_now(); |
109 | 118 | echo preg_replace( '/<li class="post-count">(.*?)<\/li>/', '', ob_get_clean() ); |
@@ -107,7 +107,9 @@ discard block |
||
107 | 107 | trailingslashit( dirname( dirname( ABSPATH ))), |
108 | 108 | ]); |
109 | 109 | foreach( (array) $configLocations as $location ) { |
110 | - if( !file_exists( $location . $configYaml ))continue; |
|
110 | + if( !file_exists( $location . $configYaml )) { |
|
111 | + continue; |
|
112 | + } |
|
111 | 113 | return $location . $configYaml; |
112 | 114 | } |
113 | 115 | return $this->app->path( 'defaults.yml' ); |
@@ -118,7 +120,8 @@ discard block |
||
118 | 120 | */ |
119 | 121 | public function normalizeArray( array $array ) |
120 | 122 | { |
121 | - array_walk( $array, function( &$value, $key ) { |
|
123 | + array_walk( $array, function( &$value, $key ) |
|
124 | + { |
|
122 | 125 | if( !is_numeric( $value ) && is_string( $value )) { |
123 | 126 | $value = $this->parseYaml( $value, $key ); |
124 | 127 | if( $this->parseError == $key ) { |
@@ -134,7 +137,8 @@ discard block |
||
134 | 137 | */ |
135 | 138 | public function normalizeYamlValues( array $array ) |
136 | 139 | { |
137 | - return array_map( function( $value ) { |
|
140 | + return array_map( function( $value ) |
|
141 | + { |
|
138 | 142 | return is_array( $value ) |
139 | 143 | ? $this->convertArrayToYaml( $value ) |
140 | 144 | : $value; |
@@ -191,7 +195,8 @@ discard block |
||
191 | 195 | } |
192 | 196 | $pattern = '/(\')((' . implode( '|', $strings ) . ')\(?.+\))(\')/'; |
193 | 197 | return stripslashes( |
194 | - preg_replace_callback( $pattern, function( $matches ) { |
|
198 | + preg_replace_callback( $pattern, function( $matches ) |
|
199 | + { |
|
195 | 200 | return str_replace( "''", "'", $matches[2] ); |
196 | 201 | }, $configString ) |
197 | 202 | ); |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | */ |
21 | 21 | protected function generateInstructions() |
22 | 22 | { |
23 | - $instructions = array_reduce( $this->getInstructionGroups(), function( $html, $metabox ) { |
|
23 | + $instructions = array_reduce( $this->getInstructionGroups(), function( $html, $metabox ) |
|
24 | + { |
|
24 | 25 | $fields = $this->getInstructionFields( $metabox ); |
25 | 26 | if( empty( $fields )) { |
26 | 27 | return $html; |
@@ -39,7 +40,8 @@ discard block |
||
39 | 40 | protected function getInstructionFields( $metabox ) |
40 | 41 | { |
41 | 42 | $skipFields = ['custom_html', 'divider', 'heading']; |
42 | - return array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox, $skipFields ) { |
|
43 | + return array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox, $skipFields ) |
|
44 | + { |
|
43 | 45 | return $this->validate( $field['condition'] ) && !in_array( $field['type'], $skipFields ) |
44 | 46 | ? $html . $this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ) . PHP_EOL |
45 | 47 | : $html; |
@@ -51,7 +53,8 @@ discard block |
||
51 | 53 | */ |
52 | 54 | protected function getInstructionGroups() |
53 | 55 | { |
54 | - return array_filter( $this->metaboxes, function( $metabox ) { |
|
56 | + return array_filter( $this->metaboxes, function( $metabox ) |
|
57 | + { |
|
55 | 58 | return $this->validate( $metabox['condition'] ) |
56 | 59 | && $this->hasPostType( $metabox ); |
57 | 60 | }); |
@@ -62,7 +65,9 @@ discard block |
||
62 | 65 | */ |
63 | 66 | protected function initInstructions() |
64 | 67 | { |
65 | - if( !$this->showInstructions() )return; |
|
68 | + if( !$this->showInstructions() ) { |
|
69 | + return; |
|
70 | + } |
|
66 | 71 | return [ |
67 | 72 | 'infodiv' => [ |
68 | 73 | 'context' => 'side', |
@@ -83,7 +88,8 @@ discard block |
||
83 | 88 | */ |
84 | 89 | protected function showInstructions() |
85 | 90 | { |
86 | - return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) { |
|
91 | + return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) |
|
92 | + { |
|
87 | 93 | return $this->show( false, $metabox ); |
88 | 94 | })) > 0 ); |
89 | 95 | } |
@@ -37,7 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function init() |
39 | 39 | { |
40 | - if( $this->app->config->disable_config )return; |
|
40 | + if( $this->app->config->disable_config ) { |
|
41 | + return; |
|
42 | + } |
|
41 | 43 | |
42 | 44 | add_action( 'admin_menu', [$this, 'registerPage'] ); |
43 | 45 | add_action( 'admin_menu', [$this, 'registerSetting'] ); |
@@ -107,7 +109,9 @@ discard block |
||
107 | 109 | { |
108 | 110 | if( filter_input( INPUT_GET, 'page' ) !== $this->app->id |
109 | 111 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
110 | - )return; |
|
112 | + ) { |
|
113 | + return; |
|
114 | + } |
|
111 | 115 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), static::id() )) { |
112 | 116 | delete_option( static::id() ); |
113 | 117 | $this->app->make( ConfigManager::class )->compile( true ); |