@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function filterPluginLinks( array $links ) |
29 | 29 | { |
30 | - $settings_url = admin_url( sprintf( 'options-general.php?page=%s', $this->app->id )); |
|
30 | + $settings_url = admin_url( sprintf( 'options-general.php?page=%s', $this->app->id ) ); |
|
31 | 31 | $links[] = $this->app->config->disable_config |
32 | - ? sprintf( '<span class="network_only">%s</span>', __( 'Settings Disabled', 'pollux' )) |
|
33 | - : sprintf( '<a href="%s">%s</a>', $settings_url, __( 'Settings', 'pollux' )); |
|
32 | + ? sprintf( '<span class="network_only">%s</span>', __( 'Settings Disabled', 'pollux' ) ) |
|
33 | + : sprintf( '<a href="%s">%s</a>', $settings_url, __( 'Settings', 'pollux' ) ); |
|
34 | 34 | return $links; |
35 | 35 | } |
36 | 36 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $widgets = apply_filters( 'pollux/dashoard/widgets', [ |
84 | 84 | 'dashboard_primary', |
85 | 85 | 'dashboard_quick_press', |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | foreach( $widgets as $widget ) { |
88 | 88 | remove_meta_box( $widget, 'dashboard', 'normal' ); |
89 | 89 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | protected function registerSettingsAssets( WP_Screen $screen ) |
154 | 154 | { |
155 | - if( $screen->id == sprintf( 'toplevel_page_%s', Settings::id() )) { |
|
155 | + if( $screen->id == sprintf( 'toplevel_page_%s', Settings::id() ) ) { |
|
156 | 156 | wp_enqueue_script( 'common' ); |
157 | 157 | wp_enqueue_script( 'postbox' ); |
158 | 158 | wp_enqueue_script( 'wp-lists' ); |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | parent::init(); |
27 | 27 | |
28 | 28 | add_action( 'wp_ajax_pollux/archives/featured/html', [$this, 'getFeaturedImageHtml'] ); |
29 | - add_action( 'pollux/archives/init', [$this, 'registerFeaturedImageMetaBox'] ); |
|
30 | - add_action( 'pollux/archives/editor', [$this, 'renderEditor'], 10, 2 ); |
|
31 | - add_action( 'wp_ajax_pollux/archives/featured', [$this, 'setFeaturedImage'] ); |
|
32 | - add_filter( 'pollux/archives/metabox/submit', [$this, 'filterSubmitMetaBox'] ); |
|
33 | - add_filter( 'pollux/archives/show/instructions', '__return_true' ); |
|
29 | + add_action( 'pollux/archives/init', [$this, 'registerFeaturedImageMetaBox'] ); |
|
30 | + add_action( 'pollux/archives/editor', [$this, 'renderEditor'], 10, 2 ); |
|
31 | + add_action( 'wp_ajax_pollux/archives/featured', [$this, 'setFeaturedImage'] ); |
|
32 | + add_filter( 'pollux/archives/metabox/submit', [$this, 'filterSubmitMetaBox'] ); |
|
33 | + add_filter( 'pollux/archives/show/instructions', '__return_true' ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | public function canProceed() |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | return sprintf( '<pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
49 | 49 | array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) { |
50 | - return $instructions . $this->filterInstruction( null, ['slug' => $id], ['slug' => $this->getPostType()] ) . PHP_EOL; |
|
50 | + return $instructions.$this->filterInstruction( null, ['slug' => $id], ['slug' => $this->getPostType()] ).PHP_EOL; |
|
51 | 51 | }) |
52 | 52 | ); |
53 | 53 | } |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | public function filterSavedSettings( $settings ) |
71 | 71 | { |
72 | 72 | return $this->filter( 'save', array_intersect_key( |
73 | - array_merge( $this->getSettings(), Helper::toArray( $settings )), |
|
73 | + array_merge( $this->getSettings(), Helper::toArray( $settings ) ), |
|
74 | 74 | $this->getPostTypesWithArchive() |
75 | - )); |
|
75 | + ) ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function getFeaturedImageHtml() |
94 | 94 | { |
95 | - check_ajax_referer( sprintf( '%s-options', static::id() )); |
|
95 | + check_ajax_referer( sprintf( '%s-options', static::id() ) ); |
|
96 | 96 | static::$current = filter_input( INPUT_POST, 'post_type' ); |
97 | 97 | ob_start(); |
98 | - $this->renderFeaturedImageMetaBox( intval( filter_input( INPUT_POST, 'thumbnail_id' ))); |
|
98 | + $this->renderFeaturedImageMetaBox( intval( filter_input( INPUT_POST, 'thumbnail_id' ) ) ); |
|
99 | 99 | wp_send_json_success( ob_get_clean() ); |
100 | 100 | } |
101 | 101 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | public function register() |
118 | 118 | { |
119 | 119 | $screenId = Helper::getCurrentScreen()->id; |
120 | - if( in_array( $screenId, $this->hooks )) { |
|
120 | + if( in_array( $screenId, $this->hooks ) ) { |
|
121 | 121 | $this->hook = $screenId; |
122 | 122 | } |
123 | 123 | parent::register(); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function registerFeaturedImageMetaBox() |
131 | 131 | { |
132 | - if( !current_user_can( 'upload_files' ))return; |
|
132 | + if( !current_user_can( 'upload_files' ) )return; |
|
133 | 133 | add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [$this, 'renderFeaturedImageMetaBox'], null, 'side', 'low' ); |
134 | 134 | } |
135 | 135 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | public function registerPage() |
141 | 141 | { |
142 | 142 | foreach( $this->getPostTypesWithArchive() as $type => $page ) { |
143 | - $labels = get_post_type_labels( get_post_type_object( $type )); |
|
143 | + $labels = get_post_type_labels( get_post_type_object( $type ) ); |
|
144 | 144 | $this->hooks[$type] = call_user_func_array( 'add_submenu_page', $this->filter( 'page', [ |
145 | 145 | $page, |
146 | 146 | sprintf( _x( '%s Archive', 'post archive', 'pollux' ), $labels->singular_name ), |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | static::CAPABILITY, |
149 | 149 | sprintf( '%s_archive', $type ), |
150 | 150 | [$this, 'renderPage'], |
151 | - ])); |
|
151 | + ] ) ); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | 'resize' => false, |
170 | 170 | 'wp_autoresize_on' => true, |
171 | 171 | ], |
172 | - ]); |
|
172 | + ] ); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function renderFeaturedImageMetaBox( $imageId = null ) |
180 | 180 | { |
181 | - if( !is_numeric( $imageId )) { |
|
181 | + if( !is_numeric( $imageId ) ) { |
|
182 | 182 | $imageId = ArchiveMeta::get( $this->getPostType(), 'featured', -1 ); |
183 | 183 | } |
184 | - $imageSize = isset( wp_get_additional_image_sizes()['post-thumbnail'] ) |
|
184 | + $imageSize = isset(wp_get_additional_image_sizes()['post-thumbnail']) |
|
185 | 185 | ? 'post-thumbnail' |
186 | 186 | : [266, 266]; |
187 | 187 | $thumbnail = get_post( $imageId ) |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | 'post_type' => $this->getPostType(), |
196 | 196 | 'remove_image' => __( 'Remove featured image', 'pollux' ), |
197 | 197 | 'thumbnail' => $thumbnail, |
198 | - ]); |
|
198 | + ] ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | public function renderPage() |
206 | 206 | { |
207 | 207 | $type = $this->getPostType(); |
208 | - if( empty( $type ))return; |
|
209 | - $labels = get_post_type_labels( get_post_type_object( $type )); |
|
208 | + if( empty($type) )return; |
|
209 | + $labels = get_post_type_labels( get_post_type_object( $type ) ); |
|
210 | 210 | $this->app->render( 'archive/index', [ |
211 | 211 | 'columns' => get_current_screen()->get_columns(), |
212 | 212 | 'content' => ArchiveMeta::get( $type, 'content', '' ), |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | 'id' => static::id(), |
215 | 215 | 'post_type' => $type, |
216 | 216 | 'title' => ArchiveMeta::get( $type, 'title', '' ), |
217 | - ]); |
|
217 | + ] ); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | protected function getPostType() |
232 | 232 | { |
233 | 233 | $type = array_search( $this->hook, $this->hooks ); |
234 | - if( !empty( $type ) && is_string( $type )) { |
|
234 | + if( !empty($type) && is_string( $type ) ) { |
|
235 | 235 | static::$current = $type; |
236 | 236 | } |
237 | 237 | return static::$current; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | { |
245 | 245 | $types = array_map( function( $value ) { |
246 | 246 | return sprintf( 'edit.php?post_type=%s', $value ); |
247 | - }, get_post_types( ['has_archive' => 1] )); |
|
247 | + }, get_post_types( ['has_archive' => 1] ) ); |
|
248 | 248 | return array_merge( $types, ['post' => 'edit.php'] ); |
249 | 249 | } |
250 | 250 | |
@@ -253,6 +253,6 @@ discard block |
||
253 | 253 | */ |
254 | 254 | protected function getSettings() |
255 | 255 | { |
256 | - return (array) ArchiveMeta::all(); |
|
256 | + return (array)ArchiveMeta::all(); |
|
257 | 257 | } |
258 | 258 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | { |
24 | 24 | foreach( $this->types as $type => $args ) { |
25 | 25 | add_action( "manage_{$type}_posts_custom_column", [$this, 'printColumnValue'], 10, 2 ); |
26 | - add_filter( "manage_{$type}_posts_columns", function( $columns ) use( $args ) { |
|
26 | + add_filter( "manage_{$type}_posts_columns", function( $columns ) use($args) { |
|
27 | 27 | return count( $args['columns'] ) > 1 |
28 | 28 | ? $args['columns'] |
29 | 29 | : $columns; |
@@ -52,15 +52,15 @@ discard block |
||
52 | 52 | protected function getColumnThumbnail( $postId ) |
53 | 53 | { |
54 | 54 | if( has_post_thumbnail( $postId ) ) { |
55 | - list( $src, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), 'thumbnail' ); |
|
55 | + list($src, $width, $height) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), 'thumbnail' ); |
|
56 | 56 | $thumbnail = sprintf( '<img src="%s" alt="%s" width="%s" height="%s">', |
57 | - esc_url( set_url_scheme( $src )), |
|
58 | - esc_attr( get_the_title( $postId )), |
|
57 | + esc_url( set_url_scheme( $src ) ), |
|
58 | + esc_attr( get_the_title( $postId ) ), |
|
59 | 59 | $width, |
60 | 60 | $height |
61 | 61 | ); |
62 | 62 | } |
63 | - return empty( $thumbnail ) |
|
63 | + return empty($thumbnail) |
|
64 | 64 | ? '—' |
65 | 65 | : $thumbnail; |
66 | 66 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | return count( PostMeta::get( 'media', [ |
74 | 74 | 'fallback' => [], |
75 | 75 | 'single' => false, |
76 | - ])); |
|
76 | + ] ) ); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | protected function normalizeColumns( array $columns ) |
92 | 92 | { |
93 | 93 | $columns = array_flip( $columns ); |
94 | - $columns = array_merge( $columns, array_intersect_key( $this->columns, $columns )); |
|
94 | + $columns = array_merge( $columns, array_intersect_key( $this->columns, $columns ) ); |
|
95 | 95 | return ['cb' => '<input type="checkbox">'] + $columns; |
96 | 96 | } |
97 | 97 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $defaults = [ |
104 | 104 | 'author' => __( 'Author', 'pollux' ), |
105 | 105 | 'categories' => __( 'Categories', 'pollux' ), |
106 | - 'comments' => sprintf( '<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%1$s</span></span>', __( 'Comments', 'pollux' )), |
|
106 | + 'comments' => sprintf( '<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%1$s</span></span>', __( 'Comments', 'pollux' ) ), |
|
107 | 107 | 'date' => __( 'Date', 'pollux' ), |
108 | 108 | 'media' => __( 'Media', 'pollux' ), |
109 | 109 | 'slug' => __( 'Slug', 'pollux' ), |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | |
28 | 28 | remove_action( 'welcome_panel', 'wp_welcome_panel' ); |
29 | 29 | |
30 | - add_action( 'init', [$this, 'disable'] ); |
|
30 | + add_action( 'init', [$this, 'disable'] ); |
|
31 | 31 | add_action( 'wp_dashboard_setup', [$this, 'modifyDashboardWidgets'] ); |
32 | - add_action( 'welcome_panel', [$this, 'modifyWelcomePanel'] ); |
|
33 | - add_action( 'admin_bar_menu', [$this, 'removeFromAdminBar'], 999 ); |
|
34 | - add_action( 'admin_menu', [$this, 'removeFromAdminMenu'] ); |
|
35 | - add_action( 'admin_init', [$this, 'unregisterDashboardWidgets'] ); |
|
36 | - add_action( 'widgets_init', [$this, 'unregisterWidgets'], 1 ); |
|
37 | - add_filter( 'posts_results', [$this, 'filterPostQuery'] ); |
|
38 | - add_filter( 'pre_get_posts', [$this, 'filterSearchQuery'] ); |
|
32 | + add_action( 'welcome_panel', [$this, 'modifyWelcomePanel'] ); |
|
33 | + add_action( 'admin_bar_menu', [$this, 'removeFromAdminBar'], 999 ); |
|
34 | + add_action( 'admin_menu', [$this, 'removeFromAdminMenu'] ); |
|
35 | + add_action( 'admin_init', [$this, 'unregisterDashboardWidgets'] ); |
|
36 | + add_action( 'widgets_init', [$this, 'unregisterWidgets'], 1 ); |
|
37 | + add_filter( 'posts_results', [$this, 'filterPostQuery'] ); |
|
38 | + add_filter( 'pre_get_posts', [$this, 'filterSearchQuery'] ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | { |
47 | 47 | if( !in_array( Helper::getCurrentScreen()->pagenow, [ |
48 | 48 | 'edit.php', 'edit-tags.php', 'post-new.php', |
49 | - ]))return; |
|
49 | + ] ) )return; |
|
50 | 50 | |
51 | 51 | if( !filter_input_array( INPUT_GET, [ |
52 | 52 | 'post_type' => FILTER_DEFAULT, |
53 | 53 | 'taxonomy' => FILTER_DEFAULT, |
54 | - ])) { |
|
54 | + ] ) ) { |
|
55 | 55 | wp_safe_redirect( get_admin_url(), 301 ); |
56 | 56 | exit; |
57 | 57 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | if( $this->isAdmin() || !$query->is_main_query() || !is_search() ) { |
87 | 87 | return $query; |
88 | 88 | } |
89 | - $post_types = get_post_types( ['exclude_from_search' => false ] ); |
|
90 | - unset( $post_types['post'] ); |
|
89 | + $post_types = get_post_types( ['exclude_from_search' => false] ); |
|
90 | + unset($post_types['post']); |
|
91 | 91 | $query->set( 'post_type', array_values( $post_types ) ); |
92 | 92 | return $query; |
93 | 93 | } |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function modifyDashboardWidgets() |
100 | 100 | { |
101 | - if( !is_blog_admin() || !current_user_can( 'edit_posts' ))return; |
|
101 | + if( !is_blog_admin() || !current_user_can( 'edit_posts' ) )return; |
|
102 | 102 | |
103 | 103 | global $wp_meta_boxes; |
104 | 104 | $widgets = &$wp_meta_boxes['dashboard']['normal']['core']; |
105 | - if( !isset( $widgets['dashboard_right_now']['callback'] ))return; |
|
105 | + if( !isset($widgets['dashboard_right_now']['callback']) )return; |
|
106 | 106 | $widgets['dashboard_right_now']['callback'] = function() { |
107 | 107 | ob_start(); |
108 | 108 | wp_dashboard_right_now(); |
@@ -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( 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,11 +102,15 @@ 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; |
|
111 | + if( !isset( $widgets['dashboard_right_now']['callback'] )) { |
|
112 | + return; |
|
113 | + } |
|
106 | 114 | $widgets['dashboard_right_now']['callback'] = function() { |
107 | 115 | ob_start(); |
108 | 116 | wp_dashboard_right_now(); |
@@ -39,7 +39,7 @@ |
||
39 | 39 | $data = wp_parse_args( $data, $defaults ); |
40 | 40 | foreach( $defaults as $key => $value ) { |
41 | 41 | $method = Helper::buildMethodName( $key, 'normalize' ); |
42 | - if( method_exists( $this, $method )) { |
|
42 | + if( method_exists( $this, $method ) ) { |
|
43 | 43 | $data[$key] = $this->$method( $data[$key], $data, $id ); |
44 | 44 | } |
45 | 45 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | protected function isAbsoluteConditionValid( $method, array $values ) |
69 | 69 | { |
70 | 70 | foreach( $values as $value ) { |
71 | - if( $this->$method( $value ))continue; |
|
71 | + if( $this->$method( $value ) )continue; |
|
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | return true; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | protected function isConditionValid( $key, $values ) |
83 | 83 | { |
84 | 84 | $method = Helper::buildMethodName( $key, 'validate' ); |
85 | - if( !method_exists( $this, $method )) { |
|
85 | + if( !method_exists( $this, $method ) ) { |
|
86 | 86 | return $this->validateUnknown( $key, $values ); |
87 | 87 | } |
88 | 88 | $values = Helper::toArray( $values ); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | protected function isLooseConditionValid( $method, array $values ) |
99 | 99 | { |
100 | 100 | foreach( $values as $value ) { |
101 | - if( !$this->$method( $value ))continue; |
|
101 | + if( !$this->$method( $value ) )continue; |
|
102 | 102 | return true; |
103 | 103 | } |
104 | 104 | return false; |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | */ |
111 | 111 | protected function normalizeCondition( $conditions ) |
112 | 112 | { |
113 | - if( !is_array( $conditions )) { |
|
113 | + if( !is_array( $conditions ) ) { |
|
114 | 114 | $conditions = []; |
115 | 115 | } |
116 | - if( count( array_filter( array_keys( $conditions ), 'is_string' )) == 0 ) { |
|
116 | + if( count( array_filter( array_keys( $conditions ), 'is_string' ) ) == 0 ) { |
|
117 | 117 | foreach( $conditions as $key ) { |
118 | 118 | $conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
119 | 119 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | return array_intersect_key( |
125 | 125 | $conditions, |
126 | - array_flip( $this->filter( 'conditions', static::conditions() )) |
|
126 | + array_flip( $this->filter( 'conditions', static::conditions() ) ) |
|
127 | 127 | ); |
128 | 128 | } |
129 | 129 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | protected function validateIsFrontPage( $value ) |
171 | 171 | { |
172 | - return $value == ( $this->getPostId() == get_option( 'page_on_front' )); |
|
172 | + return $value == ($this->getPostId() == get_option( 'page_on_front' )); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | protected function validateIsHome( $value ) |
180 | 180 | { |
181 | - return $value == ( $this->getPostId() == get_option( 'page_for_posts' )); |
|
181 | + return $value == ($this->getPostId() == get_option( 'page_for_posts' )); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | protected function validateIsPageTemplate( $value ) |
189 | 189 | { |
190 | - return Helper::endsWith( $value, basename( get_page_template_slug( $this->getPostId() ))); |
|
190 | + return Helper::endsWith( $value, basename( get_page_template_slug( $this->getPostId() ) ) ); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -68,7 +68,9 @@ discard block |
||
68 | 68 | protected function isAbsoluteConditionValid( $method, array $values ) |
69 | 69 | { |
70 | 70 | foreach( $values as $value ) { |
71 | - if( $this->$method( $value ))continue; |
|
71 | + if( $this->$method( $value )) { |
|
72 | + continue; |
|
73 | + } |
|
72 | 74 | return false; |
73 | 75 | } |
74 | 76 | return true; |
@@ -98,7 +100,9 @@ discard block |
||
98 | 100 | protected function isLooseConditionValid( $method, array $values ) |
99 | 101 | { |
100 | 102 | foreach( $values as $value ) { |
101 | - if( !$this->$method( $value ))continue; |
|
103 | + if( !$this->$method( $value )) { |
|
104 | + continue; |
|
105 | + } |
|
102 | 106 | return true; |
103 | 107 | } |
104 | 108 | return false; |
@@ -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,12 +276,12 @@ 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; |
|
281 | - $dependency = array_search( $value, array_column( $fields, 'id' )); |
|
279 | + array_walk( $depends, function( $value, $index ) use(&$fields, $metabox) { |
|
280 | + if( empty($value) )return; |
|
281 | + $dependency = array_search( $value, array_column( $fields, 'id' ) ); |
|
282 | 282 | $fields[$index]['attributes']['data-depends'] = $value; |
283 | - if( !$this->getMetaValue( $fields[$dependency]['slug'], '', $metabox['slug'] )) { |
|
284 | - $fields[$index]['class'] = trim( 'hidden ' . $fields[$index]['class'] ); |
|
283 | + if( !$this->getMetaValue( $fields[$dependency]['slug'], '', $metabox['slug'] ) ) { |
|
284 | + $fields[$index]['class'] = trim( 'hidden '.$fields[$index]['class'] ); |
|
285 | 285 | } |
286 | 286 | }); |
287 | 287 | return $metabox; |
@@ -32,7 +32,9 @@ 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} )) { |
|
36 | + return; |
|
37 | + } |
|
36 | 38 | $this->normalize( $this->app->config->{static::ID}, [ |
37 | 39 | 'post_types' => [], |
38 | 40 | ]); |
@@ -260,7 +262,9 @@ discard block |
||
260 | 262 | protected function normalizeValidation( array $validation, array $data, $parentId ) |
261 | 263 | { |
262 | 264 | foreach( ['messages', 'rules'] as $key ) { |
263 | - if( empty( $validation[$key] ))continue; |
|
265 | + if( empty( $validation[$key] )) { |
|
266 | + continue; |
|
267 | + } |
|
264 | 268 | foreach( $validation[$key] as $id => $value ) { |
265 | 269 | $validation[$key][$this->normalizeFieldName( $id, ['slug' => $id], $parentId )] = $value; |
266 | 270 | unset( $validation[$key][$id] ); |
@@ -277,7 +281,9 @@ discard block |
||
277 | 281 | $fields = &$metabox['fields']; |
278 | 282 | $depends = array_column( $fields, 'depends' ); |
279 | 283 | array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) { |
280 | - if( empty( $value ))return; |
|
284 | + if( empty( $value )) { |
|
285 | + return; |
|
286 | + } |
|
281 | 287 | $dependency = array_search( $value, array_column( $fields, 'id' )); |
282 | 288 | $fields[$index]['attributes']['data-depends'] = $value; |
283 | 289 | if( !$this->getMetaValue( $fields[$dependency]['slug'], '', $metabox['slug'] )) { |
@@ -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 | /** |
@@ -104,7 +104,7 @@ discard block |
||
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 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | public function register() |
126 | 126 | { |
127 | 127 | if( Helper::getCurrentScreen()->id != $this->hook )return; |
128 | - if( $this->app->gatekeeper->hasDependency( self::DEPENDENCY )) { |
|
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 | /** |
@@ -174,7 +174,7 @@ discard block |
||
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 | /** |
@@ -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 | |
@@ -124,7 +126,9 @@ discard block |
||
124 | 126 | */ |
125 | 127 | public function register() |
126 | 128 | { |
127 | - if( Helper::getCurrentScreen()->id != $this->hook )return; |
|
129 | + if( Helper::getCurrentScreen()->id != $this->hook ) { |
|
130 | + return; |
|
131 | + } |
|
128 | 132 | if( $this->app->gatekeeper->hasDependency( self::DEPENDENCY )) { |
129 | 133 | foreach( parent::register() as $metabox ) { |
130 | 134 | new RWMetaBox( $metabox, static::ID, $this ); |
@@ -169,7 +173,9 @@ discard block |
||
169 | 173 | */ |
170 | 174 | public function renderFooterScript() |
171 | 175 | { |
172 | - if( Helper::getCurrentScreen()->id != $this->hook )return; |
|
176 | + if( Helper::getCurrentScreen()->id != $this->hook ) { |
|
177 | + return; |
|
178 | + } |
|
173 | 179 | $this->app->render( 'settings/script', [ |
174 | 180 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
175 | 181 | 'hook' => $this->hook, |
@@ -217,7 +223,9 @@ discard block |
||
217 | 223 | { |
218 | 224 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
219 | 225 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
220 | - )return; |
|
226 | + ) { |
|
227 | + return; |
|
228 | + } |
|
221 | 229 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
222 | 230 | update_option( static::id(), $this->getDefaults() ); |
223 | 231 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
@@ -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_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 | } |