wp-pay-extensions /
memberpress
| 1 | <?php |
||||
| 2 | /** |
||||
| 3 | * Admin transactions |
||||
| 4 | * |
||||
| 5 | * @author Pronamic <[email protected]> |
||||
| 6 | * @copyright 2005-2019 Pronamic |
||||
| 7 | * @license GPL-3.0-or-later |
||||
| 8 | * @package Pronamic\WordPress\Pay\Extensions\MemberPress |
||||
| 9 | */ |
||||
| 10 | |||||
| 11 | namespace Pronamic\WordPress\Pay\Extensions\MemberPress\Admin; |
||||
| 12 | |||||
| 13 | use WP_Query; |
||||
| 14 | |||||
| 15 | /** |
||||
| 16 | * Admin transactions |
||||
| 17 | * |
||||
| 18 | * @author Remco Tolsma |
||||
| 19 | * @version 2.0.4 |
||||
| 20 | * @since 1.0.0 |
||||
| 21 | */ |
||||
| 22 | class AdminTransactions { |
||||
| 23 | /** |
||||
| 24 | * Setup. |
||||
| 25 | */ |
||||
| 26 | public function setup() { |
||||
| 27 | // @link https://github.com/wp-premium/memberpress-business/blob/1.3.36/app/controllers/MeprTransactionsCtrl.php |
||||
| 28 | $hook = 'memberpress_page_memberpress-trans'; |
||||
| 29 | |||||
| 30 | add_filter( 'manage_' .$hook . '_columns', array( $this, 'manage_transactions_columns' ), 10 ); |
||||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||||
| 31 | |||||
| 32 | add_filter( 'mepr_view_get_string', array( $this, 'extend_transaction_row' ), 10, 3 ); |
||||
| 33 | add_filter( 'mepr_view_get_string', array( $this, 'extend_transaction_form' ), 10, 3 ); |
||||
| 34 | } |
||||
| 35 | |||||
| 36 | /** |
||||
| 37 | * Manage transactions columns. |
||||
| 38 | * |
||||
| 39 | * @param array $columns Columns. |
||||
| 40 | */ |
||||
| 41 | public function manage_transactions_columns( $columns ) { |
||||
| 42 | $columns['pronamic_payment'] = __( 'Pronamic Payment', 'pronamic_ideal' ); |
||||
| 43 | |||||
| 44 | return $columns; |
||||
| 45 | } |
||||
| 46 | |||||
| 47 | /** |
||||
| 48 | * Extend transaction row. |
||||
| 49 | * |
||||
| 50 | * @link https://github.com/wp-premium/memberpress-business/blob/1.3.36/app/controllers/MeprTransactionsCtrl.php#L479-L486 |
||||
| 51 | * @link https://github.com/wp-premium/memberpress-business/blob/1.3.36/app/views/admin/transactions/list.php |
||||
| 52 | * @link https://github.com/wp-premium/memberpress-business/blob/1.3.36/app/views/admin/transactions/row.php |
||||
| 53 | * |
||||
| 54 | * @param string $view View. |
||||
| 55 | * @param string $slug Slug. |
||||
| 56 | * @param array $vars Variables. |
||||
| 57 | * @return string |
||||
| 58 | */ |
||||
| 59 | public function extend_transaction_row( $view, $slug, $vars ) { |
||||
|
1 ignored issue
–
show
The parameter
$vars is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 60 | if ( '/admin/transactions/row' !== $slug ) { |
||||
| 61 | return $view; |
||||
| 62 | } |
||||
| 63 | |||||
| 64 | /* |
||||
| 65 | * Unfortunately there is currently no filter to extend the transactions table row. |
||||
| 66 | * @link https://github.com/wp-premium/memberpress-business/blob/1.3.36/app/views/admin/transactions/row.php |
||||
| 67 | * |
||||
| 68 | * If we want to add a custom column we should extend the HTML/DOM. |
||||
| 69 | * @link https://docs.gravityforms.com/gform_submit_button/#5-append-custom-css-classes-to-the-button |
||||
| 70 | */ |
||||
| 71 | |||||
| 72 | return $view; |
||||
| 73 | } |
||||
| 74 | |||||
| 75 | /** |
||||
| 76 | * Extend transaction form. |
||||
| 77 | * |
||||
| 78 | * @param string $view View. |
||||
| 79 | * @param string $slug Slug. |
||||
| 80 | * @param array $vars Variables. |
||||
| 81 | * @return string |
||||
| 82 | */ |
||||
| 83 | public function extend_transaction_form( $view, $slug, $vars ) { |
||||
| 84 | if ( '/admin/transactions/trans_form' !== $slug ) { |
||||
| 85 | return $view; |
||||
| 86 | } |
||||
| 87 | |||||
| 88 | if ( ! array_key_exists( 'txn', $vars ) ) { |
||||
| 89 | return $view; |
||||
| 90 | } |
||||
| 91 | |||||
| 92 | $memberpress_transaction = $vars['txn']; |
||||
| 93 | |||||
| 94 | /* |
||||
| 95 | * Check if variable is a object, should be instance of `MeprTransaction`. |
||||
| 96 | * @link https://github.com/wp-premium/memberpress-business/blob/1.3.36/app/models/MeprTransaction.php |
||||
| 97 | */ |
||||
| 98 | if ( ! is_object( $memberpress_transaction ) ) { |
||||
| 99 | return $view; |
||||
| 100 | } |
||||
| 101 | |||||
| 102 | if ( ! isset( $memberpress_transaction->id ) ) { |
||||
| 103 | return $view; |
||||
| 104 | } |
||||
| 105 | |||||
| 106 | $memberpress_transaction_id = $memberpress_transaction->id; |
||||
| 107 | |||||
| 108 | ob_start(); |
||||
| 109 | |||||
| 110 | include dirname( __FILE__ ) . '/../../views/transaction-form.php'; |
||||
| 111 | |||||
| 112 | $view .= ob_get_clean(); |
||||
| 113 | |||||
| 114 | return $view; |
||||
| 115 | } |
||||
| 116 | } |
||||
| 117 |