Open bobbingwide opened 2 years ago
Unpack to wp-a2z
Instead of unpacking to the wp-content/themes
folder I implemented similar logic for plugins... install the theme.
This has its drawbacks...
This logic doesn't cater for themes which are not supported in the currently installed version of WordPress.
Notes:
fetch theme info
In the first version of this routine I've used the logic I developed for wp-top12 - accessing the theme's info from a cached version of the theme info. in cache_t2/wporg_saved.themes.slug.json
where slug is the theme's slug eg tt1-blocks
.
This assumes that the wp-top12 downloads routine has been run for all FSE themes.
If I were to want to use this logic on blocks.wp-a2z.org then I need the following:
WP_org_downloads_themes::get_theme()
returns null it attempt to load and save the theme info. ie. update the cache.If I were to want to use this logic on blocks.wp-a2z.org
I tried this and discovered other problems
wp-admin/file.php
which causes a problem when we try to load it.#Workaround: deactivate Jetpack.
find directory for patterns
In Gutenberg 12.1.0, templates and template parts are expected to be found in predefined folders.
But patterns are not.
The Twenty Twenty Two theme registers its patterns in response to init
. See inc/block-patterns.php
.
The callback function is twentytwentytwo_register_block_patterns
.
The patterns are themselves stored in inc\patterns
.
After filtering the required patterns are registered
register_block_pattern(
'twentytwentytwo/' . $block_pattern,
require $pattern_file
);
Other themes register the patterns with inline structures Each pattern has a number of fields. Some are required.
Field | Example | Notes |
---|---|---|
name | twentytwentytwo/general-divider-dark | |
title | Divider with image and color (dark) | Translatable |
content | Block HTML markup for the pattern, which may contain PHP to provide variable results at run time | |
description | Optional | |
viewportWidth | Optional | |
categories | [ featured ] | Array of categories |
keywords | Array of keywords | |
blockTypes | Optional array of blocks |
Documentation for register_block_pattern()
doesn't quite match the usage in Twenty Twenty Two, which uses blockTypes
and categories
but not other fields.
If we want to simulate the pattern registration we can consider loading and invoking the callback function programmatically. This is preferable to making the theme the active theme. But it's a bit of a fiddle.
if ( class_exists( 'WP_Block_Patterns_Registry' ) ) {
// Remove core patterns except 'Two Columns of Text'.
// Unfortunately, \WP_Block_Patterns_Registry::get_instance()->get_all_registered() doesn't return the pattern names as keys.
foreach ( \WP_Block_Patterns_Registry::get_instance()->get_all_registered() as $pattern ) {
find directory for patterns
The solution I found for patterns was to use the preview_theme
capability in oik-patterns. See https://github.com/bobbingwide/oik-patterns/issues/4
There are now 64 FSE themes registered in wordpress.org https://wordpress.org/themes/tags/full-site-editing/ I need a quick process that will register the themes in blocks.wp.a2z then clone them to blocks.wp-a2z.org OR to simply run on the live server.
In addition to the 10 new themes that need installing and cataloguing 42 of the themes installed in wp.a2z need updating. We need logic similar to that for blocks to
Update oik-themer.php
theme_preview
request to repopulate the patterns.oik-update v1.3.0 is now on wp-a2z.org and oik-themer.php has been run. There was one glitch due to the Grigori Blocks theme requiring PHP 7.4 but PHP version on the command line was 7.3 Resolved by setting the PHP version to 8.0 by updating the alias.
alias php='/usr/local/php80/bin/php-cli'
64 themes on wordpress.org are now published on blocks.wp-a2z.org. See the theme summary https://blocks.wp-a2z.org/about/fse-themes-summary/
Note: The themes process can be run on both blocks.wp.a2z
and blocks.wp-a2z.org
.
It should produce the same results in both environments.
Doing this is quicker than the original process which involved running the themes
routine on both sites.
And a hell of a lot faster than the previous process which required the themes to be installed and updated manually.
I closed this issue before completing the tasks listed in April. Now there's a new theme, twentytwentythree, which isn't yet on wordpress.org but which I want to document. Running themes twentytwentythree
didn't work. But I need to register it to both blocks.wp.a2z ( blocks and themes ) and wp.a2z ( WordPress a2z plugins and themes ). Re-opening therefore.
The task to implement is this one.
TwentyTwenty-Three is now on wordpress.org... but there's another problem.
If a theme is no longer tagged full-site-editing
then it doesn't appear in wordpress.org's list
but it's not removed from my site.
It appears that the them called Edunation was updated on 10th November.
Some of the tags were changed in style.css.
full-site-editing
became Full Site Editing
.
Assuming this was an intentional change there are two problems to address
The latest problem I had was when the system attempted to update a theme requiring a parent theme.
Downloading: https://downloads.wordpress.org/theme/gutenify-architech.1.0.2.zip
Written: /home/customer/www/bobbingwide.org.uk/public_html//downloads/themes/gutenify-architech.1.0.2.zip
Bytes: 2032044
<div class="wrap"><h1></h1><p>Unpacking the package…</p>
<p>Installing the theme…</p>
<p>Removing the old version of the theme…</p>
<p>This theme requires a parent theme. Checking if it is installed…</p>
Fatal error: Uncaught Error: Call to undefined function themes_api().
Fatal error: Uncaught Error: Call to undefined function themes_api() in /home/customer/www/bobbingwide.org.uk/public_html/wp-admin/includes/class-theme-upgrader.php:141
Stack trace:
#0 /home/customer/www/bobbingwide.org.uk/public_html/wp-includes/class-wp-hook.php(308): Theme_Upgrader->check_parent_theme_filter(true, Array, Array)
#1 /home/customer/www/bobbingwide.org.uk/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(true, Array)
#2 /home/customer/www/bobbingwide.org.uk/public_html/wp-admin/includes/class-wp-upgrader.php(642): apply_filters('upgrader_post_i...', true, Array, Array)
#3 /home/customer/www/bobbingwide.org.uk/public_html/wp-admin/includes/class-wp-upgrader.php(815): WP_Upgrader->install_package(Array)
#4 /home/customer/www/bobbingwide.org.uk/public_html/wp-admin/includes/class-theme-upgrader.php(250): WP_Upgrader->run(Array)
#5 /home/customer/www/bobbingwide.org.uk/public_html/wp-content/plugins/oik-update/classes/class-OIK-themer.php(221): Theme_Upgrader->install('/home/customer/...', Array)
#6 /home/customer/www/bobbingwide.org.uk/public_html/wp-content/plugins/oik-update/classes/class-OIK-themer.php(182): OIK_themer->update_installed_theme()
#7 /home/customer/www/bobbingwide.org.uk/public_html/wp-content/plugins/oik-update/oik-themer.php(160): OIK_themer->download_theme_version()
#8 /home/customer/www/bobbingwide.org.uk/public_html/wp-content/plugins/oik-update/oik-themer.php(198): oik_themer_update_component_version(Object(OIK_themer), 'gutenify-archit...', '1.0.2')
#9 /home/customer/www/bobbingwide.org.uk/public_html/wp-content/plugins/oik-update/oik-themer.php(141): oik_themer_update_components_that_need_it(Object(OIK_themer))
#10 /home/customer/www/bobbingwide.org.uk/public_html/wp-content/plugins/oik-update/oik-themer.php(206): oik_themer()
#11 /home/customer/www/bobbingwide.org.uk/public_html/wp-content/plugins/oik-batch/libs/oik-cli.php(605): require_once('/home/customer/...')
#12 /home/customer/www/bobbingwide.org.uk/public_html/wp-content/plugins/oik-batch/libs/oik-cli.php(573): oik_batch_run_script('oik-themer.php')
#13 /home/customer/www/bobbingwide.org.uk/public_html/wp-content/plugins/oik-batch/oik-wp.php(117): oik_batch_run()
#14 /home/customer/www/bobbingwide.org.uk/public_html/wp-content/plugins/oik-batch/oik-wp.php(156): oik_wp_loaded()
#15 {main}
thrown in /home/customer/www/bobbingwide.org.uk/public_html/wp-admin/includes/class-theme-upgrader.php on line 141
There are now 31 FSE themes registered in wordpress.org https://wordpress.org/themes/tags/full-site-editing/ I need a quick process that will register the themes in blocks.wp.a2z then clone them to blocks.wp-a2z.org OR to simply run on the live server.
Proposed solution
[x] find directory for patterns
It may not be necessary to download the theme to the local installation other than to be able to verify that the templates, template parts and patterns are located. Not that there's support for patterns yet.