In Wordpress I'm creating a custom screen in the admin area.
For this I am extending my class customProductsListTable
to class WP_List_Table
:
class customProductsListTable extends WP_List_Table
I have another class for another custom screen that extends the same class WP_List_Table
:
class customReviewsListTable extends WP_List_Table
The problem is that in classes customProductsListTable
and customReviewsListTable
I have created some methods that are common and do not exist in class WP_List_Table
.
Then we have the following scenario:
-
The
customReviewsListTable
andcustomProductsListTable
classes overwrite some methods of theWP_List_Table
class, but the code behaves differently in each class. -
The
customReviewsListTable
andcustomProductsListTable
classes have new methods but with the same behavior.
I'm clearly duplicating code in both classes, but we can not inherit PHP in more than one class.
How to solve the code duplication problem?