@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | $method = strtolower( $name ); |
| 31 | 31 | $status = substr( $method, 3 ); |
| 32 | - if( 'add' == substr( $method, 0, 3 ) && in_array( $status, ['error', 'info', 'success', 'warning'] )) { |
|
| 33 | - return call_user_func_array( [$this, 'addNotice'], array_merge( [$status], $args )); |
|
| 32 | + if( 'add' == substr( $method, 0, 3 ) && in_array( $status, ['error', 'info', 'success', 'warning'] ) ) { |
|
| 33 | + return call_user_func_array( [$this, 'addNotice'], array_merge( [$status], $args ) ); |
|
| 34 | 34 | } |
| 35 | - throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name )); |
|
| 35 | + throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name ) ); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public function __get( $property ) |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | if( $property == 'all' ) { |
| 41 | 41 | return $this->app->notices; |
| 42 | 42 | } |
| 43 | - throw new Exception( sprintf( 'Not a valid property: %s', $property )); |
|
| 43 | + throw new Exception( sprintf( 'Not a valid property: %s', $property ) ); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function activateButton( array $plugin ) |
| 50 | 50 | { |
| 51 | - $actionUrl = self_admin_url( sprintf( 'options-general.php?page=%s&action=activate&plugin=%s', $this->app->id, $plugin['plugin'] )); |
|
| 51 | + $actionUrl = self_admin_url( sprintf( 'options-general.php?page=%s&action=activate&plugin=%s', $this->app->id, $plugin['plugin'] ) ); |
|
| 52 | 52 | return $this->button( sprintf( '%s %s', __( 'Activate', 'pollux' ), $plugin['name'] ), [ |
| 53 | 53 | 'data-name' => $plugin['name'], |
| 54 | 54 | 'data-plugin' => $plugin['plugin'], |
| 55 | 55 | 'data-slug' => $plugin['slug'], |
| 56 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'activate-plugin_%s', $plugin['plugin'] )), |
|
| 57 | - ]); |
|
| 56 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'activate-plugin_%s', $plugin['plugin'] ) ), |
|
| 57 | + ] ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | $atts = wp_parse_args( $atts, [ |
| 67 | 67 | 'class' => '', |
| 68 | 68 | 'href' => '', |
| 69 | - ]); |
|
| 70 | - $atts['class'] = trim( $atts['class'] . ' button button-small' ); |
|
| 71 | - $attributes = array_reduce( array_keys( $atts ), function( $carry, $key ) use( $atts ) { |
|
| 72 | - return $carry . sprintf( ' %s="%s"', $key, $atts[$key] ); |
|
| 69 | + ] ); |
|
| 70 | + $atts['class'] = trim( $atts['class'].' button button-small' ); |
|
| 71 | + $attributes = array_reduce( array_keys( $atts ), function( $carry, $key ) use($atts) { |
|
| 72 | + return $carry.sprintf( ' %s="%s"', $key, $atts[$key] ); |
|
| 73 | 73 | }); |
| 74 | 74 | return sprintf( '<a%s>%s</a>', $attributes, $title ); |
| 75 | 75 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | if( $unset ) { |
| 83 | 83 | $index = array_search( $notice, $this->app->notices ); |
| 84 | 84 | if( $index !== false ) { |
| 85 | - unset( $this->app->notices[$index] ); |
|
| 85 | + unset($this->app->notices[$index]); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | return $this->buildNotice( $notice ); |
@@ -93,13 +93,13 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function installButton( array $plugin ) |
| 95 | 95 | { |
| 96 | - $actionUrl = self_admin_url( sprintf( 'update.php?action=install-plugin&plugin=%s', $plugin['slug'] )); |
|
| 96 | + $actionUrl = self_admin_url( sprintf( 'update.php?action=install-plugin&plugin=%s', $plugin['slug'] ) ); |
|
| 97 | 97 | return $this->button( sprintf( '%s %s', __( 'Install', 'pollux' ), $plugin['name'] ), [ |
| 98 | 98 | 'data-name' => $plugin['name'], |
| 99 | 99 | 'data-plugin' => $plugin['plugin'], |
| 100 | 100 | 'data-slug' => $plugin['slug'], |
| 101 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'install-plugin_%s', $plugin['slug'] )), |
|
| 102 | - ]); |
|
| 101 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'install-plugin_%s', $plugin['slug'] ) ), |
|
| 102 | + ] ); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function updateButton( array $plugin ) |
| 109 | 109 | { |
| 110 | - $actionUrl = self_admin_url( sprintf( 'update.php?action=upgrade-plugin&plugin=%s', $plugin['plugin'] )); |
|
| 110 | + $actionUrl = self_admin_url( sprintf( 'update.php?action=upgrade-plugin&plugin=%s', $plugin['plugin'] ) ); |
|
| 111 | 111 | return $this->button( sprintf( '%s %s', __( 'Update', 'pollux' ), $plugin['name'] ), [ |
| 112 | 112 | 'data-name' => $plugin['name'], |
| 113 | 113 | 'data-plugin' => $plugin['plugin'], |
| 114 | 114 | 'data-slug' => $plugin['slug'], |
| 115 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'upgrade-plugin_%s', $plugin['plugin'] )), |
|
| 116 | - ]); |
|
| 115 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'upgrade-plugin_%s', $plugin['plugin'] ) ), |
|
| 116 | + ] ); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | $this->app->notices[] = [ |
| 137 | 137 | 'dismissible' => $dismissible, |
| 138 | - 'message' => $this->buildMessage( array_filter( (array) $messages )), |
|
| 138 | + 'message' => $this->buildMessage( array_filter( (array)$messages ) ), |
|
| 139 | 139 | 'type' => $type, |
| 140 | 140 | ]; |
| 141 | 141 | $this->app->notices = array_unique( $this->app->notices, SORT_REGULAR ); |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | protected function buildMessage( array $messages ) |
| 148 | 148 | { |
| 149 | 149 | foreach( $messages as $key => &$message ) { |
| 150 | - if( !is_wp_error( $message ))continue; |
|
| 150 | + if( !is_wp_error( $message ) )continue; |
|
| 151 | 151 | $message = $message->get_error_message(); |
| 152 | 152 | } |
| 153 | - return wpautop( implode( PHP_EOL . PHP_EOL, $messages )); |
|
| 153 | + return wpautop( implode( PHP_EOL.PHP_EOL, $messages ) ); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public static function id() |
| 32 | 32 | { |
| 33 | - return apply_filters( sprintf( 'pollux/%s/id', static::ID ), Application::prefix() . static::ID ); |
|
| 33 | + return apply_filters( sprintf( 'pollux/%s/id', static::ID ), Application::prefix().static::ID ); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -42,20 +42,20 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $this->normalize( $this->app->config->{static::ID} ); |
| 44 | 44 | |
| 45 | - add_action( 'pollux/'.static::ID.'/init', [$this, 'addSubmitMetaBox'] ); |
|
| 46 | - add_action( 'current_screen', [$this, 'register'] ); |
|
| 47 | - add_action( 'admin_menu', [$this, 'registerPage'] ); |
|
| 48 | - add_action( 'admin_menu', [$this, 'registerSetting'] ); |
|
| 49 | - add_action( 'pollux/'.static::ID.'/init', [$this, 'resetPage'] ); |
|
| 50 | - add_action( 'admin_print_footer_scripts', [$this, 'renderFooterScript'] ); |
|
| 51 | - add_filter( 'pollux/'.static::ID.'/instruction', [$this, 'filterInstruction'], 10, 3 ); |
|
| 45 | + add_action( 'pollux/'.static::ID.'/init', [$this, 'addSubmitMetaBox'] ); |
|
| 46 | + add_action( 'current_screen', [$this, 'register'] ); |
|
| 47 | + add_action( 'admin_menu', [$this, 'registerPage'] ); |
|
| 48 | + add_action( 'admin_menu', [$this, 'registerSetting'] ); |
|
| 49 | + add_action( 'pollux/'.static::ID.'/init', [$this, 'resetPage'] ); |
|
| 50 | + add_action( 'admin_print_footer_scripts', [$this, 'renderFooterScript'] ); |
|
| 51 | + add_filter( 'pollux/'.static::ID.'/instruction', [$this, 'filterInstruction'], 10, 3 ); |
|
| 52 | 52 | add_filter( 'pollux/'.static::ID.'/before/instructions', [$this, 'filterBeforeInstructions'] ); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | public function canProceed() |
| 56 | 56 | { |
| 57 | 57 | return $this->app->gatekeeper->hasDependency( static::DEPENDENCY ) |
| 58 | - && !empty( $this->app->config->{static::ID} ); |
|
| 58 | + && !empty($this->app->config->{static::ID} ); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $this->hook, |
| 72 | 72 | 'side', |
| 73 | 73 | 'high', |
| 74 | - ])); |
|
| 74 | + ] ) ); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function filterSavedSettings( $settings ) |
| 102 | 102 | { |
| 103 | - $settings = ( new Helper )->toArray( $settings ); |
|
| 103 | + $settings = (new Helper)->toArray( $settings ); |
|
| 104 | 104 | return $this->filter( 'save', array_merge( |
| 105 | 105 | array_intersect_key( $this->getSettings(), $settings ), |
| 106 | 106 | $settings |
| 107 | - )); |
|
| 107 | + ) ); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function register() |
| 126 | 126 | { |
| 127 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
| 128 | - if( $this->app->gatekeeper->hasDependency( self::DEPENDENCY )) { |
|
| 127 | + if( (new Helper)->getCurrentScreen()->id != $this->hook )return; |
|
| 128 | + if( $this->app->gatekeeper->hasDependency( self::DEPENDENCY ) ) { |
|
| 129 | 129 | foreach( parent::register() as $metabox ) { |
| 130 | 130 | new RWMetaBox( $metabox, static::ID, $this ); |
| 131 | 131 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 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 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | [$this, 'renderPage'], |
| 152 | 152 | 'dashicons-screenoptions', |
| 153 | 153 | 1313 |
| 154 | - ])); |
|
| 154 | + ] ) ); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -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 | |
@@ -236,8 +236,8 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | protected function filterArrayByKey( array $array, $key ) |
| 238 | 238 | { |
| 239 | - return array_filter( $array, function( $value ) use( $key ) { |
|
| 240 | - return !empty( $value[$key] ); |
|
| 239 | + return array_filter( $array, function( $value ) use($key) { |
|
| 240 | + return !empty($value[$key]); |
|
| 241 | 241 | }); |
| 242 | 242 | } |
| 243 | 243 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $fields = array_map( function( $field ) { |
| 253 | 253 | $field = wp_parse_args( $field, ['std' => ''] ); |
| 254 | 254 | return [$field['slug'] => $field['std']]; |
| 255 | - }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |
|
| 255 | + }, $this->filterArrayByKey( $metabox['fields'], 'slug' ) ); |
|
| 256 | 256 | $metabox = [ |
| 257 | 257 | $metabox['slug'] => call_user_func_array( 'array_merge', $fields ), |
| 258 | 258 | ]; |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | protected function getSettings() |
| 264 | 264 | { |
| 265 | - return (array) SiteMeta::all(); |
|
| 265 | + return (array)SiteMeta::all(); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | add_action( 'pollux/archives/init', [$this, 'add_meta_boxes'] ); |
| 26 | 26 | add_action( 'pollux/settings/init', [$this, 'add_meta_boxes'] ); |
| 27 | - add_filter( 'rwmb_field_meta', [$this, '_get_field_meta'], 10, 3 ); |
|
| 27 | + add_filter( 'rwmb_field_meta', [$this, '_get_field_meta'], 10, 3 ); |
|
| 28 | 28 | add_filter( 'rwmb_normalize_field', [$this, '_normalize_field'] ); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function _get_field_meta( $meta, array $field, $saved ) |
| 38 | 38 | { |
| 39 | - if( !$this->is_edit_screen() || !empty(( new Helper )->toArray( $meta )) || empty( $field['slug'] )) { |
|
| 39 | + if( !$this->is_edit_screen() || !empty((new Helper)->toArray( $meta )) || empty($field['slug']) ) { |
|
| 40 | 40 | return $meta; |
| 41 | 41 | } |
| 42 | - $meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ( $saved |
|
| 42 | + $meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ($saved |
|
| 43 | 43 | ? $this->pollux_caller->getMetaValue( $field['slug'], $meta, $this->meta_box['slug'] ) |
| 44 | 44 | : $field['std'] |
| 45 | - )); |
|
| 45 | + ) ); |
|
| 46 | 46 | return $this->_normalize_field_meta( $meta, $field ); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function _normalize_field( array $field ) |
| 53 | 53 | { |
| 54 | - if( !empty( $field['multiple'] ) && $field['id'] == substr( $field['field_name'], 0, -2 )) { |
|
| 55 | - $parts = array_filter( explode( '-', $field['id'] )); |
|
| 54 | + if( !empty($field['multiple']) && $field['id'] == substr( $field['field_name'], 0, -2 ) ) { |
|
| 55 | + $parts = array_filter( explode( '-', $field['id'] ) ); |
|
| 56 | 56 | $first = array_shift( $parts ); |
| 57 | 57 | $field['field_name'] = array_reduce( $parts, function( $carry, $part ) { |
| 58 | 58 | return sprintf( '%s[%s]', $carry, $part ); |
| 59 | - }, $first ) . '[]'; |
|
| 59 | + }, $first ).'[]'; |
|
| 60 | 60 | } |
| 61 | 61 | return $field; |
| 62 | 62 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function _normalize_field_meta( $meta, array $field ) |
| 69 | 69 | { |
| 70 | - if( !empty( $meta ) && is_array( $meta )) { |
|
| 70 | + if( !empty($meta) && is_array( $meta ) ) { |
|
| 71 | 71 | return $meta; |
| 72 | 72 | } |
| 73 | 73 | if( $field['clone'] ) { |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | public function is_saved() |
| 111 | 111 | { |
| 112 | 112 | foreach( array_column( $this->fields, 'slug' ) as $field ) { |
| 113 | - if( !is_null( $this->pollux_caller->getMetaValue( $field, null, $this->meta_box['slug'] ))) { |
|
| 113 | + if( !is_null( $this->pollux_caller->getMetaValue( $field, null, $this->meta_box['slug'] ) ) ) { |
|
| 114 | 114 | return true; |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public static function normalize( $metabox ) |
| 125 | 125 | { |
| 126 | - unset( $metabox['post_types'] ); |
|
| 126 | + unset($metabox['post_types']); |
|
| 127 | 127 | return wp_parse_args( $metabox, ['slug' => ''] ); |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -35,13 +35,13 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function init() |
| 37 | 37 | { |
| 38 | - if( empty( $this->app->config->taxonomies ))return; |
|
| 38 | + if( empty($this->app->config->taxonomies) )return; |
|
| 39 | 39 | |
| 40 | 40 | $this->normalize(); |
| 41 | 41 | |
| 42 | - add_action( 'restrict_manage_posts', [ $this, 'printFilters'] ); |
|
| 43 | - add_action( 'init', [ $this, 'register'] ); |
|
| 44 | - add_filter( 'parse_query', [ $this, 'filterByTaxonomy'] ); |
|
| 42 | + add_action( 'restrict_manage_posts', [$this, 'printFilters'] ); |
|
| 43 | + add_action( 'init', [$this, 'register'] ); |
|
| 44 | + add_filter( 'parse_query', [$this, 'filterByTaxonomy'] ); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function filterByTaxonomy( WP_Query $query ) |
| 52 | 52 | { |
| 53 | - if( !is_admin() || ( new Helper )->getCurrentScreen()->base != 'edit' )return; |
|
| 53 | + if( !is_admin() || (new Helper)->getCurrentScreen()->base != 'edit' )return; |
|
| 54 | 54 | $vars = &$query->query_vars; |
| 55 | 55 | foreach( array_keys( $this->taxonomies ) as $taxonomy ) { |
| 56 | - if( !isset( $vars[$taxonomy] ))return; |
|
| 57 | - if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) { |
|
| 56 | + if( !isset($vars[$taxonomy]) )return; |
|
| 57 | + if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy ) ) { |
|
| 58 | 58 | $vars[$taxonomy] = $term->slug; |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -69,18 +69,18 @@ discard block |
||
| 69 | 69 | { |
| 70 | 70 | global $wp_query; |
| 71 | 71 | foreach( $this->taxonomies as $taxonomy => $args ) { |
| 72 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue; |
|
| 73 | - $selected = isset( $wp_query->query[$taxonomy] ) |
|
| 72 | + if( !in_array( get_current_screen()->post_type, $args['post_types'] ) )continue; |
|
| 73 | + $selected = isset($wp_query->query[$taxonomy]) |
|
| 74 | 74 | ? $wp_query->query[$taxonomy] |
| 75 | 75 | : false; |
| 76 | - wp_dropdown_categories([ |
|
| 76 | + wp_dropdown_categories( [ |
|
| 77 | 77 | 'hide_if_empty' => true, |
| 78 | 78 | 'name' => $taxonomy, |
| 79 | 79 | 'orderby' => 'name', |
| 80 | 80 | 'selected' => $selected, |
| 81 | 81 | 'show_option_all' => $args['labels']['all_items'], |
| 82 | 82 | 'taxonomy' => $taxonomy, |
| 83 | - ]); |
|
| 83 | + ] ); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | public function register() |
| 92 | 92 | { |
| 93 | 93 | array_walk( $this->taxonomies, function( $args, $taxonomy ) { |
| 94 | - register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( static::CUSTOM_KEYS ))); |
|
| 94 | + register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( static::CUSTOM_KEYS ) ) ); |
|
| 95 | 95 | foreach( $args['post_types'] as $type ) { |
| 96 | 96 | register_taxonomy_for_object_type( $taxonomy, $type ); |
| 97 | 97 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | protected function normalizeLabels( $labels, array $args ) |
| 122 | 122 | { |
| 123 | - return wp_parse_args( $labels, $this->setLabels( $args )); |
|
| 123 | + return wp_parse_args( $labels, $this->setLabels( $args ) ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | protected function normalizeMenuName( $menuname, array $args ) |
| 131 | 131 | { |
| 132 | - return empty( $menuname ) |
|
| 132 | + return empty($menuname) |
|
| 133 | 133 | ? $args['plural'] |
| 134 | 134 | : $menuname; |
| 135 | 135 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | protected function normalizePostTypes( $types ) |
| 142 | 142 | { |
| 143 | - return ( new Helper )->toArray( $types ); |
|
| 143 | + return (new Helper)->toArray( $types ); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public static function getInstance( array $aliases = [] ) |
| 42 | 42 | { |
| 43 | - if( is_null( static::$instance )) { |
|
| 44 | - return static::$instance = new static( $aliases ); |
|
| 43 | + if( is_null( static::$instance ) ) { |
|
| 44 | + return static::$instance = new static($aliases); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $aliases = array_merge( static::$instance->aliases, $aliases ); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function load( $alias ) |
| 62 | 62 | { |
| 63 | - if( isset( $this->aliases[$alias] )) { |
|
| 63 | + if( isset($this->aliases[$alias]) ) { |
|
| 64 | 64 | return class_alias( $this->aliases[$alias], $alias ); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function __construct() |
| 33 | 33 | { |
| 34 | - $this->file = realpath( dirname( dirname( __FILE__ )) . '/pollux.php' ); |
|
| 35 | - $this->gatekeeper = new GateKeeper( plugin_basename( $this->file )); |
|
| 34 | + $this->file = realpath( dirname( dirname( __FILE__ ) ).'/pollux.php' ); |
|
| 35 | + $this->gatekeeper = new GateKeeper( plugin_basename( $this->file ) ); |
|
| 36 | 36 | |
| 37 | 37 | $data = get_file_data( $this->file, array( |
| 38 | 38 | 'id' => 'Text Domain', |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | add_action( 'plugins_loaded', function() { |
| 59 | 59 | $this->bootstrap(); |
| 60 | 60 | }); |
| 61 | - add_action( 'admin_enqueue_scripts', array( $controller, 'registerAssets' )); |
|
| 62 | - add_action( 'admin_init', array( $controller, 'removeDashboardWidgets' )); |
|
| 63 | - add_action( 'wp_before_admin_bar_render', array( $controller, 'removeWordPressMenu' )); |
|
| 64 | - add_filter( "plugin_action_links_{$basename}", array( $controller, 'filterPluginLinks' )); |
|
| 65 | - add_filter( 'admin_footer_text', array( $controller, 'filterWordPressFooter' )); |
|
| 61 | + add_action( 'admin_enqueue_scripts', array( $controller, 'registerAssets' ) ); |
|
| 62 | + add_action( 'admin_init', array( $controller, 'removeDashboardWidgets' ) ); |
|
| 63 | + add_action( 'wp_before_admin_bar_render', array( $controller, 'removeWordPressMenu' ) ); |
|
| 64 | + add_filter( "plugin_action_links_{$basename}", array( $controller, 'filterPluginLinks' ) ); |
|
| 65 | + add_filter( 'admin_footer_text', array( $controller, 'filterWordPressFooter' ) ); |
|
| 66 | 66 | |
| 67 | 67 | // Disallow indexing of the site on non-production environments |
| 68 | 68 | if( !$this->environment( 'production' ) && !is_admin() ) { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public function environment( $checkFor = '' ) |
| 78 | 78 | { |
| 79 | 79 | $environment = defined( 'WP_ENV' ) ? WP_ENV : 'production'; |
| 80 | - if( !empty( $checkFor )) { |
|
| 80 | + if( !empty($checkFor) ) { |
|
| 81 | 81 | return $environment == $checkFor; |
| 82 | 82 | } |
| 83 | 83 | return $environment; |
@@ -92,16 +92,16 @@ discard block |
||
| 92 | 92 | $theme = wp_get_theme(); |
| 93 | 93 | $filename = apply_filters( 'pollux/file', $filename ); |
| 94 | 94 | $locations = apply_filters( 'pollux/file/locations', [ |
| 95 | - trailingslashit( trailingslashit( $theme->theme_root ) . $theme->stylesheet ), |
|
| 96 | - trailingslashit( trailingslashit( $theme->theme_root ) . $theme->template ), |
|
| 95 | + trailingslashit( trailingslashit( $theme->theme_root ).$theme->stylesheet ), |
|
| 96 | + trailingslashit( trailingslashit( $theme->theme_root ).$theme->template ), |
|
| 97 | 97 | trailingslashit( WP_CONTENT_DIR ), |
| 98 | 98 | trailingslashit( ABSPATH ), |
| 99 | - trailingslashit( dirname( ABSPATH )), |
|
| 100 | - trailingslashit( dirname( dirname( ABSPATH ))), |
|
| 101 | - ]); |
|
| 102 | - foreach( (array) $locations as $location ) { |
|
| 103 | - if( !file_exists( $location . $filename ))continue; |
|
| 104 | - return $location . $filename; |
|
| 99 | + trailingslashit( dirname( ABSPATH ) ), |
|
| 100 | + trailingslashit( dirname( dirname( ABSPATH ) ) ), |
|
| 101 | + ] ); |
|
| 102 | + foreach( (array)$locations as $location ) { |
|
| 103 | + if( !file_exists( $location.$filename ) )continue; |
|
| 104 | + return $location.$filename; |
|
| 105 | 105 | } |
| 106 | 106 | return null; |
| 107 | 107 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function path( $file = '' ) |
| 128 | 128 | { |
| 129 | - return plugin_dir_path( $this->file ) . ltrim( trim( $file ), '/' ); |
|
| 129 | + return plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' ); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | public function render( $view, array $data = [] ) |
| 137 | 137 | { |
| 138 | 138 | $file = apply_filters( 'pollux/views/file', |
| 139 | - $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ))), |
|
| 139 | + $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ) ) ), |
|
| 140 | 140 | $view, |
| 141 | 141 | $data |
| 142 | 142 | ); |
| 143 | - if( !file_exists( $file ))return; |
|
| 143 | + if( !file_exists( $file ) )return; |
|
| 144 | 144 | extract( $data ); |
| 145 | 145 | include $file; |
| 146 | 146 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function url( $path = '' ) |
| 153 | 153 | { |
| 154 | - return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' )); |
|
| 154 | + return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function loadHooks() |
| 186 | 186 | { |
| 187 | - if( $file = $this->getFile( 'pollux-hooks.php' )) { |
|
| 187 | + if( $file = $this->getFile( 'pollux-hooks.php' ) ) { |
|
| 188 | 188 | include_once $file; |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | protected function loadTextdomain() |
| 196 | 196 | { |
| 197 | - load_plugin_textdomain( $this->id, false, plugin_basename( $this->path() ) . '/languages/' ); |
|
| 197 | + load_plugin_textdomain( $this->id, false, plugin_basename( $this->path() ).'/languages/' ); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -206,6 +206,6 @@ discard block |
||
| 206 | 206 | 'ArchiveMeta' => 'GeminiLabs\Pollux\Facades\ArchiveMeta', |
| 207 | 207 | 'PostMeta' => 'GeminiLabs\Pollux\Facades\PostMeta', |
| 208 | 208 | 'SiteMeta' => 'GeminiLabs\Pollux\Facades\SiteMeta', |
| 209 | - )))->register(); |
|
| 209 | + ) ) )->register(); |
|
| 210 | 210 | } |
| 211 | 211 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public static function id() |
| 26 | 26 | { |
| 27 | - return Application::PREFIX . static::ID; |
|
| 27 | + return Application::PREFIX.static::ID; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public function __construct( Application $app ) |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | if( $this->app->config->disable_config )return; |
| 41 | 41 | |
| 42 | - add_action( 'admin_menu', [$this, 'registerPage'] ); |
|
| 43 | - add_action( 'admin_menu', [$this, 'registerSetting'] ); |
|
| 42 | + add_action( 'admin_menu', [$this, 'registerPage'] ); |
|
| 43 | + add_action( 'admin_menu', [$this, 'registerSetting'] ); |
|
| 44 | 44 | add_action( 'current_screen', [$this, 'resetPage'] ); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | 'config' => $this->app->make( ConfigManager::class ), |
| 95 | 95 | 'heading' => __( 'Pollux Settings', 'pollux' ), |
| 96 | 96 | 'id' => static::id(), |
| 97 | - 'reset_url' => esc_url( add_query_arg( $query, admin_url( 'options-general.php' ))), |
|
| 97 | + 'reset_url' => esc_url( add_query_arg( $query, admin_url( 'options-general.php' ) ) ), |
|
| 98 | 98 | 'has_meta_box' => $this->app->gatekeeper->hasDependency( 'meta-box/meta-box.php' ), |
| 99 | - ]); |
|
| 99 | + ] ); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -108,16 +108,16 @@ discard block |
||
| 108 | 108 | if( filter_input( INPUT_GET, 'page' ) !== $this->app->id |
| 109 | 109 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
| 110 | 110 | )return; |
| 111 | - if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), static::id() )) { |
|
| 111 | + if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), static::id() ) ) { |
|
| 112 | 112 | delete_option( static::id() ); |
| 113 | 113 | $this->app->make( ConfigManager::class )->compile( true ); |
| 114 | 114 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
| 115 | 115 | } |
| 116 | 116 | else { |
| 117 | - add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' )); |
|
| 117 | + add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' ) ); |
|
| 118 | 118 | } |
| 119 | 119 | set_transient( 'settings_errors', get_settings_errors(), 30 ); |
| 120 | - wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() )); |
|
| 120 | + wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() ) ); |
|
| 121 | 121 | exit; |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -42,13 +42,13 @@ discard block |
||
| 42 | 42 | $yamlFile = $this->getYamlFile(); |
| 43 | 43 | $yaml = $this->normalizeYamlValues( $this->normalize( |
| 44 | 44 | $this->parseYaml( file_get_contents( $yamlFile ), $yamlFile ) |
| 45 | - )); |
|
| 45 | + ) ); |
|
| 46 | 46 | if( !$yaml['disable_config'] ) { |
| 47 | - $config = array_filter( (array) get_option( Config::id(), [] )); |
|
| 47 | + $config = array_filter( (array)get_option( Config::id(), [] ) ); |
|
| 48 | 48 | } |
| 49 | - return empty( $config ) |
|
| 50 | - ? $this->setTimestamp( $yaml, filemtime( $yamlFile )) |
|
| 51 | - : $this->normalizeYamlValues( $this->normalize( $config )); |
|
| 49 | + return empty($config) |
|
| 50 | + ? $this->setTimestamp( $yaml, filemtime( $yamlFile ) ) |
|
| 51 | + : $this->normalizeYamlValues( $this->normalize( $config ) ); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -58,15 +58,15 @@ discard block |
||
| 58 | 58 | public function compile( $force = false ) |
| 59 | 59 | { |
| 60 | 60 | $configFile = $this->getCompileDestination(); |
| 61 | - if( $force || $this->shouldCompile( $configFile )) { |
|
| 61 | + if( $force || $this->shouldCompile( $configFile ) ) { |
|
| 62 | 62 | $config = $this->normalizeArray( $this->options ); |
| 63 | 63 | if( $this->parseError ) { |
| 64 | - return (object) $config; |
|
| 64 | + return (object)$config; |
|
| 65 | 65 | } |
| 66 | 66 | file_put_contents( $configFile, sprintf( '<?php // DO NOT MODIFY THIS FILE DIRECTLY!%sreturn (object) %s;', |
| 67 | 67 | PHP_EOL, |
| 68 | - $this->parseRawStrings( var_export( $this->setTimestamp( $config ), true )) |
|
| 69 | - )); |
|
| 68 | + $this->parseRawStrings( var_export( $this->setTimestamp( $config ), true ) ) |
|
| 69 | + ) ); |
|
| 70 | 70 | } |
| 71 | 71 | return include $configFile; |
| 72 | 72 | } |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function convertArrayToYaml( array $array ) |
| 78 | 78 | { |
| 79 | - return !empty( $array ) |
|
| 80 | - ? trim( $this->parseRawStrings( $this->dumpYaml( $array ))) |
|
| 79 | + return !empty($array) |
|
| 80 | + ? trim( $this->parseRawStrings( $this->dumpYaml( $array ) ) ) |
|
| 81 | 81 | : ''; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function getYamlFile() |
| 99 | 99 | { |
| 100 | - if( $file = $this->app->getFile( 'pollux.yml' )) { |
|
| 100 | + if( $file = $this->app->getFile( 'pollux.yml' ) ) { |
|
| 101 | 101 | return $file; |
| 102 | 102 | } |
| 103 | 103 | return $this->app->path( 'defaults.yml' ); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | public function normalizeArray( array $array ) |
| 110 | 110 | { |
| 111 | 111 | array_walk( $array, function( &$value, $key ) { |
| 112 | - if( !is_numeric( $value ) && is_string( $value )) { |
|
| 112 | + if( !is_numeric( $value ) && is_string( $value ) ) { |
|
| 113 | 113 | $value = $this->parseYaml( $value, $key ); |
| 114 | 114 | if( $this->parseError == $key ) { |
| 115 | 115 | $value = []; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | return wp_parse_args( |
| 163 | 163 | $config, |
| 164 | 164 | $this->parseYaml( |
| 165 | - file_get_contents( $this->app->path( 'defaults.yml' )), |
|
| 165 | + file_get_contents( $this->app->path( 'defaults.yml' ) ), |
|
| 166 | 166 | $this->app->path( 'defaults.yml' ) |
| 167 | 167 | ) |
| 168 | 168 | ); |
@@ -176,10 +176,10 @@ discard block |
||
| 176 | 176 | protected function parseRawStrings( $configString ) |
| 177 | 177 | { |
| 178 | 178 | $strings = apply_filters( 'pollux/config/raw_strings', static::RAW_STRINGS ); |
| 179 | - if( empty( $strings )) { |
|
| 179 | + if( empty($strings) ) { |
|
| 180 | 180 | return $configString; |
| 181 | 181 | } |
| 182 | - $pattern = '/(\')((' . implode( '|', $strings ) . ')\(?.+\))(\')/'; |
|
| 182 | + $pattern = '/(\')(('.implode( '|', $strings ).')\(?.+\))(\')/'; |
|
| 183 | 183 | return stripslashes( |
| 184 | 184 | preg_replace_callback( $pattern, function( $matches ) { |
| 185 | 185 | return str_replace( "''", "'", $matches[2] ); |
@@ -194,20 +194,20 @@ discard block |
||
| 194 | 194 | protected function parseYaml( $value, $file = null ) |
| 195 | 195 | { |
| 196 | 196 | try { |
| 197 | - return (array) Yaml::parse( $value ); |
|
| 197 | + return (array)Yaml::parse( $value ); |
|
| 198 | 198 | } |
| 199 | 199 | catch( ParseException $e ) { |
| 200 | 200 | $this->parseError = $file; |
| 201 | 201 | if( $file ) { |
| 202 | 202 | $file = sprintf( '<code>%s</code>', $file ); |
| 203 | 203 | } |
| 204 | - $this->app->make( 'Notice' )->addError([ |
|
| 204 | + $this->app->make( 'Notice' )->addError( [ |
|
| 205 | 205 | sprintf( '<strong>Pollux Error:</strong> Unable to parse config at line %s (near "%s").', |
| 206 | 206 | $e->getParsedLine(), |
| 207 | 207 | $e->getSnippet() |
| 208 | 208 | ), |
| 209 | 209 | $file |
| 210 | - ]); |
|
| 210 | + ] ); |
|
| 211 | 211 | return $value; |
| 212 | 212 | } |
| 213 | 213 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | protected function shouldCompile( $configFile ) |
| 220 | 220 | { |
| 221 | - if( !file_exists( $configFile )) { |
|
| 221 | + if( !file_exists( $configFile ) ) { |
|
| 222 | 222 | return true; |
| 223 | 223 | } |
| 224 | 224 | $config = include $configFile; |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $this->notice = pollux_app()->make( 'Notice' ); |
| 38 | 38 | |
| 39 | - add_action( 'current_screen', [$this, 'activatePlugin'] ); |
|
| 39 | + add_action( 'current_screen', [$this, 'activatePlugin'] ); |
|
| 40 | 40 | add_action( 'wp_ajax_pollux/dependency/activate_url', [$this, 'ajaxActivatePluginLink'] ); |
| 41 | - add_action( 'admin_notices', [$this, 'printNotices'] ); |
|
| 42 | - add_action( 'current_screen', [$this, 'setDependencyNotice'] ); |
|
| 41 | + add_action( 'admin_notices', [$this, 'printNotices'] ); |
|
| 42 | + add_action( 'current_screen', [$this, 'setDependencyNotice'] ); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | || filter_input( INPUT_GET, 'action' ) != 'activate' |
| 52 | 52 | )return; |
| 53 | 53 | $plugin = filter_input( INPUT_GET, 'plugin' ); |
| 54 | - check_admin_referer( 'activate-plugin_' . $plugin ); |
|
| 54 | + check_admin_referer( 'activate-plugin_'.$plugin ); |
|
| 55 | 55 | $result = activate_plugin( $plugin, null, is_network_admin(), true ); |
| 56 | - if( is_wp_error( $result )) { |
|
| 56 | + if( is_wp_error( $result ) ) { |
|
| 57 | 57 | wp_die( $result->get_error_message() ); |
| 58 | 58 | } |
| 59 | 59 | wp_safe_redirect( wp_get_referer() ); |
@@ -67,19 +67,19 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | check_ajax_referer( 'updates' ); |
| 69 | 69 | $plugin = filter_input( INPUT_POST, 'plugin' ); |
| 70 | - if( !$this->isPluginDependency( $plugin )) { |
|
| 70 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
| 71 | 71 | wp_send_json_error(); |
| 72 | 72 | } |
| 73 | - $activateUrl = add_query_arg([ |
|
| 74 | - '_wpnonce' => wp_create_nonce( sprintf( 'activate-plugin_%s', $plugin )), |
|
| 73 | + $activateUrl = add_query_arg( [ |
|
| 74 | + '_wpnonce' => wp_create_nonce( sprintf( 'activate-plugin_%s', $plugin ) ), |
|
| 75 | 75 | 'action' => 'activate', |
| 76 | 76 | 'page' => pollux_app()->id, |
| 77 | 77 | 'plugin' => $plugin, |
| 78 | - ], self_admin_url( 'options-general.php' )); |
|
| 79 | - wp_send_json_success([ |
|
| 78 | + ], self_admin_url( 'options-general.php' ) ); |
|
| 79 | + wp_send_json_success( [ |
|
| 80 | 80 | 'activate_url' => $activateUrl, |
| 81 | 81 | filter_input( INPUT_POST, 'type' ) => $plugin, |
| 82 | - ]); |
|
| 82 | + ] ); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function hasDependency( $plugin ) |
| 89 | 89 | { |
| 90 | - if( !$this->isPluginDependency( $plugin )) { |
|
| 90 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
| 91 | 91 | return true; |
| 92 | 92 | } |
| 93 | 93 | return $this->isPluginInstalled( $plugin ) && $this->isPluginValid( $plugin ); |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | public function hasPendingDependencies() |
| 100 | 100 | { |
| 101 | 101 | foreach( static::DEPENDENCIES as $plugin => $data ) { |
| 102 | - if( !$this->isPluginDependency( $plugin ))continue; |
|
| 102 | + if( !$this->isPluginDependency( $plugin ) )continue; |
|
| 103 | 103 | $this->isPluginActive( $plugin ); |
| 104 | 104 | $this->isPluginVersionValid( $plugin ); |
| 105 | 105 | } |
| 106 | - return !empty( $this->errors ); |
|
| 106 | + return !empty($this->errors); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -147,17 +147,17 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function isPluginVersionValid( $plugin ) |
| 149 | 149 | { |
| 150 | - if( !$this->isPluginDependency( $plugin )) { |
|
| 150 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
| 151 | 151 | return true; |
| 152 | 152 | } |
| 153 | - if( !$this->isPluginInstalled( $plugin )) { |
|
| 153 | + if( !$this->isPluginInstalled( $plugin ) ) { |
|
| 154 | 154 | return false; |
| 155 | 155 | } |
| 156 | 156 | return $this->catchError( $plugin, 'wrong_version', version_compare( |
| 157 | 157 | $this->getPluginRequirements( $plugin, 'version' ), |
| 158 | 158 | $this->getAllPlugins()[$plugin]['Version'], |
| 159 | 159 | '<=' |
| 160 | - )); |
|
| 160 | + ) ); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -194,13 +194,13 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | protected function catchError( $plugin, $error, $isValid ) |
| 196 | 196 | { |
| 197 | - if( !$isValid && $this->isPluginDependency( $plugin )) { |
|
| 198 | - if( !isset( $this->errors[$plugin] )) { |
|
| 197 | + if( !$isValid && $this->isPluginDependency( $plugin ) ) { |
|
| 198 | + if( !isset($this->errors[$plugin]) ) { |
|
| 199 | 199 | $this->errors[$plugin] = []; |
| 200 | 200 | } |
| 201 | 201 | $this->errors[$plugin] = array_keys( array_flip( |
| 202 | 202 | array_merge( $this->errors[$plugin], [$error] ) |
| 203 | - )); |
|
| 203 | + ) ); |
|
| 204 | 204 | } |
| 205 | 205 | return $isValid; |
| 206 | 206 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | protected function getAllPlugins() |
| 212 | 212 | { |
| 213 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 213 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
| 214 | 214 | return array_merge( get_plugins(), $this->getMustUsePlugins() ); |
| 215 | 215 | } |
| 216 | 216 | |
@@ -221,14 +221,14 @@ discard block |
||
| 221 | 221 | { |
| 222 | 222 | $actions = ''; |
| 223 | 223 | foreach( $this->errors as $plugin => $errors ) { |
| 224 | - if( in_array( 'not_found', $errors ) && current_user_can( 'install_plugins' )) { |
|
| 225 | - $actions .= $this->notice->installButton( $this->getPluginRequirements( $plugin )); |
|
| 224 | + if( in_array( 'not_found', $errors ) && current_user_can( 'install_plugins' ) ) { |
|
| 225 | + $actions .= $this->notice->installButton( $this->getPluginRequirements( $plugin ) ); |
|
| 226 | 226 | } |
| 227 | - else if( in_array( 'wrong_version', $errors ) && current_user_can( 'update_plugins' )) { |
|
| 228 | - $actions .= $this->notice->updateButton( $this->getPluginInformation( $plugin )); |
|
| 227 | + else if( in_array( 'wrong_version', $errors ) && current_user_can( 'update_plugins' ) ) { |
|
| 228 | + $actions .= $this->notice->updateButton( $this->getPluginInformation( $plugin ) ); |
|
| 229 | 229 | } |
| 230 | - else if( in_array( 'inactive', $errors ) && current_user_can( 'activate_plugins' )) { |
|
| 231 | - $actions .= $this->notice->activateButton( $this->getPluginInformation( $plugin )); |
|
| 230 | + else if( in_array( 'inactive', $errors ) && current_user_can( 'activate_plugins' ) ) { |
|
| 231 | + $actions .= $this->notice->activateButton( $this->getPluginInformation( $plugin ) ); |
|
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | return $actions; |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | protected function getDependencyLinks() |
| 241 | 241 | { |
| 242 | 242 | return array_reduce( array_keys( $this->errors ), function( $carry, $plugin ) { |
| 243 | - return $carry . $this->getPluginLink( $plugin ); |
|
| 243 | + return $carry.$this->getPluginLink( $plugin ); |
|
| 244 | 244 | }); |
| 245 | 245 | } |
| 246 | 246 | |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | protected function getMustUsePlugins() |
| 251 | 251 | { |
| 252 | 252 | $plugins = get_mu_plugins(); |
| 253 | - if( in_array( 'Bedrock Autoloader', array_column( $plugins, 'Name' ))) { |
|
| 253 | + if( in_array( 'Bedrock Autoloader', array_column( $plugins, 'Name' ) ) ) { |
|
| 254 | 254 | $autoloadedPlugins = get_site_option( 'bedrock_autoloader' ); |
| 255 | - if( !empty( $autoloadedPlugins['plugins'] )) { |
|
| 255 | + if( !empty($autoloadedPlugins['plugins']) ) { |
|
| 256 | 256 | return array_merge( $plugins, $autoloadedPlugins['plugins'] ); |
| 257 | 257 | } |
| 258 | 258 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | protected function getPlugin( $plugin ) |
| 266 | 266 | { |
| 267 | - if( $this->isPluginInstalled( $plugin )) { |
|
| 267 | + if( $this->isPluginInstalled( $plugin ) ) { |
|
| 268 | 268 | return $this->getAllPlugins()[$plugin]; |
| 269 | 269 | } |
| 270 | 270 | return false; |
@@ -275,17 +275,17 @@ discard block |
||
| 275 | 275 | */ |
| 276 | 276 | protected function getPluginData( $plugin, $data, $key = null ) |
| 277 | 277 | { |
| 278 | - if( !is_array( $data )) { |
|
| 279 | - throw new Exception( sprintf( 'Plugin information not found for: %s', $plugin )); |
|
| 278 | + if( !is_array( $data ) ) { |
|
| 279 | + throw new Exception( sprintf( 'Plugin information not found for: %s', $plugin ) ); |
|
| 280 | 280 | } |
| 281 | 281 | $data['plugin'] = $plugin; |
| 282 | 282 | $data['slug'] = $this->getPluginSlug( $plugin ); |
| 283 | 283 | $data = array_change_key_case( $data ); |
| 284 | - if( is_null( $key )) { |
|
| 284 | + if( is_null( $key ) ) { |
|
| 285 | 285 | return $data; |
| 286 | 286 | } |
| 287 | 287 | $key = strtolower( $key ); |
| 288 | - return isset( $data[$key] ) |
|
| 288 | + return isset($data[$key]) |
|
| 289 | 289 | ? $data[$key] |
| 290 | 290 | : ''; |
| 291 | 291 | } |
@@ -333,6 +333,6 @@ discard block |
||
| 333 | 333 | */ |
| 334 | 334 | protected function getPluginSlug( $plugin ) |
| 335 | 335 | { |
| 336 | - return substr( $plugin, 0, strrpos( $plugin, '/' )); |
|
| 336 | + return substr( $plugin, 0, strrpos( $plugin, '/' ) ); |
|
| 337 | 337 | } |
| 338 | 338 | } |