@@ -31,7 +31,9 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function init() |
| 33 | 33 | { |
| 34 | - if( empty( $this->app->config->{static::ID} ))return; |
|
| 34 | + if( empty( $this->app->config->{static::ID} )) { |
|
| 35 | + return; |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | $this->normalize( $this->app->config->{static::ID}, [ |
| 37 | 39 | 'post_types' => [], |
@@ -199,7 +201,8 @@ discard block |
||
| 199 | 201 | */ |
| 200 | 202 | protected function normalizeFields( array $fields, array $data, $parentId ) |
| 201 | 203 | { |
| 202 | - return array_map( function( $id, $field ) use( $parentId ) { |
|
| 204 | + return array_map( function( $id, $field ) use( $parentId ) |
|
| 205 | + { |
|
| 203 | 206 | $defaults = [ |
| 204 | 207 | 'attributes' => [], |
| 205 | 208 | 'class' => '', |
@@ -238,7 +241,9 @@ discard block |
||
| 238 | 241 | protected function normalizeValidation( array $validation, array $data, $parentId ) |
| 239 | 242 | { |
| 240 | 243 | foreach( ['messages', 'rules'] as $key ) { |
| 241 | - if( empty( $validation[$key] ))continue; |
|
| 244 | + if( empty( $validation[$key] )) { |
|
| 245 | + continue; |
|
| 246 | + } |
|
| 242 | 247 | foreach( $validation[$key] as $id => $value ) { |
| 243 | 248 | $validation[$key][$this->normalizeFieldName( $id, ['slug' => $id], $parentId )] = $value; |
| 244 | 249 | unset( $validation[$key][$id] ); |
@@ -254,8 +259,11 @@ discard block |
||
| 254 | 259 | { |
| 255 | 260 | $fields = &$metabox['fields']; |
| 256 | 261 | $depends = array_column( $fields, 'depends' ); |
| 257 | - array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) { |
|
| 258 | - if( empty( $value ))return; |
|
| 262 | + array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) |
|
| 263 | + { |
|
| 264 | + if( empty( $value )) { |
|
| 265 | + return; |
|
| 266 | + } |
|
| 259 | 267 | $dependency = array_search( $value, array_column( $fields, 'id' )); |
| 260 | 268 | $fields[$index]['attributes']['data-depends'] = $value; |
| 261 | 269 | if( !$this->getMetaValue( $fields[$dependency]['slug'], '', $metabox['slug'] )) { |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if( !function_exists( 'pollux_app' )) { |
| 4 | - function pollux_app() { |
|
| 4 | + function pollux_app() |
|
| 5 | + { |
|
| 5 | 6 | return GeminiLabs\Pollux\Application::getInstance(); |
| 6 | 7 | } |
| 7 | 8 | } |
@@ -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() ); |
@@ -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 ) { |
|
| 43 | + return array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) |
|
| 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 | } |