@@ -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'] ); |
@@ -106,7 +108,9 @@ discard block |
||
| 106 | 108 | { |
| 107 | 109 | if( filter_input( INPUT_GET, 'page' ) !== $this->app->id |
| 108 | 110 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
| 109 | - )return; |
|
| 111 | + ) { |
|
| 112 | + return; |
|
| 113 | + } |
|
| 110 | 114 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), static::id() )) { |
| 111 | 115 | delete_option( static::id() ); |
| 112 | 116 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
@@ -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 | - return array_map( function( $value ) { |
|
| 123 | + return array_map( function( $value ) |
|
| 124 | + { |
|
| 122 | 125 | return !is_numeric( $value ) && is_string( $value ) |
| 123 | 126 | ? $this->parseYaml( $value ) |
| 124 | 127 | : $value; |
@@ -130,7 +133,8 @@ discard block |
||
| 130 | 133 | */ |
| 131 | 134 | public function normalizeYamlValues( array $array ) |
| 132 | 135 | { |
| 133 | - return array_map( function( $value ) { |
|
| 136 | + return array_map( function( $value ) |
|
| 137 | + { |
|
| 134 | 138 | return is_array( $value ) |
| 135 | 139 | ? $this->convertArrayToYaml( $value ) |
| 136 | 140 | : $value; |
@@ -188,7 +192,8 @@ discard block |
||
| 188 | 192 | $strings = apply_filters( 'pollux/config/raw_strings', static::RAW_STRINGS ); |
| 189 | 193 | $pattern = '/(\')((' . implode( '|', $strings ) . ')\(?.+\))(\')/'; |
| 190 | 194 | return stripslashes( |
| 191 | - preg_replace_callback( $pattern, function( $matches ) { |
|
| 195 | + preg_replace_callback( $pattern, function( $matches ) |
|
| 196 | + { |
|
| 192 | 197 | return str_replace( "''", "'", $matches[2] ); |
| 193 | 198 | }, $configString ) |
| 194 | 199 | ); |
@@ -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 | } |
@@ -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_quick_press', |
| 85 | 89 | ]); |
@@ -94,7 +98,9 @@ discard block |
||
| 94 | 98 | */ |
| 95 | 99 | public function removeWordPressMenu() |
| 96 | 100 | { |
| 97 | - if( !$this->app->config->remove_wordpress_menu )return; |
|
| 101 | + if( !$this->app->config->remove_wordpress_menu ) { |
|
| 102 | + return; |
|
| 103 | + } |
|
| 98 | 104 | global $wp_admin_bar; |
| 99 | 105 | $wp_admin_bar->remove_menu( 'wp-logo' ); |
| 100 | 106 | } |
@@ -144,7 +150,8 @@ discard block |
||
| 144 | 150 | && $screen->pagenow == 'options-general.php' |
| 145 | 151 | && $this->app->gatekeeper->hasPendingDependencies() ) { |
| 146 | 152 | wp_enqueue_script( 'updates' ); |
| 147 | - add_filter( 'pollux/enqueue/js/localize/variables', function( $vars ) { |
|
| 153 | + add_filter( 'pollux/enqueue/js/localize/variables', function( $vars ) |
|
| 154 | + { |
|
| 148 | 155 | $vars['l10n'] = [ |
| 149 | 156 | 'pluginActivatingLabel' => __( 'Activating %s...', 'pollux' ), |
| 150 | 157 | 'pluginActivatedLabel' => __( '%s activated!', 'pollux' ), |
@@ -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 | } |