I want to include WC_Admin_List_Table_Products
class in my custom plugin so I can re-use woocommerce product admin table in my plugin and customize the actions and buttons on different page. How I can do that? I have tried different ways as.
include_once( WP_PLUGIN_DIR . '/woocommerce/include/admin/list-tables/class-wc-admin-list-table-products.php' );
$wc_list_table = new WC_Admin_List_Table_Products();
Even using the plugin_dir_path.
include_once plugin_dir_path('woocommerce/include/admin/list-tables/class-wc-admin-list-table-products.php');
$wc_list_table = new WC_Admin_List_Table_Products();
Both are not working at all.
2
Answers
Using plugin_dir_path will not work as plugin_dir_path will return current plugin file or directory path. Replace below line with your line
You have made small mistake in writting directory name of ‘include‘. Correct directory name is ‘includes‘.
You should use it like this:
and then call your new class in the right location: