Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
18 / 18 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Post_BH_Bitcoin_Transaction | |
100.00% |
18 / 18 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| register_transaction_post_type | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Add a custom post type for Bitcoin transaction. |
| 4 | * |
| 5 | * @see \BrianHenryIE\WP_Bitcoin_Gateway\Admin\Transactions_List_Table |
| 6 | * |
| 7 | * @package brianhenryie/bh-wp-bitcoin-gateway |
| 8 | */ |
| 9 | |
| 10 | namespace BrianHenryIE\WP_Bitcoin_Gateway\WP_Includes; |
| 11 | |
| 12 | use BrianHenryIE\WP_Bitcoin_Gateway\API\Model\Payments\Bitcoin_Transaction_WP_Post_Interface; |
| 13 | use BrianHenryIE\WP_Bitcoin_Gateway\API_Interface; |
| 14 | |
| 15 | /** |
| 16 | * Register the custom post types with WordPress. |
| 17 | * |
| 18 | * @see register_post_type() |
| 19 | * @see register_post_status() |
| 20 | * |
| 21 | * @see wp-admin/edit.php?post_type=bh-bitcoin-transaction |
| 22 | */ |
| 23 | class Post_BH_Bitcoin_Transaction { |
| 24 | |
| 25 | /** |
| 26 | * Array of plugin objects to pass to post types. |
| 27 | * |
| 28 | * @var array{api:API_Interface} $plugin_objects |
| 29 | */ |
| 30 | protected array $plugin_objects = array(); |
| 31 | |
| 32 | /** |
| 33 | * Constructor |
| 34 | * |
| 35 | * @param API_Interface $api The main plugin functions. |
| 36 | */ |
| 37 | public function __construct( API_Interface $api ) { |
| 38 | $this->plugin_objects['api'] = $api; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Registers the bh-bitcoin-transaction post type and its statuses. |
| 43 | * |
| 44 | * @hooked init |
| 45 | */ |
| 46 | public function register_transaction_post_type(): void { |
| 47 | |
| 48 | $labels = array( |
| 49 | 'name' => _x( 'Bitcoin Transactions', 'post type general name', 'bh-wp-bitcoin-gateway' ), |
| 50 | 'singular_name' => _x( 'Bitcoin Transaction', 'post type singular name', 'bh-wp-bitcoin-gateway' ), |
| 51 | 'menu_name' => 'Bitcoin Transactions', |
| 52 | ); |
| 53 | $args = array( |
| 54 | 'labels' => $labels, |
| 55 | 'description' => 'Transactions used with WooCommerce Bitcoin gateways.', |
| 56 | 'public' => true, |
| 57 | 'menu_position' => 8, |
| 58 | 'supports' => array( 'title', 'thumbnail', 'excerpt', 'comments' ), |
| 59 | 'has_archive' => false, |
| 60 | 'show_in_menu' => false, |
| 61 | 'plugin_objects' => $this->plugin_objects, |
| 62 | 'show_in_rest' => false, // TODO: change to `true` after ensuring correct authorization. |
| 63 | ); |
| 64 | register_post_type( Bitcoin_Transaction_WP_Post_Interface::POST_TYPE, $args ); |
| 65 | } |
| 66 | } |