Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Register_List_Tables | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
8 | |
100.00% |
1 / 1 |
| register_bitcoin_wallet_table | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
4 | |||
| register_bitcoin_address_table | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Register the admin table UIs for wallets and addresses. |
| 4 | * |
| 5 | * @package brianhenryie/bh-wp-bitcoin-gateway |
| 6 | */ |
| 7 | |
| 8 | namespace BrianHenryIE\WP_Bitcoin_Gateway\Admin; |
| 9 | |
| 10 | use WP_Screen; |
| 11 | |
| 12 | /** |
| 13 | * Return our WP_List_Table subclasses. |
| 14 | * |
| 15 | * @see _get_list_table() |
| 16 | */ |
| 17 | class Register_List_Tables { |
| 18 | |
| 19 | /** |
| 20 | * Use the `Wallets_List_Table` class on the `wp-admin/edit.php?post_type=bh-bitcoin-wallet` screen. |
| 21 | * |
| 22 | * @see _get_list_table() |
| 23 | * @hooked wp_list_table_class_name |
| 24 | * |
| 25 | * @param string $class_name Default WP_Posts_List_Table class to instantiate. |
| 26 | * @param array{screen?:WP_Screen|mixed} $args An array containing _get_list_table() arguments, which is seemingly just 'screen'. |
| 27 | * |
| 28 | * @return string |
| 29 | */ |
| 30 | public function register_bitcoin_wallet_table( string $class_name, array $args ): string { |
| 31 | |
| 32 | if ( isset( $args['screen'] ) && ( $args['screen'] instanceof WP_Screen ) && 'edit-bh-bitcoin-wallet' === $args['screen']->id ) { |
| 33 | return Wallets_List_Table::class; |
| 34 | } |
| 35 | |
| 36 | return $class_name; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Use the `Addresses_List_Table` class on the `wp-admin/edit.php?post_type=bh-bitcoin-address` screen. |
| 41 | * |
| 42 | * @see _get_list_table() |
| 43 | * @hooked wp_list_table_class_name |
| 44 | * |
| 45 | * @param string $class_name Default WP_Posts_List_Table class to instantiate. |
| 46 | * @param array{screen?:WP_Screen|mixed} $args An array containing _get_list_table() arguments, which is seemingly just 'screen'. |
| 47 | * |
| 48 | * @return string |
| 49 | */ |
| 50 | public function register_bitcoin_address_table( string $class_name, array $args ): string { |
| 51 | |
| 52 | if ( isset( $args['screen'] ) && ( $args['screen'] instanceof WP_Screen ) && 'edit-bh-bitcoin-address' === $args['screen']->id ) { |
| 53 | return Addresses_List_Table::class; |
| 54 | } |
| 55 | |
| 56 | return $class_name; |
| 57 | } |
| 58 | } |