@@ -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 )); |
@@ -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() ); |
@@ -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 ); |
@@ -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', 'taxonomy']; |
| 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 | } |
@@ -108,7 +108,8 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function normalizeArray( array $array ) |
| 110 | 110 | { |
| 111 | - array_walk( $array, function( &$value, $key ) { |
|
| 111 | + array_walk( $array, function( &$value, $key ) |
|
| 112 | + { |
|
| 112 | 113 | if( !is_numeric( $value ) && is_string( $value )) { |
| 113 | 114 | $value = $this->parseYaml( $value, $key ); |
| 114 | 115 | if( $this->parseError == $key ) { |
@@ -124,7 +125,8 @@ discard block |
||
| 124 | 125 | */ |
| 125 | 126 | public function normalizeYamlValues( array $array ) |
| 126 | 127 | { |
| 127 | - return array_map( function( $value ) { |
|
| 128 | + return array_map( function( $value ) |
|
| 129 | + { |
|
| 128 | 130 | return is_array( $value ) |
| 129 | 131 | ? $this->convertArrayToYaml( $value ) |
| 130 | 132 | : $value; |
@@ -181,7 +183,8 @@ discard block |
||
| 181 | 183 | } |
| 182 | 184 | $pattern = '/(\')((' . implode( '|', $strings ) . ')\(?.+\))(\')/'; |
| 183 | 185 | return stripslashes( |
| 184 | - preg_replace_callback( $pattern, function( $matches ) { |
|
| 186 | + preg_replace_callback( $pattern, function( $matches ) |
|
| 187 | + { |
|
| 185 | 188 | return str_replace( "''", "'", $matches[2] ); |
| 186 | 189 | }, $configString ) |
| 187 | 190 | ); |
@@ -55,7 +55,8 @@ |
||
| 55 | 55 | if( !empty( $field['multiple'] ) && $field['id'] == substr( $field['field_name'], 0, -2 )) { |
| 56 | 56 | $parts = array_filter( explode( '-', $field['id'] )); |
| 57 | 57 | $first = array_shift( $parts ); |
| 58 | - $field['field_name'] = array_reduce( $parts, function( $carry, $part ) { |
|
| 58 | + $field['field_name'] = array_reduce( $parts, function( $carry, $part ) |
|
| 59 | + { |
|
| 59 | 60 | return sprintf( '%s[%s]', $carry, $part ); |
| 60 | 61 | }, $first ) . '[]'; |
| 61 | 62 | } |
@@ -3,7 +3,8 @@ |
||
| 3 | 3 | /** |
| 4 | 4 | * Compatibility with Give WP plugin |
| 5 | 5 | */ |
| 6 | -add_filter( 'give_load_admin_scripts', function( $is_admin_page, $hook ) { |
|
| 6 | +add_filter( 'give_load_admin_scripts', function( $is_admin_page, $hook ) |
|
| 7 | +{ |
|
| 7 | 8 | $needle = sprintf( '_page_%s', filter_input( INPUT_GET, 'page' )); |
| 8 | 9 | return substr( $hook, - strlen( $needle )) !== $needle |
| 9 | 10 | ? $is_admin_page |
@@ -55,7 +55,8 @@ discard block |
||
| 55 | 55 | $basename = plugin_basename( $this->file ); |
| 56 | 56 | $controller = $this->make( 'Controller' ); |
| 57 | 57 | |
| 58 | - add_action( 'plugins_loaded', function() { |
|
| 58 | + add_action( 'plugins_loaded', function() |
|
| 59 | + { |
|
| 59 | 60 | $this->bootstrap(); |
| 60 | 61 | }); |
| 61 | 62 | add_action( 'admin_enqueue_scripts', array( $controller, 'registerAssets' )); |
@@ -100,7 +101,9 @@ discard block |
||
| 100 | 101 | trailingslashit( dirname( dirname( ABSPATH ))), |
| 101 | 102 | ]); |
| 102 | 103 | foreach( (array) $locations as $location ) { |
| 103 | - if( !file_exists( $location . $filename ))continue; |
|
| 104 | + if( !file_exists( $location . $filename )) { |
|
| 105 | + continue; |
|
| 106 | + } |
|
| 104 | 107 | return $location . $filename; |
| 105 | 108 | } |
| 106 | 109 | return null; |
@@ -140,7 +143,9 @@ discard block |
||
| 140 | 143 | $view, |
| 141 | 144 | $data |
| 142 | 145 | ); |
| 143 | - if( !file_exists( $file ))return; |
|
| 146 | + if( !file_exists( $file )) { |
|
| 147 | + return; |
|
| 148 | + } |
|
| 144 | 149 | extract( $data ); |
| 145 | 150 | include $file; |
| 146 | 151 | } |