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

Improve the process for adding / updating FSE themes #4

Open
6 tasks done
bobbingwide opened this issue Dec 16, 2021 · 11 comments
Open
6 tasks done

Improve the process for adding / updating FSE themes #4

bobbingwide opened this issue Dec 16, 2021 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

bobbingwide commented Dec 16, 2021

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.

  • oik-blocker is used for updating blocks
  • oik-update is used for update the API reference
  • oik-themer is needed to define and update themes

Proposed solution

  • Download the theme's zip
  • Unpack to wp-a2z
  • fetch theme info
  • create / update theme
  • set featured image to screenshot
  • 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.

@bobbingwide bobbingwide self-assigned this Dec 16, 2021
@bobbingwide bobbingwide added the enhancement New feature or request label Dec 16, 2021
@bobbingwide
Copy link
Owner Author

bobbingwide commented Dec 17, 2021

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:

  • wecodeart required 5.9-beta3.
  • When I updated to 5.9-beta3 I got Notices.
  • Reverting to 5.9-beta2 resolved the issue..

@bobbingwide
Copy link
Owner Author

bobbingwide commented Dec 18, 2021

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:

  1. wp-top12 to be installed on wp-a2z.org, but not necessarily activated
  2. if WP_org_downloads_themes::get_theme() returns null it attempt to load and save the theme info. ie. update the cache.
  3. This information could therefore be used to provide the wp-top12 report for WordPress FSE themes on blocks.wp-a2z.org

@bobbingwide
Copy link
Owner Author

If I were to want to use this logic on blocks.wp-a2z.org

I tried this and discovered other problems

  • It appears that Jetpack loads wp-admin/file.php which causes a problem when we try to load it.#

Workaround: deactivate Jetpack.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Dec 19, 2021

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 ) {
			

@bobbingwide
Copy link
Owner Author

find directory for patterns

The solution I found for patterns was to use the preview_theme capability in oik-patterns. See bobbingwide/oik-patterns#4

@bobbingwide
Copy link
Owner Author

bobbingwide commented Apr 11, 2022

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

  • obtain a list of all FSE themes
  • for each new theme or any theme with updates
    • download the latest version
    • create/update the oik-themes entry
    • run the patterns preview logic

Proposed solution

Update oik-themer.php

  • To find the list of themes to update / install using the theme listing logic from wp-top12
  • To not download a theme version for a theme which is a Git repository ( similar to blocks.php )
  • To create a theme that's missing and update a theme's modified date when it needs it.
  • To run the theme_preview request to repopulate the patterns.
  • Preferably the solution should work both on Windows and the live server.
  • To be able to update themes which aren't hosted on wordpress.org ( eg fizzie and wizzie )

@bobbingwide
Copy link
Owner Author

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/

@bobbingwide
Copy link
Owner Author

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.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Oct 11, 2022

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.

  • To be able to update themes which aren't hosted on wordpress.org ( eg fizzie and whizzie )

@bobbingwide
Copy link
Owner Author

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

  1. The original .json file should have been removed
  2. There should be some additional reconciliation logic to compare the registered themes.

@bobbingwide
Copy link
Owner Author

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&#8230;</p>
<p>Installing the theme&#8230;</p>
<p>Removing the old version of the theme&#8230;</p>
<p>This theme requires a parent theme. Checking if it is installed&#8230;</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

bobbingwide added a commit that referenced this issue May 24, 2023
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