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:
| 1 | <?php |
||
| 27 | class LSX_Customize_Layout_Control extends WP_Customize_Control { |
||
| 28 | |||
| 29 | public $type = 'layout'; |
||
| 30 | public $statuses; |
||
| 31 | public $layouts = array(); |
||
| 32 | |||
| 33 | public function __construct( $manager, $id, $args = array() ) { |
||
| 34 | parent::__construct( $manager, $id, $args ); |
||
| 35 | if ( ! empty( $args['choices'] ) ) { |
||
| 36 | $this->layouts = $args['choices']; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Enqueue scripts/styles for the color picker. |
||
| 42 | */ |
||
| 43 | public function enqueue() { |
||
| 44 | wp_enqueue_script( 'lsx-layout-control', get_template_directory_uri() . '/assets/js/admin/customizer-layout.js', array( 'jquery' ), LSX_VERSION, true ); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Render output. |
||
| 49 | */ |
||
| 50 | public function render_content() { |
||
| 77 | </div> |
||
| 78 | </label> |
||
| 79 | <?php |
||
| 80 | } |
||
| 81 | |||
| 82 | } |
||
| 83 | |||
| 85 |