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

Open
bobbingwide opened this Issue Mar 5, 2019 · 5 comments

Comments

Projects
None yet
1 participant
@bobbingwide
Copy link
Owner

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

This comment has been minimized.

Copy link
Owner Author

commented Mar 6, 2019

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

This comment has been minimized.

Copy link
Owner Author

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

Issue #1 - start adding admin page for oik-loader. Implement logic to…
… activate/deactivate the oik-loader-mu plugin
@bobbingwide

This comment has been minimized.

Copy link
Owner Author

commented Mar 7, 2019

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

This comment has been minimized.

Copy link
Owner Author

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

This comment has been minimized.

Copy link
Owner Author

commented Mar 9, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.