@@ -11,10 +11,10 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | public static function buildClassName( $name, $path = '' ) |
| 13 | 13 | { |
| 14 | - $className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ))); |
|
| 14 | + $className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ) ) ); |
|
| 15 | 15 | $className = implode( '', $className ); |
| 16 | - return !empty( $path ) |
|
| 17 | - ? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className )) |
|
| 16 | + return !empty($path) |
|
| 17 | + ? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className ) ) |
|
| 18 | 18 | : $className; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public static function buildMethodName( $name, $prefix = 'get' ) |
| 27 | 27 | { |
| 28 | - return lcfirst( static::buildClassName( $prefix . '-' . $name )); |
|
| 28 | + return lcfirst( static::buildClassName( $prefix.'-'.$name ) ); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | public static function getCurrentScreen() |
| 62 | 62 | { |
| 63 | 63 | global $hook_suffix, $pagenow; |
| 64 | - if( function_exists( 'get_current_screen' )) { |
|
| 64 | + if( function_exists( 'get_current_screen' ) ) { |
|
| 65 | 65 | $screen = get_current_screen(); |
| 66 | 66 | } |
| 67 | - if( empty( $screen )) { |
|
| 67 | + if( empty($screen) ) { |
|
| 68 | 68 | $screen = new \stdClass(); |
| 69 | 69 | $screen->base = $screen->id = $hook_suffix; |
| 70 | 70 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public static function startsWith( $needle, $haystack ) |
| 81 | 81 | { |
| 82 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
| 82 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -88,6 +88,6 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public static function toArray( $value ) |
| 90 | 90 | { |
| 91 | - return array_filter( (array) $value ); |
|
| 91 | + return array_filter( (array)$value ); |
|
| 92 | 92 | } |
| 93 | 93 | } |
@@ -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 | /** |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | if( !is_admin() || 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 | } |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function init() |
| 34 | 34 | { |
| 35 | - if( empty( $this->app->config->{static::ID} ))return; |
|
| 35 | + if( empty($this->app->config->{static::ID} ) )return; |
|
| 36 | 36 | $this->normalize( $this->app->config->{static::ID}, [ |
| 37 | 37 | 'post_types' => [], |
| 38 | - ]); |
|
| 38 | + ] ); |
|
| 39 | 39 | add_filter( 'rwmb_normalize_map_field', [$this, 'normalizeMapField'] ); |
| 40 | - add_filter( 'rwmb_show', [$this, 'show'], 10, 2 ); |
|
| 41 | - add_filter( 'rwmb_meta_boxes', [$this, 'register'] ); |
|
| 42 | - add_filter( 'rwmb_outer_html', [$this, 'renderField'], 10, 2 ); |
|
| 40 | + add_filter( 'rwmb_show', [$this, 'show'], 10, 2 ); |
|
| 41 | + add_filter( 'rwmb_meta_boxes', [$this, 'register'] ); |
|
| 42 | + add_filter( 'rwmb_outer_html', [$this, 'renderField'], 10, 2 ); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | { |
| 73 | 73 | return PostMeta::get( $key, [ |
| 74 | 74 | 'id' => $this->getPostId(), |
| 75 | - ]); |
|
| 75 | + ] ); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function normalizeMapField( $field ) |
| 83 | 83 | { |
| 84 | - if( empty( $field['address_field'] )) { |
|
| 84 | + if( empty($field['address_field']) ) { |
|
| 85 | 85 | return $field; |
| 86 | 86 | } |
| 87 | - if( !Helper::startsWith( Application::PREFIX, $field['address_field'] )) { |
|
| 88 | - $field['address_field'] = Application::PREFIX . $field['address_field']; |
|
| 87 | + if( !Helper::startsWith( Application::PREFIX, $field['address_field'] ) ) { |
|
| 88 | + $field['address_field'] = Application::PREFIX.$field['address_field']; |
|
| 89 | 89 | } |
| 90 | 90 | $apiKey = SiteMeta::services( $field['api_key'] ); |
| 91 | - if( !empty( $apiKey ) && is_string( $apiKey )) { |
|
| 91 | + if( !empty($apiKey) && is_string( $apiKey ) ) { |
|
| 92 | 92 | $field['api_key'] = $apiKey; |
| 93 | 93 | } |
| 94 | 94 | return $field; |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function register() |
| 102 | 102 | { |
| 103 | - if( current_user_can( 'switch_themes' )) { |
|
| 103 | + if( current_user_can( 'switch_themes' ) ) { |
|
| 104 | 104 | $instructions = $this->initInstructions(); |
| 105 | - if( is_array( $instructions )) { |
|
| 105 | + if( is_array( $instructions ) ) { |
|
| 106 | 106 | $this->normalize( $instructions ); |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | $metaboxes = func_num_args() |
| 110 | - ? Helper::toArray( func_get_arg(0) ) |
|
| 110 | + ? Helper::toArray( func_get_arg( 0 ) ) |
|
| 111 | 111 | : []; |
| 112 | 112 | return array_merge( $metaboxes, $this->metaboxes ); |
| 113 | 113 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function renderField( $html, $field ) |
| 120 | 120 | { |
| 121 | - return !isset( $field['condition'] ) || $this->validate( $field['condition'] ) |
|
| 121 | + return !isset($field['condition']) || $this->validate( $field['condition'] ) |
|
| 122 | 122 | ? $html |
| 123 | 123 | : ''; |
| 124 | 124 | } |
@@ -130,8 +130,8 @@ discard block |
||
| 130 | 130 | public function show( $bool, array $metabox ) |
| 131 | 131 | { |
| 132 | 132 | if( defined( 'DOING_AJAX' ) |
| 133 | - || !isset( $metabox['condition'] ) |
|
| 134 | - || !$this->hasPostType( $metabox )) { |
|
| 133 | + || !isset($metabox['condition']) |
|
| 134 | + || !$this->hasPostType( $metabox ) ) { |
|
| 135 | 135 | return $bool; |
| 136 | 136 | } |
| 137 | 137 | return $this->validate( $metabox['condition'] ); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | protected function getPostId() |
| 144 | 144 | { |
| 145 | - if( !( $postId = filter_input( INPUT_GET, 'post' ))) { |
|
| 145 | + if( !($postId = filter_input( INPUT_GET, 'post' )) ) { |
|
| 146 | 146 | $postId = filter_input( INPUT_POST, 'post_ID' ); |
| 147 | 147 | } |
| 148 | 148 | return intval( $postId ); |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | { |
| 156 | 156 | return array_unique( iterator_to_array( |
| 157 | 157 | new RecursiveIteratorIterator( |
| 158 | - new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' )) |
|
| 158 | + new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ) ) |
|
| 159 | 159 | ), |
| 160 | 160 | false |
| 161 | - )); |
|
| 161 | + ) ); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -166,10 +166,10 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | protected function hasPostType( array $metabox ) |
| 168 | 168 | { |
| 169 | - if( !isset( $metabox['post_types'] )) { |
|
| 169 | + if( !isset($metabox['post_types']) ) { |
|
| 170 | 170 | return true; |
| 171 | 171 | } |
| 172 | - if( !( $type = filter_input( INPUT_GET, 'post_type' ))) { |
|
| 172 | + if( !($type = filter_input( INPUT_GET, 'post_type' )) ) { |
|
| 173 | 173 | $type = get_post_type( $this->getPostId() ); |
| 174 | 174 | } |
| 175 | 175 | return in_array( $type, $metabox['post_types'] ); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | 'id' => $id, |
| 188 | 188 | 'slug' => $id, |
| 189 | 189 | 'validation' => [], |
| 190 | - ]); |
|
| 190 | + ] ); |
|
| 191 | 191 | $this->metaboxes[] = $this->setDependencies( |
| 192 | 192 | $this->normalizeThis( $metabox, $data, $id ) |
| 193 | 193 | ); |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | protected function normalizeDepends( $depends, array $data, $parentId ) |
| 203 | 203 | { |
| 204 | - return is_string( $depends ) && !empty( $depends ) |
|
| 204 | + return is_string( $depends ) && !empty($depends) |
|
| 205 | 205 | ? $this->normalizeId( $depends, $data, $parentId ) |
| 206 | 206 | : ''; |
| 207 | 207 | } |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | protected function normalizeFields( array $fields, array $data, $parentId ) |
| 223 | 223 | { |
| 224 | - return array_map( function( $id, $field ) use( $parentId ) { |
|
| 225 | - $defaults = [ |
|
| 224 | + return array_map( function( $id, $field ) use($parentId) { |
|
| 225 | + $defaults = [ |
|
| 226 | 226 | 'attributes' => [], |
| 227 | 227 | 'class' => '', |
| 228 | 228 | 'condition' => [], |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | protected function normalizeId( $id, array $data, $parentId ) |
| 244 | 244 | { |
| 245 | - return Application::prefix() . $id; |
|
| 245 | + return Application::prefix().$id; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -260,10 +260,10 @@ discard block |
||
| 260 | 260 | protected function normalizeValidation( array $validation, array $data, $parentId ) |
| 261 | 261 | { |
| 262 | 262 | foreach( ['messages', 'rules'] as $key ) { |
| 263 | - if( empty( $validation[$key] ))continue; |
|
| 263 | + if( empty($validation[$key]) )continue; |
|
| 264 | 264 | foreach( $validation[$key] as $id => $value ) { |
| 265 | 265 | $validation[$key][$this->normalizeFieldName( $id, ['slug' => $id], $parentId )] = $value; |
| 266 | - unset( $validation[$key][$id] ); |
|
| 266 | + unset($validation[$key][$id]); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | return $validation; |
@@ -276,17 +276,17 @@ discard block |
||
| 276 | 276 | { |
| 277 | 277 | $fields = &$metabox['fields']; |
| 278 | 278 | $depends = array_column( $fields, 'depends' ); |
| 279 | - array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) { |
|
| 280 | - if( empty( $value ))return; |
|
| 279 | + array_walk( $depends, function( $value, $index ) use(&$fields, $metabox) { |
|
| 280 | + if( empty($value) )return; |
|
| 281 | 281 | $fields[$index]['attributes']['data-depends'] = $value; |
| 282 | - list( $key, $value ) = array_pad( explode( '|', $value ), 2, null ); |
|
| 283 | - $dependency = array_search( $key, array_column( $fields, 'id' )); |
|
| 282 | + list($key, $value) = array_pad( explode( '|', $value ), 2, null ); |
|
| 283 | + $dependency = array_search( $key, array_column( $fields, 'id' ) ); |
|
| 284 | 284 | $metaValue = $this->getMetaValue( $fields[$dependency]['slug'], '', $metabox['slug'] ); |
| 285 | 285 | $isHidden = $value === null |
| 286 | 286 | ? $metaValue === '' |
| 287 | 287 | : $metaValue != $value; |
| 288 | 288 | if( $isHidden ) { |
| 289 | - $fields[$index]['class'] = trim( 'hidden ' . $fields[$index]['class'] ); |
|
| 289 | + $fields[$index]['class'] = trim( 'hidden '.$fields[$index]['class'] ); |
|
| 290 | 290 | } |
| 291 | 291 | }); |
| 292 | 292 | return $metabox; |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | defined( 'WPINC' ) || die; |
| 20 | 20 | |
| 21 | -if( !class_exists( 'GL_Plugin_Check_v3' )) { |
|
| 21 | +if( !class_exists( 'GL_Plugin_Check_v3' ) ) { |
|
| 22 | 22 | require_once __DIR__.'/activate.php'; |
| 23 | 23 | } |
| 24 | 24 | if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() )return; |
@@ -28,10 +28,10 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | $app = GeminiLabs\Pollux\Application::getInstance(); |
| 30 | 30 | |
| 31 | -register_activation_hook( __FILE__, array( $app, 'onActivation' )); |
|
| 32 | -register_deactivation_hook( __FILE__, array( $app, 'onDeactivation' )); |
|
| 31 | +register_activation_hook( __FILE__, array( $app, 'onActivation' ) ); |
|
| 32 | +register_deactivation_hook( __FILE__, array( $app, 'onDeactivation' ) ); |
|
| 33 | 33 | |
| 34 | 34 | $app->register( new GeminiLabs\Pollux\Provider ); |
| 35 | -$app->init([ |
|
| 35 | +$app->init( [ |
|
| 36 | 36 | 'meta-box/meta-box.php' => 'Meta Box|5.0.1|https://wordpress.org/plugins/meta-box/', |
| 37 | -]); |
|
| 37 | +] ); |
|
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | { |
| 36 | 36 | $this->notice = pollux_app()->make( 'Notice' ); |
| 37 | 37 | |
| 38 | - add_action( 'current_screen', [$this, 'activatePlugin'] ); |
|
| 38 | + add_action( 'current_screen', [$this, 'activatePlugin'] ); |
|
| 39 | 39 | add_action( 'wp_ajax_pollux/dependency/activate_url', [$this, 'ajaxActivatePluginLink'] ); |
| 40 | - add_action( 'admin_notices', [$this, 'printNotices'] ); |
|
| 41 | - add_action( 'current_screen', [$this, 'setDependencyNotice'] ); |
|
| 40 | + add_action( 'admin_notices', [$this, 'printNotices'] ); |
|
| 41 | + add_action( 'current_screen', [$this, 'setDependencyNotice'] ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | || filter_input( INPUT_GET, 'action' ) != 'activate' |
| 51 | 51 | )return; |
| 52 | 52 | $plugin = filter_input( INPUT_GET, 'plugin' ); |
| 53 | - check_admin_referer( 'activate-plugin_' . $plugin ); |
|
| 53 | + check_admin_referer( 'activate-plugin_'.$plugin ); |
|
| 54 | 54 | $result = activate_plugin( $plugin, null, is_network_admin(), true ); |
| 55 | - if( is_wp_error( $result )) { |
|
| 55 | + if( is_wp_error( $result ) ) { |
|
| 56 | 56 | wp_die( $result->get_error_message() ); |
| 57 | 57 | } |
| 58 | 58 | wp_safe_redirect( wp_get_referer() ); |
@@ -66,19 +66,19 @@ discard block |
||
| 66 | 66 | { |
| 67 | 67 | check_ajax_referer( 'updates' ); |
| 68 | 68 | $plugin = filter_input( INPUT_POST, 'plugin' ); |
| 69 | - if( !$this->isPluginDependency( $plugin )) { |
|
| 69 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
| 70 | 70 | wp_send_json_error(); |
| 71 | 71 | } |
| 72 | - $activateUrl = add_query_arg([ |
|
| 73 | - '_wpnonce' => wp_create_nonce( sprintf( 'activate-plugin_%s', $plugin )), |
|
| 72 | + $activateUrl = add_query_arg( [ |
|
| 73 | + '_wpnonce' => wp_create_nonce( sprintf( 'activate-plugin_%s', $plugin ) ), |
|
| 74 | 74 | 'action' => 'activate', |
| 75 | 75 | 'page' => pollux_app()->id, |
| 76 | 76 | 'plugin' => $plugin, |
| 77 | - ], self_admin_url( 'options-general.php' )); |
|
| 78 | - wp_send_json_success([ |
|
| 77 | + ], self_admin_url( 'options-general.php' ) ); |
|
| 78 | + wp_send_json_success( [ |
|
| 79 | 79 | 'activate_url' => $activateUrl, |
| 80 | 80 | filter_input( INPUT_POST, 'type' ) => $plugin, |
| 81 | - ]); |
|
| 81 | + ] ); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function hasDependency( $plugin ) |
| 88 | 88 | { |
| 89 | - if( !$this->isPluginDependency( $plugin )) { |
|
| 89 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
| 90 | 90 | return true; |
| 91 | 91 | } |
| 92 | 92 | return $this->isPluginInstalled( $plugin ) && $this->isPluginValid( $plugin ); |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | public function hasPendingDependencies() |
| 99 | 99 | { |
| 100 | 100 | foreach( $this->dependencies as $plugin => $data ) { |
| 101 | - if( !$this->isPluginDependency( $plugin ))continue; |
|
| 101 | + if( !$this->isPluginDependency( $plugin ) )continue; |
|
| 102 | 102 | $this->isPluginActive( $plugin ); |
| 103 | 103 | $this->isPluginVersionValid( $plugin ); |
| 104 | 104 | } |
| 105 | - return !empty( $this->errors ); |
|
| 105 | + return !empty($this->errors); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -146,17 +146,17 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function isPluginVersionValid( $plugin ) |
| 148 | 148 | { |
| 149 | - if( !$this->isPluginDependency( $plugin )) { |
|
| 149 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
| 150 | 150 | return true; |
| 151 | 151 | } |
| 152 | - if( !$this->isPluginInstalled( $plugin )) { |
|
| 152 | + if( !$this->isPluginInstalled( $plugin ) ) { |
|
| 153 | 153 | return false; |
| 154 | 154 | } |
| 155 | 155 | return $this->catchError( $plugin, 'wrong_version', version_compare( |
| 156 | 156 | $this->getPluginRequirements( $plugin, 'version' ), |
| 157 | 157 | $this->getAllPlugins()[$plugin]['Version'], |
| 158 | 158 | '<=' |
| 159 | - )); |
|
| 159 | + ) ); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -193,13 +193,13 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | protected function catchError( $plugin, $error, $isValid ) |
| 195 | 195 | { |
| 196 | - if( !$isValid && $this->isPluginDependency( $plugin )) { |
|
| 197 | - if( !isset( $this->errors[$plugin] )) { |
|
| 196 | + if( !$isValid && $this->isPluginDependency( $plugin ) ) { |
|
| 197 | + if( !isset($this->errors[$plugin]) ) { |
|
| 198 | 198 | $this->errors[$plugin] = []; |
| 199 | 199 | } |
| 200 | 200 | $this->errors[$plugin] = array_keys( array_flip( |
| 201 | 201 | array_merge( $this->errors[$plugin], [$error] ) |
| 202 | - )); |
|
| 202 | + ) ); |
|
| 203 | 203 | } |
| 204 | 204 | return $isValid; |
| 205 | 205 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | protected function getAllPlugins() |
| 211 | 211 | { |
| 212 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 212 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
| 213 | 213 | return array_merge( get_plugins(), $this->getMustUsePlugins() ); |
| 214 | 214 | } |
| 215 | 215 | |
@@ -220,14 +220,14 @@ discard block |
||
| 220 | 220 | { |
| 221 | 221 | $actions = ''; |
| 222 | 222 | foreach( $this->errors as $plugin => $errors ) { |
| 223 | - if( in_array( 'not_found', $errors ) && current_user_can( 'install_plugins' )) { |
|
| 224 | - $actions .= $this->notice->installButton( $this->getPluginRequirements( $plugin )); |
|
| 223 | + if( in_array( 'not_found', $errors ) && current_user_can( 'install_plugins' ) ) { |
|
| 224 | + $actions .= $this->notice->installButton( $this->getPluginRequirements( $plugin ) ); |
|
| 225 | 225 | } |
| 226 | - else if( in_array( 'wrong_version', $errors ) && current_user_can( 'update_plugins' )) { |
|
| 227 | - $actions .= $this->notice->updateButton( $this->getPluginInformation( $plugin )); |
|
| 226 | + else if( in_array( 'wrong_version', $errors ) && current_user_can( 'update_plugins' ) ) { |
|
| 227 | + $actions .= $this->notice->updateButton( $this->getPluginInformation( $plugin ) ); |
|
| 228 | 228 | } |
| 229 | - else if( in_array( 'inactive', $errors ) && current_user_can( 'activate_plugins' )) { |
|
| 230 | - $actions .= $this->notice->activateButton( $this->getPluginInformation( $plugin )); |
|
| 229 | + else if( in_array( 'inactive', $errors ) && current_user_can( 'activate_plugins' ) ) { |
|
| 230 | + $actions .= $this->notice->activateButton( $this->getPluginInformation( $plugin ) ); |
|
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | return $actions; |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | protected function getDependencyLinks() |
| 240 | 240 | { |
| 241 | 241 | return array_reduce( array_keys( $this->errors ), function( $carry, $plugin ) { |
| 242 | - return $carry . $this->getPluginLink( $plugin ); |
|
| 242 | + return $carry.$this->getPluginLink( $plugin ); |
|
| 243 | 243 | }); |
| 244 | 244 | } |
| 245 | 245 | |
@@ -249,9 +249,9 @@ discard block |
||
| 249 | 249 | protected function getMustUsePlugins() |
| 250 | 250 | { |
| 251 | 251 | $plugins = get_mu_plugins(); |
| 252 | - if( in_array( 'Bedrock Autoloader', array_column( $plugins, 'Name' ))) { |
|
| 252 | + if( in_array( 'Bedrock Autoloader', array_column( $plugins, 'Name' ) ) ) { |
|
| 253 | 253 | $autoloadedPlugins = get_site_option( 'bedrock_autoloader' ); |
| 254 | - if( !empty( $autoloadedPlugins['plugins'] )) { |
|
| 254 | + if( !empty($autoloadedPlugins['plugins']) ) { |
|
| 255 | 255 | return array_merge( $plugins, $autoloadedPlugins['plugins'] ); |
| 256 | 256 | } |
| 257 | 257 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | protected function getPlugin( $plugin ) |
| 265 | 265 | { |
| 266 | - if( $this->isPluginInstalled( $plugin )) { |
|
| 266 | + if( $this->isPluginInstalled( $plugin ) ) { |
|
| 267 | 267 | return $this->getAllPlugins()[$plugin]; |
| 268 | 268 | } |
| 269 | 269 | return false; |
@@ -274,17 +274,17 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | protected function getPluginData( $plugin, $data, $key = null ) |
| 276 | 276 | { |
| 277 | - if( !is_array( $data )) { |
|
| 278 | - throw new Exception( sprintf( 'Plugin information not found for: %s', $plugin )); |
|
| 277 | + if( !is_array( $data ) ) { |
|
| 278 | + throw new Exception( sprintf( 'Plugin information not found for: %s', $plugin ) ); |
|
| 279 | 279 | } |
| 280 | 280 | $data['plugin'] = $plugin; |
| 281 | 281 | $data['slug'] = $this->getPluginSlug( $plugin ); |
| 282 | 282 | $data = array_change_key_case( $data ); |
| 283 | - if( is_null( $key )) { |
|
| 283 | + if( is_null( $key ) ) { |
|
| 284 | 284 | return $data; |
| 285 | 285 | } |
| 286 | 286 | $key = strtolower( $key ); |
| 287 | - return isset( $data[$key] ) |
|
| 287 | + return isset($data[$key]) |
|
| 288 | 288 | ? $data[$key] |
| 289 | 289 | : ''; |
| 290 | 290 | } |
@@ -332,6 +332,6 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | protected function getPluginSlug( $plugin ) |
| 334 | 334 | { |
| 335 | - return substr( $plugin, 0, strrpos( $plugin, '/' )); |
|
| 335 | + return substr( $plugin, 0, strrpos( $plugin, '/' ) ); |
|
| 336 | 336 | } |
| 337 | 337 | } |
@@ -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( Helper::toArray( $meta )) || empty( $field['slug'] )) { |
|
| 39 | + if( !$this->is_edit_screen() || !empty(Helper::toArray( $meta )) || empty($field['slug']) ) { |
|
| 40 | 40 | return $meta; |
| 41 | 41 | } |
| 42 | - $meta = call_user_func( [RWMB_Helpers_Field::get_class( $field ), 'esc_meta'], ( $saved |
|
| 42 | + $meta = call_user_func( [RWMB_Helpers_Field::get_class( $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 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function __construct() |
| 33 | 33 | { |
| 34 | - $this->file = realpath( dirname( dirname( __FILE__ )) . '/pollux.php' ); |
|
| 34 | + $this->file = realpath( dirname( dirname( __FILE__ ) ).'/pollux.php' ); |
|
| 35 | 35 | |
| 36 | 36 | $data = get_file_data( $this->file, array( |
| 37 | 37 | 'id' => 'Text Domain', |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | add_action( 'plugins_loaded', function() { |
| 60 | 60 | $this->bootstrap(); |
| 61 | 61 | }); |
| 62 | - add_action( 'admin_enqueue_scripts', array( $controller, 'registerAssets' )); |
|
| 63 | - add_action( 'admin_init', array( $controller, 'removeDashboardWidgets' )); |
|
| 64 | - add_action( 'wp_before_admin_bar_render', array( $controller, 'removeWordPressMenu' )); |
|
| 65 | - add_filter( "plugin_action_links_{$basename}", array( $controller, 'filterPluginLinks' )); |
|
| 66 | - add_filter( 'admin_footer_text', array( $controller, 'filterWordPressFooter' )); |
|
| 62 | + add_action( 'admin_enqueue_scripts', array( $controller, 'registerAssets' ) ); |
|
| 63 | + add_action( 'admin_init', array( $controller, 'removeDashboardWidgets' ) ); |
|
| 64 | + add_action( 'wp_before_admin_bar_render', array( $controller, 'removeWordPressMenu' ) ); |
|
| 65 | + add_filter( "plugin_action_links_{$basename}", array( $controller, 'filterPluginLinks' ) ); |
|
| 66 | + add_filter( 'admin_footer_text', array( $controller, 'filterWordPressFooter' ) ); |
|
| 67 | 67 | |
| 68 | 68 | // Disallow indexing of the site on non-production environments |
| 69 | 69 | if( !$this->environment( 'production' ) && !is_admin() ) { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | public function environment( $checkFor = '' ) |
| 79 | 79 | { |
| 80 | 80 | $environment = defined( 'WP_ENV' ) ? WP_ENV : 'production'; |
| 81 | - if( !empty( $checkFor )) { |
|
| 81 | + if( !empty($checkFor) ) { |
|
| 82 | 82 | return $environment == $checkFor; |
| 83 | 83 | } |
| 84 | 84 | return $environment; |
@@ -93,16 +93,16 @@ discard block |
||
| 93 | 93 | $theme = wp_get_theme(); |
| 94 | 94 | $filename = apply_filters( 'pollux/file', $filename ); |
| 95 | 95 | $locations = apply_filters( 'pollux/file/locations', [ |
| 96 | - trailingslashit( trailingslashit( $theme->theme_root ) . $theme->stylesheet ), |
|
| 97 | - trailingslashit( trailingslashit( $theme->theme_root ) . $theme->template ), |
|
| 96 | + trailingslashit( trailingslashit( $theme->theme_root ).$theme->stylesheet ), |
|
| 97 | + trailingslashit( trailingslashit( $theme->theme_root ).$theme->template ), |
|
| 98 | 98 | trailingslashit( WP_CONTENT_DIR ), |
| 99 | 99 | trailingslashit( ABSPATH ), |
| 100 | - trailingslashit( dirname( ABSPATH )), |
|
| 101 | - trailingslashit( dirname( dirname( ABSPATH ))), |
|
| 102 | - ]); |
|
| 103 | - foreach( (array) $locations as $location ) { |
|
| 104 | - if( !file_exists( $location . $filename ))continue; |
|
| 105 | - return $location . $filename; |
|
| 100 | + trailingslashit( dirname( ABSPATH ) ), |
|
| 101 | + trailingslashit( dirname( dirname( ABSPATH ) ) ), |
|
| 102 | + ] ); |
|
| 103 | + foreach( (array)$locations as $location ) { |
|
| 104 | + if( !file_exists( $location.$filename ) )continue; |
|
| 105 | + return $location.$filename; |
|
| 106 | 106 | } |
| 107 | 107 | return null; |
| 108 | 108 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function path( $file = '' ) |
| 129 | 129 | { |
| 130 | - return plugin_dir_path( $this->file ) . ltrim( trim( $file ), '/' ); |
|
| 130 | + return plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' ); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -137,11 +137,11 @@ discard block |
||
| 137 | 137 | public function render( $view, array $data = [] ) |
| 138 | 138 | { |
| 139 | 139 | $file = apply_filters( 'pollux/views/file', |
| 140 | - $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ))), |
|
| 140 | + $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ) ) ), |
|
| 141 | 141 | $view, |
| 142 | 142 | $data |
| 143 | 143 | ); |
| 144 | - if( !file_exists( $file ))return; |
|
| 144 | + if( !file_exists( $file ) )return; |
|
| 145 | 145 | extract( $data ); |
| 146 | 146 | include $file; |
| 147 | 147 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function url( $path = '' ) |
| 154 | 154 | { |
| 155 | - return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' )); |
|
| 155 | + return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | protected function loadHooks() |
| 187 | 187 | { |
| 188 | - if( $file = $this->getFile( 'pollux-hooks.php' )) { |
|
| 188 | + if( $file = $this->getFile( 'pollux-hooks.php' ) ) { |
|
| 189 | 189 | include_once $file; |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | protected function loadTextdomain() |
| 197 | 197 | { |
| 198 | - load_plugin_textdomain( $this->id, false, plugin_basename( $this->path() ) . '/languages/' ); |
|
| 198 | + load_plugin_textdomain( $this->id, false, plugin_basename( $this->path() ).'/languages/' ); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -207,6 +207,6 @@ discard block |
||
| 207 | 207 | 'ArchiveMeta' => 'GeminiLabs\Pollux\Facades\ArchiveMeta', |
| 208 | 208 | 'PostMeta' => 'GeminiLabs\Pollux\Facades\PostMeta', |
| 209 | 209 | 'SiteMeta' => 'GeminiLabs\Pollux\Facades\SiteMeta', |
| 210 | - )))->register(); |
|
| 210 | + ) ) )->register(); |
|
| 211 | 211 | } |
| 212 | 212 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public static function getInstance() |
| 39 | 39 | { |
| 40 | - if( is_null( static::$instance )) { |
|
| 40 | + if( is_null( static::$instance ) ) { |
|
| 41 | 41 | static::$instance = new static; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function make( $abstract ) |
| 70 | 70 | { |
| 71 | - $service = isset( $this->services[$abstract] ) |
|
| 71 | + $service = isset($this->services[$abstract]) |
|
| 72 | 72 | ? $this->services[$abstract] |
| 73 | 73 | : $this->addNamespace( $abstract ); |
| 74 | 74 | |
| 75 | - if( is_callable( $service )) { |
|
| 75 | + if( is_callable( $service ) ) { |
|
| 76 | 76 | return call_user_func_array( $service, [$this] ); |
| 77 | 77 | } |
| 78 | - if( is_object( $service )) { |
|
| 78 | + if( is_object( $service ) ) { |
|
| 79 | 79 | return $service; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function singleton( $abstract, $concrete ) |
| 94 | 94 | { |
| 95 | - $this->bind( $abstract, $this->make( $concrete )); |
|
| 95 | + $this->bind( $abstract, $this->make( $concrete ) ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function __get( $item ) |
| 106 | 106 | { |
| 107 | - return isset( $this->bucket[$item] ) |
|
| 107 | + return isset($this->bucket[$item]) |
|
| 108 | 108 | ? $this->bucket[$item] |
| 109 | 109 | : null; |
| 110 | 110 | } |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | protected function addNamespace( $abstract ) |
| 143 | 143 | { |
| 144 | - if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract )) { |
|
| 145 | - $abstract = __NAMESPACE__ . "\\$abstract"; |
|
| 144 | + if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract ) ) { |
|
| 145 | + $abstract = __NAMESPACE__."\\$abstract"; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | return $abstract; |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | * @param \ReflectionParameter $parameter |
| 153 | 153 | * @return null|\ReflectionClass|\ReflectionNamedType|\ReflectionType |
| 154 | 154 | */ |
| 155 | - protected function getClass($parameter) |
|
| 155 | + protected function getClass( $parameter ) |
|
| 156 | 156 | { |
| 157 | - if (version_compare(phpversion(), '8', '<')) { |
|
| 157 | + if( version_compare( phpversion(), '8', '<' ) ) { |
|
| 158 | 158 | return $parameter->getClass(); // @compat PHP < 8 |
| 159 | 159 | } |
| 160 | 160 | return $parameter->getType(); |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | return $this->notInstantiable( $concrete ); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if( is_null(( $constructor = $reflector->getConstructor() ))) { |
|
| 198 | + if( is_null( ($constructor = $reflector->getConstructor()) ) ) { |
|
| 199 | 199 | return new $concrete; |
| 200 | 200 | } |
| 201 | 201 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | protected function resolveClass( ReflectionParameter $parameter ) |
| 214 | 214 | { |
| 215 | 215 | try { |
| 216 | - return $this->make( $this->getClass($parameter)->getName() ); |
|
| 216 | + return $this->make( $this->getClass( $parameter )->getName() ); |
|
| 217 | 217 | } |
| 218 | 218 | catch( Exception $e ) { |
| 219 | 219 | if( $parameter->isOptional() ) { |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | foreach( $dependencies as $dependency ) { |
| 236 | 236 | // If the class is null, the dependency is a string or some other primitive type |
| 237 | - $results[] = !is_null( $class = $this->getClass($dependency) ) |
|
| 237 | + $results[] = !is_null( $class = $this->getClass( $dependency ) ) |
|
| 238 | 238 | ? $this->resolveClass( $dependency ) |
| 239 | 239 | : null; |
| 240 | 240 | } |