pronamic / wp-pay-core

Core components for the WordPress payment processing library. This library is used in the WordPress plugin Pronamic Pay: https://www.pronamicpay.com/, but also allows other plugin developers to set up a payment plugin.
https://www.wp-pay.org/
GNU General Public License v3.0
27 stars 3 forks source link

Home URL changes detection problem with empty URL #119

Closed remcotolsma closed 1 year ago

remcotolsma commented 1 year ago

We had some users with the following notice:

Scherm­afbeelding 2023-05-24 om 11 59 31

This is already fixed/improved in https://github.com/pronamic/wp-pay-core/commit/4eeb83ae251dff9e33c603e4d8be06817516714d.

Before we could not reproduce this, but i think saving the Pronamic Pay settings page causes this. We register the pronamic_pay_home_url setting but have no settings field for this setting.

https://github.com/pronamic/wp-pay-core/blob/4eeb83ae251dff9e33c603e4d8be06817516714d/src/HomeUrlController.php#L42-L51

We should check how WordPress handles the saving of registered settings. Should we not register settings that don't have UI settings field?

remcotolsma commented 1 year ago

Registered setting are added to the $new_allowed_options array and merged in https://github.com/WordPress/wordpress-develop/blob/d51ee6ce097fb288aca9da1f95899fc3d77c0fa4/src/wp-includes/option.php#L2430

remcotolsma commented 1 year ago

The advantage of registering the setting is the sanitze callback and adjusting the value via, for example, the /wp-admin/options.php page.