Skip to content

Commit

Permalink
feat: register hook add_meta_boxes in the correct order
Browse files Browse the repository at this point in the history
  • Loading branch information
mastudillot committed Nov 13, 2024
1 parent f85f4d9 commit f6be020
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions plugin/webpay-rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@
$hposExists = $hposHelper->checkIfHposExists();

add_action('plugins_loaded', 'registerPaymentGateways', 0);
add_action('wp_loaded', function () use ($hposExists) {
woocommerceTransbankInit($hposExists);
});
add_action('wp_loaded', 'woocommerceTransbankInit');
add_action('admin_init', 'on_transbank_rest_webpay_plugins_loaded');
add_action('add_meta_boxes', function () use ($hposExists) {
addTransbankStatusMetaBox($hposExists);
});

add_action('init', function() {
add_action('wp_ajax_check_connection', ConnectionCheck::class . '::check');
Expand Down Expand Up @@ -113,7 +114,7 @@ function (Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_
}
});

function woocommerceTransbankInit(bool $hposExists)
function woocommerceTransbankInit()
{
if (!class_exists('WC_Payment_Gateway')) {
noticeMissingWoocommerce();
Expand All @@ -122,7 +123,6 @@ function woocommerceTransbankInit(bool $hposExists)

registerAdminMenu();
registerPluginActionLinks();
registerMetaBoxes($hposExists);
NoticeHelper::registerNoticesDismissHook();
NoticeHelper::handleReviewNotice();
}
Expand Down Expand Up @@ -177,13 +177,6 @@ function registerPluginActionLinks()
});
}

function registerMetaBoxes(bool $hPosExists)
{
add_action('add_meta_boxes', function () use ($hPosExists) {
addTransbankStatusMetaBox($hPosExists);
});
}

function addTransbankStatusMetaBox(bool $hPosExists)
{
if ($hPosExists) {
Expand Down

0 comments on commit f6be020

Please sign in to comment.