Merge pull request #351 from woocommerce/PCP-390-paypal-payments-page-empty-after

Add option for flushing rewrite rules
This commit is contained in:
Emili Castells 2021-11-08 15:14:29 +01:00 committed by GitHub
commit 1a5e5d88fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 2 deletions

4
.psalm/stubs.php Normal file
View file

@ -0,0 +1,4 @@
<?php
if (!defined('EP_PAGES')) {
define('EP_PAGES', 4096);
}

View file

@ -57,6 +57,27 @@ class VaultingModule implements ModuleInterface {
}
);
add_action(
'woocommerce_paypal_payments_gateway_migrate',
function () {
add_action(
'init',
function () {
add_rewrite_endpoint( 'ppcp-paypal-payment-tokens', EP_PAGES );
flush_rewrite_rules();
}
);
}
);
add_action(
'woocommerce_paypal_payments_gateway_activate',
function () {
add_rewrite_endpoint( 'ppcp-paypal-payment-tokens', EP_PAGES );
flush_rewrite_rules();
}
);
add_action(
'woocommerce_account_ppcp-paypal-payment-tokens_endpoint',
function () use ( $container ) {

View file

@ -37,7 +37,7 @@
"prearchive": "rm -rf $npm_package_name.zip",
"archive": "zip -r $npm_package_name.zip . -x **.git/\\* **node_modules/\\*",
"postarchive": "yarn run archive:cleanup && rm -rf $npm_package_name && unzip $npm_package_name.zip -d $npm_package_name && rm $npm_package_name.zip && zip -r $npm_package_name.zip $npm_package_name && rm -rf $npm_package_name",
"archive:cleanup": "zip -d $npm_package_name.zip .env* docker/\\* docker-compose.yml .editorconfig tests/\\* .github/\\* wordpress_org_assets/\\* \\*.DS_Store README.md .gitattributes .gitignore .travis.yml composer.json composer.lock package.json package-lock.json patchwork.json yarn.lock phpunit.xml.dist .phpunit.result.cache phpcs.xml.dist modules/ppcp-button/.babelrc modules/ppcp-button/package.json modules/ppcp-button/webpack.config.js modules/ppcp-button/yarn.lock vendor/\\*/.idea/\\* vendor/\\*/.gitignore vendor/\\*/.gitattributes vendor/\\*/.travis.yml"
"archive:cleanup": "zip -d $npm_package_name.zip .env* docker/\\* docker-compose.yml .editorconfig tests/\\* .github/\\* .psalm/\\* wordpress_org_assets/\\* \\*.DS_Store README.md .gitattributes .gitignore .travis.yml composer.json composer.lock package.json package-lock.json patchwork.json yarn.lock phpunit.xml.dist .phpunit.result.cache phpcs.xml.dist modules/ppcp-button/.babelrc modules/ppcp-button/package.json modules/ppcp-button/webpack.config.js modules/ppcp-button/yarn.lock vendor/\\*/.idea/\\* vendor/\\*/.gitignore vendor/\\*/.gitattributes vendor/\\*/.travis.yml"
},
"config": {
"wp_org_slug": "woocommerce-paypal-payments"

View file

@ -29,6 +29,7 @@
</projectFiles>
<stubs>
<file name=".psalm/stubs.php"/>
<file name="vendor/php-stubs/wordpress-stubs/wordpress-stubs.php"/>
<file name="vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php"/>
</stubs>

View file

@ -81,6 +81,16 @@ define( 'PPCP_FLAG_SUBSCRIPTION', true );
'plugins_loaded',
function () {
init();
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugin_data = get_plugin_data( __DIR__ . '/woocommerce-paypal-payments.php' );
$plugin_version = $plugin_data['Version'] ?? null;
if ( get_option( 'woocommerce-ppcp-version' ) !== $plugin_version ) {
do_action( 'woocommerce_paypal_payments_gateway_migrate' );
update_option( 'woocommerce-ppcp-version', $plugin_version );
}
}
);
register_activation_hook(
@ -88,7 +98,6 @@ define( 'PPCP_FLAG_SUBSCRIPTION', true );
function () {
init();
do_action( 'woocommerce_paypal_payments_gateway_activate' );
flush_rewrite_rules();
}
);
register_deactivation_hook(