pronamic / wp-pronamic-pay

The Pronamic Pay plugin allows you to easily accept payments with payment methods like credit card, iDEAL, Bancontact and Sofort through a variety of payment providers on your WordPress website.
https://pronamicpay.com
35 stars 14 forks source link

WordPress.org » This plugin provides 4 blocks » 4 × "Pronamic Pay" #185

Closed remcotolsma closed 3 years ago

remcotolsma commented 3 years ago

https://wordpress.org/plugins/pronamic-ideal/

Schermafbeelding 2021-08-17 om 11 24 45

Why do we see a "Pronamic Pay" block 4 times on https://wordpress.org/plugins/pronamic-ideal/?

rvdsteege commented 3 years ago

Because we're registering 4 blocks (1 core and 3 fundraising).

Adding the titles might fix the displayed block names (we'll have to wait and see for next plugin update):

remcotolsma commented 3 years ago

@rvdsteege Was this just a guess, or did you read somewhere that this should fix it?

I searched for the "This plugin provides %d blocks." translation on https://translate.wordpress.org/ and found this: https://translate.wordpress.org/projects/meta/plugins-v3/nl/default/?filters%5Bstatus%5D=either&filters%5Boriginal_id%5D=7524862&filters%5Btranslation_id%5D=64565995

References: https://meta.trac.wordpress.org/browser/sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/section-blocks.php?marks=41#L41.

I think finding the blocks is handled in https://github.com/WordPress/wordpress.org/blob/3d3cc7df3b9be7a58ab369218b7a7a4eff845547/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php#L733-L797.

It seems that the titles for blocks registered via PHP are not being read?

Is a block.json file for each block the way forward?

Starting in WordPress 5.8 release, we encourage using the block.json metadata file as the canonical way to register block types. Here is an example block.json file that would define the metadata for a plugin create a notice block.

https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/

For WooCommerce I think it's read from the registerBlockType call from for example: https://plugins.trac.wordpress.org/browser/woocommerce/tags/5.6.0/packages/woocommerce-blocks/build/price-filter.js

rvdsteege commented 3 years ago

Adding the titles was a wild guess, but indeed did not resolve the issue.

remcotolsma commented 3 years ago

@rvdsteege I think we have to change the build script, store block.json for each block in https://github.com/pronamic/wp-pronamic-pay-fundraising/tree/develop/js/dist.

Same way like in https://plugins.trac.wordpress.org/browser/gutenberg/tags/11.5.1/build/block-library/blocks#calendar.

And start using register_block_type_from_metadata? https://github.com/WordPress/gutenberg/search?q=register_block_type_from_metadata

Same for the pronamic-pay/payment-form → "Payment Form" block in https://github.com/pronamic/wp-pay-core/search?q=register_block_type.

rvdsteege commented 3 years ago

Fundraising block.json added and started using register_block_type_from_metadata() (requires WordPress 5.5 or higher):

Issue left open to update payment form block.json.

rvdsteege commented 3 years ago

Seems that if there are block.json files, *.js and *.php files are not being processed by the wordpress.org plugin directory:

That is why only the fundraising blocks got listed now in the plugin directory. Added block.json for the pronamic-pay/payment-form block in https://github.com/pronamic/wp-pay-core/commit/0def70499e870a12de361c919f44b27992ecbdc3.