Merge pull request #19436 from liquidweb/feature/register-additional-woocommerce-tables
Add the "woocommerce_install_get_tables" filter to WC_Install::get_tables()
This commit is contained in:
commit
127b9a89d0
|
@ -780,6 +780,15 @@ CREATE TABLE {$wpdb->prefix}woocommerce_termmeta (
|
|||
$tables[] = "{$wpdb->prefix}woocommerce_termmeta";
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the list of known WooCommerce tables.
|
||||
*
|
||||
* If WooCommerce plugins need to add new tables, they can inject them here.
|
||||
*
|
||||
* @param array $tables An array of WooCommerce-specific database table names.
|
||||
*/
|
||||
$tables = apply_filters( 'woocommerce_install_get_tables', $tables );
|
||||
|
||||
return $tables;
|
||||
}
|
||||
|
||||
|
|
|
@ -125,4 +125,25 @@ class WC_Tests_Install extends WC_Unit_Test_Case {
|
|||
|
||||
$this->assertEquals( $tables, WC_Install::get_tables() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test - get tables should apply the woocommerce_install_get_tables filter.
|
||||
*/
|
||||
public function test_get_tables_enables_filter() {
|
||||
$default = WC_Install::get_tables();
|
||||
$added = $this->append_table_to_get_tables( array() );
|
||||
|
||||
add_filter( 'woocommerce_install_get_tables', array( $this, 'append_table_to_get_tables' ) );
|
||||
|
||||
$this->assertEquals( $added, array_values( array_diff( WC_Install::get_tables(), $default ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter callback for test_get_tables_enables_filter().
|
||||
*/
|
||||
public function append_table_to_get_tables( $tables ) {
|
||||
$tables[] = 'some_table_name';
|
||||
|
||||
return $tables;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue