Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
bobbingwide opened this issue Mar 5, 2019 · 11 comments
Closed
4 tasks done

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

bobbingwide opened this issue Mar 5, 2019 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

bobbingwide commented Mar 5, 2019

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

  • At present it only contains reference information for 20 or so plugins.
  • Approximately 150 block CPTs have been created to document the blocks delivered by these plugins.
  • There'll be another 100 or so when all the blocks for these plugins have been created.

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

  • Some plugins do not play well with others.
  • Some plugins are resource hungry.
  • A WordPress website needs to be quick - server and load time
  • Some blocks are static... once the block content has been generated the plugin does not need to be active for the block to work
  • Others are dynamic... run time code is required to make the block work
  • There is a practical limit to how many plugins can be activated at any one time
  • There are a lot of plugins that deliver blocks
  • For a complete reference there will be a lot of block CPTs
  • We probably can't run a site with all the block plugins activated

Requirements

  • Run with as few plugins as possible activated
  • Auto activation of required plugin(s) to satisfy a request to view a block
  • Auto activation of required plugin(s) to satisfy a request to edit a block
  • Auto activation of required plugin(s) to satisfy a request to render a block in the editor

Proposed solution

  • A Must Use plugin that adds the required plugins to the list of plugins to load.
  • A directory of required plugins for each piece of content
  • A manageable solution to the problem
@bobbingwide bobbingwide added the enhancement New feature or request label Mar 5, 2019
@bobbingwide bobbingwide self-assigned this Mar 5, 2019
@bobbingwide
Copy link
Owner Author

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

  • URL is the full path of the permalink excluding scheme and domain
  • The plugin name is plugin-slug/plugin-main-file.php
  • ID is for cross reference and for mapping during edit

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
Copy link
Owner Author

bobbingwide commented Mar 6, 2019

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 added a commit that referenced this issue Mar 6, 2019
… activate/deactivate the oik-loader-mu plugin
@bobbingwide
Copy link
Owner Author

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
Copy link
Owner Author

bobbingwide commented Mar 8, 2019

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
Copy link
Owner Author

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
Copy link
Owner Author

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
Copy link
Owner Author

bobbingwide commented Oct 16, 2019

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 bobbingwide/genesis-a2z#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
Copy link
Owner Author

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
Copy link
Owner Author

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

  • sellpress/product; which is registered
  • shop-ct/category, shop-ct/catalog and shop-ct/cart-button;
    which are commented out.

Cart Button

@bobbingwide
Copy link
Owner Author

bobbingwide commented Oct 21, 2019

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
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant