1 | <?php |
||
10 | class MetaBox extends Component |
||
11 | { |
||
12 | const CONDITIONS = [ |
||
13 | 'hook', 'is_front_page', 'is_home', 'is_page_template', 'is_plugin_active', |
||
14 | 'is_plugin_inactive', |
||
15 | ]; |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | public $metaboxes; |
||
21 | |||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | public function init() |
||
32 | |||
33 | /** |
||
34 | * @return array |
||
35 | */ |
||
36 | public function register( $metaboxes = [] ) |
||
43 | |||
44 | /** |
||
45 | * @return bool |
||
46 | */ |
||
47 | public function isVisible( $bool, array $metabox ) |
||
48 | { |
||
49 | if( defined( 'DOING_AJAX' ) && DOING_AJAX |
||
50 | || !isset( $metabox['condition'] ) |
||
51 | || !$this->hasPostType( $metabox )) { |
||
52 | return $bool; |
||
53 | } |
||
54 | return $this->verifyMetaBoxCondition( $metabox['condition'] ); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @return bool |
||
59 | */ |
||
60 | public function verifyMetaBoxCondition( array $conditions ) |
||
70 | |||
71 | protected function addInstructions() |
||
88 | |||
89 | /** |
||
90 | * @return string |
||
91 | */ |
||
92 | protected function generateInstructions() |
||
105 | |||
106 | /** |
||
107 | * @return array |
||
108 | */ |
||
109 | protected function getInstructions() |
||
116 | |||
117 | /** |
||
118 | * @return int |
||
119 | */ |
||
120 | protected function getPostId() |
||
127 | |||
128 | /** |
||
129 | * @return array |
||
130 | */ |
||
131 | protected function getPostTypes() |
||
140 | |||
141 | /** |
||
142 | * @return bool |
||
143 | */ |
||
144 | protected function hasPostType( array $metabox ) |
||
151 | |||
152 | /** |
||
153 | * {@inheritdoc} |
||
154 | */ |
||
155 | protected function normalize() |
||
169 | |||
170 | /** |
||
171 | * @param mixed $conditions |
||
172 | * @return array |
||
173 | */ |
||
174 | protected function normalizeCondition( $conditions ) |
||
191 | |||
192 | /** |
||
193 | * @return array |
||
194 | */ |
||
195 | protected function normalizeFields( array $fields, array $data, $parentId ) |
||
208 | |||
209 | /** |
||
210 | * @param string $id |
||
211 | * @param string $parentId |
||
212 | * @return string |
||
213 | */ |
||
214 | protected function normalizeId( $id, array $data, $parentId ) |
||
218 | |||
219 | /** |
||
220 | * @param mixed $types |
||
221 | * @return array |
||
222 | */ |
||
223 | protected function normalizePostTypes( $types ) |
||
227 | |||
228 | /** |
||
229 | * @param string $value |
||
230 | * @return bool |
||
231 | */ |
||
232 | protected function validateHook( $value ) |
||
236 | |||
237 | /** |
||
238 | * @param bool $value |
||
239 | * @return bool |
||
240 | */ |
||
241 | protected function validateIsFrontPage( $value ) |
||
245 | |||
246 | /** |
||
247 | * @param bool $value |
||
248 | * @return bool |
||
249 | */ |
||
250 | protected function validateIsHome( $value ) |
||
254 | |||
255 | /** |
||
256 | * @param string $value |
||
257 | * @return bool |
||
258 | */ |
||
259 | protected function validateIsPageTemplate( $value ) |
||
263 | |||
264 | /** |
||
265 | * @param string $value |
||
266 | * @return bool |
||
267 | */ |
||
268 | protected function validateIsPluginActive( $value ) |
||
272 | |||
273 | /** |
||
274 | * @param string $value |
||
275 | * @return bool |
||
276 | */ |
||
277 | protected function validateIsPluginInactive( $value ) |
||
281 | |||
282 | /** |
||
283 | * @param string $key |
||
284 | * @param mixed $value |
||
285 | * @return bool |
||
286 | */ |
||
287 | protected function validateUnknown( $key, $value ) |
||
291 | } |
||
292 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.