Open bobbingwide opened 5 years ago
In the first stage of this development we'll copy the functions from the OIK_component_update
class into a parent class OIK_wp_a2z
which the OIK_blocker
class will extend.
We'll implement the logic to:
Note: Some plugins aren't versioned in wordpress.org.
These need to be downloaded with a blank version
parameter.
e.g.
oikwp oik-blocker.php block-gallery "" url=blocks.wp.a2z
oikwp oik-blocker.php coblocks "" url=blocks.wp.a2z
In the next stage we'll attach the banner image to the oik_plugin post. We may need to create an attachment A new banner file will replace the existing file.
Then we'll add logic to update the post content to match the desired structure, if the content doesn't already contain a bw_plug shortcode. And logic to create the oik-plugins post if it doesn't already exist.
Now we need to improve the creation of the block list block. Adding the ‘component’ is easy. Getting the prefix is harder. the prefix can be found using v1.2 of the WordPress plugins api. I’ve added some logic to the downloads routine in wp-top12 that gets the list of blocks known to wordpress.org.
Seems to work.
This routine’s been working reasonably well but needs a couple of tweaks.
15 months later... I've been going through the rather laborious process of updating the blocks for the plugins already catalogued. On the live site:
So less than half way.
There are some plugins with many blocks and variations that I haven't catalogued and I need a faster mechanism for creating the missing blocks.
Plugin | slug | # blocks | catalogued | # block.json |
---|---|---|---|---|
WooCommerce Blocks | woo-gutenberg-products-block | 51 | 28 | 21 |
Cosmic Blocks | cosmic-blocks | 50 | 0 | 0 |
Stackable | stackable-ultimate-gutenberg-blocks | 125 | 0 | 63 |
Ultimate Addons for Gutenberg | ultimate-addons-for-gutenberg | 66 | 33 | 0 |
For the complete list of numbers of blocks to be catalogued see https://blocks.wp-a2z.org/about/block-plugin-summary/ WooCommerce blocks are also created in woocommerce.wp-a2z.org
blocks
routine to automatically detect blocks that are registered from block.json
filesWIBNI's...
Using the blocks social-share-buttons-lite
routine to register the Algori Social Share Buttons Lite plugin the
post_name for the generated block didn't match the name generated by the oik-block/blocklist block.
The Block title is Social Share Buttons but the generated block has a post title prefixed with Algori
Workaround is to remove the Algori prefix from the generated block's post title and update the permalink.
This routine’s been working reasonably well but needs a couple of tweaks.
- When it can’t find a banner to upload it shouldn’t upload an empty file
- I need to make sure it’s safe to use when I want to catalogue my own single block plugins.
Ditto for when the plugin name was incorrect in the first place. Don't create the plugin at all.
I definitely want to do this.
The blocks.bat
file, which runs oik-blocker.php
, extract below is OK for creating blocks for a new block plugin.
cd c:\apache\htdocs\wp-a2z\wp-content\plugins\oik-update
php c:\apache\htdocs\wp-a2z\wp-content\plugins\oik-batch\oik-wp.php oik-blocker.php %* url=blocks.wp.a2z
But it's no good for existing plugins that needs updating.
Improve the process such that if no parameters to oik-blocker.php
are specified it finds the list of plugins that need updating and applies the updates, running $oik_blocker
's methods as appropriate.
The logic that detects if the plugin is a Git repo should not apply updates to plugins in the WP-a2z organization.
These would still need to be processed by the update.bat
file.
Obtain the list of plugins to be updated from the wp_sitemeta
table _site_transient_update_plugins
.
The API to access this information $option = get_site_option( "_site_transient_update_plugins" );
For each plugin in the list apply the updates to the plugin and any blocks listed in block.json files.
Note: Similar logic can be applied for themes.
For each plugin in the list apply the updates to the plugin and any blocks listed in block.json files.
I changed the logic to get a list of plugins to be updated. There are a couple of problems.
media-file-renamer
. I got a Fatal with this.
Fatal error: Cannot redeclare media_upload_tabs()
(previously declared in C:\apache\htdocs\wp-a2z\wp-admin\includes\media.php:18)
I also got the same Fatal attempting to upload the todo-list-block banner.
Looks like I've got to change some more include
commands to include_once
or require_once
, as I had to do in update_installed_plugin()
when first enabling the loop.
Having implemented the changes to oik-blocker.php
I ran it against blocks.wp.a2z and blocks.wp-a2z.org
There were a couple of problems.
- Blocks created for wptravel and other plugins don't have a title
Block | Explanation |
---|---|
a8c/post-lists | Incomplete block.json found in full-site-editing\posts-list-block\blocks\posts-list |
homepage-articles | Incomplete block.json in full-site-editing\newspack-blocks\synced-newspack-blocks\blocks\homepage-articles |
core/widget-group | Incomplete block.json in gutenberg\build\widgets\blocks\widget-group |
shareablock | Incomplete block.json in block-options\src\blocks\shareablock |
wp-travel x n | Incomplete blocks.json in wp-travel-blocks\src\blocks subdirectories |
Several blocks with theme-isle
prefix were created for the otter-blocks
plugin, which is registered as Gutenberg Blocks and Template library.
facebook-for-woocommerce
.Correcting the problem involved matching the oik-plugins
entry with an existing plugin.
- Some plugins didn't get updated since they can't be downloaded using the version number.
When applying automatic updates we can save a bit of processing by using information from the plugin_info structure. eg. For the Download Manager plugin, which doesn't have any blocks, but is a dependency for WPDM - Gutenberg Blocks the plugin_info structure is:
stdClass Object
(
[id] => w.org/plugins/download-manager
[slug] => download-manager
[plugin] => download-manager/download-manager.php
[new_version] => 3.2.40
[url] => https://wordpress.org/plugins/download-manager/
[package] => https://downloads.wordpress.org/plugin/download-manager.zip
[icons] => Array
(
[2x] => https://ps.w.org/download-manager/assets/icon-256x256.png?rev=1561688
[1x] => https://ps.w.org/download-manager/assets/icon-128x128.png?rev=1561688
)
[banners] => Array
(
[1x] => https://ps.w.org/download-manager/assets/banner-772x250.png?rev=1722853
)
[banners_rtl] => Array
(
)
[requires] => 5.3
[tested] => 5.9.3
[requires_php] =>
)
Here we can see:
package
doesn't include the version number: https://downloads.wordpress.org/plugin/download-manager.zip
.png
file. Run oik-loader update to refresh the list.
After updating plugins and blocks, oik-loader's Rebuild index logic shoud be run automatically.
This is not the same as visiting https://blocks.wp.a2z/wp-admin/admin.php?page=oik_loader&mu=rebuild
since this requires the user to be logged in. Just implement the underlying functionality.
In wp.a2z I have multiple versions of Gutenberg installed. A couple of the versions are back level, they always appear to need updating. oik-blocker runs this when it's unnecessary. Perhaps it should ignore any plugin that starts Gutenberg
To cater for plugins which don’t use block.json files, it might make sense to invoke a server function that will determine the blocks that are registered in the server and create/update the block post from this list.
The process will involve
The first thing to write here are steps 2 and 3.
I started writing some code for step 2 and quickly discovered that this may be a non-starter. The information for the registered blocks may not be as useful in the server; the list of blocks / variations is incomplete or key data may be missing.
Component | # server blocks | # client blocks | Notes on server registered blocks |
---|---|---|---|
core | 136 | 193 | Doesn't list the variations of core/embed |
jetpack | 47 | 50 | No titles or descriptions available |
coblocks | 29 | 67 | No titles or descriptions available |
stackable | 36 | 37 + 91 | Doesn't list variations |
Differences for Jetpack are: server includes: jetpack/donations, jetpack/simple-payments, jetpack/social-previews, jetpack/videopress-block client includes: jetpack/related-posts and the 7 variations.
I didn't look at the differences for CoBlocks or Stackable
For plugin version updates I'm now considering another client-server solution that will perform a reconciliation of the blocks listed in the front end with those registered in the server for the selected component.
oik/blocklist
block, from the oik-blocks plugin. Regarding Stackable ( stackable-ultimate-gutenberg-blocks ).
In blocks.wp.a2z I'd already documented blocks prefixed with ugb
. eg ugb/accordion
.
stackable-v2
. (v2)
. Since v3 Stackable's blocks
stackable
and have a category of stackable
.Other than changing the title, I reckon I'll leave the documentation for the v2 blocks as they are.
Issue #1 makes it easier to get a new run time version of a component in a Git repo which just contains the released versions. This is needed for re-parsing the PHP, using the oik-shortcodes batch routine.
For components which deliver WordPress blocks ( primarily plugins ) we also want to be able to automate, as far as is possible, the process of registering the plugin and identifying and then registering the blocks delivered by the plugin.
We want a process similar to
oik-update.php
which will bring together the manual steps required. The process should take into consideration whether or not the plugin has an existing Git repository. Ideally the routine would be run as a batch routine. For the time being we’ll call itoik-blocker.php
Syntax:
Where Plugin is the name of the plugin to download Version is the version number to download - latest will do Etc are other parameters we might need to pass manually
The manual process will need to evolve to cater for my development and run-time environments.