PluginProbe
PayPlug for WooCommerce (Official) / 2.9.0
PayPlug for WooCommerce (Official) v2.9.0
3.1.0 3.0.0 2.18.0 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.10.0 1.10.1 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 All 102 releases
← All changes | src/Admin/Metabox.php +76 -76 2.18.0 → 2.9.0 View file →
@@ -2,10 +2,10 @@
2 2
3 3 namespace Payplug\PayplugWoocommerce\Admin;
4 4
5 5 // Exit if accessed directly
6 -if (!defined('ABSPATH')) {
7 - exit;
6 +if ( ! defined( 'ABSPATH' ) ) {
7 + exit;
8 8 }
9 9
10 10 use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
11 11 use Payplug\PayplugWoocommerce\PayplugWoocommerceHelper;
@@ -12,110 +12,110 @@
12 12 use WP_Post;
13 13
14 14 /**
15 15 * PayPlug metadata metabox.
16 + *
17 + * @package Payplug\PayplugWoocommerce\Admin
16 18 */
17 -class Metabox
18 -{
19 - /**
20 - * Metabox constructor.
21 - */
22 - public function __construct()
23 - {
24 - add_action('add_meta_boxes', [$this, 'register_payplug_metabox'], 100);
25 - }
19 +class Metabox {
26 20
27 - /**
28 - * Register a custom metabox to display metadata for the current order.
29 - *
30 - * This metabox is only register if the current order has been paid via PayPlug.
31 - */
32 - public function register_payplug_metabox()
33 - {
34 - global $post;
21 + /**
22 + * Metabox constructor.
23 + */
24 + public function __construct() {
25 + add_action( 'add_meta_boxes', [ $this, 'register_payplug_metabox' ], 100 );
26 + }
35 27
36 - $screen = class_exists('\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController') && wc_get_container()->get(CustomOrdersTableController::class)->custom_orders_table_usage_is_enabled()
37 - ? function_exists('wc_get_page_screen_id') ? wc_get_page_screen_id('shop-order') : 'shop_order'
38 - : 'shop_order';
28 + /**
29 + * Register a custom metabox to display metadata for the current order.
30 + *
31 + * This metabox is only register if the current order has been paid via PayPlug.
32 + */
33 + public function register_payplug_metabox() {
34 + global $post;
39 35
40 - add_meta_box(
41 - 'payplug-transaction-details',
42 - __('PayPlug payment details', 'payplug'),
43 - [$this, 'render'],
44 - $screen,
45 - 'side'
46 - );
47 - }
36 + $screen = class_exists( '\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController' ) && wc_get_container()->get( CustomOrdersTableController::class )->custom_orders_table_usage_is_enabled()
37 + ? function_exists("wc_get_page_screen_id") ? wc_get_page_screen_id( 'shop-order' ) : "shop_order"
38 + : 'shop_order';
48 39
49 - /**
50 - * Render the metabox content.
51 - *
52 - * @param WP_Post $post
53 - */
54 - public function render($post)
55 - {
56 - $order = ($post instanceof WP_Post) ? wc_get_order($post->ID) : $post;
40 + add_meta_box(
41 + 'payplug-transaction-details',
42 + __( 'PayPlug payment details', 'payplug' ),
43 + [ $this, 'render' ],
44 + $screen,
45 + 'side'
46 + );
47 + }
57 48
58 - if (false === $order) {
59 - return;
60 - }
49 + /**
50 + * Render the metabox content.
51 + *
52 + * @param WP_Post $post
53 + */
54 + public function render( $post ) {
61 55
62 - if (!in_array($order->get_payment_method(), ['payplug', 'oney_x3_with_fees', 'oney_x4_with_fees', 'oney_x3_without_fees', 'oney_x4_without_fees', 'bancontact', 'apple_pay', 'american_express', 'satispay', 'sofort', 'ideal', 'mybank', 'wero', 'bizum', 'scalapay'])) {
63 - return;
64 - }
56 + $order = ( $post instanceof WP_Post ) ? wc_get_order( $post->ID ) : $post;
65 57
66 - $metadata = PayplugWoocommerceHelper::get_transaction_metadata($order);
67 - $date_format = get_option('date_format', 'j F Y');
68 - $time_format = get_option('time_format', 'G \h i \m\i\n');
69 - if (empty($metadata)) : ?>
70 - <p><?php _e('No metadata available for the current order.', 'payplug'); ?></p>
58 + if ( false === $order ) {
59 + return;
60 + }
61 +
62 + if( !in_array($order->get_payment_method(), ['payplug', 'oney_x3_with_fees', 'oney_x4_with_fees', 'oney_x3_without_fees', 'oney_x4_without_fees','bancontact', 'apple_pay', 'american_express', 'satispay', 'sofort', 'ideal', 'mybank'])){
63 + return;
64 + }
65 +
66 + $metadata = PayplugWoocommerceHelper::get_transaction_metadata( $order );
67 + $date_format = get_option( 'date_format', 'j F Y' );
68 + $time_format = get_option( 'time_format', 'G \h i \m\i\n' );
69 + if ( empty( $metadata ) ) : ?>
70 + <p><?php _e( 'No metadata available for the current order.', 'payplug' ); ?></p>
71 71 <?php else : ?>
72 72 <ul>
73 - <li><span><?php _e('PayPlug Payment ID', 'payplug'); ?>
74 - :</span> <?php echo esc_html($metadata['transaction_id']); ?></li>
75 - <li><span><?php _e('Status', 'payplug'); ?>
73 + <li><span><?php _e( 'PayPlug Payment ID', 'payplug' ); ?>
74 + :</span> <?php echo esc_html( $metadata['transaction_id'] ); ?></li>
75 + <li><span><?php _e( 'Status', 'payplug' ); ?>
76 76 :</span>
77 - <?php if (isset($metadata['refunded']) && true === $metadata['refunded']) : _e('Refunded', 'payplug'); ?>
78 - <?php elseif (isset($metadata['refunded']) && false === $metadata['refunded'] && (int) $metadata['amount_refunded'] > 0) : _e('Partially refunded', 'payplug'); ?>
79 - <?php elseif (isset($metadata['paid']) && true === $metadata['paid']) : _e('Paid', 'payplug'); ?>
80 - <?php else : _e('Not Paid', 'payplug'); ?>
77 + <?php if ( isset( $metadata['refunded'] ) && true === $metadata['refunded'] ) : _e( 'Refunded', 'payplug' ); ?>
78 + <?php elseif ( isset( $metadata['refunded'] ) && false === $metadata['refunded'] && (int) $metadata['amount_refunded'] > 0 ) : _e( 'Partially refunded', 'payplug' ); ?>
79 + <?php elseif ( isset( $metadata['paid'] ) && true === $metadata['paid'] ) : _e( 'Paid', 'payplug' ); ?>
80 + <?php else : _e( 'Not Paid', 'payplug' ); ?>
81 81 <?php endif; ?>
82 82 </li>
83 83 <!-- PPRO methods don't have card brand info-->
84 - <?php if (empty($metadata['card_brand']) && $order->get_payment_method() != 'payplug') { ?>
85 - <li><span><?php _e('payment_method', 'payplug'); ?>:</span> <?php echo str_replace('_', ' ', ucfirst($order->get_payment_method())); ?></li>
84 + <?php if( empty( $metadata['card_brand'] ) && $order->get_payment_method() != 'payplug' ){ ?>
85 + <li><span><?php _e( 'payment_method', 'payplug' ); ?>:</span> <?php echo str_replace("_", " ",ucfirst($order->get_payment_method())); ?></li>
86 86 <?php } ?>
87 - <li><span><?php _e('Amount', 'payplug'); ?>
88 - :</span> <?php echo wc_price((int) $metadata['amount'] / 100); ?></li>
89 - <li><span><?php _e('Paid at', 'payplug'); ?>
90 - :</span> <?php echo !empty($metadata['paid_at']) ? esc_html(date_i18n(sprintf('%s %s', $date_format, $time_format), $metadata['paid_at'])) : ''; ?>
87 + <li><span><?php _e( 'Amount', 'payplug' ); ?>
88 + :</span> <?php echo wc_price( (int) $metadata['amount'] / 100 ); ?></li>
89 + <li><span><?php _e( 'Paid at', 'payplug' ); ?>
90 + :</span> <?php echo ! empty( $metadata['paid_at'] ) ? esc_html( date_i18n( sprintf( '%s %s', $date_format, $time_format ), $metadata['paid_at'] ) ) : ''; ?>
91 91 </li>
92 92
93 - <?php if (!empty($metadata['card_brand'])) { ?>
94 - <li><span><?php _e('Credit card', 'payplug'); ?>
95 - :</span> <?php echo !empty($metadata['card_brand']) ? esc_html(sprintf('%s (%s)', $metadata['card_brand'], $metadata['card_country'])) : ''; ?>
93 + <?php if(!empty( $metadata['card_brand'])){ ?>
94 + <li><span><?php _e( 'Credit card', 'payplug' ); ?>
95 + :</span> <?php echo ! empty( $metadata['card_brand'] ) ? esc_html( sprintf( '%s (%s)', $metadata['card_brand'], $metadata['card_country'] ) ) : ''; ?>
96 96 </li>
97 97 <?php } ?>
98 98
99 - <?php if (!empty($metadata['card_last4'])) { ?>
100 - <li><span><?php _e('Card mask', 'payplug'); ?>
101 - :</span> <?php echo !empty($metadata['card_last4']) ? esc_html(sprintf('**** **** **** %s', $metadata['card_last4'])) : ''; ?>
99 + <?php if(!empty( $metadata['card_last4'])){ ?>
100 + <li><span><?php _e( 'Card mask', 'payplug' ); ?>
101 + :</span> <?php echo ! empty( $metadata['card_last4'] ) ? esc_html( sprintf( '**** **** **** %s', $metadata['card_last4'] ) ) : ''; ?>
102 102 </li>
103 103 <?php } ?>
104 104
105 - <li><span><?php _e('3 D Secure', 'payplug'); ?>
106 - :</span> <?php echo isset($metadata['3ds']) ? true === $metadata['3ds'] ? __('Yes', 'payplug') : __('No', 'payplug') : ''; ?>
105 + <li><span><?php _e( '3 D Secure', 'payplug' ); ?>
106 + :</span> <?php echo isset( $metadata['3ds'] ) ? true === $metadata['3ds'] ? __( 'Yes', 'payplug' ) : __( 'No', 'payplug' ) : ''; ?>
107 107 </li>
108 108
109 - <?php if (!empty($metadata['card_exp_month']) && !empty($metadata['card_exp_year'])) { ?>
110 - <li><span><?php _e('Expiration date', 'payplug'); ?>
111 - :</span> <?php echo (!empty($metadata['card_exp_month']) && !empty($metadata['card_exp_year'])) ? esc_html(sprintf('%s/%s', zeroise($metadata['card_exp_month'], 2), zeroise($metadata['card_exp_year'], 2))) : ''; ?>
109 + <?php if( ! empty( $metadata['card_exp_month'] ) && ! empty( $metadata['card_exp_year'] ) ){ ?>
110 + <li><span><?php _e( 'Expiration date', 'payplug' ); ?>
111 + :</span> <?php echo ( ! empty( $metadata['card_exp_month'] ) && ! empty( $metadata['card_exp_year'] ) ) ? esc_html( sprintf( '%s/%s', zeroise( $metadata['card_exp_month'], 2 ), zeroise( $metadata['card_exp_year'], 2 ) ) ) : ''; ?>
112 112 </li>
113 113 <?php } ?>
114 114
115 - <li><span><?php _e('Mode', 'payplug'); ?>
116 - :</span> <?php echo true === $metadata['live'] ? _e('Live', 'payplug') : _e('Test', 'payplug'); ?>
115 + <li><span><?php _e( 'Mode', 'payplug' ); ?>
116 + :</span> <?php echo true === $metadata['live'] ? _e( 'Live', 'payplug' ) : _e( 'Test', 'payplug' ); ?>
117 117 </li>
118 118 </ul>
119 119 <?php endif;
120 - }
120 + }
121 121 }