bobbingwide / oik-loader

WordPress Must Use plugin to load required plugins
0 stars 0 forks source link

Create a block plugin loader for blocks.wp-a2z.org #1

Closed bobbingwide closed 2 years ago

bobbingwide commented 5 years ago

The WordPress blocks reference at https://blocks.wp-a2z.org contains documentation for Blocks for the WordPress Block Editor.

Stats

Content Catalogued To Do Projected - end 2019
Plugins 22 200 = 14 x 14 500
Blocks 155 2000 = 200 x 10 5000

Some home truths

Requirements

Proposed solution

bobbingwide commented 5 years ago

The first version of the code seemed to work for the oik-magnetic-block plugin. I now need to add an admin interface to support the following

  1. Enablement / disablement of the MU plugin
  2. Generation of the oik-loader.csv mapping file
  3. Display of the current status

The format of the CSV file is: URL ,ID,plugin-name where

The oik-loader.csv file will be generated in the WPMU_PLUGIN_DIR, normally wp-content/mu-plugins.

The first version only generates the entries for post type block. It may need to be extended for oik-plugins and block_example CPTs.

bobbingwide commented 5 years ago

Don't forget to make it work for WordPress Multi Site! Each site will need its own oik-loader.csv file, so give it a suffix based on the site ID. e.g. oik-loader.1.csv

bobbingwide commented 5 years ago

When the block is being loaded for Edit we need to detect the post ID which is passed in the edit query

/wp-admin/post.php?post=552&action=edit

when a Block within the block is being rendered we need to detect the post ID which is passed in the block-renderer query

/wp-json/wp/v2/block-renderer/oik-block/wp?
context=edit&attributes%5Bv%5D=v&attributes%5Bp%5D=p&attributes%5Bm%5D=M
&post_id=552

Note: For the post_id to be passed, ServerSideRender needs to be imported from wp.editor NOT wp.components.

bobbingwide commented 5 years ago

When a block is being previewed then the query is, for example

https://blocks.wp.a2z/oik-plugins/advanced-gutenberg/?
preview_id=110&preview_nonce=0be5da3f34&preview=true

So that's post, post_id and preview_id we might be looking for!

bobbingwide commented 5 years ago

Need to add block_example to the CPTs to index. Only for use on oik-plugins.com at present but you never know when someone might create examples on blocks.wp-a2z.org.

bobbingwide commented 5 years ago

Some updated stats, from blocks.wp.a2z

Stats

Content Catalogued Estimate To Do Projected - end 2019
Plugins 35 400 = 20 x 20 500
Blocks 325 4000 = 400 x 10 5000

Plugin count determined from https://wordpress.org/plugins/browse/blocks/ 20 pages of 20 per page, plus 1

Block estimate based on average blocks per plugin.

bobbingwide commented 5 years ago

Of the 400 plugins above here are some counts

I'll put them in order of most recently analysed, which should be the order you see on

https://wordpress.org/plugins/browse/blocks/

Unless the number of active installs changes drastically.

Plugin slug Blocks Notes
wpforms-lite 1
mailchimp-for-wp 1
Wp-smushit 0 It extends core/image
ninja-forms 1
nextgen-gallery 1 It broke my site
ml-slider 1
shortcodes-ultimate 0 Extends: paragraph, shortcode, classic
the-events-calendar 12 Only available to the tribe_events post type
sellpress 1 Needed some fiddling to make it work. See https://github.com/bobbingwide/genesis-a2z/issues/21
contact-widgets 2
smart-slider-3 1
amp 9 5 according to readme. but I can get it to list 9 blocks in s.b/wp53 - Twenty Twenty theme
woo-gutenberg-products-block 15 4 more than WooCommerce currently delivers
bobbingwide commented 5 years ago

Hmm, the Events Calendar plugin ( the-events-calendar ) creates blocks that are only available in the tribe_events CPT. So how do we documents them in oik_plugins and block.

And what the heck is going on here? image

bobbingwide commented 5 years ago

According to wordpress.org the SellPress plugin has 4 blocks. I think that's because it scans .js files for blocks.registerBlockType It found:

Cart Button

bobbingwide commented 5 years ago

I got sent a spreadsheet of 53,258 plugins in wordpress.org. This is 1,646 fewer than the 54,896 currently mentioned on https://wordpress.org/plugins/ I wrote a simple routine to find those plugins that seemed to match 'gutenberg' or 'block' This reduced the list to 977. Now I need to eliminate the false positives.
It's a helluva boring task.

I wrote back to the person who sent me the spreadsheet.

I've been reading up on the Block directory project with interest as I've been building my own block directory in parallel. What would be really nice is for the REST API to expose the all_blocks post meta data. Then I would be able to determine how many blocks are known in wordpress.org - not just the Javascript only ones. And I'd also be able to know how complete my repository is. Once populated with the bare bones details for each block it could then become more useful. Helping users to find the blocks they want to use. I used your spreadsheet to filter the subset of plugins that appear to deliver Gutenberg blocks. I found 551 plugins to consider. approx 150 more than in the curated list. For each of these I'll like to be able to obtain the all_blocks meta data. a simple select * from wp_postmeta where meta_key = 'all_blocks' would be a tremendous help.

bobbingwide commented 2 years ago

Closing this issue. oik-loader v1.2.0 is now on wp-a2z.org. I still don't have a fully automated process for finding and documenting blocks but it's getting better. See the oik-update plugin.