Skip to content

Commit

Permalink
attempt to fix rewrite reload issue
Browse files Browse the repository at this point in the history
  • Loading branch information
carlHandy committed Nov 18, 2024
1 parent 1ee4664 commit be8737e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion includes/class-mmg-checkout-payment-activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MMG_Checkout_Payment_Activator {
*/
public static function activate() {
self::mmg_activate();
add_action( 'init', array( 'self', 'add_rewrite_rules' ) );
// add_action( 'init', array( 'self', 'add_rewrite_rules' ) );
}

/**
Expand Down Expand Up @@ -65,3 +65,4 @@ private static function add_rewrite_rules() {
add_rewrite_tag( '%mmg-checkout%', '([^&]+)' );
}
}

20 changes: 20 additions & 0 deletions includes/class-mmg-checkout-payment-rewrites.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
class MMG_Checkout_Payment_Rewrites {
public static function init() {
add_action('init', array(__CLASS__, 'add_rewrite_rules'));
}

public static function add_rewrite_rules() {
add_rewrite_rule(
'^wc-api/mmg-checkout/([^/]+)/?',
'index.php?mmg-checkout=1&callback_key=$matches[1]',
'top'
);
add_rewrite_rule(
'^wc-api/mmg-checkout/([^/]+)/errorpayment/?',
'index.php?mmg-checkout=errorpayment&callback_key=$matches[1]',
'top'
);
add_rewrite_tag('%mmg-checkout%', '([^&]+)');
}
}
3 changes: 3 additions & 0 deletions main.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
require_once plugin_dir_path( __FILE__ ) . 'includes/class-mmg-checkout-payment-activator.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/class-mmg-checkout-payment-deactivator.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/class-mmg-checkout-payment-deactivator.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/class-mmg-checkout-payment-rewrites.php';
// This is temporary until the plugin is uploaded to the WordPress repository.
use YahnisElsts\PluginUpdateChecker\v5\PucFactory;

Expand All @@ -43,6 +44,8 @@
);
$update_checker->getVcsApi()->enableReleaseAssets();

MMG_Checkout_Payment_Rewrites::init();

if ( MMG_Dependency_Checker::check_dependencies() ) {
/**
* Initialize the MMG Checkout Payment functionality.
Expand Down

0 comments on commit be8737e

Please sign in to comment.