for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
<?php
/*
* This file is part of the WPFoundation library.
*
* Copyright (c) 2015 LIN3S <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace LIN3S\WPFoundation\PostTypes\Fields;
/**
* Abstract custom post type fields class that extends the fields basic
* behaviour, implementing the "connector" and "removeScreenAttributes"
* methods with the common use case.
* @author Beñat Espiña <[email protected]>
abstract class CustomPostTypeFields extends Fields
{
* {@inheritdoc}
public function connector()
return [
[
'param' => 'post_type',
'operator' => '==',
'value' => $this->name,
],
];
}
public function removeScreenAttributes()
remove_post_type_support('page', 'comments');
remove_post_type_support('page', 'custom-fields');