bobbingwide / oik-shortcodes

Shortcode, block and API server
https://www.oik-plugins.com/oik-plugins/oik-shortcode-server/
GNU General Public License v2.0
1 stars 0 forks source link

Add batch routine to create a block post given block_type_name, title and component #64

Closed bobbingwide closed 4 years ago

bobbingwide commented 5 years ago

There are over 140 blocks in the first 9 plugins that I want to catalogue. See #61. Manually creating them takes too long, even with the template for new posts.

Proposed solution

Create a batch routine to generate the posts, setting post_meta, Yoast SEO stuff and so on. Each block will need editing... but it'll be a kick start.

run from oik-shortcodes/admin

oikwp oik-create-blocks.php oik-block/uk-tides "UK Tides" oik-blocks
bobbingwide commented 5 years ago

Since there are so many blocks delivered by multiple plugins we need to make it easier to list them.

Requirements

Proposed solution

Auto population

example.

oikwp oik-create-blocks.php advgb/accordion "Accordion"  url=blocks.wp-a2z.org
oikwp oik-update-blocks.php advgb/accordion "accordion,list,faq" agb url=blocks.wp-a2z.org
bobbingwide commented 5 years ago

The keyword category is no longer limited to 3 keywords.

bobbingwide commented 5 years ago

For improved display of the excerpt the more tag should be after the block info tag.

bobbingwide commented 5 years ago

The batch routines served their purpose when creating new blocks but were only able to go so far.

I now want to add some PHP server logic that will generate / update the block definition given the block's registration information, including the icon.

Proposed solution

Implement an AJAX request oiksc_create_or_update_block that will be invoked from the Block List block. The PHP logic will combine the functions developed for the batch routine to create or update the definition for a block. When a new block CPT is being created it will create the correct oik-blocks/blockinfo block using the icon which is passed as a serialised string.

Most of the block CPT's fields should be correctly populated. It should then be a case of editing the generated content to create the example(s) and screenshot and adding a link to documentation, if known.

Stage 1 - Prototype

In this first version the AJAX request will be run directly by the user, by right clicking on the link in the block list block and choosing Open link in new window. The output from the AJAX request will be displayed here. This will include a link to edit the post after the create or update has been run.

See https://github.com/bobbingwide/oik-blocks/issues/27 for the changes to the Block list block.

Stage 2 - Reconciliation

The Block List block will assist in the process, providing buttons to perform the required actions, retrieving the results and displaying them accordingly.

bobbingwide commented 5 years ago

The json_encode() call used to encode attrs needs to include the additional option required in the oik-clone logic. JSON_UNESCAPED_UNICODE... to not encode Unicode characters. Example being the ellipsis ... which would be converted to /u2026.

How do I get a backslash on this iPad keyboard? Ah. Use the fn key: fn+x

bobbingwide commented 4 years ago

The original batch routine have been superceded by the AJAX method. This method sometimes fails when the block icon's SVG is enormous. The workaround is to edit the request to remove the icon and run it again. The issue was released in v1.35.0